]>
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" |
1c0d8808 | 35 | #include "lib_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" |
dd65f45e | 67 | #include "bgpd/bgp_evpn_vty.h" |
dcc68b5e | 68 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 69 | #include "bgpd/bgp_mac.h" |
dd65f45e DL |
70 | #include "bgpd/bgp_flowspec.h" |
71 | #if ENABLE_BGP_VNC | |
72 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" | |
73 | #endif | |
74 | ||
5d5393b9 DL |
75 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
76 | { .val_long = true, .match_profile = "datacenter", }, | |
77 | { .val_long = false }, | |
78 | ) | |
79 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
80 | { .val_long = true, .match_profile = "datacenter", }, | |
81 | { .val_long = false }, | |
82 | ) | |
83 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, | |
84 | { .val_long = true, .match_profile = "datacenter", }, | |
85 | { .val_long = false }, | |
86 | ) | |
87 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
88 | { .val_long = true, .match_profile = "datacenter", }, | |
89 | { .val_long = false }, | |
90 | ) | |
91 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
92 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
93 | { .val_ulong = 120 }, | |
94 | ) | |
95 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
96 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
97 | { .val_ulong = 180 }, | |
98 | ) | |
99 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
100 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
101 | { .val_ulong = 60 }, | |
102 | ) | |
103 | ||
dd65f45e DL |
104 | DEFINE_HOOK(bgp_inst_config_write, |
105 | (struct bgp *bgp, struct vty *vty), | |
106 | (bgp, vty)) | |
718e3744 | 107 | |
36235319 QY |
108 | #define GR_NO_OPER \ |
109 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
110 | #define GR_INVALID \ | |
111 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 112 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
113 | struct prefix *range, int exact); | |
114 | ||
055679e9 | 115 | /* Show BGP peer's information. */ |
116 | enum show_type { | |
117 | show_all, | |
118 | show_peer, | |
119 | show_ipv4_all, | |
120 | show_ipv6_all, | |
121 | show_ipv4_peer, | |
122 | show_ipv6_peer | |
123 | }; | |
124 | ||
36235319 QY |
125 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
126 | struct prefix *range, int exact); | |
2986cac2 | 127 | |
36235319 QY |
128 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
129 | struct bgp *bgp, | |
130 | bool use_json, | |
131 | json_object *json); | |
2986cac2 | 132 | |
36235319 QY |
133 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
134 | enum show_type type, | |
135 | const char *ip_str, | |
136 | afi_t afi, bool use_json); | |
2986cac2 | 137 | |
d62a17ae | 138 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
139 | { | |
140 | switch (afi) { | |
141 | case AFI_IP: | |
142 | switch (safi) { | |
143 | case SAFI_UNICAST: | |
144 | return BGP_IPV4_NODE; | |
145 | break; | |
146 | case SAFI_MULTICAST: | |
147 | return BGP_IPV4M_NODE; | |
148 | break; | |
149 | case SAFI_LABELED_UNICAST: | |
150 | return BGP_IPV4L_NODE; | |
151 | break; | |
152 | case SAFI_MPLS_VPN: | |
153 | return BGP_VPNV4_NODE; | |
154 | break; | |
7c40bf39 | 155 | case SAFI_FLOWSPEC: |
156 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
157 | default: |
158 | /* not expected */ | |
159 | return BGP_IPV4_NODE; | |
160 | break; | |
d62a17ae | 161 | } |
162 | break; | |
163 | case AFI_IP6: | |
164 | switch (safi) { | |
165 | case SAFI_UNICAST: | |
166 | return BGP_IPV6_NODE; | |
167 | break; | |
168 | case SAFI_MULTICAST: | |
169 | return BGP_IPV6M_NODE; | |
170 | break; | |
171 | case SAFI_LABELED_UNICAST: | |
172 | return BGP_IPV6L_NODE; | |
173 | break; | |
174 | case SAFI_MPLS_VPN: | |
175 | return BGP_VPNV6_NODE; | |
176 | break; | |
7c40bf39 | 177 | case SAFI_FLOWSPEC: |
178 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
179 | default: |
180 | /* not expected */ | |
181 | return BGP_IPV4_NODE; | |
182 | break; | |
d62a17ae | 183 | } |
184 | break; | |
185 | case AFI_L2VPN: | |
186 | return BGP_EVPN_NODE; | |
187 | break; | |
b26f891d | 188 | case AFI_UNSPEC: |
d62a17ae | 189 | case AFI_MAX: |
190 | // We should never be here but to clarify the switch statement.. | |
191 | return BGP_IPV4_NODE; | |
192 | break; | |
193 | } | |
194 | ||
195 | // Impossible to happen | |
196 | return BGP_IPV4_NODE; | |
f51bae9c | 197 | } |
20eb8864 | 198 | |
5cb5f4d0 DD |
199 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
200 | { | |
201 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
202 | return "IPv4 Unicast"; | |
203 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
204 | return "IPv4 Multicast"; | |
205 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
206 | return "IPv4 Labeled Unicast"; | |
207 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
208 | return "IPv4 VPN"; | |
209 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
210 | return "IPv4 Encap"; | |
211 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
212 | return "IPv4 Flowspec"; | |
213 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
214 | return "IPv6 Unicast"; | |
215 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
216 | return "IPv6 Multicast"; | |
217 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
218 | return "IPv6 Labeled Unicast"; | |
219 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
220 | return "IPv6 VPN"; | |
221 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
222 | return "IPv6 Encap"; | |
223 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
224 | return "IPv6 Flowspec"; | |
225 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
226 | return "L2VPN EVPN"; | |
8e5509b0 | 227 | else |
5cb5f4d0 | 228 | return "Unknown"; |
5cb5f4d0 DD |
229 | } |
230 | ||
231 | /* | |
232 | * Please note that we have intentionally camelCased | |
233 | * the return strings here. So if you want | |
234 | * to use this function, please ensure you | |
235 | * are doing this within json output | |
236 | */ | |
237 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
238 | { | |
239 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
240 | return "ipv4Unicast"; | |
241 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
242 | return "ipv4Multicast"; | |
243 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
244 | return "ipv4LabeledUnicast"; | |
245 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
246 | return "ipv4Vpn"; | |
247 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
248 | return "ipv4Encap"; | |
249 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
250 | return "ipv4Flowspec"; | |
251 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
252 | return "ipv6Unicast"; | |
253 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
254 | return "ipv6Multicast"; | |
255 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
256 | return "ipv6LabeledUnicast"; | |
257 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
258 | return "ipv6Vpn"; | |
259 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
260 | return "ipv6Encap"; | |
261 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
262 | return "ipv6Flowspec"; | |
263 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
264 | return "l2VpnEvpn"; | |
8e5509b0 | 265 | else |
5cb5f4d0 | 266 | return "Unknown"; |
5cb5f4d0 DD |
267 | } |
268 | ||
718e3744 | 269 | /* Utility function to get address family from current node. */ |
d62a17ae | 270 | afi_t bgp_node_afi(struct vty *vty) |
271 | { | |
272 | afi_t afi; | |
273 | switch (vty->node) { | |
274 | case BGP_IPV6_NODE: | |
275 | case BGP_IPV6M_NODE: | |
276 | case BGP_IPV6L_NODE: | |
277 | case BGP_VPNV6_NODE: | |
7c40bf39 | 278 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 279 | afi = AFI_IP6; |
280 | break; | |
281 | case BGP_EVPN_NODE: | |
282 | afi = AFI_L2VPN; | |
283 | break; | |
284 | default: | |
285 | afi = AFI_IP; | |
286 | break; | |
287 | } | |
288 | return afi; | |
718e3744 | 289 | } |
290 | ||
291 | /* Utility function to get subsequent address family from current | |
292 | node. */ | |
d62a17ae | 293 | safi_t bgp_node_safi(struct vty *vty) |
294 | { | |
295 | safi_t safi; | |
296 | switch (vty->node) { | |
297 | case BGP_VPNV4_NODE: | |
298 | case BGP_VPNV6_NODE: | |
299 | safi = SAFI_MPLS_VPN; | |
300 | break; | |
301 | case BGP_IPV4M_NODE: | |
302 | case BGP_IPV6M_NODE: | |
303 | safi = SAFI_MULTICAST; | |
304 | break; | |
305 | case BGP_EVPN_NODE: | |
306 | safi = SAFI_EVPN; | |
307 | break; | |
308 | case BGP_IPV4L_NODE: | |
309 | case BGP_IPV6L_NODE: | |
310 | safi = SAFI_LABELED_UNICAST; | |
311 | break; | |
7c40bf39 | 312 | case BGP_FLOWSPECV4_NODE: |
313 | case BGP_FLOWSPECV6_NODE: | |
314 | safi = SAFI_FLOWSPEC; | |
315 | break; | |
d62a17ae | 316 | default: |
317 | safi = SAFI_UNICAST; | |
318 | break; | |
319 | } | |
320 | return safi; | |
718e3744 | 321 | } |
322 | ||
55f91488 QY |
323 | /** |
324 | * Converts an AFI in string form to afi_t | |
325 | * | |
326 | * @param afi string, one of | |
327 | * - "ipv4" | |
328 | * - "ipv6" | |
81cf0de5 | 329 | * - "l2vpn" |
55f91488 QY |
330 | * @return the corresponding afi_t |
331 | */ | |
d62a17ae | 332 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
333 | { | |
334 | afi_t afi = AFI_MAX; /* unknown */ | |
335 | if (strmatch(afi_str, "ipv4")) | |
336 | afi = AFI_IP; | |
337 | else if (strmatch(afi_str, "ipv6")) | |
338 | afi = AFI_IP6; | |
81cf0de5 CS |
339 | else if (strmatch(afi_str, "l2vpn")) |
340 | afi = AFI_L2VPN; | |
d62a17ae | 341 | return afi; |
342 | } | |
343 | ||
344 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
345 | afi_t *afi) | |
346 | { | |
347 | int ret = 0; | |
348 | if (argv_find(argv, argc, "ipv4", index)) { | |
349 | ret = 1; | |
350 | if (afi) | |
351 | *afi = AFI_IP; | |
352 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
353 | ret = 1; | |
354 | if (afi) | |
355 | *afi = AFI_IP6; | |
8688b3e7 DS |
356 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
357 | ret = 1; | |
358 | if (afi) | |
359 | *afi = AFI_L2VPN; | |
d62a17ae | 360 | } |
361 | return ret; | |
46f296b4 LB |
362 | } |
363 | ||
375a2e67 | 364 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 365 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
366 | { | |
367 | safi_t safi = SAFI_MAX; /* unknown */ | |
368 | if (strmatch(safi_str, "multicast")) | |
369 | safi = SAFI_MULTICAST; | |
370 | else if (strmatch(safi_str, "unicast")) | |
371 | safi = SAFI_UNICAST; | |
372 | else if (strmatch(safi_str, "vpn")) | |
373 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
374 | else if (strmatch(safi_str, "evpn")) |
375 | safi = SAFI_EVPN; | |
d62a17ae | 376 | else if (strmatch(safi_str, "labeled-unicast")) |
377 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 378 | else if (strmatch(safi_str, "flowspec")) |
379 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 380 | return safi; |
381 | } | |
382 | ||
383 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
384 | safi_t *safi) | |
385 | { | |
386 | int ret = 0; | |
387 | if (argv_find(argv, argc, "unicast", index)) { | |
388 | ret = 1; | |
389 | if (safi) | |
390 | *safi = SAFI_UNICAST; | |
391 | } else if (argv_find(argv, argc, "multicast", index)) { | |
392 | ret = 1; | |
393 | if (safi) | |
394 | *safi = SAFI_MULTICAST; | |
395 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
396 | ret = 1; | |
397 | if (safi) | |
398 | *safi = SAFI_LABELED_UNICAST; | |
399 | } else if (argv_find(argv, argc, "vpn", index)) { | |
400 | ret = 1; | |
401 | if (safi) | |
402 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
403 | } else if (argv_find(argv, argc, "evpn", index)) { |
404 | ret = 1; | |
405 | if (safi) | |
406 | *safi = SAFI_EVPN; | |
7c40bf39 | 407 | } else if (argv_find(argv, argc, "flowspec", index)) { |
408 | ret = 1; | |
409 | if (safi) | |
410 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 411 | } |
412 | return ret; | |
46f296b4 LB |
413 | } |
414 | ||
5d5393b9 DL |
415 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
416 | enum bgp_instance_type inst_type) | |
417 | { | |
418 | int ret = bgp_get(bgp, as, name, inst_type); | |
419 | ||
420 | if (ret == BGP_CREATED) { | |
421 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
422 | DFLT_BGP_CONNECT_RETRY); | |
423 | ||
424 | if (DFLT_BGP_IMPORT_CHECK) | |
425 | bgp_flag_set(*bgp, BGP_FLAG_IMPORT_CHECK); | |
426 | if (DFLT_BGP_SHOW_HOSTNAME) | |
427 | bgp_flag_set(*bgp, BGP_FLAG_SHOW_HOSTNAME); | |
428 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) | |
429 | bgp_flag_set(*bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
430 | if (DFLT_BGP_DETERMINISTIC_MED) | |
431 | bgp_flag_set(*bgp, BGP_FLAG_DETERMINISTIC_MED); | |
432 | ||
433 | ret = BGP_SUCCESS; | |
434 | } | |
435 | return ret; | |
436 | } | |
437 | ||
7eeee51e | 438 | /* |
f212a857 | 439 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 440 | * |
f212a857 DS |
441 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
442 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
443 | * to appropriate values for the calling function. This is to allow the |
444 | * calling function to make decisions appropriate for the show command | |
445 | * that is being parsed. | |
446 | * | |
447 | * The show commands are generally of the form: | |
d62a17ae | 448 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
449 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
450 | * |
451 | * Since we use argv_find if the show command in particular doesn't have: | |
452 | * [ip] | |
18c57037 | 453 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 454 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
455 | * The command parsing should still be ok. |
456 | * | |
457 | * vty -> The vty for the command so we can output some useful data in | |
458 | * the event of a parse error in the vrf. | |
459 | * argv -> The command tokens | |
460 | * argc -> How many command tokens we have | |
d62a17ae | 461 | * idx -> The current place in the command, generally should be 0 for this |
462 | * function | |
7eeee51e DS |
463 | * afi -> The parsed afi if it was included in the show command, returned here |
464 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 465 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 466 | * use_json -> json is configured or not |
7eeee51e DS |
467 | * |
468 | * The function returns the correct location in the parse tree for the | |
469 | * last token found. | |
0e37c258 DS |
470 | * |
471 | * Returns 0 for failure to parse correctly, else the idx position of where | |
472 | * it found the last token. | |
7eeee51e | 473 | */ |
d62a17ae | 474 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
475 | struct cmd_token **argv, int argc, | |
476 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 477 | struct bgp **bgp, bool use_json) |
d62a17ae | 478 | { |
479 | char *vrf_name = NULL; | |
480 | ||
481 | assert(afi); | |
482 | assert(safi); | |
483 | assert(bgp); | |
484 | ||
485 | if (argv_find(argv, argc, "ip", idx)) | |
486 | *afi = AFI_IP; | |
487 | ||
9a8bdf1c | 488 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 489 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
490 | else if (argv_find(argv, argc, "vrf", idx)) { |
491 | vrf_name = argv[*idx + 1]->arg; | |
492 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
493 | vrf_name = NULL; | |
494 | } | |
495 | if (vrf_name) { | |
d62a17ae | 496 | if (strmatch(vrf_name, "all")) |
497 | *bgp = NULL; | |
498 | else { | |
499 | *bgp = bgp_lookup_by_name(vrf_name); | |
500 | if (!*bgp) { | |
52e5b8c4 SP |
501 | if (use_json) { |
502 | json_object *json = NULL; | |
503 | json = json_object_new_object(); | |
504 | json_object_string_add( | |
505 | json, "warning", | |
506 | "View/Vrf is unknown"); | |
507 | vty_out(vty, "%s\n", | |
508 | json_object_to_json_string_ext(json, | |
509 | JSON_C_TO_STRING_PRETTY)); | |
510 | json_object_free(json); | |
511 | } | |
ca61fd25 DS |
512 | else |
513 | vty_out(vty, "View/Vrf %s is unknown\n", | |
514 | vrf_name); | |
d62a17ae | 515 | *idx = 0; |
516 | return 0; | |
517 | } | |
518 | } | |
519 | } else { | |
520 | *bgp = bgp_get_default(); | |
521 | if (!*bgp) { | |
52e5b8c4 SP |
522 | if (use_json) { |
523 | json_object *json = NULL; | |
524 | json = json_object_new_object(); | |
525 | json_object_string_add( | |
526 | json, "warning", | |
527 | "Default BGP instance not found"); | |
528 | vty_out(vty, "%s\n", | |
529 | json_object_to_json_string_ext(json, | |
530 | JSON_C_TO_STRING_PRETTY)); | |
531 | json_object_free(json); | |
532 | } | |
ca61fd25 DS |
533 | else |
534 | vty_out(vty, | |
535 | "Default BGP instance not found\n"); | |
d62a17ae | 536 | *idx = 0; |
537 | return 0; | |
538 | } | |
539 | } | |
540 | ||
541 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
542 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
543 | ||
544 | *idx += 1; | |
545 | return *idx; | |
546 | } | |
547 | ||
548 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
549 | { | |
550 | struct interface *ifp = NULL; | |
551 | ||
552 | if (su->sa.sa_family == AF_INET) | |
553 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
554 | else if (su->sa.sa_family == AF_INET6) | |
555 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
556 | su->sin6.sin6_scope_id, | |
557 | bgp->vrf_id); | |
558 | ||
559 | if (ifp) | |
560 | return 1; | |
561 | ||
562 | return 0; | |
718e3744 | 563 | } |
564 | ||
565 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
566 | /* This is used only for configuration, so disallow if attempted on |
567 | * a dynamic neighbor. | |
568 | */ | |
d62a17ae | 569 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
570 | { | |
571 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
572 | int ret; | |
573 | union sockunion su; | |
574 | struct peer *peer; | |
575 | ||
576 | if (!bgp) { | |
577 | return NULL; | |
578 | } | |
579 | ||
580 | ret = str2sockunion(ip_str, &su); | |
581 | if (ret < 0) { | |
582 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
583 | if (!peer) { | |
584 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
585 | == NULL) { | |
586 | vty_out(vty, | |
587 | "%% Malformed address or name: %s\n", | |
588 | ip_str); | |
589 | return NULL; | |
590 | } | |
591 | } | |
592 | } else { | |
593 | peer = peer_lookup(bgp, &su); | |
594 | if (!peer) { | |
595 | vty_out(vty, | |
596 | "%% Specify remote-as or peer-group commands first\n"); | |
597 | return NULL; | |
598 | } | |
599 | if (peer_dynamic_neighbor(peer)) { | |
600 | vty_out(vty, | |
601 | "%% Operation not allowed on a dynamic neighbor\n"); | |
602 | return NULL; | |
603 | } | |
604 | } | |
605 | return peer; | |
718e3744 | 606 | } |
607 | ||
608 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
609 | /* This is used only for configuration, so disallow if attempted on |
610 | * a dynamic neighbor. | |
611 | */ | |
d62a17ae | 612 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
613 | { | |
614 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
615 | int ret; | |
616 | union sockunion su; | |
617 | struct peer *peer = NULL; | |
618 | struct peer_group *group = NULL; | |
619 | ||
620 | if (!bgp) { | |
621 | return NULL; | |
622 | } | |
623 | ||
624 | ret = str2sockunion(peer_str, &su); | |
625 | if (ret == 0) { | |
626 | /* IP address, locate peer. */ | |
627 | peer = peer_lookup(bgp, &su); | |
628 | } else { | |
629 | /* Not IP, could match either peer configured on interface or a | |
630 | * group. */ | |
631 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
632 | if (!peer) | |
633 | group = peer_group_lookup(bgp, peer_str); | |
634 | } | |
635 | ||
636 | if (peer) { | |
637 | if (peer_dynamic_neighbor(peer)) { | |
638 | vty_out(vty, | |
639 | "%% Operation not allowed on a dynamic neighbor\n"); | |
640 | return NULL; | |
641 | } | |
642 | ||
643 | return peer; | |
644 | } | |
645 | ||
646 | if (group) | |
647 | return group->conf; | |
648 | ||
649 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
650 | ||
651 | return NULL; | |
652 | } | |
653 | ||
654 | int bgp_vty_return(struct vty *vty, int ret) | |
655 | { | |
656 | const char *str = NULL; | |
657 | ||
658 | switch (ret) { | |
659 | case BGP_ERR_INVALID_VALUE: | |
660 | str = "Invalid value"; | |
661 | break; | |
662 | case BGP_ERR_INVALID_FLAG: | |
663 | str = "Invalid flag"; | |
664 | break; | |
665 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
666 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
667 | break; | |
668 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
669 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
670 | break; | |
671 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
672 | str = "Specify remote-as or peer-group remote AS first"; | |
673 | break; | |
674 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
675 | str = "Cannot change the peer-group. Deconfigure first"; | |
676 | break; | |
677 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
678 | str = "Peer is not a member of this peer-group"; | |
679 | break; | |
680 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
681 | str = "Prefix/distribute list can not co-exist"; | |
682 | break; | |
683 | case BGP_ERR_NOT_INTERNAL_PEER: | |
684 | str = "Invalid command. Not an internal neighbor"; | |
685 | break; | |
686 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
687 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
688 | break; | |
689 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
690 | str = "Local-AS allowed only for EBGP peers"; | |
691 | break; | |
692 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
693 | str = "Cannot have local-as same as BGP AS number"; | |
694 | break; | |
695 | case BGP_ERR_TCPSIG_FAILED: | |
696 | str = "Error while applying TCP-Sig to session(s)"; | |
697 | break; | |
698 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
699 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
700 | break; | |
701 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
702 | str = "ttl-security only allowed for EBGP peers"; | |
703 | break; | |
704 | case BGP_ERR_AS_OVERRIDE: | |
705 | str = "as-override cannot be configured for IBGP peers"; | |
706 | break; | |
707 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
708 | str = "Invalid limit for number of dynamic neighbors"; | |
709 | break; | |
710 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
711 | str = "Dynamic neighbor listen range already exists"; | |
712 | break; | |
713 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
714 | str = "Operation not allowed on a dynamic neighbor"; | |
715 | break; | |
716 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
717 | str = "Operation not allowed on a directly connected neighbor"; | |
718 | break; | |
719 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 720 | str = GR_INVALID; |
721 | break; | |
722 | case BGP_ERR_GR_INVALID_CMD: | |
723 | str = "The Graceful Restart command used is not valid at this moment."; | |
724 | break; | |
725 | case BGP_ERR_GR_OPERATION_FAILED: | |
726 | str = "The Graceful Restart Operation failed due to an err."; | |
727 | break; | |
728 | case BGP_GR_NO_OPERATION: | |
729 | str = GR_NO_OPER; | |
d62a17ae | 730 | break; |
731 | } | |
732 | if (str) { | |
733 | vty_out(vty, "%% %s\n", str); | |
734 | return CMD_WARNING_CONFIG_FAILED; | |
735 | } | |
736 | return CMD_SUCCESS; | |
718e3744 | 737 | } |
738 | ||
7aafcaca | 739 | /* BGP clear sort. */ |
d62a17ae | 740 | enum clear_sort { |
741 | clear_all, | |
742 | clear_peer, | |
743 | clear_group, | |
744 | clear_external, | |
745 | clear_as | |
7aafcaca DS |
746 | }; |
747 | ||
d62a17ae | 748 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
749 | safi_t safi, int error) | |
750 | { | |
751 | switch (error) { | |
752 | case BGP_ERR_AF_UNCONFIGURED: | |
753 | vty_out(vty, | |
754 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 755 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 756 | break; |
757 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
758 | vty_out(vty, | |
759 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
760 | peer->host); | |
761 | break; | |
762 | default: | |
763 | break; | |
764 | } | |
7aafcaca DS |
765 | } |
766 | ||
dc912615 DS |
767 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
768 | struct listnode *nnode, enum bgp_clear_type stype) | |
769 | { | |
770 | int ret = 0; | |
771 | ||
772 | /* if afi/.safi not specified, spin thru all of them */ | |
773 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
774 | afi_t tmp_afi; | |
775 | safi_t tmp_safi; | |
776 | ||
777 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
778 | if (!peer->afc[tmp_afi][tmp_safi]) | |
779 | continue; | |
780 | ||
781 | if (stype == BGP_CLEAR_SOFT_NONE) | |
782 | ret = peer_clear(peer, &nnode); | |
783 | else | |
784 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
785 | stype); | |
786 | } | |
787 | /* if afi specified and safi not, spin thru safis on this afi */ | |
788 | } else if (safi == SAFI_UNSPEC) { | |
789 | safi_t tmp_safi; | |
790 | ||
791 | for (tmp_safi = SAFI_UNICAST; | |
792 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
793 | if (!peer->afc[afi][tmp_safi]) | |
794 | continue; | |
795 | ||
796 | if (stype == BGP_CLEAR_SOFT_NONE) | |
797 | ret = peer_clear(peer, &nnode); | |
798 | else | |
799 | ret = peer_clear_soft(peer, afi, | |
800 | tmp_safi, stype); | |
801 | } | |
802 | /* both afi/safi specified, let the caller know if not defined */ | |
803 | } else { | |
804 | if (!peer->afc[afi][safi]) | |
805 | return 1; | |
806 | ||
807 | if (stype == BGP_CLEAR_SOFT_NONE) | |
808 | ret = peer_clear(peer, &nnode); | |
809 | else | |
810 | ret = peer_clear_soft(peer, afi, safi, stype); | |
811 | } | |
812 | ||
813 | return ret; | |
814 | } | |
815 | ||
7aafcaca | 816 | /* `clear ip bgp' functions. */ |
d62a17ae | 817 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
818 | enum clear_sort sort, enum bgp_clear_type stype, | |
819 | const char *arg) | |
820 | { | |
dc912615 | 821 | int ret = 0; |
3ae8bfa5 | 822 | bool found = false; |
d62a17ae | 823 | struct peer *peer; |
dc95985f | 824 | |
825 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 826 | |
827 | /* Clear all neighbors. */ | |
828 | /* | |
829 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
830 | * nodes on the BGP instance as that may get freed if it is a |
831 | * doppelganger | |
d62a17ae | 832 | */ |
833 | if (sort == clear_all) { | |
834 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 835 | |
836 | bgp_peer_gr_flags_update(peer); | |
837 | ||
36235319 | 838 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 839 | gr_router_detected = true; |
840 | ||
dc912615 DS |
841 | ret = bgp_peer_clear(peer, afi, safi, nnode, |
842 | stype); | |
d62a17ae | 843 | |
844 | if (ret < 0) | |
845 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
dc95985f | 846 | } |
847 | ||
36235319 QY |
848 | if (gr_router_detected |
849 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 850 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
851 | } else if (!gr_router_detected |
852 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 853 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 854 | } |
d62a17ae | 855 | |
856 | /* This is to apply read-only mode on this clear. */ | |
857 | if (stype == BGP_CLEAR_SOFT_NONE) | |
858 | bgp->update_delay_over = 0; | |
859 | ||
860 | return CMD_SUCCESS; | |
7aafcaca DS |
861 | } |
862 | ||
3ae8bfa5 | 863 | /* Clear specified neighbor. */ |
d62a17ae | 864 | if (sort == clear_peer) { |
865 | union sockunion su; | |
d62a17ae | 866 | |
867 | /* Make sockunion for lookup. */ | |
868 | ret = str2sockunion(arg, &su); | |
869 | if (ret < 0) { | |
870 | peer = peer_lookup_by_conf_if(bgp, arg); | |
871 | if (!peer) { | |
872 | peer = peer_lookup_by_hostname(bgp, arg); | |
873 | if (!peer) { | |
874 | vty_out(vty, | |
875 | "Malformed address or name: %s\n", | |
876 | arg); | |
877 | return CMD_WARNING; | |
878 | } | |
879 | } | |
880 | } else { | |
881 | peer = peer_lookup(bgp, &su); | |
882 | if (!peer) { | |
883 | vty_out(vty, | |
884 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
885 | arg); | |
886 | return CMD_WARNING; | |
887 | } | |
888 | } | |
7aafcaca | 889 | |
dc95985f | 890 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
891 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
892 | ||
dc912615 DS |
893 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
894 | ||
895 | /* if afi/safi not defined for this peer, let caller know */ | |
896 | if (ret == 1) | |
3ae8bfa5 | 897 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 898 | |
d62a17ae | 899 | if (ret < 0) |
900 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 901 | |
d62a17ae | 902 | return CMD_SUCCESS; |
7aafcaca | 903 | } |
7aafcaca | 904 | |
3ae8bfa5 | 905 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 906 | if (sort == clear_group) { |
907 | struct peer_group *group; | |
7aafcaca | 908 | |
d62a17ae | 909 | group = peer_group_lookup(bgp, arg); |
910 | if (!group) { | |
911 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
912 | return CMD_WARNING; | |
913 | } | |
914 | ||
915 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
dc912615 | 916 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 917 | |
d62a17ae | 918 | if (ret < 0) |
919 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
920 | else |
921 | found = true; | |
d62a17ae | 922 | } |
3ae8bfa5 PM |
923 | |
924 | if (!found) | |
925 | vty_out(vty, | |
926 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 927 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 928 | |
d62a17ae | 929 | return CMD_SUCCESS; |
7aafcaca | 930 | } |
7aafcaca | 931 | |
3ae8bfa5 | 932 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 933 | if (sort == clear_external) { |
934 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
935 | if (peer->sort == BGP_PEER_IBGP) | |
936 | continue; | |
7aafcaca | 937 | |
dc95985f | 938 | bgp_peer_gr_flags_update(peer); |
939 | ||
36235319 | 940 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 941 | gr_router_detected = true; |
dc95985f | 942 | |
dc912615 | 943 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 944 | |
d62a17ae | 945 | if (ret < 0) |
946 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
947 | else |
948 | found = true; | |
d62a17ae | 949 | } |
3ae8bfa5 | 950 | |
36235319 QY |
951 | if (gr_router_detected |
952 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 953 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
954 | } else if (!gr_router_detected |
955 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 956 | bgp_zebra_send_capabilities(bgp, true); |
957 | } | |
958 | ||
3ae8bfa5 PM |
959 | if (!found) |
960 | vty_out(vty, | |
961 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 962 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 963 | |
d62a17ae | 964 | return CMD_SUCCESS; |
965 | } | |
966 | ||
3ae8bfa5 | 967 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 968 | if (sort == clear_as) { |
3ae8bfa5 | 969 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 970 | |
971 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
972 | if (peer->as != as) | |
973 | continue; | |
974 | ||
dc95985f | 975 | bgp_peer_gr_flags_update(peer); |
976 | ||
36235319 | 977 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 978 | gr_router_detected = true; |
dc95985f | 979 | |
dc912615 | 980 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
d62a17ae | 981 | |
982 | if (ret < 0) | |
983 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
984 | else |
985 | found = true; | |
d62a17ae | 986 | } |
3ae8bfa5 | 987 | |
36235319 QY |
988 | if (gr_router_detected |
989 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 990 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
991 | } else if (!gr_router_detected |
992 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 993 | bgp_zebra_send_capabilities(bgp, true); |
994 | } | |
995 | ||
3ae8bfa5 | 996 | if (!found) |
d62a17ae | 997 | vty_out(vty, |
3ae8bfa5 | 998 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 999 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1000 | |
d62a17ae | 1001 | return CMD_SUCCESS; |
1002 | } | |
1003 | ||
1004 | return CMD_SUCCESS; | |
1005 | } | |
1006 | ||
1007 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
1008 | safi_t safi, enum clear_sort sort, | |
1009 | enum bgp_clear_type stype, const char *arg) | |
1010 | { | |
1011 | struct bgp *bgp; | |
1012 | ||
1013 | /* BGP structure lookup. */ | |
1014 | if (name) { | |
1015 | bgp = bgp_lookup_by_name(name); | |
1016 | if (bgp == NULL) { | |
1017 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1018 | return CMD_WARNING; | |
1019 | } | |
1020 | } else { | |
1021 | bgp = bgp_get_default(); | |
1022 | if (bgp == NULL) { | |
1023 | vty_out(vty, "No BGP process is configured\n"); | |
1024 | return CMD_WARNING; | |
1025 | } | |
1026 | } | |
1027 | ||
1028 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
1029 | } |
1030 | ||
1031 | /* clear soft inbound */ | |
d62a17ae | 1032 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1033 | { |
99b3ebd3 NS |
1034 | afi_t afi; |
1035 | safi_t safi; | |
1036 | ||
1037 | FOREACH_AFI_SAFI (afi, safi) | |
1038 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1039 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1040 | } |
1041 | ||
1042 | /* clear soft outbound */ | |
d62a17ae | 1043 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1044 | { |
99b3ebd3 NS |
1045 | afi_t afi; |
1046 | safi_t safi; | |
1047 | ||
1048 | FOREACH_AFI_SAFI (afi, safi) | |
1049 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1050 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1051 | } |
1052 | ||
1053 | ||
f787d7a0 | 1054 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1055 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1056 | #endif |
1057 | ||
8029b216 AK |
1058 | DEFUN_HIDDEN (bgp_local_mac, |
1059 | bgp_local_mac_cmd, | |
093e3f23 | 1060 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1061 | BGP_STR |
1062 | "Local MAC config\n" | |
1063 | "VxLAN Network Identifier\n" | |
1064 | "VNI number\n" | |
1065 | "local mac\n" | |
1066 | "mac address\n" | |
1067 | "mac-mobility sequence\n" | |
1068 | "seq number\n") | |
1069 | { | |
1070 | int rv; | |
1071 | vni_t vni; | |
1072 | struct ethaddr mac; | |
1073 | struct ipaddr ip; | |
1074 | uint32_t seq; | |
1075 | struct bgp *bgp; | |
1076 | ||
1077 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1078 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1079 | vty_out(vty, "%% Malformed MAC address\n"); | |
1080 | return CMD_WARNING; | |
1081 | } | |
1082 | memset(&ip, 0, sizeof(ip)); | |
1083 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1084 | ||
1085 | bgp = bgp_get_default(); | |
1086 | if (!bgp) { | |
1087 | vty_out(vty, "Default BGP instance is not there\n"); | |
1088 | return CMD_WARNING; | |
1089 | } | |
1090 | ||
1091 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1092 | if (rv < 0) { | |
1093 | vty_out(vty, "Internal error\n"); | |
1094 | return CMD_WARNING; | |
1095 | } | |
1096 | ||
1097 | return CMD_SUCCESS; | |
1098 | } | |
1099 | ||
1100 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1101 | no_bgp_local_mac_cmd, | |
093e3f23 | 1102 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1103 | NO_STR |
1104 | BGP_STR | |
1105 | "Local MAC config\n" | |
1106 | "VxLAN Network Identifier\n" | |
1107 | "VNI number\n" | |
1108 | "local mac\n" | |
1109 | "mac address\n") | |
1110 | { | |
1111 | int rv; | |
1112 | vni_t vni; | |
1113 | struct ethaddr mac; | |
1114 | struct ipaddr ip; | |
1115 | struct bgp *bgp; | |
1116 | ||
1117 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1118 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1119 | vty_out(vty, "%% Malformed MAC address\n"); | |
1120 | return CMD_WARNING; | |
1121 | } | |
1122 | memset(&ip, 0, sizeof(ip)); | |
1123 | ||
1124 | bgp = bgp_get_default(); | |
1125 | if (!bgp) { | |
1126 | vty_out(vty, "Default BGP instance is not there\n"); | |
1127 | return CMD_WARNING; | |
1128 | } | |
1129 | ||
ec0ab544 | 1130 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1131 | if (rv < 0) { |
1132 | vty_out(vty, "Internal error\n"); | |
1133 | return CMD_WARNING; | |
1134 | } | |
1135 | ||
1136 | return CMD_SUCCESS; | |
1137 | } | |
1138 | ||
718e3744 | 1139 | DEFUN (no_synchronization, |
1140 | no_synchronization_cmd, | |
1141 | "no synchronization", | |
1142 | NO_STR | |
1143 | "Perform IGP synchronization\n") | |
1144 | { | |
d62a17ae | 1145 | return CMD_SUCCESS; |
718e3744 | 1146 | } |
1147 | ||
1148 | DEFUN (no_auto_summary, | |
1149 | no_auto_summary_cmd, | |
1150 | "no auto-summary", | |
1151 | NO_STR | |
1152 | "Enable automatic network number summarization\n") | |
1153 | { | |
d62a17ae | 1154 | return CMD_SUCCESS; |
718e3744 | 1155 | } |
3d515fd9 | 1156 | |
718e3744 | 1157 | /* "router bgp" commands. */ |
505e5056 | 1158 | DEFUN_NOSH (router_bgp, |
f412b39a | 1159 | router_bgp_cmd, |
2ed9fe4a | 1160 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1161 | ROUTER_STR |
1162 | BGP_STR | |
31500417 DW |
1163 | AS_STR |
1164 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1165 | { |
d62a17ae | 1166 | int idx_asn = 2; |
1167 | int idx_view_vrf = 3; | |
1168 | int idx_vrf = 4; | |
ecec9495 | 1169 | int is_new_bgp = 0; |
d62a17ae | 1170 | int ret; |
1171 | as_t as; | |
1172 | struct bgp *bgp; | |
1173 | const char *name = NULL; | |
1174 | enum bgp_instance_type inst_type; | |
1175 | ||
1176 | // "router bgp" without an ASN | |
1177 | if (argc == 2) { | |
1178 | // Pending: Make VRF option available for ASN less config | |
1179 | bgp = bgp_get_default(); | |
1180 | ||
1181 | if (bgp == NULL) { | |
1182 | vty_out(vty, "%% No BGP process is configured\n"); | |
1183 | return CMD_WARNING_CONFIG_FAILED; | |
1184 | } | |
1185 | ||
1186 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1187 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1188 | return CMD_WARNING_CONFIG_FAILED; |
1189 | } | |
1190 | } | |
1191 | ||
1192 | // "router bgp X" | |
1193 | else { | |
1194 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1195 | ||
1196 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1197 | if (argc > 3) { | |
1198 | name = argv[idx_vrf]->arg; | |
1199 | ||
9a8bdf1c PG |
1200 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1201 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1202 | name = NULL; | |
1203 | else | |
1204 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1205 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1206 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1207 | } | |
1208 | ||
ecec9495 AD |
1209 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1210 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1211 | ||
5d5393b9 | 1212 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1213 | switch (ret) { |
d62a17ae | 1214 | case BGP_ERR_AS_MISMATCH: |
1215 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1216 | return CMD_WARNING_CONFIG_FAILED; | |
1217 | case BGP_ERR_INSTANCE_MISMATCH: | |
1218 | vty_out(vty, | |
1219 | "BGP instance name and AS number mismatch\n"); | |
1220 | vty_out(vty, | |
1221 | "BGP instance is already running; AS is %u\n", | |
1222 | as); | |
1223 | return CMD_WARNING_CONFIG_FAILED; | |
1224 | } | |
1225 | ||
3bd70bf8 PZ |
1226 | /* |
1227 | * If we just instantiated the default instance, complete | |
1228 | * any pending VRF-VPN leaking that was configured via | |
1229 | * earlier "router bgp X vrf FOO" blocks. | |
1230 | */ | |
ecec9495 | 1231 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1232 | vpn_leak_postchange_all(); |
1233 | ||
48381346 CS |
1234 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1235 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1236 | /* Pending: handle when user tries to change a view to vrf n vv. |
1237 | */ | |
1238 | } | |
1239 | ||
0b5131c9 MK |
1240 | /* unset the auto created flag as the user config is now present */ |
1241 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1242 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1243 | ||
1244 | return CMD_SUCCESS; | |
718e3744 | 1245 | } |
1246 | ||
718e3744 | 1247 | /* "no router bgp" commands. */ |
1248 | DEFUN (no_router_bgp, | |
1249 | no_router_bgp_cmd, | |
2ed9fe4a | 1250 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1251 | NO_STR |
1252 | ROUTER_STR | |
1253 | BGP_STR | |
31500417 DW |
1254 | AS_STR |
1255 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1256 | { |
d62a17ae | 1257 | int idx_asn = 3; |
1258 | int idx_vrf = 5; | |
1259 | as_t as; | |
1260 | struct bgp *bgp; | |
1261 | const char *name = NULL; | |
718e3744 | 1262 | |
d62a17ae | 1263 | // "no router bgp" without an ASN |
1264 | if (argc == 3) { | |
1265 | // Pending: Make VRF option available for ASN less config | |
1266 | bgp = bgp_get_default(); | |
718e3744 | 1267 | |
d62a17ae | 1268 | if (bgp == NULL) { |
1269 | vty_out(vty, "%% No BGP process is configured\n"); | |
1270 | return CMD_WARNING_CONFIG_FAILED; | |
1271 | } | |
7fb21a9f | 1272 | |
d62a17ae | 1273 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1274 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1275 | return CMD_WARNING_CONFIG_FAILED; |
1276 | } | |
0b5131c9 MK |
1277 | |
1278 | if (bgp->l3vni) { | |
1279 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1280 | bgp->l3vni); | |
1281 | return CMD_WARNING_CONFIG_FAILED; | |
1282 | } | |
d62a17ae | 1283 | } else { |
1284 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1285 | |
d62a17ae | 1286 | if (argc > 4) |
1287 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1288 | |
d62a17ae | 1289 | /* Lookup bgp structure. */ |
1290 | bgp = bgp_lookup(as, name); | |
1291 | if (!bgp) { | |
1292 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1293 | return CMD_WARNING_CONFIG_FAILED; | |
1294 | } | |
0b5131c9 MK |
1295 | |
1296 | if (bgp->l3vni) { | |
dd5868c2 | 1297 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1298 | bgp->l3vni); |
1299 | return CMD_WARNING_CONFIG_FAILED; | |
1300 | } | |
dd5868c2 DS |
1301 | |
1302 | /* Cannot delete default instance if vrf instances exist */ | |
1303 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1304 | struct listnode *node; | |
1305 | struct bgp *tmp_bgp; | |
1306 | ||
1307 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1308 | if (tmp_bgp->inst_type | |
1309 | == BGP_INSTANCE_TYPE_VRF) { | |
1310 | vty_out(vty, | |
1311 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1312 | return CMD_WARNING_CONFIG_FAILED; | |
1313 | } | |
1314 | } | |
1315 | } | |
d62a17ae | 1316 | } |
718e3744 | 1317 | |
9ecf931b CS |
1318 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1319 | return CMD_WARNING_CONFIG_FAILED; | |
1320 | ||
d62a17ae | 1321 | bgp_delete(bgp); |
718e3744 | 1322 | |
d62a17ae | 1323 | return CMD_SUCCESS; |
718e3744 | 1324 | } |
1325 | ||
6b0655a2 | 1326 | |
718e3744 | 1327 | /* BGP router-id. */ |
1328 | ||
f787d7a0 | 1329 | DEFPY (bgp_router_id, |
718e3744 | 1330 | bgp_router_id_cmd, |
1331 | "bgp router-id A.B.C.D", | |
1332 | BGP_STR | |
1333 | "Override configured router identifier\n" | |
1334 | "Manually configured router identifier\n") | |
1335 | { | |
d62a17ae | 1336 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1337 | bgp_router_id_static_set(bgp, router_id); | |
1338 | return CMD_SUCCESS; | |
718e3744 | 1339 | } |
1340 | ||
f787d7a0 | 1341 | DEFPY (no_bgp_router_id, |
718e3744 | 1342 | no_bgp_router_id_cmd, |
31500417 | 1343 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1344 | NO_STR |
1345 | BGP_STR | |
31500417 DW |
1346 | "Override configured router identifier\n" |
1347 | "Manually configured router identifier\n") | |
718e3744 | 1348 | { |
d62a17ae | 1349 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1350 | |
d62a17ae | 1351 | if (router_id_str) { |
1352 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1353 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1354 | return CMD_WARNING_CONFIG_FAILED; | |
1355 | } | |
e018c7cc | 1356 | } |
718e3744 | 1357 | |
d62a17ae | 1358 | router_id.s_addr = 0; |
1359 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1360 | |
d62a17ae | 1361 | return CMD_SUCCESS; |
718e3744 | 1362 | } |
1363 | ||
6b0655a2 | 1364 | |
718e3744 | 1365 | /* BGP Cluster ID. */ |
718e3744 | 1366 | DEFUN (bgp_cluster_id, |
1367 | bgp_cluster_id_cmd, | |
838758ac | 1368 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1369 | BGP_STR |
1370 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1371 | "Route-Reflector Cluster-id in IP address format\n" |
1372 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1373 | { |
d62a17ae | 1374 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1375 | int idx_ipv4 = 2; | |
1376 | int ret; | |
1377 | struct in_addr cluster; | |
718e3744 | 1378 | |
d62a17ae | 1379 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1380 | if (!ret) { | |
1381 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1382 | return CMD_WARNING_CONFIG_FAILED; | |
1383 | } | |
718e3744 | 1384 | |
d62a17ae | 1385 | bgp_cluster_id_set(bgp, &cluster); |
1386 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1387 | |
d62a17ae | 1388 | return CMD_SUCCESS; |
718e3744 | 1389 | } |
1390 | ||
718e3744 | 1391 | DEFUN (no_bgp_cluster_id, |
1392 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1393 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1394 | NO_STR |
1395 | BGP_STR | |
838758ac DW |
1396 | "Configure Route-Reflector Cluster-id\n" |
1397 | "Route-Reflector Cluster-id in IP address format\n" | |
1398 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1399 | { |
d62a17ae | 1400 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1401 | bgp_cluster_id_unset(bgp); | |
1402 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1403 | |
d62a17ae | 1404 | return CMD_SUCCESS; |
718e3744 | 1405 | } |
1406 | ||
718e3744 | 1407 | DEFUN (bgp_confederation_identifier, |
1408 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1409 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1410 | "BGP specific commands\n" |
1411 | "AS confederation parameters\n" | |
1412 | "AS number\n" | |
1413 | "Set routing domain confederation AS\n") | |
1414 | { | |
d62a17ae | 1415 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1416 | int idx_number = 3; | |
1417 | as_t as; | |
718e3744 | 1418 | |
d62a17ae | 1419 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1420 | |
d62a17ae | 1421 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1422 | |
d62a17ae | 1423 | return CMD_SUCCESS; |
718e3744 | 1424 | } |
1425 | ||
1426 | DEFUN (no_bgp_confederation_identifier, | |
1427 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1428 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1429 | NO_STR |
1430 | "BGP specific commands\n" | |
1431 | "AS confederation parameters\n" | |
3a2d747c QY |
1432 | "AS number\n" |
1433 | "Set routing domain confederation AS\n") | |
718e3744 | 1434 | { |
d62a17ae | 1435 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1436 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1437 | |
d62a17ae | 1438 | return CMD_SUCCESS; |
718e3744 | 1439 | } |
1440 | ||
718e3744 | 1441 | DEFUN (bgp_confederation_peers, |
1442 | bgp_confederation_peers_cmd, | |
12dcf78e | 1443 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1444 | "BGP specific commands\n" |
1445 | "AS confederation parameters\n" | |
1446 | "Peer ASs in BGP confederation\n" | |
1447 | AS_STR) | |
1448 | { | |
d62a17ae | 1449 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1450 | int idx_asn = 3; | |
1451 | as_t as; | |
1452 | int i; | |
718e3744 | 1453 | |
d62a17ae | 1454 | for (i = idx_asn; i < argc; i++) { |
1455 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1456 | |
d62a17ae | 1457 | if (bgp->as == as) { |
1458 | vty_out(vty, | |
1459 | "%% Local member-AS not allowed in confed peer list\n"); | |
1460 | continue; | |
1461 | } | |
718e3744 | 1462 | |
d62a17ae | 1463 | bgp_confederation_peers_add(bgp, as); |
1464 | } | |
1465 | return CMD_SUCCESS; | |
718e3744 | 1466 | } |
1467 | ||
1468 | DEFUN (no_bgp_confederation_peers, | |
1469 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1470 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1471 | NO_STR |
1472 | "BGP specific commands\n" | |
1473 | "AS confederation parameters\n" | |
1474 | "Peer ASs in BGP confederation\n" | |
1475 | AS_STR) | |
1476 | { | |
d62a17ae | 1477 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1478 | int idx_asn = 4; | |
1479 | as_t as; | |
1480 | int i; | |
718e3744 | 1481 | |
d62a17ae | 1482 | for (i = idx_asn; i < argc; i++) { |
1483 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1484 | |
d62a17ae | 1485 | bgp_confederation_peers_remove(bgp, as); |
1486 | } | |
1487 | return CMD_SUCCESS; | |
718e3744 | 1488 | } |
6b0655a2 | 1489 | |
5e242b0d DS |
1490 | /** |
1491 | * Central routine for maximum-paths configuration. | |
1492 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1493 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1494 | */ | |
d62a17ae | 1495 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1496 | const char *mpaths, uint16_t options, |
d62a17ae | 1497 | int set) |
1498 | { | |
1499 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1500 | uint16_t maxpaths = 0; |
d62a17ae | 1501 | int ret; |
1502 | afi_t afi; | |
1503 | safi_t safi; | |
1504 | ||
1505 | afi = bgp_node_afi(vty); | |
1506 | safi = bgp_node_safi(vty); | |
1507 | ||
1508 | if (set) { | |
1509 | maxpaths = strtol(mpaths, NULL, 10); | |
1510 | if (maxpaths > multipath_num) { | |
1511 | vty_out(vty, | |
1512 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1513 | maxpaths, multipath_num); | |
1514 | return CMD_WARNING_CONFIG_FAILED; | |
1515 | } | |
1516 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1517 | options); | |
1518 | } else | |
1519 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1520 | ||
1521 | if (ret < 0) { | |
1522 | vty_out(vty, | |
1523 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1524 | (set == 1) ? "" : "un", | |
1525 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1526 | maxpaths, afi, safi); | |
1527 | return CMD_WARNING_CONFIG_FAILED; | |
1528 | } | |
1529 | ||
1530 | bgp_recalculate_all_bestpaths(bgp); | |
1531 | ||
1532 | return CMD_SUCCESS; | |
165b5fff JB |
1533 | } |
1534 | ||
abc920f8 DS |
1535 | DEFUN (bgp_maxmed_admin, |
1536 | bgp_maxmed_admin_cmd, | |
1537 | "bgp max-med administrative ", | |
1538 | BGP_STR | |
1539 | "Advertise routes with max-med\n" | |
1540 | "Administratively applied, for an indefinite period\n") | |
1541 | { | |
d62a17ae | 1542 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1543 | |
d62a17ae | 1544 | bgp->v_maxmed_admin = 1; |
1545 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1546 | |
d62a17ae | 1547 | bgp_maxmed_update(bgp); |
abc920f8 | 1548 | |
d62a17ae | 1549 | return CMD_SUCCESS; |
abc920f8 DS |
1550 | } |
1551 | ||
1552 | DEFUN (bgp_maxmed_admin_medv, | |
1553 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1554 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1555 | BGP_STR |
1556 | "Advertise routes with max-med\n" | |
1557 | "Administratively applied, for an indefinite period\n" | |
1558 | "Max MED value to be used\n") | |
1559 | { | |
d62a17ae | 1560 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1561 | int idx_number = 3; | |
abc920f8 | 1562 | |
d62a17ae | 1563 | bgp->v_maxmed_admin = 1; |
1564 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1565 | |
d62a17ae | 1566 | bgp_maxmed_update(bgp); |
abc920f8 | 1567 | |
d62a17ae | 1568 | return CMD_SUCCESS; |
abc920f8 DS |
1569 | } |
1570 | ||
1571 | DEFUN (no_bgp_maxmed_admin, | |
1572 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1573 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1574 | NO_STR |
1575 | BGP_STR | |
1576 | "Advertise routes with max-med\n" | |
838758ac DW |
1577 | "Administratively applied, for an indefinite period\n" |
1578 | "Max MED value to be used\n") | |
abc920f8 | 1579 | { |
d62a17ae | 1580 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1581 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1582 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1583 | bgp_maxmed_update(bgp); | |
abc920f8 | 1584 | |
d62a17ae | 1585 | return CMD_SUCCESS; |
abc920f8 DS |
1586 | } |
1587 | ||
abc920f8 DS |
1588 | DEFUN (bgp_maxmed_onstartup, |
1589 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1590 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1591 | BGP_STR |
1592 | "Advertise routes with max-med\n" | |
1593 | "Effective on a startup\n" | |
1594 | "Time (seconds) period for max-med\n" | |
1595 | "Max MED value to be used\n") | |
1596 | { | |
d62a17ae | 1597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1598 | int idx = 0; | |
4668a151 | 1599 | |
d62a17ae | 1600 | argv_find(argv, argc, "(5-86400)", &idx); |
1601 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1602 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1603 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1604 | else | |
1605 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1606 | |
d62a17ae | 1607 | bgp_maxmed_update(bgp); |
abc920f8 | 1608 | |
d62a17ae | 1609 | return CMD_SUCCESS; |
abc920f8 DS |
1610 | } |
1611 | ||
1612 | DEFUN (no_bgp_maxmed_onstartup, | |
1613 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1614 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1615 | NO_STR |
1616 | BGP_STR | |
1617 | "Advertise routes with max-med\n" | |
838758ac DW |
1618 | "Effective on a startup\n" |
1619 | "Time (seconds) period for max-med\n" | |
1620 | "Max MED value to be used\n") | |
abc920f8 | 1621 | { |
d62a17ae | 1622 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1623 | |
d62a17ae | 1624 | /* Cancel max-med onstartup if its on */ |
1625 | if (bgp->t_maxmed_onstartup) { | |
1626 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1627 | bgp->maxmed_onstartup_over = 1; | |
1628 | } | |
abc920f8 | 1629 | |
d62a17ae | 1630 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1631 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1632 | |
d62a17ae | 1633 | bgp_maxmed_update(bgp); |
abc920f8 | 1634 | |
d62a17ae | 1635 | return CMD_SUCCESS; |
abc920f8 DS |
1636 | } |
1637 | ||
d62a17ae | 1638 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1639 | const char *wait) | |
f188f2c4 | 1640 | { |
d62a17ae | 1641 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1642 | uint16_t update_delay; |
1643 | uint16_t establish_wait; | |
f188f2c4 | 1644 | |
d62a17ae | 1645 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1646 | |
d62a17ae | 1647 | if (!wait) /* update-delay <delay> */ |
1648 | { | |
1649 | bgp->v_update_delay = update_delay; | |
1650 | bgp->v_establish_wait = bgp->v_update_delay; | |
1651 | return CMD_SUCCESS; | |
1652 | } | |
f188f2c4 | 1653 | |
d62a17ae | 1654 | /* update-delay <delay> <establish-wait> */ |
1655 | establish_wait = atoi(wait); | |
1656 | if (update_delay < establish_wait) { | |
1657 | vty_out(vty, | |
1658 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1659 | return CMD_WARNING_CONFIG_FAILED; | |
1660 | } | |
f188f2c4 | 1661 | |
d62a17ae | 1662 | bgp->v_update_delay = update_delay; |
1663 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1664 | |
d62a17ae | 1665 | return CMD_SUCCESS; |
f188f2c4 DS |
1666 | } |
1667 | ||
d62a17ae | 1668 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1669 | { |
d62a17ae | 1670 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1671 | |
d62a17ae | 1672 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1673 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1674 | |
d62a17ae | 1675 | return CMD_SUCCESS; |
f188f2c4 DS |
1676 | } |
1677 | ||
2b791107 | 1678 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1679 | { |
d62a17ae | 1680 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1681 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1682 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1683 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1684 | vty_out(vty, "\n"); | |
1685 | } | |
f188f2c4 DS |
1686 | } |
1687 | ||
1688 | ||
1689 | /* Update-delay configuration */ | |
1690 | DEFUN (bgp_update_delay, | |
1691 | bgp_update_delay_cmd, | |
6147e2c6 | 1692 | "update-delay (0-3600)", |
f188f2c4 DS |
1693 | "Force initial delay for best-path and updates\n" |
1694 | "Seconds\n") | |
1695 | { | |
d62a17ae | 1696 | int idx_number = 1; |
1697 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1698 | } |
1699 | ||
1700 | DEFUN (bgp_update_delay_establish_wait, | |
1701 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1702 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1703 | "Force initial delay for best-path and updates\n" |
1704 | "Seconds\n" | |
f188f2c4 DS |
1705 | "Seconds\n") |
1706 | { | |
d62a17ae | 1707 | int idx_number = 1; |
1708 | int idx_number_2 = 2; | |
1709 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1710 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1711 | } |
1712 | ||
1713 | /* Update-delay deconfiguration */ | |
1714 | DEFUN (no_bgp_update_delay, | |
1715 | no_bgp_update_delay_cmd, | |
838758ac DW |
1716 | "no update-delay [(0-3600) [(1-3600)]]", |
1717 | NO_STR | |
f188f2c4 | 1718 | "Force initial delay for best-path and updates\n" |
838758ac | 1719 | "Seconds\n" |
7111c1a0 | 1720 | "Seconds\n") |
f188f2c4 | 1721 | { |
d62a17ae | 1722 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1723 | } |
1724 | ||
5e242b0d | 1725 | |
8fa7732f QY |
1726 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1727 | bool set) | |
cb1faec9 | 1728 | { |
d62a17ae | 1729 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1730 | |
8fa7732f QY |
1731 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1732 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1733 | |
1734 | return CMD_SUCCESS; | |
1735 | } | |
1736 | ||
8fa7732f QY |
1737 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1738 | bool set) | |
555e09d4 QY |
1739 | { |
1740 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1741 | ||
8fa7732f QY |
1742 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1743 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1744 | |
d62a17ae | 1745 | return CMD_SUCCESS; |
cb1faec9 DS |
1746 | } |
1747 | ||
2b791107 | 1748 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1749 | { |
555e09d4 QY |
1750 | uint32_t quanta = |
1751 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1752 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1753 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1754 | } |
1755 | ||
555e09d4 QY |
1756 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1757 | { | |
1758 | uint32_t quanta = | |
1759 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1760 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1761 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1762 | } |
cb1faec9 | 1763 | |
8fa7732f QY |
1764 | /* Packet quanta configuration |
1765 | * | |
1766 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1767 | * thread. When changing these limits be careful to prevent stack overflow. | |
1768 | * | |
1769 | * Furthermore, the maximums used here should correspond to | |
1770 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1771 | */ | |
1772 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1773 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1774 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1775 | NO_STR |
8fa7732f | 1776 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1777 | "Number of packets\n") |
1778 | { | |
8fa7732f | 1779 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1780 | } |
1781 | ||
8fa7732f | 1782 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1783 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1784 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1785 | NO_STR |
1786 | "How many packets to read from peer socket per I/O cycle\n" | |
1787 | "Number of packets\n") | |
1788 | { | |
8fa7732f | 1789 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1790 | } |
1791 | ||
2b791107 | 1792 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1793 | { |
37a333fe | 1794 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1795 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1796 | } |
1797 | ||
1798 | ||
1799 | DEFUN (bgp_coalesce_time, | |
1800 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1801 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1802 | "Subgroup coalesce timer\n" |
1803 | "Subgroup coalesce timer value (in ms)\n") | |
1804 | { | |
d62a17ae | 1805 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1806 | |
d62a17ae | 1807 | int idx = 0; |
1808 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1809 | bgp->heuristic_coalesce = false; |
d62a17ae | 1810 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1811 | return CMD_SUCCESS; | |
3f9c7369 DS |
1812 | } |
1813 | ||
1814 | DEFUN (no_bgp_coalesce_time, | |
1815 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1816 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1817 | NO_STR |
3f9c7369 DS |
1818 | "Subgroup coalesce timer\n" |
1819 | "Subgroup coalesce timer value (in ms)\n") | |
1820 | { | |
d62a17ae | 1821 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1822 | |
37a333fe | 1823 | bgp->heuristic_coalesce = true; |
d62a17ae | 1824 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1825 | return CMD_SUCCESS; | |
3f9c7369 DS |
1826 | } |
1827 | ||
5e242b0d DS |
1828 | /* Maximum-paths configuration */ |
1829 | DEFUN (bgp_maxpaths, | |
1830 | bgp_maxpaths_cmd, | |
6319fd63 | 1831 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1832 | "Forward packets over multiple paths\n" |
1833 | "Number of paths\n") | |
1834 | { | |
d62a17ae | 1835 | int idx_number = 1; |
1836 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1837 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1838 | } |
1839 | ||
d62a17ae | 1840 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1841 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1842 | "Forward packets over multiple paths\n" | |
1843 | "Number of paths\n") | |
596c17ba | 1844 | |
165b5fff JB |
1845 | DEFUN (bgp_maxpaths_ibgp, |
1846 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1847 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1848 | "Forward packets over multiple paths\n" |
1849 | "iBGP-multipath\n" | |
1850 | "Number of paths\n") | |
1851 | { | |
d62a17ae | 1852 | int idx_number = 2; |
1853 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1854 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1855 | } |
165b5fff | 1856 | |
d62a17ae | 1857 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1858 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1859 | "Forward packets over multiple paths\n" | |
1860 | "iBGP-multipath\n" | |
1861 | "Number of paths\n") | |
596c17ba | 1862 | |
5e242b0d DS |
1863 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1864 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1865 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1866 | "Forward packets over multiple paths\n" |
1867 | "iBGP-multipath\n" | |
1868 | "Number of paths\n" | |
1869 | "Match the cluster length\n") | |
1870 | { | |
d62a17ae | 1871 | int idx_number = 2; |
1872 | return bgp_maxpaths_config_vty( | |
1873 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1874 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1875 | } |
1876 | ||
d62a17ae | 1877 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1878 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1879 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1880 | "Forward packets over multiple paths\n" | |
1881 | "iBGP-multipath\n" | |
1882 | "Number of paths\n" | |
1883 | "Match the cluster length\n") | |
596c17ba | 1884 | |
165b5fff JB |
1885 | DEFUN (no_bgp_maxpaths, |
1886 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1887 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1888 | NO_STR |
1889 | "Forward packets over multiple paths\n" | |
1890 | "Number of paths\n") | |
1891 | { | |
d62a17ae | 1892 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1893 | } |
1894 | ||
d62a17ae | 1895 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1896 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1897 | "Forward packets over multiple paths\n" |
1898 | "Number of paths\n") | |
596c17ba | 1899 | |
165b5fff JB |
1900 | DEFUN (no_bgp_maxpaths_ibgp, |
1901 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1902 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1903 | NO_STR |
1904 | "Forward packets over multiple paths\n" | |
1905 | "iBGP-multipath\n" | |
838758ac DW |
1906 | "Number of paths\n" |
1907 | "Match the cluster length\n") | |
165b5fff | 1908 | { |
d62a17ae | 1909 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1910 | } |
1911 | ||
d62a17ae | 1912 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1913 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1914 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1915 | NO_STR | |
1916 | "Forward packets over multiple paths\n" | |
1917 | "iBGP-multipath\n" | |
1918 | "Number of paths\n" | |
1919 | "Match the cluster length\n") | |
596c17ba | 1920 | |
dd65f45e DL |
1921 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1922 | afi_t afi, safi_t safi) | |
165b5fff | 1923 | { |
d62a17ae | 1924 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1925 | vty_out(vty, " maximum-paths %d\n", |
1926 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1927 | } | |
165b5fff | 1928 | |
d62a17ae | 1929 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1930 | vty_out(vty, " maximum-paths ibgp %d", |
1931 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1932 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1933 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1934 | vty_out(vty, " equal-cluster-length"); | |
1935 | vty_out(vty, "\n"); | |
1936 | } | |
165b5fff | 1937 | } |
6b0655a2 | 1938 | |
718e3744 | 1939 | /* BGP timers. */ |
1940 | ||
1941 | DEFUN (bgp_timers, | |
1942 | bgp_timers_cmd, | |
6147e2c6 | 1943 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1944 | "Adjust routing timers\n" |
1945 | "BGP timers\n" | |
1946 | "Keepalive interval\n" | |
1947 | "Holdtime\n") | |
1948 | { | |
d62a17ae | 1949 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1950 | int idx_number = 2; | |
1951 | int idx_number_2 = 3; | |
1952 | unsigned long keepalive = 0; | |
1953 | unsigned long holdtime = 0; | |
718e3744 | 1954 | |
d62a17ae | 1955 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1956 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1957 | |
d62a17ae | 1958 | /* Holdtime value check. */ |
1959 | if (holdtime < 3 && holdtime != 0) { | |
1960 | vty_out(vty, | |
1961 | "%% hold time value must be either 0 or greater than 3\n"); | |
1962 | return CMD_WARNING_CONFIG_FAILED; | |
1963 | } | |
718e3744 | 1964 | |
5d5393b9 | 1965 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1966 | |
d62a17ae | 1967 | return CMD_SUCCESS; |
718e3744 | 1968 | } |
1969 | ||
1970 | DEFUN (no_bgp_timers, | |
1971 | no_bgp_timers_cmd, | |
838758ac | 1972 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1973 | NO_STR |
1974 | "Adjust routing timers\n" | |
838758ac DW |
1975 | "BGP timers\n" |
1976 | "Keepalive interval\n" | |
1977 | "Holdtime\n") | |
718e3744 | 1978 | { |
d62a17ae | 1979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1980 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1981 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1982 | |
d62a17ae | 1983 | return CMD_SUCCESS; |
718e3744 | 1984 | } |
1985 | ||
6b0655a2 | 1986 | |
718e3744 | 1987 | DEFUN (bgp_client_to_client_reflection, |
1988 | bgp_client_to_client_reflection_cmd, | |
1989 | "bgp client-to-client reflection", | |
1990 | "BGP specific commands\n" | |
1991 | "Configure client to client route reflection\n" | |
1992 | "reflection of routes allowed\n") | |
1993 | { | |
d62a17ae | 1994 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1995 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1996 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1997 | |
d62a17ae | 1998 | return CMD_SUCCESS; |
718e3744 | 1999 | } |
2000 | ||
2001 | DEFUN (no_bgp_client_to_client_reflection, | |
2002 | no_bgp_client_to_client_reflection_cmd, | |
2003 | "no bgp client-to-client reflection", | |
2004 | NO_STR | |
2005 | "BGP specific commands\n" | |
2006 | "Configure client to client route reflection\n" | |
2007 | "reflection of routes allowed\n") | |
2008 | { | |
d62a17ae | 2009 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2010 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2011 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2012 | |
d62a17ae | 2013 | return CMD_SUCCESS; |
718e3744 | 2014 | } |
2015 | ||
2016 | /* "bgp always-compare-med" configuration. */ | |
2017 | DEFUN (bgp_always_compare_med, | |
2018 | bgp_always_compare_med_cmd, | |
2019 | "bgp always-compare-med", | |
2020 | "BGP specific commands\n" | |
2021 | "Allow comparing MED from different neighbors\n") | |
2022 | { | |
d62a17ae | 2023 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2024 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2025 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2026 | |
d62a17ae | 2027 | return CMD_SUCCESS; |
718e3744 | 2028 | } |
2029 | ||
2030 | DEFUN (no_bgp_always_compare_med, | |
2031 | no_bgp_always_compare_med_cmd, | |
2032 | "no bgp always-compare-med", | |
2033 | NO_STR | |
2034 | "BGP specific commands\n" | |
2035 | "Allow comparing MED from different neighbors\n") | |
2036 | { | |
d62a17ae | 2037 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2038 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2039 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2040 | |
d62a17ae | 2041 | return CMD_SUCCESS; |
718e3744 | 2042 | } |
6b0655a2 | 2043 | |
9dac9fc8 DA |
2044 | |
2045 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2046 | "bgp ebgp-requires-policy", | |
2047 | "BGP specific commands\n" | |
2048 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2049 | { | |
2050 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2051 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
2052 | return CMD_SUCCESS; | |
2053 | } | |
2054 | ||
2055 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2056 | "no bgp ebgp-requires-policy", | |
2057 | NO_STR | |
2058 | "BGP specific commands\n" | |
2059 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2060 | { | |
2061 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2062 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
2063 | return CMD_SUCCESS; | |
2064 | } | |
2065 | ||
fb29348a DA |
2066 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2067 | "bgp reject-as-sets", | |
2068 | "BGP specific commands\n" | |
2069 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2070 | { | |
2071 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2072 | struct listnode *node, *nnode; | |
2073 | struct peer *peer; | |
2074 | ||
2075 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_ENABLED; | |
2076 | ||
2077 | /* Reset existing BGP sessions to reject routes | |
2078 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2079 | */ | |
2080 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2081 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2082 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2083 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2084 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2085 | } | |
2086 | } | |
2087 | ||
2088 | return CMD_SUCCESS; | |
2089 | } | |
2090 | ||
2091 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2092 | "no bgp reject-as-sets", | |
2093 | NO_STR | |
2094 | "BGP specific commands\n" | |
2095 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2096 | { | |
2097 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2098 | struct listnode *node, *nnode; | |
2099 | struct peer *peer; | |
2100 | ||
2101 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_DISABLED; | |
2102 | ||
2103 | /* Reset existing BGP sessions to reject routes | |
2104 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2105 | */ | |
2106 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2107 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2108 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2109 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2110 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2111 | } | |
2112 | } | |
2113 | ||
2114 | return CMD_SUCCESS; | |
2115 | } | |
9dac9fc8 | 2116 | |
718e3744 | 2117 | /* "bgp deterministic-med" configuration. */ |
2118 | DEFUN (bgp_deterministic_med, | |
2119 | bgp_deterministic_med_cmd, | |
2120 | "bgp deterministic-med", | |
2121 | "BGP specific commands\n" | |
2122 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2123 | { | |
d62a17ae | 2124 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2125 | |
d62a17ae | 2126 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
2127 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2128 | bgp_recalculate_all_bestpaths(bgp); | |
2129 | } | |
7aafcaca | 2130 | |
d62a17ae | 2131 | return CMD_SUCCESS; |
718e3744 | 2132 | } |
2133 | ||
2134 | DEFUN (no_bgp_deterministic_med, | |
2135 | no_bgp_deterministic_med_cmd, | |
2136 | "no bgp deterministic-med", | |
2137 | NO_STR | |
2138 | "BGP specific commands\n" | |
2139 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2140 | { | |
d62a17ae | 2141 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2142 | int bestpath_per_as_used; | |
2143 | afi_t afi; | |
2144 | safi_t safi; | |
2145 | struct peer *peer; | |
2146 | struct listnode *node, *nnode; | |
2147 | ||
2148 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
2149 | bestpath_per_as_used = 0; | |
2150 | ||
2151 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2152 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2153 | if (bgp_addpath_dmed_required( |
2154 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2155 | bestpath_per_as_used = 1; |
2156 | break; | |
2157 | } | |
d62a17ae | 2158 | |
2159 | if (bestpath_per_as_used) | |
2160 | break; | |
2161 | } | |
2162 | ||
2163 | if (bestpath_per_as_used) { | |
2164 | vty_out(vty, | |
2165 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2166 | return CMD_WARNING_CONFIG_FAILED; | |
2167 | } else { | |
2168 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2169 | bgp_recalculate_all_bestpaths(bgp); | |
2170 | } | |
2171 | } | |
2172 | ||
2173 | return CMD_SUCCESS; | |
718e3744 | 2174 | } |
538621f2 | 2175 | |
055679e9 | 2176 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2177 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2178 | bgp_graceful_restart_cmd, |
2179 | "bgp graceful-restart", | |
2180 | "BGP specific commands\n" | |
2181 | GR_CMD | |
055679e9 | 2182 | ) |
538621f2 | 2183 | { |
055679e9 | 2184 | int ret = BGP_GR_FAILURE; |
2185 | ||
2186 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2187 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2188 | |
d62a17ae | 2189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2190 | |
2191 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2192 | ||
36235319 QY |
2193 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2194 | ret); | |
5cce3f05 | 2195 | |
055679e9 | 2196 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2197 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2198 | vty_out(vty, |
2199 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2200 | return bgp_vty_return(vty, ret); |
538621f2 | 2201 | } |
2202 | ||
2203 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2204 | no_bgp_graceful_restart_cmd, |
2205 | "no bgp graceful-restart", | |
2206 | NO_STR | |
2207 | "BGP specific commands\n" | |
2208 | NO_GR_CMD | |
055679e9 | 2209 | ) |
538621f2 | 2210 | { |
d62a17ae | 2211 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2212 | |
2213 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2214 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2215 | |
2216 | int ret = BGP_GR_FAILURE; | |
2217 | ||
2218 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2219 | ||
36235319 QY |
2220 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2221 | ret); | |
5cce3f05 | 2222 | |
055679e9 | 2223 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2224 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2225 | vty_out(vty, |
2226 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2227 | |
2228 | return bgp_vty_return(vty, ret); | |
538621f2 | 2229 | } |
2230 | ||
93406d87 | 2231 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2232 | bgp_graceful_restart_stalepath_time_cmd, |
2233 | "bgp graceful-restart stalepath-time (1-4095)", | |
2234 | "BGP specific commands\n" | |
2235 | "Graceful restart capability parameters\n" | |
2236 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2237 | "Delay value (seconds)\n") | |
93406d87 | 2238 | { |
d62a17ae | 2239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2240 | int idx_number = 3; | |
d7c0a89a | 2241 | uint32_t stalepath; |
93406d87 | 2242 | |
d62a17ae | 2243 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2244 | bgp->stalepath_time = stalepath; | |
2245 | return CMD_SUCCESS; | |
93406d87 | 2246 | } |
2247 | ||
eb6f1b41 | 2248 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2249 | bgp_graceful_restart_restart_time_cmd, |
2250 | "bgp graceful-restart restart-time (1-4095)", | |
2251 | "BGP specific commands\n" | |
2252 | "Graceful restart capability parameters\n" | |
2253 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2254 | "Delay value (seconds)\n") | |
eb6f1b41 | 2255 | { |
d62a17ae | 2256 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2257 | int idx_number = 3; | |
d7c0a89a | 2258 | uint32_t restart; |
eb6f1b41 | 2259 | |
d62a17ae | 2260 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2261 | bgp->restart_time = restart; | |
2262 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2263 | } |
2264 | ||
cfd47646 | 2265 | DEFUN (bgp_graceful_restart_select_defer_time, |
2266 | bgp_graceful_restart_select_defer_time_cmd, | |
2267 | "bgp graceful-restart select-defer-time (0-3600)", | |
2268 | "BGP specific commands\n" | |
2269 | "Graceful restart capability parameters\n" | |
2270 | "Set the time to defer the BGP route selection after restart\n" | |
2271 | "Delay value (seconds, 0 - disable)\n") | |
2272 | { | |
2273 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2274 | int idx_number = 3; | |
2275 | uint32_t defer_time; | |
2276 | ||
2277 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2278 | bgp->select_defer_time = defer_time; | |
2279 | if (defer_time == 0) | |
2280 | bgp_flag_set(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2281 | else | |
2282 | bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2283 | ||
2284 | return CMD_SUCCESS; | |
2285 | } | |
2286 | ||
93406d87 | 2287 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2288 | no_bgp_graceful_restart_stalepath_time_cmd, |
2289 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2290 | NO_STR | |
2291 | "BGP specific commands\n" | |
2292 | "Graceful restart capability parameters\n" | |
2293 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2294 | "Delay value (seconds)\n") | |
93406d87 | 2295 | { |
d62a17ae | 2296 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2297 | |
d62a17ae | 2298 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2299 | return CMD_SUCCESS; | |
93406d87 | 2300 | } |
2301 | ||
eb6f1b41 | 2302 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2303 | no_bgp_graceful_restart_restart_time_cmd, |
2304 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2305 | NO_STR | |
2306 | "BGP specific commands\n" | |
2307 | "Graceful restart capability parameters\n" | |
2308 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2309 | "Delay value (seconds)\n") | |
eb6f1b41 | 2310 | { |
d62a17ae | 2311 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2312 | |
d62a17ae | 2313 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2314 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2315 | } |
2316 | ||
cfd47646 | 2317 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2318 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2319 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2320 | NO_STR | |
2321 | "BGP specific commands\n" | |
2322 | "Graceful restart capability parameters\n" | |
2323 | "Set the time to defer the BGP route selection after restart\n" | |
2324 | "Delay value (seconds)\n") | |
2325 | { | |
2326 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2327 | ||
2328 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
2329 | bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2330 | ||
2331 | return CMD_SUCCESS; | |
2332 | } | |
2333 | ||
43fc21b3 | 2334 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2335 | bgp_graceful_restart_preserve_fw_cmd, |
2336 | "bgp graceful-restart preserve-fw-state", | |
2337 | "BGP specific commands\n" | |
2338 | "Graceful restart capability parameters\n" | |
2339 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2340 | { |
d62a17ae | 2341 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2342 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2343 | return CMD_SUCCESS; | |
43fc21b3 JC |
2344 | } |
2345 | ||
2346 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2347 | no_bgp_graceful_restart_preserve_fw_cmd, |
2348 | "no bgp graceful-restart preserve-fw-state", | |
2349 | NO_STR | |
2350 | "BGP specific commands\n" | |
2351 | "Graceful restart capability parameters\n" | |
2352 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2353 | { |
d62a17ae | 2354 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2355 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2356 | return CMD_SUCCESS; | |
43fc21b3 JC |
2357 | } |
2358 | ||
055679e9 | 2359 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2360 | bgp_graceful_restart_disable_cmd, |
2361 | "bgp graceful-restart-disable", | |
2362 | "BGP specific commands\n" | |
2363 | GR_DISABLE) | |
055679e9 | 2364 | { |
2365 | int ret = BGP_GR_FAILURE; | |
2366 | ||
2367 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2368 | zlog_debug( | |
2ba1fe69 | 2369 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2370 | |
055679e9 | 2371 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2372 | ||
2373 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2374 | ||
dc95985f | 2375 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2376 | bgp->peer, ret); | |
5cce3f05 | 2377 | |
055679e9 | 2378 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2379 | zlog_debug( | |
2ba1fe69 | 2380 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2381 | vty_out(vty, |
2382 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2383 | ||
055679e9 | 2384 | return bgp_vty_return(vty, ret); |
2385 | } | |
2386 | ||
2387 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2388 | no_bgp_graceful_restart_disable_cmd, |
2389 | "no bgp graceful-restart-disable", | |
2390 | NO_STR | |
2391 | "BGP specific commands\n" | |
2392 | NO_GR_DISABLE | |
055679e9 | 2393 | ) |
2394 | { | |
2395 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2396 | ||
2397 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2398 | zlog_debug( | |
2ba1fe69 | 2399 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2400 | |
2401 | int ret = BGP_GR_FAILURE; | |
2402 | ||
2403 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2404 | ||
36235319 QY |
2405 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2406 | ret); | |
5cce3f05 | 2407 | |
055679e9 | 2408 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2409 | zlog_debug( | |
2ba1fe69 | 2410 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2411 | vty_out(vty, |
2412 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2413 | |
2414 | return bgp_vty_return(vty, ret); | |
2415 | } | |
2416 | ||
2417 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2418 | bgp_neighbor_graceful_restart_set_cmd, |
2419 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2420 | NEIGHBOR_STR | |
2421 | NEIGHBOR_ADDR_STR2 | |
2422 | GR_NEIGHBOR_CMD | |
055679e9 | 2423 | ) |
2424 | { | |
2425 | int idx_peer = 1; | |
2426 | struct peer *peer; | |
2427 | int ret = BGP_GR_FAILURE; | |
2428 | ||
dc95985f | 2429 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2430 | ||
055679e9 | 2431 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2432 | zlog_debug( | |
2ba1fe69 | 2433 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2434 | |
055679e9 | 2435 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2436 | if (!peer) | |
2437 | return CMD_WARNING_CONFIG_FAILED; | |
2438 | ||
2439 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2440 | ||
dc95985f | 2441 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2442 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2443 | |
2444 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2445 | zlog_debug( | |
2ba1fe69 | 2446 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2447 | vty_out(vty, |
2448 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2449 | |
2450 | return bgp_vty_return(vty, ret); | |
2451 | } | |
2452 | ||
2453 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2454 | no_bgp_neighbor_graceful_restart_set_cmd, |
2455 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2456 | NO_STR | |
2457 | NEIGHBOR_STR | |
2458 | NEIGHBOR_ADDR_STR2 | |
2459 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2460 | ) |
2461 | { | |
2462 | int idx_peer = 2; | |
2463 | int ret = BGP_GR_FAILURE; | |
2464 | struct peer *peer; | |
2465 | ||
dc95985f | 2466 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2467 | ||
055679e9 | 2468 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2469 | if (!peer) | |
2470 | return CMD_WARNING_CONFIG_FAILED; | |
2471 | ||
2472 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2473 | zlog_debug( | |
2ba1fe69 | 2474 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2475 | |
2476 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2477 | ||
dc95985f | 2478 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2479 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2480 | |
2481 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2482 | zlog_debug( | |
2ba1fe69 | 2483 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2484 | vty_out(vty, |
2485 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2486 | |
2487 | return bgp_vty_return(vty, ret); | |
2488 | } | |
2489 | ||
2490 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2491 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2492 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2493 | NEIGHBOR_STR | |
2494 | NEIGHBOR_ADDR_STR2 | |
2495 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2496 | ) |
2497 | { | |
2498 | int idx_peer = 1; | |
2499 | struct peer *peer; | |
2500 | int ret = BGP_GR_FAILURE; | |
2501 | ||
dc95985f | 2502 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2503 | ||
055679e9 | 2504 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2505 | zlog_debug( | |
2ba1fe69 | 2506 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2507 | |
055679e9 | 2508 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2509 | ||
055679e9 | 2510 | if (!peer) |
2511 | return CMD_WARNING_CONFIG_FAILED; | |
2512 | ||
2513 | ||
2514 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2515 | |
dc95985f | 2516 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2517 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2518 | |
055679e9 | 2519 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2520 | zlog_debug( | |
2ba1fe69 | 2521 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2522 | vty_out(vty, |
2523 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2524 | |
2525 | return bgp_vty_return(vty, ret); | |
2526 | } | |
2527 | ||
2528 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2529 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2530 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2531 | NO_STR | |
2532 | NEIGHBOR_STR | |
2533 | NEIGHBOR_ADDR_STR2 | |
2534 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2535 | ) |
2536 | { | |
2537 | int idx_peer = 2; | |
2538 | int ret = BGP_GR_FAILURE; | |
2539 | struct peer *peer; | |
2540 | ||
dc95985f | 2541 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2542 | ||
055679e9 | 2543 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2544 | if (!peer) | |
2545 | return CMD_WARNING_CONFIG_FAILED; | |
2546 | ||
2547 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2548 | zlog_debug( | |
2ba1fe69 | 2549 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2550 | |
36235319 | 2551 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2552 | |
dc95985f | 2553 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2554 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2555 | |
2556 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2557 | zlog_debug( | |
2ba1fe69 | 2558 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2559 | vty_out(vty, |
2560 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2561 | |
2562 | return bgp_vty_return(vty, ret); | |
2563 | } | |
2564 | ||
2565 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2566 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2567 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2568 | NEIGHBOR_STR | |
2569 | NEIGHBOR_ADDR_STR2 | |
2570 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2571 | ) |
2572 | { | |
2573 | int idx_peer = 1; | |
2574 | struct peer *peer; | |
2575 | int ret = BGP_GR_FAILURE; | |
2576 | ||
dc95985f | 2577 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2578 | ||
055679e9 | 2579 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2580 | zlog_debug( | |
2ba1fe69 | 2581 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2582 | |
2583 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2584 | if (!peer) | |
2585 | return CMD_WARNING_CONFIG_FAILED; | |
2586 | ||
36235319 | 2587 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2588 | |
2589 | if (peer->bgp->t_startup) | |
2590 | bgp_peer_gr_flags_update(peer); | |
2591 | ||
dc95985f | 2592 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2593 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2594 | ||
055679e9 | 2595 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2596 | zlog_debug( | |
2ba1fe69 | 2597 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2598 | vty_out(vty, |
2599 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2600 | |
2601 | return bgp_vty_return(vty, ret); | |
2602 | } | |
2603 | ||
2604 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2605 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2606 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2607 | NO_STR | |
2608 | NEIGHBOR_STR | |
2609 | NEIGHBOR_ADDR_STR2 | |
2610 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2611 | ) |
2612 | { | |
2613 | int idx_peer = 2; | |
2614 | int ret = BGP_GR_FAILURE; | |
2615 | struct peer *peer; | |
2616 | ||
dc95985f | 2617 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2618 | ||
055679e9 | 2619 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2620 | if (!peer) | |
2621 | return CMD_WARNING_CONFIG_FAILED; | |
2622 | ||
2623 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2624 | zlog_debug( | |
2ba1fe69 | 2625 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2626 | |
2627 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2628 | ||
dc95985f | 2629 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2630 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2631 | |
2632 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2633 | zlog_debug( | |
2ba1fe69 | 2634 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2635 | vty_out(vty, |
2636 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2637 | |
2638 | return bgp_vty_return(vty, ret); | |
2639 | } | |
2640 | ||
d6e3c15b | 2641 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2642 | bgp_graceful_restart_disable_eor_cmd, | |
2643 | "bgp graceful-restart disable-eor", | |
2644 | "BGP specific commands\n" | |
2645 | "Graceful restart configuration parameters\n" | |
2646 | "Disable EOR Check\n") | |
2647 | { | |
2648 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2649 | bgp_flag_set(bgp, BGP_FLAG_GR_DISABLE_EOR); | |
dc95985f | 2650 | |
d6e3c15b | 2651 | return CMD_SUCCESS; |
2652 | } | |
2653 | ||
2654 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2655 | no_bgp_graceful_restart_disable_eor_cmd, | |
2656 | "no bgp graceful-restart disable-eor", | |
2657 | NO_STR | |
2658 | "BGP specific commands\n" | |
2659 | "Graceful restart configuration parameters\n" | |
2660 | "Disable EOR Check\n") | |
2661 | { | |
2662 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2663 | bgp_flag_unset(bgp, BGP_FLAG_GR_DISABLE_EOR); | |
dc95985f | 2664 | |
2665 | return CMD_SUCCESS; | |
2666 | } | |
2667 | ||
2668 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2669 | bgp_graceful_restart_rib_stale_time_cmd, | |
2670 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2671 | "BGP specific commands\n" | |
2672 | "Graceful restart configuration parameters\n" | |
2673 | "Specify the stale route removal timer in rib\n" | |
2674 | "Delay value (seconds)\n") | |
2675 | { | |
2676 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2677 | int idx_number = 3; | |
2678 | uint32_t stale_time; | |
2679 | ||
2680 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2681 | bgp->rib_stale_time = stale_time; | |
2682 | /* Send the stale timer update message to RIB */ | |
2683 | if (bgp_zebra_stale_timer_update(bgp)) | |
2684 | return CMD_WARNING; | |
2685 | ||
2686 | return CMD_SUCCESS; | |
2687 | } | |
2688 | ||
2689 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2690 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2691 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2692 | NO_STR | |
2693 | "BGP specific commands\n" | |
2694 | "Graceful restart configuration parameters\n" | |
2695 | "Specify the stale route removal timer in rib\n" | |
2696 | "Delay value (seconds)\n") | |
2697 | { | |
2698 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2699 | ||
2700 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2701 | /* Send the stale timer update message to RIB */ | |
2702 | if (bgp_zebra_stale_timer_update(bgp)) | |
2703 | return CMD_WARNING; | |
2704 | ||
d6e3c15b | 2705 | return CMD_SUCCESS; |
2706 | } | |
2707 | ||
7f323236 DW |
2708 | /* "bgp graceful-shutdown" configuration */ |
2709 | DEFUN (bgp_graceful_shutdown, | |
2710 | bgp_graceful_shutdown_cmd, | |
2711 | "bgp graceful-shutdown", | |
2712 | BGP_STR | |
2713 | "Graceful shutdown parameters\n") | |
2714 | { | |
2715 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2716 | ||
2717 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2718 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2719 | bgp_static_redo_import_check(bgp); | |
2720 | bgp_redistribute_redo(bgp); | |
2721 | bgp_clear_star_soft_out(vty, bgp->name); | |
2722 | bgp_clear_star_soft_in(vty, bgp->name); | |
2723 | } | |
2724 | ||
2725 | return CMD_SUCCESS; | |
2726 | } | |
2727 | ||
2728 | DEFUN (no_bgp_graceful_shutdown, | |
2729 | no_bgp_graceful_shutdown_cmd, | |
2730 | "no bgp graceful-shutdown", | |
2731 | NO_STR | |
2732 | BGP_STR | |
2733 | "Graceful shutdown parameters\n") | |
2734 | { | |
2735 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2736 | ||
2737 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2738 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2739 | bgp_static_redo_import_check(bgp); | |
2740 | bgp_redistribute_redo(bgp); | |
2741 | bgp_clear_star_soft_out(vty, bgp->name); | |
2742 | bgp_clear_star_soft_in(vty, bgp->name); | |
2743 | } | |
2744 | ||
2745 | return CMD_SUCCESS; | |
2746 | } | |
2747 | ||
718e3744 | 2748 | /* "bgp fast-external-failover" configuration. */ |
2749 | DEFUN (bgp_fast_external_failover, | |
2750 | bgp_fast_external_failover_cmd, | |
2751 | "bgp fast-external-failover", | |
2752 | BGP_STR | |
2753 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2754 | { | |
d62a17ae | 2755 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2756 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2757 | return CMD_SUCCESS; | |
718e3744 | 2758 | } |
2759 | ||
2760 | DEFUN (no_bgp_fast_external_failover, | |
2761 | no_bgp_fast_external_failover_cmd, | |
2762 | "no bgp fast-external-failover", | |
2763 | NO_STR | |
2764 | BGP_STR | |
2765 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2766 | { | |
d62a17ae | 2767 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2768 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2769 | return CMD_SUCCESS; | |
718e3744 | 2770 | } |
6b0655a2 | 2771 | |
718e3744 | 2772 | /* "bgp bestpath compare-routerid" configuration. */ |
2773 | DEFUN (bgp_bestpath_compare_router_id, | |
2774 | bgp_bestpath_compare_router_id_cmd, | |
2775 | "bgp bestpath compare-routerid", | |
2776 | "BGP specific commands\n" | |
2777 | "Change the default bestpath selection\n" | |
2778 | "Compare router-id for identical EBGP paths\n") | |
2779 | { | |
d62a17ae | 2780 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2781 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2782 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2783 | |
d62a17ae | 2784 | return CMD_SUCCESS; |
718e3744 | 2785 | } |
2786 | ||
2787 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2788 | no_bgp_bestpath_compare_router_id_cmd, | |
2789 | "no bgp bestpath compare-routerid", | |
2790 | NO_STR | |
2791 | "BGP specific commands\n" | |
2792 | "Change the default bestpath selection\n" | |
2793 | "Compare router-id for identical EBGP paths\n") | |
2794 | { | |
d62a17ae | 2795 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2796 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2797 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2798 | |
d62a17ae | 2799 | return CMD_SUCCESS; |
718e3744 | 2800 | } |
6b0655a2 | 2801 | |
718e3744 | 2802 | /* "bgp bestpath as-path ignore" configuration. */ |
2803 | DEFUN (bgp_bestpath_aspath_ignore, | |
2804 | bgp_bestpath_aspath_ignore_cmd, | |
2805 | "bgp bestpath as-path ignore", | |
2806 | "BGP specific commands\n" | |
2807 | "Change the default bestpath selection\n" | |
2808 | "AS-path attribute\n" | |
2809 | "Ignore as-path length in selecting a route\n") | |
2810 | { | |
d62a17ae | 2811 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2812 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2813 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2814 | |
d62a17ae | 2815 | return CMD_SUCCESS; |
718e3744 | 2816 | } |
2817 | ||
2818 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2819 | no_bgp_bestpath_aspath_ignore_cmd, | |
2820 | "no bgp bestpath as-path ignore", | |
2821 | NO_STR | |
2822 | "BGP specific commands\n" | |
2823 | "Change the default bestpath selection\n" | |
2824 | "AS-path attribute\n" | |
2825 | "Ignore as-path length in selecting a route\n") | |
2826 | { | |
d62a17ae | 2827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2828 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2829 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2830 | |
d62a17ae | 2831 | return CMD_SUCCESS; |
718e3744 | 2832 | } |
6b0655a2 | 2833 | |
6811845b | 2834 | /* "bgp bestpath as-path confed" configuration. */ |
2835 | DEFUN (bgp_bestpath_aspath_confed, | |
2836 | bgp_bestpath_aspath_confed_cmd, | |
2837 | "bgp bestpath as-path confed", | |
2838 | "BGP specific commands\n" | |
2839 | "Change the default bestpath selection\n" | |
2840 | "AS-path attribute\n" | |
2841 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2842 | { | |
d62a17ae | 2843 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2844 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2845 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2846 | |
d62a17ae | 2847 | return CMD_SUCCESS; |
6811845b | 2848 | } |
2849 | ||
2850 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2851 | no_bgp_bestpath_aspath_confed_cmd, | |
2852 | "no bgp bestpath as-path confed", | |
2853 | NO_STR | |
2854 | "BGP specific commands\n" | |
2855 | "Change the default bestpath selection\n" | |
2856 | "AS-path attribute\n" | |
2857 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2858 | { | |
d62a17ae | 2859 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2860 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2861 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2862 | |
d62a17ae | 2863 | return CMD_SUCCESS; |
6811845b | 2864 | } |
6b0655a2 | 2865 | |
2fdd455c PM |
2866 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2867 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2868 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2869 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2870 | "BGP specific commands\n" |
2871 | "Change the default bestpath selection\n" | |
2872 | "AS-path attribute\n" | |
2873 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2874 | "Generate an AS_SET\n" |
16fc1eec DS |
2875 | "Do not generate an AS_SET\n") |
2876 | { | |
d62a17ae | 2877 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2878 | int idx = 0; | |
2879 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2880 | |
d62a17ae | 2881 | /* no-as-set is now the default behavior so we can silently |
2882 | * ignore it */ | |
2883 | if (argv_find(argv, argc, "as-set", &idx)) | |
2884 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2885 | else | |
2886 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2887 | |
d62a17ae | 2888 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2889 | |
d62a17ae | 2890 | return CMD_SUCCESS; |
16fc1eec DS |
2891 | } |
2892 | ||
219178b6 DW |
2893 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2894 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2895 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2896 | NO_STR |
2897 | "BGP specific commands\n" | |
2898 | "Change the default bestpath selection\n" | |
2899 | "AS-path attribute\n" | |
2900 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2901 | "Generate an AS_SET\n" |
16fc1eec DS |
2902 | "Do not generate an AS_SET\n") |
2903 | { | |
d62a17ae | 2904 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2905 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2906 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2907 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2908 | |
d62a17ae | 2909 | return CMD_SUCCESS; |
2fdd455c | 2910 | } |
6b0655a2 | 2911 | |
848973c7 | 2912 | /* "bgp log-neighbor-changes" configuration. */ |
2913 | DEFUN (bgp_log_neighbor_changes, | |
2914 | bgp_log_neighbor_changes_cmd, | |
2915 | "bgp log-neighbor-changes", | |
2916 | "BGP specific commands\n" | |
2917 | "Log neighbor up/down and reset reason\n") | |
2918 | { | |
d62a17ae | 2919 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2920 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2921 | return CMD_SUCCESS; | |
848973c7 | 2922 | } |
2923 | ||
2924 | DEFUN (no_bgp_log_neighbor_changes, | |
2925 | no_bgp_log_neighbor_changes_cmd, | |
2926 | "no bgp log-neighbor-changes", | |
2927 | NO_STR | |
2928 | "BGP specific commands\n" | |
2929 | "Log neighbor up/down and reset reason\n") | |
2930 | { | |
d62a17ae | 2931 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2932 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2933 | return CMD_SUCCESS; | |
848973c7 | 2934 | } |
6b0655a2 | 2935 | |
718e3744 | 2936 | /* "bgp bestpath med" configuration. */ |
2937 | DEFUN (bgp_bestpath_med, | |
2938 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2939 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2940 | "BGP specific commands\n" |
2941 | "Change the default bestpath selection\n" | |
2942 | "MED attribute\n" | |
2943 | "Compare MED among confederation paths\n" | |
838758ac DW |
2944 | "Treat missing MED as the least preferred one\n" |
2945 | "Treat missing MED as the least preferred one\n" | |
2946 | "Compare MED among confederation paths\n") | |
718e3744 | 2947 | { |
d62a17ae | 2948 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2949 | |
d62a17ae | 2950 | int idx = 0; |
2951 | if (argv_find(argv, argc, "confed", &idx)) | |
2952 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2953 | idx = 0; | |
2954 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2955 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2956 | |
d62a17ae | 2957 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2958 | |
d62a17ae | 2959 | return CMD_SUCCESS; |
718e3744 | 2960 | } |
2961 | ||
718e3744 | 2962 | DEFUN (no_bgp_bestpath_med, |
2963 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2964 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2965 | NO_STR |
2966 | "BGP specific commands\n" | |
2967 | "Change the default bestpath selection\n" | |
2968 | "MED attribute\n" | |
2969 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2970 | "Treat missing MED as the least preferred one\n" |
2971 | "Treat missing MED as the least preferred one\n" | |
2972 | "Compare MED among confederation paths\n") | |
718e3744 | 2973 | { |
d62a17ae | 2974 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2975 | |
d62a17ae | 2976 | int idx = 0; |
2977 | if (argv_find(argv, argc, "confed", &idx)) | |
2978 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2979 | idx = 0; | |
2980 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2981 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2982 | |
d62a17ae | 2983 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2984 | |
d62a17ae | 2985 | return CMD_SUCCESS; |
718e3744 | 2986 | } |
2987 | ||
718e3744 | 2988 | /* "no bgp default ipv4-unicast". */ |
2989 | DEFUN (no_bgp_default_ipv4_unicast, | |
2990 | no_bgp_default_ipv4_unicast_cmd, | |
2991 | "no bgp default ipv4-unicast", | |
2992 | NO_STR | |
2993 | "BGP specific commands\n" | |
2994 | "Configure BGP defaults\n" | |
2995 | "Activate ipv4-unicast for a peer by default\n") | |
2996 | { | |
d62a17ae | 2997 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2998 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2999 | return CMD_SUCCESS; | |
718e3744 | 3000 | } |
3001 | ||
3002 | DEFUN (bgp_default_ipv4_unicast, | |
3003 | bgp_default_ipv4_unicast_cmd, | |
3004 | "bgp default ipv4-unicast", | |
3005 | "BGP specific commands\n" | |
3006 | "Configure BGP defaults\n" | |
3007 | "Activate ipv4-unicast for a peer by default\n") | |
3008 | { | |
d62a17ae | 3009 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3010 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
3011 | return CMD_SUCCESS; | |
718e3744 | 3012 | } |
6b0655a2 | 3013 | |
04b6bdc0 DW |
3014 | /* Display hostname in certain command outputs */ |
3015 | DEFUN (bgp_default_show_hostname, | |
3016 | bgp_default_show_hostname_cmd, | |
3017 | "bgp default show-hostname", | |
3018 | "BGP specific commands\n" | |
3019 | "Configure BGP defaults\n" | |
0437e105 | 3020 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3021 | { |
d62a17ae | 3022 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3023 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
3024 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3025 | } |
3026 | ||
3027 | DEFUN (no_bgp_default_show_hostname, | |
3028 | no_bgp_default_show_hostname_cmd, | |
3029 | "no bgp default show-hostname", | |
3030 | NO_STR | |
3031 | "BGP specific commands\n" | |
3032 | "Configure BGP defaults\n" | |
0437e105 | 3033 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3034 | { |
d62a17ae | 3035 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3036 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
3037 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3038 | } |
3039 | ||
8233ef81 | 3040 | /* "bgp network import-check" configuration. */ |
718e3744 | 3041 | DEFUN (bgp_network_import_check, |
3042 | bgp_network_import_check_cmd, | |
5623e905 | 3043 | "bgp network import-check", |
718e3744 | 3044 | "BGP specific commands\n" |
3045 | "BGP network command\n" | |
5623e905 | 3046 | "Check BGP network route exists in IGP\n") |
718e3744 | 3047 | { |
d62a17ae | 3048 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3049 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
3050 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
3051 | bgp_static_redo_import_check(bgp); | |
3052 | } | |
078430f6 | 3053 | |
d62a17ae | 3054 | return CMD_SUCCESS; |
718e3744 | 3055 | } |
3056 | ||
d62a17ae | 3057 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3058 | "bgp network import-check exact", | |
3059 | "BGP specific commands\n" | |
3060 | "BGP network command\n" | |
3061 | "Check BGP network route exists in IGP\n" | |
3062 | "Match route precisely\n") | |
8233ef81 | 3063 | |
718e3744 | 3064 | DEFUN (no_bgp_network_import_check, |
3065 | no_bgp_network_import_check_cmd, | |
5623e905 | 3066 | "no bgp network import-check", |
718e3744 | 3067 | NO_STR |
3068 | "BGP specific commands\n" | |
3069 | "BGP network command\n" | |
3070 | "Check BGP network route exists in IGP\n") | |
3071 | { | |
d62a17ae | 3072 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3073 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
3074 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
3075 | bgp_static_redo_import_check(bgp); | |
3076 | } | |
5623e905 | 3077 | |
d62a17ae | 3078 | return CMD_SUCCESS; |
718e3744 | 3079 | } |
6b0655a2 | 3080 | |
718e3744 | 3081 | DEFUN (bgp_default_local_preference, |
3082 | bgp_default_local_preference_cmd, | |
6147e2c6 | 3083 | "bgp default local-preference (0-4294967295)", |
718e3744 | 3084 | "BGP specific commands\n" |
3085 | "Configure BGP defaults\n" | |
3086 | "local preference (higher=more preferred)\n" | |
3087 | "Configure default local preference value\n") | |
3088 | { | |
d62a17ae | 3089 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3090 | int idx_number = 3; | |
d7c0a89a | 3091 | uint32_t local_pref; |
718e3744 | 3092 | |
d62a17ae | 3093 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3094 | |
d62a17ae | 3095 | bgp_default_local_preference_set(bgp, local_pref); |
3096 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3097 | |
d62a17ae | 3098 | return CMD_SUCCESS; |
718e3744 | 3099 | } |
3100 | ||
3101 | DEFUN (no_bgp_default_local_preference, | |
3102 | no_bgp_default_local_preference_cmd, | |
838758ac | 3103 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 3104 | NO_STR |
3105 | "BGP specific commands\n" | |
3106 | "Configure BGP defaults\n" | |
838758ac DW |
3107 | "local preference (higher=more preferred)\n" |
3108 | "Configure default local preference value\n") | |
718e3744 | 3109 | { |
d62a17ae | 3110 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3111 | bgp_default_local_preference_unset(bgp); | |
3112 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3113 | |
d62a17ae | 3114 | return CMD_SUCCESS; |
718e3744 | 3115 | } |
3116 | ||
6b0655a2 | 3117 | |
3f9c7369 DS |
3118 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3119 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3120 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3121 | "BGP specific commands\n" |
3122 | "Configure BGP defaults\n" | |
3123 | "subgroup-pkt-queue-max\n" | |
3124 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3125 | { |
d62a17ae | 3126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3127 | int idx_number = 3; | |
d7c0a89a | 3128 | uint32_t max_size; |
8bd9d948 | 3129 | |
d62a17ae | 3130 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3131 | |
d62a17ae | 3132 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3133 | |
d62a17ae | 3134 | return CMD_SUCCESS; |
3f9c7369 DS |
3135 | } |
3136 | ||
3137 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3138 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3139 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3140 | NO_STR |
3141 | "BGP specific commands\n" | |
3142 | "Configure BGP defaults\n" | |
838758ac DW |
3143 | "subgroup-pkt-queue-max\n" |
3144 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3145 | { |
d62a17ae | 3146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3147 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3148 | return CMD_SUCCESS; | |
8bd9d948 DS |
3149 | } |
3150 | ||
813d4307 | 3151 | |
8bd9d948 DS |
3152 | DEFUN (bgp_rr_allow_outbound_policy, |
3153 | bgp_rr_allow_outbound_policy_cmd, | |
3154 | "bgp route-reflector allow-outbound-policy", | |
3155 | "BGP specific commands\n" | |
3156 | "Allow modifications made by out route-map\n" | |
3157 | "on ibgp neighbors\n") | |
3158 | { | |
d62a17ae | 3159 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3160 | |
d62a17ae | 3161 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3162 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3163 | update_group_announce_rrclients(bgp); | |
3164 | bgp_clear_star_soft_out(vty, bgp->name); | |
3165 | } | |
8bd9d948 | 3166 | |
d62a17ae | 3167 | return CMD_SUCCESS; |
8bd9d948 DS |
3168 | } |
3169 | ||
3170 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3171 | no_bgp_rr_allow_outbound_policy_cmd, | |
3172 | "no bgp route-reflector allow-outbound-policy", | |
3173 | NO_STR | |
3174 | "BGP specific commands\n" | |
3175 | "Allow modifications made by out route-map\n" | |
3176 | "on ibgp neighbors\n") | |
3177 | { | |
d62a17ae | 3178 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3179 | |
d62a17ae | 3180 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3181 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3182 | update_group_announce_rrclients(bgp); | |
3183 | bgp_clear_star_soft_out(vty, bgp->name); | |
3184 | } | |
8bd9d948 | 3185 | |
d62a17ae | 3186 | return CMD_SUCCESS; |
8bd9d948 DS |
3187 | } |
3188 | ||
f14e6fdb DS |
3189 | DEFUN (bgp_listen_limit, |
3190 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3191 | "bgp listen limit (1-5000)", |
f14e6fdb | 3192 | "BGP specific commands\n" |
1601a46f | 3193 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3194 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3195 | "Configure Dynamic Neighbors listen limit value\n") |
3196 | { | |
d62a17ae | 3197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3198 | int idx_number = 3; | |
3199 | int listen_limit; | |
f14e6fdb | 3200 | |
d62a17ae | 3201 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3202 | |
d62a17ae | 3203 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3204 | |
d62a17ae | 3205 | return CMD_SUCCESS; |
f14e6fdb DS |
3206 | } |
3207 | ||
3208 | DEFUN (no_bgp_listen_limit, | |
3209 | no_bgp_listen_limit_cmd, | |
838758ac | 3210 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3211 | NO_STR |
f14e6fdb | 3212 | "BGP specific commands\n" |
1601a46f | 3213 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3214 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3215 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3216 | { |
d62a17ae | 3217 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3218 | bgp_listen_limit_unset(bgp); | |
3219 | return CMD_SUCCESS; | |
f14e6fdb DS |
3220 | } |
3221 | ||
3222 | ||
20eb8864 | 3223 | /* |
3224 | * Check if this listen range is already configured. Check for exact | |
3225 | * match or overlap based on input. | |
3226 | */ | |
d62a17ae | 3227 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3228 | struct prefix *range, int exact) | |
3229 | { | |
3230 | struct listnode *node, *nnode; | |
3231 | struct listnode *node1, *nnode1; | |
3232 | struct peer_group *group; | |
3233 | struct prefix *lr; | |
3234 | afi_t afi; | |
3235 | int match; | |
3236 | ||
3237 | afi = family2afi(range->family); | |
3238 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3239 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3240 | lr)) { | |
3241 | if (exact) | |
3242 | match = prefix_same(range, lr); | |
3243 | else | |
3244 | match = (prefix_match(range, lr) | |
3245 | || prefix_match(lr, range)); | |
3246 | if (match) | |
3247 | return group; | |
3248 | } | |
3249 | } | |
3250 | ||
3251 | return NULL; | |
20eb8864 | 3252 | } |
3253 | ||
f14e6fdb DS |
3254 | DEFUN (bgp_listen_range, |
3255 | bgp_listen_range_cmd, | |
d7b9898c | 3256 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3257 | "BGP specific commands\n" |
d7fa34c1 QY |
3258 | "Configure BGP dynamic neighbors listen range\n" |
3259 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3260 | NEIGHBOR_ADDR_STR |
3261 | "Member of the peer-group\n" | |
3262 | "Peer-group name\n") | |
f14e6fdb | 3263 | { |
d62a17ae | 3264 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3265 | struct prefix range; | |
3266 | struct peer_group *group, *existing_group; | |
3267 | afi_t afi; | |
3268 | int ret; | |
3269 | int idx = 0; | |
3270 | ||
3271 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3272 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3273 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3274 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3275 | char *peergroup = argv[idx]->arg; |
3276 | ||
3277 | /* Convert IP prefix string to struct prefix. */ | |
3278 | ret = str2prefix(prefix, &range); | |
3279 | if (!ret) { | |
3280 | vty_out(vty, "%% Malformed listen range\n"); | |
3281 | return CMD_WARNING_CONFIG_FAILED; | |
3282 | } | |
3283 | ||
3284 | afi = family2afi(range.family); | |
3285 | ||
3286 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3287 | vty_out(vty, | |
3288 | "%% Malformed listen range (link-local address)\n"); | |
3289 | return CMD_WARNING_CONFIG_FAILED; | |
3290 | } | |
3291 | ||
3292 | apply_mask(&range); | |
3293 | ||
3294 | /* Check if same listen range is already configured. */ | |
3295 | existing_group = listen_range_exists(bgp, &range, 1); | |
3296 | if (existing_group) { | |
3297 | if (strcmp(existing_group->name, peergroup) == 0) | |
3298 | return CMD_SUCCESS; | |
3299 | else { | |
3300 | vty_out(vty, | |
3301 | "%% Same listen range is attached to peer-group %s\n", | |
3302 | existing_group->name); | |
3303 | return CMD_WARNING_CONFIG_FAILED; | |
3304 | } | |
3305 | } | |
3306 | ||
3307 | /* Check if an overlapping listen range exists. */ | |
3308 | if (listen_range_exists(bgp, &range, 0)) { | |
3309 | vty_out(vty, | |
3310 | "%% Listen range overlaps with existing listen range\n"); | |
3311 | return CMD_WARNING_CONFIG_FAILED; | |
3312 | } | |
3313 | ||
3314 | group = peer_group_lookup(bgp, peergroup); | |
3315 | if (!group) { | |
3316 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3317 | return CMD_WARNING_CONFIG_FAILED; | |
3318 | } | |
3319 | ||
3320 | ret = peer_group_listen_range_add(group, &range); | |
3321 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3322 | } |
3323 | ||
3324 | DEFUN (no_bgp_listen_range, | |
3325 | no_bgp_listen_range_cmd, | |
d7b9898c | 3326 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3327 | NO_STR |
f14e6fdb | 3328 | "BGP specific commands\n" |
d7fa34c1 QY |
3329 | "Unconfigure BGP dynamic neighbors listen range\n" |
3330 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3331 | NEIGHBOR_ADDR_STR | |
3332 | "Member of the peer-group\n" | |
3333 | "Peer-group name\n") | |
f14e6fdb | 3334 | { |
d62a17ae | 3335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3336 | struct prefix range; | |
3337 | struct peer_group *group; | |
3338 | afi_t afi; | |
3339 | int ret; | |
3340 | int idx = 0; | |
3341 | ||
3342 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3343 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3344 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3345 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3346 | char *peergroup = argv[idx]->arg; |
3347 | ||
3348 | /* Convert IP prefix string to struct prefix. */ | |
3349 | ret = str2prefix(prefix, &range); | |
3350 | if (!ret) { | |
3351 | vty_out(vty, "%% Malformed listen range\n"); | |
3352 | return CMD_WARNING_CONFIG_FAILED; | |
3353 | } | |
3354 | ||
3355 | afi = family2afi(range.family); | |
3356 | ||
3357 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3358 | vty_out(vty, | |
3359 | "%% Malformed listen range (link-local address)\n"); | |
3360 | return CMD_WARNING_CONFIG_FAILED; | |
3361 | } | |
3362 | ||
3363 | apply_mask(&range); | |
3364 | ||
3365 | group = peer_group_lookup(bgp, peergroup); | |
3366 | if (!group) { | |
3367 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3368 | return CMD_WARNING_CONFIG_FAILED; | |
3369 | } | |
3370 | ||
3371 | ret = peer_group_listen_range_del(group, &range); | |
3372 | return bgp_vty_return(vty, ret); | |
3373 | } | |
3374 | ||
2b791107 | 3375 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3376 | { |
3377 | struct peer_group *group; | |
3378 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3379 | struct prefix *range; | |
3380 | afi_t afi; | |
3381 | char buf[PREFIX2STR_BUFFER]; | |
3382 | ||
3383 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3384 | vty_out(vty, " bgp listen limit %d\n", | |
3385 | bgp->dynamic_neighbors_limit); | |
3386 | ||
3387 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3388 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3389 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3390 | nrnode, range)) { | |
3391 | prefix2str(range, buf, sizeof(buf)); | |
3392 | vty_out(vty, | |
3393 | " bgp listen range %s peer-group %s\n", | |
3394 | buf, group->name); | |
3395 | } | |
3396 | } | |
3397 | } | |
f14e6fdb DS |
3398 | } |
3399 | ||
3400 | ||
907f92c8 DS |
3401 | DEFUN (bgp_disable_connected_route_check, |
3402 | bgp_disable_connected_route_check_cmd, | |
3403 | "bgp disable-ebgp-connected-route-check", | |
3404 | "BGP specific commands\n" | |
3405 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3406 | { | |
d62a17ae | 3407 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3408 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
3409 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3410 | |
d62a17ae | 3411 | return CMD_SUCCESS; |
907f92c8 DS |
3412 | } |
3413 | ||
3414 | DEFUN (no_bgp_disable_connected_route_check, | |
3415 | no_bgp_disable_connected_route_check_cmd, | |
3416 | "no bgp disable-ebgp-connected-route-check", | |
3417 | NO_STR | |
3418 | "BGP specific commands\n" | |
3419 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3420 | { | |
d62a17ae | 3421 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3422 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
3423 | bgp_clear_star_soft_in(vty, bgp->name); | |
3424 | ||
3425 | return CMD_SUCCESS; | |
3426 | } | |
3427 | ||
3428 | ||
3429 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3430 | const char *as_str, afi_t afi, safi_t safi) | |
3431 | { | |
3432 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3433 | int ret; | |
3434 | as_t as; | |
3435 | int as_type = AS_SPECIFIED; | |
3436 | union sockunion su; | |
3437 | ||
3438 | if (as_str[0] == 'i') { | |
3439 | as = 0; | |
3440 | as_type = AS_INTERNAL; | |
3441 | } else if (as_str[0] == 'e') { | |
3442 | as = 0; | |
3443 | as_type = AS_EXTERNAL; | |
3444 | } else { | |
3445 | /* Get AS number. */ | |
3446 | as = strtoul(as_str, NULL, 10); | |
3447 | } | |
3448 | ||
390485fd | 3449 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3450 | ret = str2sockunion(peer_str, &su); |
3451 | if (ret < 0) { | |
390485fd DS |
3452 | struct peer *peer; |
3453 | ||
3454 | /* Check if existing interface peer */ | |
3455 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3456 | ||
d62a17ae | 3457 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3458 | safi); | |
390485fd DS |
3459 | |
3460 | /* if not interface peer, check peer-group settings */ | |
3461 | if (ret < 0 && !peer) { | |
d62a17ae | 3462 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3463 | if (ret < 0) { | |
3464 | vty_out(vty, | |
390485fd | 3465 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3466 | return CMD_WARNING_CONFIG_FAILED; |
3467 | } | |
3468 | return CMD_SUCCESS; | |
3469 | } | |
3470 | } else { | |
3471 | if (peer_address_self_check(bgp, &su)) { | |
3472 | vty_out(vty, | |
3473 | "%% Can not configure the local system as neighbor\n"); | |
3474 | return CMD_WARNING_CONFIG_FAILED; | |
3475 | } | |
3476 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3477 | } | |
3478 | ||
3479 | /* This peer belongs to peer group. */ | |
3480 | switch (ret) { | |
3481 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3482 | vty_out(vty, | |
faa16034 | 3483 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3484 | return CMD_WARNING_CONFIG_FAILED; |
3485 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3486 | vty_out(vty, | |
faa16034 | 3487 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3488 | return CMD_WARNING_CONFIG_FAILED; |
3489 | } | |
3490 | return bgp_vty_return(vty, ret); | |
718e3744 | 3491 | } |
3492 | ||
f26845f9 QY |
3493 | DEFUN (bgp_default_shutdown, |
3494 | bgp_default_shutdown_cmd, | |
3495 | "[no] bgp default shutdown", | |
3496 | NO_STR | |
3497 | BGP_STR | |
3498 | "Configure BGP defaults\n" | |
b012cbe2 | 3499 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3500 | { |
3501 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3502 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3503 | return CMD_SUCCESS; | |
3504 | } | |
3505 | ||
718e3744 | 3506 | DEFUN (neighbor_remote_as, |
3507 | neighbor_remote_as_cmd, | |
3a2d747c | 3508 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3509 | NEIGHBOR_STR |
3510 | NEIGHBOR_ADDR_STR2 | |
3511 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3512 | AS_STR |
3a2d747c QY |
3513 | "Internal BGP peer\n" |
3514 | "External BGP peer\n") | |
718e3744 | 3515 | { |
d62a17ae | 3516 | int idx_peer = 1; |
3517 | int idx_remote_as = 3; | |
3518 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3519 | argv[idx_remote_as]->arg, AFI_IP, | |
3520 | SAFI_UNICAST); | |
3521 | } | |
3522 | ||
3523 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3524 | afi_t afi, safi_t safi, int v6only, | |
3525 | const char *peer_group_name, | |
3526 | const char *as_str) | |
3527 | { | |
3528 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3529 | as_t as = 0; | |
3530 | int as_type = AS_UNSPECIFIED; | |
3531 | struct peer *peer; | |
3532 | struct peer_group *group; | |
3533 | int ret = 0; | |
3534 | union sockunion su; | |
3535 | ||
3536 | group = peer_group_lookup(bgp, conf_if); | |
3537 | ||
3538 | if (group) { | |
3539 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3540 | return CMD_WARNING_CONFIG_FAILED; | |
3541 | } | |
3542 | ||
3543 | if (as_str) { | |
3544 | if (as_str[0] == 'i') { | |
3545 | as_type = AS_INTERNAL; | |
3546 | } else if (as_str[0] == 'e') { | |
3547 | as_type = AS_EXTERNAL; | |
3548 | } else { | |
3549 | /* Get AS number. */ | |
3550 | as = strtoul(as_str, NULL, 10); | |
3551 | as_type = AS_SPECIFIED; | |
3552 | } | |
3553 | } | |
3554 | ||
3555 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3556 | if (peer) { | |
3557 | if (as_str) | |
cc4d4ce8 | 3558 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3559 | afi, safi); |
3560 | } else { | |
3561 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
3562 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
3563 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3564 | as_type, 0, 0, NULL); | |
3565 | else | |
3566 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3567 | as_type, afi, safi, NULL); | |
3568 | ||
3569 | if (!peer) { | |
3570 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3571 | return CMD_WARNING_CONFIG_FAILED; | |
3572 | } | |
3573 | ||
3574 | if (v6only) | |
527de3dc | 3575 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3576 | |
3577 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3578 | * this | |
3579 | * any unnumbered peer in order to not worry about run-time | |
3580 | * transitions | |
3581 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3582 | * address | |
3583 | * gets deleted later etc.) | |
3584 | */ | |
3585 | if (peer->ifp) | |
3586 | bgp_zebra_initiate_radv(bgp, peer); | |
3587 | } | |
3588 | ||
3589 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3590 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3591 | if (v6only) | |
527de3dc | 3592 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3593 | else |
527de3dc | 3594 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3595 | |
3596 | /* v6only flag changed. Reset bgp seesion */ | |
3597 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3598 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3599 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3600 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3601 | } else | |
3602 | bgp_session_reset(peer); | |
3603 | } | |
3604 | ||
9fb964de PM |
3605 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3606 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3607 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3608 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3609 | } |
d62a17ae | 3610 | |
3611 | if (peer_group_name) { | |
3612 | group = peer_group_lookup(bgp, peer_group_name); | |
3613 | if (!group) { | |
3614 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3615 | return CMD_WARNING_CONFIG_FAILED; | |
3616 | } | |
3617 | ||
3618 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3619 | } | |
3620 | ||
3621 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3622 | } |
3623 | ||
4c48cf63 DW |
3624 | DEFUN (neighbor_interface_config, |
3625 | neighbor_interface_config_cmd, | |
d7b9898c | 3626 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3627 | NEIGHBOR_STR |
3628 | "Interface name or neighbor tag\n" | |
31500417 DW |
3629 | "Enable BGP on interface\n" |
3630 | "Member of the peer-group\n" | |
16cedbb0 | 3631 | "Peer-group name\n") |
4c48cf63 | 3632 | { |
d62a17ae | 3633 | int idx_word = 1; |
3634 | int idx_peer_group_word = 4; | |
31500417 | 3635 | |
d62a17ae | 3636 | if (argc > idx_peer_group_word) |
3637 | return peer_conf_interface_get( | |
3638 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3639 | argv[idx_peer_group_word]->arg, NULL); | |
3640 | else | |
3641 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3642 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3643 | } |
3644 | ||
4c48cf63 DW |
3645 | DEFUN (neighbor_interface_config_v6only, |
3646 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3647 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3648 | NEIGHBOR_STR |
3649 | "Interface name or neighbor tag\n" | |
3650 | "Enable BGP on interface\n" | |
31500417 DW |
3651 | "Enable BGP with v6 link-local only\n" |
3652 | "Member of the peer-group\n" | |
16cedbb0 | 3653 | "Peer-group name\n") |
4c48cf63 | 3654 | { |
d62a17ae | 3655 | int idx_word = 1; |
3656 | int idx_peer_group_word = 5; | |
31500417 | 3657 | |
d62a17ae | 3658 | if (argc > idx_peer_group_word) |
3659 | return peer_conf_interface_get( | |
3660 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3661 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3662 | |
d62a17ae | 3663 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3664 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3665 | } |
3666 | ||
a80beece | 3667 | |
b3a39dc5 DD |
3668 | DEFUN (neighbor_interface_config_remote_as, |
3669 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3670 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3671 | NEIGHBOR_STR |
3672 | "Interface name or neighbor tag\n" | |
3673 | "Enable BGP on interface\n" | |
3a2d747c | 3674 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3675 | AS_STR |
3a2d747c QY |
3676 | "Internal BGP peer\n" |
3677 | "External BGP peer\n") | |
b3a39dc5 | 3678 | { |
d62a17ae | 3679 | int idx_word = 1; |
3680 | int idx_remote_as = 4; | |
3681 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3682 | SAFI_UNICAST, 0, NULL, | |
3683 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3684 | } |
3685 | ||
3686 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3687 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3688 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3689 | NEIGHBOR_STR |
3690 | "Interface name or neighbor tag\n" | |
3a2d747c | 3691 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3692 | "Enable BGP on interface\n" |
3a2d747c | 3693 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3694 | AS_STR |
3a2d747c QY |
3695 | "Internal BGP peer\n" |
3696 | "External BGP peer\n") | |
b3a39dc5 | 3697 | { |
d62a17ae | 3698 | int idx_word = 1; |
3699 | int idx_remote_as = 5; | |
3700 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3701 | SAFI_UNICAST, 1, NULL, | |
3702 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3703 | } |
3704 | ||
718e3744 | 3705 | DEFUN (neighbor_peer_group, |
3706 | neighbor_peer_group_cmd, | |
3707 | "neighbor WORD peer-group", | |
3708 | NEIGHBOR_STR | |
a80beece | 3709 | "Interface name or neighbor tag\n" |
718e3744 | 3710 | "Configure peer-group\n") |
3711 | { | |
d62a17ae | 3712 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3713 | int idx_word = 1; | |
3714 | struct peer *peer; | |
3715 | struct peer_group *group; | |
718e3744 | 3716 | |
d62a17ae | 3717 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3718 | if (peer) { | |
3719 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3720 | return CMD_WARNING_CONFIG_FAILED; | |
3721 | } | |
718e3744 | 3722 | |
d62a17ae | 3723 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3724 | if (!group) { | |
3725 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3726 | return CMD_WARNING_CONFIG_FAILED; | |
3727 | } | |
718e3744 | 3728 | |
d62a17ae | 3729 | return CMD_SUCCESS; |
718e3744 | 3730 | } |
3731 | ||
3732 | DEFUN (no_neighbor, | |
3733 | no_neighbor_cmd, | |
dab8cd00 | 3734 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3735 | NO_STR |
3736 | NEIGHBOR_STR | |
3a2d747c QY |
3737 | NEIGHBOR_ADDR_STR2 |
3738 | "Specify a BGP neighbor\n" | |
3739 | AS_STR | |
3740 | "Internal BGP peer\n" | |
3741 | "External BGP peer\n") | |
718e3744 | 3742 | { |
d62a17ae | 3743 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3744 | int idx_peer = 2; | |
3745 | int ret; | |
3746 | union sockunion su; | |
3747 | struct peer_group *group; | |
3748 | struct peer *peer; | |
3749 | struct peer *other; | |
3750 | ||
3751 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3752 | if (ret < 0) { | |
3753 | /* look up for neighbor by interface name config. */ | |
3754 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3755 | if (peer) { | |
3756 | /* Request zebra to terminate IPv6 RAs on this | |
3757 | * interface. */ | |
3758 | if (peer->ifp) | |
3759 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3760 | peer_notify_unconfig(peer); |
d62a17ae | 3761 | peer_delete(peer); |
3762 | return CMD_SUCCESS; | |
3763 | } | |
f14e6fdb | 3764 | |
d62a17ae | 3765 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3766 | if (group) { |
3767 | peer_group_notify_unconfig(group); | |
d62a17ae | 3768 | peer_group_delete(group); |
4e2786df | 3769 | } else { |
d62a17ae | 3770 | vty_out(vty, "%% Create the peer-group first\n"); |
3771 | return CMD_WARNING_CONFIG_FAILED; | |
3772 | } | |
3773 | } else { | |
3774 | peer = peer_lookup(bgp, &su); | |
3775 | if (peer) { | |
3776 | if (peer_dynamic_neighbor(peer)) { | |
3777 | vty_out(vty, | |
3778 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3779 | return CMD_WARNING_CONFIG_FAILED; | |
3780 | } | |
3781 | ||
3782 | other = peer->doppelganger; | |
4e2786df | 3783 | peer_notify_unconfig(peer); |
d62a17ae | 3784 | peer_delete(peer); |
4e2786df DA |
3785 | if (other && other->status != Deleted) { |
3786 | peer_notify_unconfig(other); | |
d62a17ae | 3787 | peer_delete(other); |
4e2786df | 3788 | } |
d62a17ae | 3789 | } |
1ff9a340 | 3790 | } |
718e3744 | 3791 | |
d62a17ae | 3792 | return CMD_SUCCESS; |
718e3744 | 3793 | } |
3794 | ||
a80beece DS |
3795 | DEFUN (no_neighbor_interface_config, |
3796 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3797 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3798 | NO_STR |
3799 | NEIGHBOR_STR | |
3800 | "Interface name\n" | |
31500417 DW |
3801 | "Configure BGP on interface\n" |
3802 | "Enable BGP with v6 link-local only\n" | |
3803 | "Member of the peer-group\n" | |
16cedbb0 | 3804 | "Peer-group name\n" |
3a2d747c QY |
3805 | "Specify a BGP neighbor\n" |
3806 | AS_STR | |
3807 | "Internal BGP peer\n" | |
3808 | "External BGP peer\n") | |
a80beece | 3809 | { |
d62a17ae | 3810 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3811 | int idx_word = 2; | |
3812 | struct peer *peer; | |
3813 | ||
3814 | /* look up for neighbor by interface name config. */ | |
3815 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3816 | if (peer) { | |
3817 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3818 | if (peer->ifp) | |
3819 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3820 | peer_notify_unconfig(peer); |
d62a17ae | 3821 | peer_delete(peer); |
3822 | } else { | |
3823 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3824 | return CMD_WARNING_CONFIG_FAILED; | |
3825 | } | |
3826 | return CMD_SUCCESS; | |
a80beece DS |
3827 | } |
3828 | ||
718e3744 | 3829 | DEFUN (no_neighbor_peer_group, |
3830 | no_neighbor_peer_group_cmd, | |
3831 | "no neighbor WORD peer-group", | |
3832 | NO_STR | |
3833 | NEIGHBOR_STR | |
3834 | "Neighbor tag\n" | |
3835 | "Configure peer-group\n") | |
3836 | { | |
d62a17ae | 3837 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3838 | int idx_word = 2; | |
3839 | struct peer_group *group; | |
718e3744 | 3840 | |
d62a17ae | 3841 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3842 | if (group) { |
3843 | peer_group_notify_unconfig(group); | |
d62a17ae | 3844 | peer_group_delete(group); |
4e2786df | 3845 | } else { |
d62a17ae | 3846 | vty_out(vty, "%% Create the peer-group first\n"); |
3847 | return CMD_WARNING_CONFIG_FAILED; | |
3848 | } | |
3849 | return CMD_SUCCESS; | |
718e3744 | 3850 | } |
3851 | ||
a80beece DS |
3852 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3853 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3854 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3855 | NO_STR |
3856 | NEIGHBOR_STR | |
a80beece | 3857 | "Interface name or neighbor tag\n" |
718e3744 | 3858 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3859 | AS_STR |
3860 | "Internal BGP peer\n" | |
3861 | "External BGP peer\n") | |
718e3744 | 3862 | { |
d62a17ae | 3863 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3864 | int idx_word = 2; | |
3865 | struct peer_group *group; | |
3866 | struct peer *peer; | |
3867 | ||
3868 | /* look up for neighbor by interface name config. */ | |
3869 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3870 | if (peer) { | |
390485fd | 3871 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3872 | return CMD_SUCCESS; |
3873 | } | |
3874 | ||
3875 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3876 | if (group) | |
3877 | peer_group_remote_as_delete(group); | |
3878 | else { | |
3879 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3880 | return CMD_WARNING_CONFIG_FAILED; | |
3881 | } | |
3882 | return CMD_SUCCESS; | |
718e3744 | 3883 | } |
6b0655a2 | 3884 | |
718e3744 | 3885 | DEFUN (neighbor_local_as, |
3886 | neighbor_local_as_cmd, | |
9ccf14f7 | 3887 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3888 | NEIGHBOR_STR |
3889 | NEIGHBOR_ADDR_STR2 | |
3890 | "Specify a local-as number\n" | |
3891 | "AS number used as local AS\n") | |
3892 | { | |
d62a17ae | 3893 | int idx_peer = 1; |
3894 | int idx_number = 3; | |
3895 | struct peer *peer; | |
3896 | int ret; | |
3897 | as_t as; | |
718e3744 | 3898 | |
d62a17ae | 3899 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3900 | if (!peer) | |
3901 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3902 | |
d62a17ae | 3903 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3904 | ret = peer_local_as_set(peer, as, 0, 0); | |
3905 | return bgp_vty_return(vty, ret); | |
718e3744 | 3906 | } |
3907 | ||
3908 | DEFUN (neighbor_local_as_no_prepend, | |
3909 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3910 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3911 | NEIGHBOR_STR |
3912 | NEIGHBOR_ADDR_STR2 | |
3913 | "Specify a local-as number\n" | |
3914 | "AS number used as local AS\n" | |
3915 | "Do not prepend local-as to updates from ebgp peers\n") | |
3916 | { | |
d62a17ae | 3917 | int idx_peer = 1; |
3918 | int idx_number = 3; | |
3919 | struct peer *peer; | |
3920 | int ret; | |
3921 | as_t as; | |
718e3744 | 3922 | |
d62a17ae | 3923 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3924 | if (!peer) | |
3925 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3926 | |
d62a17ae | 3927 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3928 | ret = peer_local_as_set(peer, as, 1, 0); | |
3929 | return bgp_vty_return(vty, ret); | |
718e3744 | 3930 | } |
3931 | ||
9d3f9705 AC |
3932 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3933 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3934 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3935 | NEIGHBOR_STR |
3936 | NEIGHBOR_ADDR_STR2 | |
3937 | "Specify a local-as number\n" | |
3938 | "AS number used as local AS\n" | |
3939 | "Do not prepend local-as to updates from ebgp peers\n" | |
3940 | "Do not prepend local-as to updates from ibgp peers\n") | |
3941 | { | |
d62a17ae | 3942 | int idx_peer = 1; |
3943 | int idx_number = 3; | |
3944 | struct peer *peer; | |
3945 | int ret; | |
3946 | as_t as; | |
9d3f9705 | 3947 | |
d62a17ae | 3948 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3949 | if (!peer) | |
3950 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3951 | |
d62a17ae | 3952 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3953 | ret = peer_local_as_set(peer, as, 1, 1); | |
3954 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3955 | } |
3956 | ||
718e3744 | 3957 | DEFUN (no_neighbor_local_as, |
3958 | no_neighbor_local_as_cmd, | |
a636c635 | 3959 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3960 | NO_STR |
3961 | NEIGHBOR_STR | |
3962 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3963 | "Specify a local-as number\n" |
3964 | "AS number used as local AS\n" | |
3965 | "Do not prepend local-as to updates from ebgp peers\n" | |
3966 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3967 | { |
d62a17ae | 3968 | int idx_peer = 2; |
3969 | struct peer *peer; | |
3970 | int ret; | |
718e3744 | 3971 | |
d62a17ae | 3972 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3973 | if (!peer) | |
3974 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3975 | |
d62a17ae | 3976 | ret = peer_local_as_unset(peer); |
3977 | return bgp_vty_return(vty, ret); | |
718e3744 | 3978 | } |
3979 | ||
718e3744 | 3980 | |
3f9c7369 DS |
3981 | DEFUN (neighbor_solo, |
3982 | neighbor_solo_cmd, | |
9ccf14f7 | 3983 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3984 | NEIGHBOR_STR |
3985 | NEIGHBOR_ADDR_STR2 | |
3986 | "Solo peer - part of its own update group\n") | |
3987 | { | |
d62a17ae | 3988 | int idx_peer = 1; |
3989 | struct peer *peer; | |
3990 | int ret; | |
3f9c7369 | 3991 | |
d62a17ae | 3992 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3993 | if (!peer) | |
3994 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3995 | |
d62a17ae | 3996 | ret = update_group_adjust_soloness(peer, 1); |
3997 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3998 | } |
3999 | ||
4000 | DEFUN (no_neighbor_solo, | |
4001 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4003 | NO_STR |
4004 | NEIGHBOR_STR | |
4005 | NEIGHBOR_ADDR_STR2 | |
4006 | "Solo peer - part of its own update group\n") | |
4007 | { | |
d62a17ae | 4008 | int idx_peer = 2; |
4009 | struct peer *peer; | |
4010 | int ret; | |
3f9c7369 | 4011 | |
d62a17ae | 4012 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4013 | if (!peer) | |
4014 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4015 | |
d62a17ae | 4016 | ret = update_group_adjust_soloness(peer, 0); |
4017 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4018 | } |
4019 | ||
0df7c91f PJ |
4020 | DEFUN (neighbor_password, |
4021 | neighbor_password_cmd, | |
9ccf14f7 | 4022 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4023 | NEIGHBOR_STR |
4024 | NEIGHBOR_ADDR_STR2 | |
4025 | "Set a password\n" | |
4026 | "The password\n") | |
4027 | { | |
d62a17ae | 4028 | int idx_peer = 1; |
4029 | int idx_line = 3; | |
4030 | struct peer *peer; | |
4031 | int ret; | |
0df7c91f | 4032 | |
d62a17ae | 4033 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4034 | if (!peer) | |
4035 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4036 | |
d62a17ae | 4037 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4038 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4039 | } |
4040 | ||
4041 | DEFUN (no_neighbor_password, | |
4042 | no_neighbor_password_cmd, | |
a636c635 | 4043 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4044 | NO_STR |
4045 | NEIGHBOR_STR | |
4046 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4047 | "Set a password\n" |
4048 | "The password\n") | |
0df7c91f | 4049 | { |
d62a17ae | 4050 | int idx_peer = 2; |
4051 | struct peer *peer; | |
4052 | int ret; | |
0df7c91f | 4053 | |
d62a17ae | 4054 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4055 | if (!peer) | |
4056 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4057 | |
d62a17ae | 4058 | ret = peer_password_unset(peer); |
4059 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4060 | } |
6b0655a2 | 4061 | |
718e3744 | 4062 | DEFUN (neighbor_activate, |
4063 | neighbor_activate_cmd, | |
9ccf14f7 | 4064 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4065 | NEIGHBOR_STR |
4066 | NEIGHBOR_ADDR_STR2 | |
4067 | "Enable the Address Family for this Neighbor\n") | |
4068 | { | |
d62a17ae | 4069 | int idx_peer = 1; |
4070 | int ret; | |
4071 | struct peer *peer; | |
718e3744 | 4072 | |
d62a17ae | 4073 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4074 | if (!peer) | |
4075 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4076 | |
d62a17ae | 4077 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4078 | return bgp_vty_return(vty, ret); | |
718e3744 | 4079 | } |
4080 | ||
d62a17ae | 4081 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4082 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4083 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4084 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4085 | |
718e3744 | 4086 | DEFUN (no_neighbor_activate, |
4087 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4088 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4089 | NO_STR |
4090 | NEIGHBOR_STR | |
4091 | NEIGHBOR_ADDR_STR2 | |
4092 | "Enable the Address Family for this Neighbor\n") | |
4093 | { | |
d62a17ae | 4094 | int idx_peer = 2; |
4095 | int ret; | |
4096 | struct peer *peer; | |
718e3744 | 4097 | |
d62a17ae | 4098 | /* Lookup peer. */ |
4099 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4100 | if (!peer) | |
4101 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4102 | |
d62a17ae | 4103 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4104 | return bgp_vty_return(vty, ret); | |
718e3744 | 4105 | } |
6b0655a2 | 4106 | |
d62a17ae | 4107 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4108 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4109 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4110 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4111 | |
718e3744 | 4112 | DEFUN (neighbor_set_peer_group, |
4113 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4114 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4115 | NEIGHBOR_STR |
a80beece | 4116 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4117 | "Member of the peer-group\n" |
16cedbb0 | 4118 | "Peer-group name\n") |
718e3744 | 4119 | { |
d62a17ae | 4120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4121 | int idx_peer = 1; | |
4122 | int idx_word = 3; | |
4123 | int ret; | |
4124 | as_t as; | |
4125 | union sockunion su; | |
4126 | struct peer *peer; | |
4127 | struct peer_group *group; | |
4128 | ||
d62a17ae | 4129 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4130 | if (ret < 0) { | |
4131 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4132 | if (!peer) { | |
4133 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4134 | argv[idx_peer]->arg); | |
4135 | return CMD_WARNING_CONFIG_FAILED; | |
4136 | } | |
4137 | } else { | |
4138 | if (peer_address_self_check(bgp, &su)) { | |
4139 | vty_out(vty, | |
4140 | "%% Can not configure the local system as neighbor\n"); | |
4141 | return CMD_WARNING_CONFIG_FAILED; | |
4142 | } | |
4143 | ||
4144 | /* Disallow for dynamic neighbor. */ | |
4145 | peer = peer_lookup(bgp, &su); | |
4146 | if (peer && peer_dynamic_neighbor(peer)) { | |
4147 | vty_out(vty, | |
4148 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4149 | return CMD_WARNING_CONFIG_FAILED; | |
4150 | } | |
4151 | } | |
4152 | ||
4153 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4154 | if (!group) { | |
4155 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4156 | return CMD_WARNING_CONFIG_FAILED; | |
4157 | } | |
4158 | ||
4159 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4160 | ||
4161 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4162 | vty_out(vty, | |
4163 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4164 | as); | |
4165 | return CMD_WARNING_CONFIG_FAILED; | |
4166 | } | |
4167 | ||
4168 | return bgp_vty_return(vty, ret); | |
4169 | } | |
4170 | ||
4171 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4172 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4173 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4174 | "Member of the peer-group\n" | |
4175 | "Peer-group name\n") | |
596c17ba | 4176 | |
718e3744 | 4177 | DEFUN (no_neighbor_set_peer_group, |
4178 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4179 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4180 | NO_STR |
4181 | NEIGHBOR_STR | |
a80beece | 4182 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4183 | "Member of the peer-group\n" |
16cedbb0 | 4184 | "Peer-group name\n") |
718e3744 | 4185 | { |
d62a17ae | 4186 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4187 | int idx_peer = 2; | |
4188 | int idx_word = 4; | |
4189 | int ret; | |
4190 | struct peer *peer; | |
4191 | struct peer_group *group; | |
4192 | ||
4193 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4194 | if (!peer) | |
4195 | return CMD_WARNING_CONFIG_FAILED; | |
4196 | ||
4197 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4198 | if (!group) { | |
4199 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4200 | return CMD_WARNING_CONFIG_FAILED; | |
4201 | } | |
718e3744 | 4202 | |
4e2786df | 4203 | peer_notify_unconfig(peer); |
827ed707 | 4204 | ret = peer_delete(peer); |
718e3744 | 4205 | |
d62a17ae | 4206 | return bgp_vty_return(vty, ret); |
718e3744 | 4207 | } |
6b0655a2 | 4208 | |
d62a17ae | 4209 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4210 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4211 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4212 | "Member of the peer-group\n" | |
4213 | "Peer-group name\n") | |
596c17ba | 4214 | |
d62a17ae | 4215 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4216 | uint32_t flag, int set) |
718e3744 | 4217 | { |
d62a17ae | 4218 | int ret; |
4219 | struct peer *peer; | |
718e3744 | 4220 | |
d62a17ae | 4221 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4222 | if (!peer) | |
4223 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4224 | |
7ebe625c QY |
4225 | /* |
4226 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4227 | * we should not accept disable-connected-check. | |
4228 | */ | |
4229 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4230 | vty_out(vty, | |
4231 | "%s is directly connected peer, cannot accept disable-" | |
4232 | "connected-check\n", | |
4233 | ip_str); | |
4234 | return CMD_WARNING_CONFIG_FAILED; | |
4235 | } | |
4236 | ||
d62a17ae | 4237 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4238 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4239 | |
d62a17ae | 4240 | if (set) |
4241 | ret = peer_flag_set(peer, flag); | |
4242 | else | |
4243 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4244 | |
d62a17ae | 4245 | return bgp_vty_return(vty, ret); |
718e3744 | 4246 | } |
4247 | ||
47cbc09b | 4248 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4249 | { |
d62a17ae | 4250 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4251 | } |
4252 | ||
d62a17ae | 4253 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4254 | uint32_t flag) |
718e3744 | 4255 | { |
d62a17ae | 4256 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4257 | } |
4258 | ||
4259 | /* neighbor passive. */ | |
4260 | DEFUN (neighbor_passive, | |
4261 | neighbor_passive_cmd, | |
9ccf14f7 | 4262 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4263 | NEIGHBOR_STR |
4264 | NEIGHBOR_ADDR_STR2 | |
4265 | "Don't send open messages to this neighbor\n") | |
4266 | { | |
d62a17ae | 4267 | int idx_peer = 1; |
4268 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4269 | } |
4270 | ||
4271 | DEFUN (no_neighbor_passive, | |
4272 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4274 | NO_STR |
4275 | NEIGHBOR_STR | |
4276 | NEIGHBOR_ADDR_STR2 | |
4277 | "Don't send open messages to this neighbor\n") | |
4278 | { | |
d62a17ae | 4279 | int idx_peer = 2; |
4280 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4281 | } |
6b0655a2 | 4282 | |
718e3744 | 4283 | /* neighbor shutdown. */ |
73d70fa6 DL |
4284 | DEFUN (neighbor_shutdown_msg, |
4285 | neighbor_shutdown_msg_cmd, | |
4286 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4287 | NEIGHBOR_STR |
4288 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
4289 | "Administratively shut down this neighbor\n" |
4290 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4291 | "Shutdown message\n") | |
718e3744 | 4292 | { |
d62a17ae | 4293 | int idx_peer = 1; |
73d70fa6 | 4294 | |
d62a17ae | 4295 | if (argc >= 5) { |
4296 | struct peer *peer = | |
4297 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4298 | char *message; | |
73d70fa6 | 4299 | |
d62a17ae | 4300 | if (!peer) |
4301 | return CMD_WARNING_CONFIG_FAILED; | |
4302 | message = argv_concat(argv, argc, 4); | |
4303 | peer_tx_shutdown_message_set(peer, message); | |
4304 | XFREE(MTYPE_TMP, message); | |
4305 | } | |
73d70fa6 | 4306 | |
d62a17ae | 4307 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4308 | } |
4309 | ||
d62a17ae | 4310 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4311 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4312 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4313 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4314 | |
4315 | DEFUN (no_neighbor_shutdown_msg, | |
4316 | no_neighbor_shutdown_msg_cmd, | |
4317 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4318 | NO_STR | |
4319 | NEIGHBOR_STR | |
4320 | NEIGHBOR_ADDR_STR2 | |
4321 | "Administratively shut down this neighbor\n" | |
4322 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4323 | "Shutdown message\n") | |
718e3744 | 4324 | { |
d62a17ae | 4325 | int idx_peer = 2; |
73d70fa6 | 4326 | |
d62a17ae | 4327 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4328 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4329 | } |
6b0655a2 | 4330 | |
d62a17ae | 4331 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4332 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4333 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4334 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4335 | |
718e3744 | 4336 | /* neighbor capability dynamic. */ |
4337 | DEFUN (neighbor_capability_dynamic, | |
4338 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4339 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4340 | NEIGHBOR_STR |
4341 | NEIGHBOR_ADDR_STR2 | |
4342 | "Advertise capability to the peer\n" | |
4343 | "Advertise dynamic capability to this neighbor\n") | |
4344 | { | |
d62a17ae | 4345 | int idx_peer = 1; |
4346 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4347 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4348 | } |
4349 | ||
4350 | DEFUN (no_neighbor_capability_dynamic, | |
4351 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4352 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4353 | NO_STR |
4354 | NEIGHBOR_STR | |
4355 | NEIGHBOR_ADDR_STR2 | |
4356 | "Advertise capability to the peer\n" | |
4357 | "Advertise dynamic capability to this neighbor\n") | |
4358 | { | |
d62a17ae | 4359 | int idx_peer = 2; |
4360 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4361 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4362 | } |
6b0655a2 | 4363 | |
718e3744 | 4364 | /* neighbor dont-capability-negotiate */ |
4365 | DEFUN (neighbor_dont_capability_negotiate, | |
4366 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4367 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4368 | NEIGHBOR_STR |
4369 | NEIGHBOR_ADDR_STR2 | |
4370 | "Do not perform capability negotiation\n") | |
4371 | { | |
d62a17ae | 4372 | int idx_peer = 1; |
4373 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4374 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4375 | } |
4376 | ||
4377 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4378 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4379 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4380 | NO_STR |
4381 | NEIGHBOR_STR | |
4382 | NEIGHBOR_ADDR_STR2 | |
4383 | "Do not perform capability negotiation\n") | |
4384 | { | |
d62a17ae | 4385 | int idx_peer = 2; |
4386 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4387 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4388 | } |
6b0655a2 | 4389 | |
8a92a8a0 DS |
4390 | /* neighbor capability extended next hop encoding */ |
4391 | DEFUN (neighbor_capability_enhe, | |
4392 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4393 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4394 | NEIGHBOR_STR |
4395 | NEIGHBOR_ADDR_STR2 | |
4396 | "Advertise capability to the peer\n" | |
4397 | "Advertise extended next-hop capability to the peer\n") | |
4398 | { | |
d62a17ae | 4399 | int idx_peer = 1; |
4400 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4401 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4402 | } |
4403 | ||
4404 | DEFUN (no_neighbor_capability_enhe, | |
4405 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4406 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4407 | NO_STR |
4408 | NEIGHBOR_STR | |
4409 | NEIGHBOR_ADDR_STR2 | |
4410 | "Advertise capability to the peer\n" | |
4411 | "Advertise extended next-hop capability to the peer\n") | |
4412 | { | |
d62a17ae | 4413 | int idx_peer = 2; |
4414 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4415 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4416 | } |
4417 | ||
d62a17ae | 4418 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4419 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4420 | int set) |
718e3744 | 4421 | { |
d62a17ae | 4422 | int ret; |
4423 | struct peer *peer; | |
718e3744 | 4424 | |
d62a17ae | 4425 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4426 | if (!peer) | |
4427 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4428 | |
d62a17ae | 4429 | if (set) |
4430 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4431 | else | |
4432 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4433 | |
d62a17ae | 4434 | return bgp_vty_return(vty, ret); |
718e3744 | 4435 | } |
4436 | ||
d62a17ae | 4437 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4438 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4439 | { |
d62a17ae | 4440 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4441 | } |
4442 | ||
d62a17ae | 4443 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4444 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4445 | { |
d62a17ae | 4446 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4447 | } |
6b0655a2 | 4448 | |
718e3744 | 4449 | /* neighbor capability orf prefix-list. */ |
4450 | DEFUN (neighbor_capability_orf_prefix, | |
4451 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4452 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4453 | NEIGHBOR_STR |
4454 | NEIGHBOR_ADDR_STR2 | |
4455 | "Advertise capability to the peer\n" | |
4456 | "Advertise ORF capability to the peer\n" | |
4457 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4458 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4459 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4460 | "Capability to SEND the ORF to this neighbor\n") | |
4461 | { | |
d62a17ae | 4462 | int idx_peer = 1; |
4463 | int idx_send_recv = 5; | |
d7c0a89a | 4464 | uint16_t flag = 0; |
d62a17ae | 4465 | |
4466 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4467 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4468 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4469 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4470 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4471 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4472 | else { | |
4473 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4474 | return CMD_WARNING_CONFIG_FAILED; | |
4475 | } | |
4476 | ||
4477 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4478 | bgp_node_safi(vty), flag); | |
4479 | } | |
4480 | ||
4481 | ALIAS_HIDDEN( | |
4482 | neighbor_capability_orf_prefix, | |
4483 | neighbor_capability_orf_prefix_hidden_cmd, | |
4484 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4485 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4486 | "Advertise capability to the peer\n" | |
4487 | "Advertise ORF capability to the peer\n" | |
4488 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4489 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4490 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4491 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4492 | |
718e3744 | 4493 | DEFUN (no_neighbor_capability_orf_prefix, |
4494 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4495 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4496 | NO_STR |
4497 | NEIGHBOR_STR | |
4498 | NEIGHBOR_ADDR_STR2 | |
4499 | "Advertise capability to the peer\n" | |
4500 | "Advertise ORF capability to the peer\n" | |
4501 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4502 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4503 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4504 | "Capability to SEND the ORF to this neighbor\n") | |
4505 | { | |
d62a17ae | 4506 | int idx_peer = 2; |
4507 | int idx_send_recv = 6; | |
d7c0a89a | 4508 | uint16_t flag = 0; |
d62a17ae | 4509 | |
4510 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4511 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4512 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4513 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4514 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4515 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4516 | else { | |
4517 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4518 | return CMD_WARNING_CONFIG_FAILED; | |
4519 | } | |
4520 | ||
4521 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4522 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4523 | flag); | |
4524 | } | |
4525 | ||
4526 | ALIAS_HIDDEN( | |
4527 | no_neighbor_capability_orf_prefix, | |
4528 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4529 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4530 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4531 | "Advertise capability to the peer\n" | |
4532 | "Advertise ORF capability to the peer\n" | |
4533 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4534 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4535 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4536 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4537 | |
718e3744 | 4538 | /* neighbor next-hop-self. */ |
4539 | DEFUN (neighbor_nexthop_self, | |
4540 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4541 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4542 | NEIGHBOR_STR |
4543 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4544 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4545 | { |
d62a17ae | 4546 | int idx_peer = 1; |
4547 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4548 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4549 | } |
9e7a53c1 | 4550 | |
d62a17ae | 4551 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4552 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4553 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4554 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4555 | |
a538debe DS |
4556 | /* neighbor next-hop-self. */ |
4557 | DEFUN (neighbor_nexthop_self_force, | |
4558 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4559 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4560 | NEIGHBOR_STR |
4561 | NEIGHBOR_ADDR_STR2 | |
4562 | "Disable the next hop calculation for this neighbor\n" | |
4563 | "Set the next hop to self for reflected routes\n") | |
4564 | { | |
d62a17ae | 4565 | int idx_peer = 1; |
4566 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4567 | bgp_node_safi(vty), | |
4568 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4569 | } |
4570 | ||
d62a17ae | 4571 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4572 | neighbor_nexthop_self_force_hidden_cmd, | |
4573 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4574 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4575 | "Disable the next hop calculation for this neighbor\n" | |
4576 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4577 | |
1bc4e531 DA |
4578 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4579 | neighbor_nexthop_self_all_hidden_cmd, | |
4580 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4581 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4582 | "Disable the next hop calculation for this neighbor\n" | |
4583 | "Set the next hop to self for reflected routes\n") | |
4584 | ||
718e3744 | 4585 | DEFUN (no_neighbor_nexthop_self, |
4586 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4587 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4588 | NO_STR |
4589 | NEIGHBOR_STR | |
4590 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4591 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4592 | { |
d62a17ae | 4593 | int idx_peer = 2; |
4594 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4595 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4596 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4597 | } |
6b0655a2 | 4598 | |
d62a17ae | 4599 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4600 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4601 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4602 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4603 | |
88b8ed8d | 4604 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4605 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4606 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4607 | NO_STR |
4608 | NEIGHBOR_STR | |
4609 | NEIGHBOR_ADDR_STR2 | |
4610 | "Disable the next hop calculation for this neighbor\n" | |
4611 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4612 | { |
d62a17ae | 4613 | int idx_peer = 2; |
4614 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4615 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4616 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4617 | } |
a538debe | 4618 | |
d62a17ae | 4619 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4620 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4621 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4622 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4623 | "Disable the next hop calculation for this neighbor\n" | |
4624 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4625 | |
1bc4e531 DA |
4626 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4627 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4629 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4630 | "Disable the next hop calculation for this neighbor\n" | |
4631 | "Set the next hop to self for reflected routes\n") | |
4632 | ||
c7122e14 DS |
4633 | /* neighbor as-override */ |
4634 | DEFUN (neighbor_as_override, | |
4635 | neighbor_as_override_cmd, | |
9ccf14f7 | 4636 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4637 | NEIGHBOR_STR |
4638 | NEIGHBOR_ADDR_STR2 | |
4639 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4640 | { | |
d62a17ae | 4641 | int idx_peer = 1; |
4642 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4643 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4644 | } |
4645 | ||
d62a17ae | 4646 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4647 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4648 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4649 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4650 | |
c7122e14 DS |
4651 | DEFUN (no_neighbor_as_override, |
4652 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4653 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4654 | NO_STR |
4655 | NEIGHBOR_STR | |
4656 | NEIGHBOR_ADDR_STR2 | |
4657 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4658 | { | |
d62a17ae | 4659 | int idx_peer = 2; |
4660 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4661 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4662 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4663 | } |
4664 | ||
d62a17ae | 4665 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4666 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4667 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4668 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4669 | |
718e3744 | 4670 | /* neighbor remove-private-AS. */ |
4671 | DEFUN (neighbor_remove_private_as, | |
4672 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4673 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4674 | NEIGHBOR_STR |
4675 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4676 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4677 | { |
d62a17ae | 4678 | int idx_peer = 1; |
4679 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4680 | bgp_node_safi(vty), | |
4681 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4682 | } |
4683 | ||
d62a17ae | 4684 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4685 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4686 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4687 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4688 | |
5000f21c DS |
4689 | DEFUN (neighbor_remove_private_as_all, |
4690 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4691 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4692 | NEIGHBOR_STR |
4693 | NEIGHBOR_ADDR_STR2 | |
4694 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4695 | "Apply to all AS numbers\n") |
5000f21c | 4696 | { |
d62a17ae | 4697 | int idx_peer = 1; |
4698 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4699 | bgp_node_safi(vty), | |
4700 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4701 | } |
4702 | ||
d62a17ae | 4703 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4704 | neighbor_remove_private_as_all_hidden_cmd, | |
4705 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4706 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4707 | "Remove private ASNs in outbound updates\n" | |
4708 | "Apply to all AS numbers") | |
596c17ba | 4709 | |
5000f21c DS |
4710 | DEFUN (neighbor_remove_private_as_replace_as, |
4711 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4712 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4713 | NEIGHBOR_STR |
4714 | NEIGHBOR_ADDR_STR2 | |
4715 | "Remove private ASNs in outbound updates\n" | |
4716 | "Replace private ASNs with our ASN in outbound updates\n") | |
4717 | { | |
d62a17ae | 4718 | int idx_peer = 1; |
4719 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4720 | bgp_node_safi(vty), | |
4721 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4722 | } |
4723 | ||
d62a17ae | 4724 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4725 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4726 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4727 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4728 | "Remove private ASNs in outbound updates\n" | |
4729 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4730 | |
5000f21c DS |
4731 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4732 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4733 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4734 | NEIGHBOR_STR |
4735 | NEIGHBOR_ADDR_STR2 | |
4736 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4737 | "Apply to all AS numbers\n" |
5000f21c DS |
4738 | "Replace private ASNs with our ASN in outbound updates\n") |
4739 | { | |
d62a17ae | 4740 | int idx_peer = 1; |
4741 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4742 | bgp_node_safi(vty), | |
4743 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4744 | } |
4745 | ||
d62a17ae | 4746 | ALIAS_HIDDEN( |
4747 | neighbor_remove_private_as_all_replace_as, | |
4748 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4749 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4750 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4751 | "Remove private ASNs in outbound updates\n" | |
4752 | "Apply to all AS numbers\n" | |
4753 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4754 | |
718e3744 | 4755 | DEFUN (no_neighbor_remove_private_as, |
4756 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4757 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4758 | NO_STR |
4759 | NEIGHBOR_STR | |
4760 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4761 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4762 | { |
d62a17ae | 4763 | int idx_peer = 2; |
4764 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4765 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4766 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4767 | } |
6b0655a2 | 4768 | |
d62a17ae | 4769 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4770 | no_neighbor_remove_private_as_hidden_cmd, | |
4771 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4772 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4773 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4774 | |
88b8ed8d | 4775 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4776 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4777 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4778 | NO_STR |
4779 | NEIGHBOR_STR | |
4780 | NEIGHBOR_ADDR_STR2 | |
4781 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4782 | "Apply to all AS numbers\n") |
88b8ed8d | 4783 | { |
d62a17ae | 4784 | int idx_peer = 2; |
4785 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4786 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4787 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4788 | } |
5000f21c | 4789 | |
d62a17ae | 4790 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4791 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4792 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4793 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4794 | "Remove private ASNs in outbound updates\n" | |
4795 | "Apply to all AS numbers\n") | |
596c17ba | 4796 | |
88b8ed8d | 4797 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4798 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4800 | NO_STR |
4801 | NEIGHBOR_STR | |
4802 | NEIGHBOR_ADDR_STR2 | |
4803 | "Remove private ASNs in outbound updates\n" | |
4804 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4805 | { |
d62a17ae | 4806 | int idx_peer = 2; |
4807 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4808 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4809 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4810 | } |
5000f21c | 4811 | |
d62a17ae | 4812 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4813 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4815 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4816 | "Remove private ASNs in outbound updates\n" | |
4817 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4818 | |
88b8ed8d | 4819 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4820 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4821 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4822 | NO_STR |
4823 | NEIGHBOR_STR | |
4824 | NEIGHBOR_ADDR_STR2 | |
4825 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4826 | "Apply to all AS numbers\n" |
5000f21c | 4827 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4828 | { |
d62a17ae | 4829 | int idx_peer = 2; |
4830 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4831 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4832 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4833 | } |
5000f21c | 4834 | |
d62a17ae | 4835 | ALIAS_HIDDEN( |
4836 | no_neighbor_remove_private_as_all_replace_as, | |
4837 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4839 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4840 | "Remove private ASNs in outbound updates\n" | |
4841 | "Apply to all AS numbers\n" | |
4842 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4843 | |
5000f21c | 4844 | |
718e3744 | 4845 | /* neighbor send-community. */ |
4846 | DEFUN (neighbor_send_community, | |
4847 | neighbor_send_community_cmd, | |
9ccf14f7 | 4848 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4849 | NEIGHBOR_STR |
4850 | NEIGHBOR_ADDR_STR2 | |
4851 | "Send Community attribute to this neighbor\n") | |
4852 | { | |
d62a17ae | 4853 | int idx_peer = 1; |
27c05d4d | 4854 | |
d62a17ae | 4855 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4856 | bgp_node_safi(vty), | |
4857 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4858 | } |
4859 | ||
d62a17ae | 4860 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4861 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4862 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4863 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4864 | |
718e3744 | 4865 | DEFUN (no_neighbor_send_community, |
4866 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4867 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4868 | NO_STR |
4869 | NEIGHBOR_STR | |
4870 | NEIGHBOR_ADDR_STR2 | |
4871 | "Send Community attribute to this neighbor\n") | |
4872 | { | |
d62a17ae | 4873 | int idx_peer = 2; |
27c05d4d | 4874 | |
d62a17ae | 4875 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4876 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4877 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4878 | } |
6b0655a2 | 4879 | |
d62a17ae | 4880 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4881 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4882 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4883 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4884 | |
718e3744 | 4885 | /* neighbor send-community extended. */ |
4886 | DEFUN (neighbor_send_community_type, | |
4887 | neighbor_send_community_type_cmd, | |
57d187bc | 4888 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4889 | NEIGHBOR_STR |
4890 | NEIGHBOR_ADDR_STR2 | |
4891 | "Send Community attribute to this neighbor\n" | |
4892 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4893 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4894 | "Send Extended Community attributes\n" |
57d187bc JS |
4895 | "Send Standard Community attributes\n" |
4896 | "Send Large Community attributes\n") | |
718e3744 | 4897 | { |
27c05d4d | 4898 | int idx_peer = 1; |
d7c0a89a | 4899 | uint32_t flag = 0; |
27c05d4d | 4900 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4901 | |
27c05d4d | 4902 | if (strmatch(type, "standard")) { |
d62a17ae | 4903 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4904 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4905 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4906 | } else if (strmatch(type, "large")) { |
d62a17ae | 4907 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4908 | } else if (strmatch(type, "both")) { |
d62a17ae | 4909 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4910 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4911 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4912 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4913 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4914 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4915 | } | |
4916 | ||
27c05d4d | 4917 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4918 | bgp_node_safi(vty), flag); |
4919 | } | |
4920 | ||
4921 | ALIAS_HIDDEN( | |
4922 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4923 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4924 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4925 | "Send Community attribute to this neighbor\n" | |
4926 | "Send Standard and Extended Community attributes\n" | |
4927 | "Send Standard, Large and Extended Community attributes\n" | |
4928 | "Send Extended Community attributes\n" | |
4929 | "Send Standard Community attributes\n" | |
4930 | "Send Large Community attributes\n") | |
596c17ba | 4931 | |
718e3744 | 4932 | DEFUN (no_neighbor_send_community_type, |
4933 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4934 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4935 | NO_STR |
4936 | NEIGHBOR_STR | |
4937 | NEIGHBOR_ADDR_STR2 | |
4938 | "Send Community attribute to this neighbor\n" | |
4939 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4940 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4941 | "Send Extended Community attributes\n" |
57d187bc JS |
4942 | "Send Standard Community attributes\n" |
4943 | "Send Large Community attributes\n") | |
718e3744 | 4944 | { |
d62a17ae | 4945 | int idx_peer = 2; |
27c05d4d | 4946 | uint32_t flag = 0; |
d62a17ae | 4947 | const char *type = argv[argc - 1]->text; |
4948 | ||
27c05d4d PM |
4949 | if (strmatch(type, "standard")) { |
4950 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4951 | } else if (strmatch(type, "extended")) { | |
4952 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4953 | } else if (strmatch(type, "large")) { | |
4954 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4955 | } else if (strmatch(type, "both")) { | |
4956 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4957 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4958 | } else { /* if (strmatch(type, "all")) */ | |
4959 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4960 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4961 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4962 | } | |
4963 | ||
4964 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4965 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4966 | flag); | |
d62a17ae | 4967 | } |
4968 | ||
4969 | ALIAS_HIDDEN( | |
4970 | no_neighbor_send_community_type, | |
4971 | no_neighbor_send_community_type_hidden_cmd, | |
4972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4973 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4974 | "Send Community attribute to this neighbor\n" | |
4975 | "Send Standard and Extended Community attributes\n" | |
4976 | "Send Standard, Large and Extended Community attributes\n" | |
4977 | "Send Extended Community attributes\n" | |
4978 | "Send Standard Community attributes\n" | |
4979 | "Send Large Community attributes\n") | |
596c17ba | 4980 | |
718e3744 | 4981 | /* neighbor soft-reconfig. */ |
4982 | DEFUN (neighbor_soft_reconfiguration, | |
4983 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4984 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4985 | NEIGHBOR_STR |
4986 | NEIGHBOR_ADDR_STR2 | |
4987 | "Per neighbor soft reconfiguration\n" | |
4988 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4989 | { | |
d62a17ae | 4990 | int idx_peer = 1; |
4991 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4992 | bgp_node_safi(vty), | |
4993 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4994 | } |
4995 | ||
d62a17ae | 4996 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4997 | neighbor_soft_reconfiguration_hidden_cmd, | |
4998 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4999 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5000 | "Per neighbor soft reconfiguration\n" | |
5001 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5002 | |
718e3744 | 5003 | DEFUN (no_neighbor_soft_reconfiguration, |
5004 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5005 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5006 | NO_STR |
5007 | NEIGHBOR_STR | |
5008 | NEIGHBOR_ADDR_STR2 | |
5009 | "Per neighbor soft reconfiguration\n" | |
5010 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5011 | { | |
d62a17ae | 5012 | int idx_peer = 2; |
5013 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5014 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5015 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5016 | } |
6b0655a2 | 5017 | |
d62a17ae | 5018 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5019 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5020 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5021 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5022 | "Per neighbor soft reconfiguration\n" | |
5023 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5024 | |
718e3744 | 5025 | DEFUN (neighbor_route_reflector_client, |
5026 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5027 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5028 | NEIGHBOR_STR |
5029 | NEIGHBOR_ADDR_STR2 | |
5030 | "Configure a neighbor as Route Reflector client\n") | |
5031 | { | |
d62a17ae | 5032 | int idx_peer = 1; |
5033 | struct peer *peer; | |
718e3744 | 5034 | |
5035 | ||
d62a17ae | 5036 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5037 | if (!peer) | |
5038 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5039 | |
d62a17ae | 5040 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5041 | bgp_node_safi(vty), | |
5042 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5043 | } |
5044 | ||
d62a17ae | 5045 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5046 | neighbor_route_reflector_client_hidden_cmd, | |
5047 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5048 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5049 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5050 | |
718e3744 | 5051 | DEFUN (no_neighbor_route_reflector_client, |
5052 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5054 | NO_STR |
5055 | NEIGHBOR_STR | |
5056 | NEIGHBOR_ADDR_STR2 | |
5057 | "Configure a neighbor as Route Reflector client\n") | |
5058 | { | |
d62a17ae | 5059 | int idx_peer = 2; |
5060 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5061 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5062 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5063 | } |
6b0655a2 | 5064 | |
d62a17ae | 5065 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5066 | no_neighbor_route_reflector_client_hidden_cmd, | |
5067 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5068 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5069 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5070 | |
718e3744 | 5071 | /* neighbor route-server-client. */ |
5072 | DEFUN (neighbor_route_server_client, | |
5073 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5074 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5075 | NEIGHBOR_STR |
5076 | NEIGHBOR_ADDR_STR2 | |
5077 | "Configure a neighbor as Route Server client\n") | |
5078 | { | |
d62a17ae | 5079 | int idx_peer = 1; |
5080 | struct peer *peer; | |
2a3d5731 | 5081 | |
d62a17ae | 5082 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5083 | if (!peer) | |
5084 | return CMD_WARNING_CONFIG_FAILED; | |
5085 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5086 | bgp_node_safi(vty), | |
5087 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5088 | } |
5089 | ||
d62a17ae | 5090 | ALIAS_HIDDEN(neighbor_route_server_client, |
5091 | neighbor_route_server_client_hidden_cmd, | |
5092 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5093 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5094 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5095 | |
718e3744 | 5096 | DEFUN (no_neighbor_route_server_client, |
5097 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5098 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5099 | NO_STR |
5100 | NEIGHBOR_STR | |
5101 | NEIGHBOR_ADDR_STR2 | |
5102 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5103 | { |
d62a17ae | 5104 | int idx_peer = 2; |
5105 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5106 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5107 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5108 | } |
6b0655a2 | 5109 | |
d62a17ae | 5110 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5111 | no_neighbor_route_server_client_hidden_cmd, | |
5112 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5113 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5114 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5115 | |
fee0f4c6 | 5116 | DEFUN (neighbor_nexthop_local_unchanged, |
5117 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5118 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5119 | NEIGHBOR_STR |
5120 | NEIGHBOR_ADDR_STR2 | |
5121 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5122 | "Leave link-local nexthop unchanged for this peer\n") | |
5123 | { | |
d62a17ae | 5124 | int idx_peer = 1; |
5125 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5126 | bgp_node_safi(vty), | |
5127 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5128 | } |
6b0655a2 | 5129 | |
fee0f4c6 | 5130 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5131 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5132 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5133 | NO_STR |
5134 | NEIGHBOR_STR | |
5135 | NEIGHBOR_ADDR_STR2 | |
5136 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5137 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5138 | { |
d62a17ae | 5139 | int idx_peer = 2; |
5140 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5141 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5142 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5143 | } |
6b0655a2 | 5144 | |
718e3744 | 5145 | DEFUN (neighbor_attr_unchanged, |
5146 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5147 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5148 | NEIGHBOR_STR |
5149 | NEIGHBOR_ADDR_STR2 | |
5150 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5151 | "As-path attribute\n" | |
5152 | "Nexthop attribute\n" | |
a8206004 | 5153 | "Med attribute\n") |
718e3744 | 5154 | { |
d62a17ae | 5155 | int idx = 0; |
8eeb0335 DW |
5156 | char *peer_str = argv[1]->arg; |
5157 | struct peer *peer; | |
d7c0a89a | 5158 | uint16_t flags = 0; |
8eeb0335 DW |
5159 | afi_t afi = bgp_node_afi(vty); |
5160 | safi_t safi = bgp_node_safi(vty); | |
5161 | ||
5162 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5163 | if (!peer) | |
5164 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5165 | |
5166 | if (argv_find(argv, argc, "as-path", &idx)) | |
5167 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5168 | idx = 0; | |
5169 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5170 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5171 | idx = 0; | |
5172 | if (argv_find(argv, argc, "med", &idx)) | |
5173 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5174 | ||
8eeb0335 DW |
5175 | /* no flags means all of them! */ |
5176 | if (!flags) { | |
d62a17ae | 5177 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
5178 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5179 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5180 | } else { |
a4d82a8a PZ |
5181 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
5182 | && peer_af_flag_check(peer, afi, safi, | |
5183 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
5184 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5185 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5186 | } | |
5187 | ||
a4d82a8a PZ |
5188 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
5189 | && peer_af_flag_check(peer, afi, safi, | |
5190 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
5191 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5192 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5193 | } | |
5194 | ||
a4d82a8a PZ |
5195 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
5196 | && peer_af_flag_check(peer, afi, safi, | |
5197 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
5198 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5199 | PEER_FLAG_MED_UNCHANGED); | |
5200 | } | |
d62a17ae | 5201 | } |
5202 | ||
8eeb0335 | 5203 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 5204 | } |
5205 | ||
5206 | ALIAS_HIDDEN( | |
5207 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5208 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5209 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5210 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5211 | "As-path attribute\n" | |
5212 | "Nexthop attribute\n" | |
5213 | "Med attribute\n") | |
596c17ba | 5214 | |
718e3744 | 5215 | DEFUN (no_neighbor_attr_unchanged, |
5216 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5217 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5218 | NO_STR |
718e3744 | 5219 | NEIGHBOR_STR |
5220 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5221 | "BGP attribute is propagated unchanged to this neighbor\n" |
5222 | "As-path attribute\n" | |
40e718b5 | 5223 | "Nexthop attribute\n" |
a8206004 | 5224 | "Med attribute\n") |
718e3744 | 5225 | { |
d62a17ae | 5226 | int idx = 0; |
5227 | char *peer = argv[2]->arg; | |
d7c0a89a | 5228 | uint16_t flags = 0; |
d62a17ae | 5229 | |
5230 | if (argv_find(argv, argc, "as-path", &idx)) | |
5231 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5232 | idx = 0; | |
5233 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5234 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5235 | idx = 0; | |
5236 | if (argv_find(argv, argc, "med", &idx)) | |
5237 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5238 | ||
5239 | if (!flags) // no flags means all of them! | |
5240 | { | |
5241 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5242 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5243 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5244 | } | |
5245 | ||
5246 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
5247 | bgp_node_safi(vty), flags); | |
5248 | } | |
5249 | ||
5250 | ALIAS_HIDDEN( | |
5251 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5252 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5253 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5254 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5255 | "As-path attribute\n" | |
5256 | "Nexthop attribute\n" | |
5257 | "Med attribute\n") | |
718e3744 | 5258 | |
718e3744 | 5259 | /* EBGP multihop configuration. */ |
d62a17ae | 5260 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5261 | const char *ttl_str) | |
718e3744 | 5262 | { |
d62a17ae | 5263 | struct peer *peer; |
5264 | unsigned int ttl; | |
718e3744 | 5265 | |
d62a17ae | 5266 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5267 | if (!peer) | |
5268 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5269 | |
d62a17ae | 5270 | if (peer->conf_if) |
5271 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5272 | |
d62a17ae | 5273 | if (!ttl_str) |
5274 | ttl = MAXTTL; | |
5275 | else | |
5276 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5277 | |
d62a17ae | 5278 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5279 | } |
5280 | ||
d62a17ae | 5281 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5282 | { |
d62a17ae | 5283 | struct peer *peer; |
718e3744 | 5284 | |
d62a17ae | 5285 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5286 | if (!peer) | |
5287 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5288 | |
d62a17ae | 5289 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5290 | } |
5291 | ||
5292 | /* neighbor ebgp-multihop. */ | |
5293 | DEFUN (neighbor_ebgp_multihop, | |
5294 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5295 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5296 | NEIGHBOR_STR |
5297 | NEIGHBOR_ADDR_STR2 | |
5298 | "Allow EBGP neighbors not on directly connected networks\n") | |
5299 | { | |
d62a17ae | 5300 | int idx_peer = 1; |
5301 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5302 | } |
5303 | ||
5304 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5305 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5306 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5307 | NEIGHBOR_STR |
5308 | NEIGHBOR_ADDR_STR2 | |
5309 | "Allow EBGP neighbors not on directly connected networks\n" | |
5310 | "maximum hop count\n") | |
5311 | { | |
d62a17ae | 5312 | int idx_peer = 1; |
5313 | int idx_number = 3; | |
5314 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5315 | argv[idx_number]->arg); | |
718e3744 | 5316 | } |
5317 | ||
5318 | DEFUN (no_neighbor_ebgp_multihop, | |
5319 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5321 | NO_STR |
5322 | NEIGHBOR_STR | |
5323 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5324 | "Allow EBGP neighbors not on directly connected networks\n" |
5325 | "maximum hop count\n") | |
718e3744 | 5326 | { |
d62a17ae | 5327 | int idx_peer = 2; |
5328 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5329 | } |
5330 | ||
6b0655a2 | 5331 | |
6ffd2079 | 5332 | /* disable-connected-check */ |
5333 | DEFUN (neighbor_disable_connected_check, | |
5334 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5335 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5336 | NEIGHBOR_STR |
7ebe625c | 5337 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5338 | "one-hop away EBGP peer using loopback address\n" |
5339 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5340 | { |
d62a17ae | 5341 | int idx_peer = 1; |
5342 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5343 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5344 | } |
5345 | ||
5346 | DEFUN (no_neighbor_disable_connected_check, | |
5347 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5348 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5349 | NO_STR |
5350 | NEIGHBOR_STR | |
7ebe625c | 5351 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5352 | "one-hop away EBGP peer using loopback address\n" |
5353 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5354 | { |
d62a17ae | 5355 | int idx_peer = 2; |
5356 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5357 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5358 | } |
5359 | ||
47cbc09b PM |
5360 | |
5361 | /* enforce-first-as */ | |
5362 | DEFUN (neighbor_enforce_first_as, | |
5363 | neighbor_enforce_first_as_cmd, | |
5364 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5365 | NEIGHBOR_STR | |
5366 | NEIGHBOR_ADDR_STR2 | |
5367 | "Enforce the first AS for EBGP routes\n") | |
5368 | { | |
5369 | int idx_peer = 1; | |
5370 | ||
5371 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5372 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5373 | } | |
5374 | ||
5375 | DEFUN (no_neighbor_enforce_first_as, | |
5376 | no_neighbor_enforce_first_as_cmd, | |
5377 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5378 | NO_STR | |
5379 | NEIGHBOR_STR | |
5380 | NEIGHBOR_ADDR_STR2 | |
5381 | "Enforce the first AS for EBGP routes\n") | |
5382 | { | |
5383 | int idx_peer = 2; | |
5384 | ||
5385 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5386 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5387 | } | |
5388 | ||
5389 | ||
718e3744 | 5390 | DEFUN (neighbor_description, |
5391 | neighbor_description_cmd, | |
e961923c | 5392 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5393 | NEIGHBOR_STR |
5394 | NEIGHBOR_ADDR_STR2 | |
5395 | "Neighbor specific description\n" | |
5396 | "Up to 80 characters describing this neighbor\n") | |
5397 | { | |
d62a17ae | 5398 | int idx_peer = 1; |
5399 | int idx_line = 3; | |
5400 | struct peer *peer; | |
5401 | char *str; | |
718e3744 | 5402 | |
d62a17ae | 5403 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5404 | if (!peer) | |
5405 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5406 | |
d62a17ae | 5407 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5408 | |
d62a17ae | 5409 | peer_description_set(peer, str); |
718e3744 | 5410 | |
d62a17ae | 5411 | XFREE(MTYPE_TMP, str); |
718e3744 | 5412 | |
d62a17ae | 5413 | return CMD_SUCCESS; |
718e3744 | 5414 | } |
5415 | ||
5416 | DEFUN (no_neighbor_description, | |
5417 | no_neighbor_description_cmd, | |
a14810f4 | 5418 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5419 | NO_STR |
5420 | NEIGHBOR_STR | |
5421 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5422 | "Neighbor specific description\n") |
718e3744 | 5423 | { |
d62a17ae | 5424 | int idx_peer = 2; |
5425 | struct peer *peer; | |
718e3744 | 5426 | |
d62a17ae | 5427 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5428 | if (!peer) | |
5429 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5430 | |
d62a17ae | 5431 | peer_description_unset(peer); |
718e3744 | 5432 | |
d62a17ae | 5433 | return CMD_SUCCESS; |
718e3744 | 5434 | } |
5435 | ||
a14810f4 PM |
5436 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5437 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5438 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5439 | "Neighbor specific description\n" | |
5440 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5441 | |
718e3744 | 5442 | /* Neighbor update-source. */ |
d62a17ae | 5443 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5444 | const char *source_str) | |
5445 | { | |
5446 | struct peer *peer; | |
5447 | struct prefix p; | |
a14810f4 | 5448 | union sockunion su; |
d62a17ae | 5449 | |
5450 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5451 | if (!peer) | |
5452 | return CMD_WARNING_CONFIG_FAILED; | |
5453 | ||
5454 | if (peer->conf_if) | |
5455 | return CMD_WARNING; | |
5456 | ||
5457 | if (source_str) { | |
a14810f4 | 5458 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5459 | peer_update_source_addr_set(peer, &su); |
5460 | else { | |
5461 | if (str2prefix(source_str, &p)) { | |
5462 | vty_out(vty, | |
5463 | "%% Invalid update-source, remove prefix length \n"); | |
5464 | return CMD_WARNING_CONFIG_FAILED; | |
5465 | } else | |
5466 | peer_update_source_if_set(peer, source_str); | |
5467 | } | |
5468 | } else | |
5469 | peer_update_source_unset(peer); | |
5470 | ||
5471 | return CMD_SUCCESS; | |
5472 | } | |
5473 | ||
5474 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5475 | "IPv4 address\n" \ | |
5476 | "IPv6 address\n" \ | |
5477 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5478 | |
718e3744 | 5479 | DEFUN (neighbor_update_source, |
5480 | neighbor_update_source_cmd, | |
9ccf14f7 | 5481 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5482 | NEIGHBOR_STR |
5483 | NEIGHBOR_ADDR_STR2 | |
5484 | "Source of routing updates\n" | |
369688c0 | 5485 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5486 | { |
d62a17ae | 5487 | int idx_peer = 1; |
5488 | int idx_peer_2 = 3; | |
5489 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5490 | argv[idx_peer_2]->arg); | |
718e3744 | 5491 | } |
5492 | ||
5493 | DEFUN (no_neighbor_update_source, | |
5494 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5495 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5496 | NO_STR |
5497 | NEIGHBOR_STR | |
5498 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5499 | "Source of routing updates\n" |
5500 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5501 | { |
d62a17ae | 5502 | int idx_peer = 2; |
5503 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5504 | } |
6b0655a2 | 5505 | |
d62a17ae | 5506 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5507 | afi_t afi, safi_t safi, | |
5508 | const char *rmap, int set) | |
718e3744 | 5509 | { |
d62a17ae | 5510 | int ret; |
5511 | struct peer *peer; | |
80912664 | 5512 | struct route_map *route_map = NULL; |
718e3744 | 5513 | |
d62a17ae | 5514 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5515 | if (!peer) | |
5516 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5517 | |
1de27621 | 5518 | if (set) { |
80912664 DS |
5519 | if (rmap) |
5520 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5521 | ret = peer_default_originate_set(peer, afi, safi, |
5522 | rmap, route_map); | |
5523 | } else | |
d62a17ae | 5524 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5525 | |
d62a17ae | 5526 | return bgp_vty_return(vty, ret); |
718e3744 | 5527 | } |
5528 | ||
5529 | /* neighbor default-originate. */ | |
5530 | DEFUN (neighbor_default_originate, | |
5531 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5532 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5533 | NEIGHBOR_STR |
5534 | NEIGHBOR_ADDR_STR2 | |
5535 | "Originate default route to this neighbor\n") | |
5536 | { | |
d62a17ae | 5537 | int idx_peer = 1; |
5538 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5539 | bgp_node_afi(vty), | |
5540 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5541 | } |
5542 | ||
d62a17ae | 5543 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5544 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5545 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5546 | "Originate default route to this neighbor\n") | |
596c17ba | 5547 | |
718e3744 | 5548 | DEFUN (neighbor_default_originate_rmap, |
5549 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5550 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5551 | NEIGHBOR_STR |
5552 | NEIGHBOR_ADDR_STR2 | |
5553 | "Originate default route to this neighbor\n" | |
5554 | "Route-map to specify criteria to originate default\n" | |
5555 | "route-map name\n") | |
5556 | { | |
d62a17ae | 5557 | int idx_peer = 1; |
5558 | int idx_word = 4; | |
5559 | return peer_default_originate_set_vty( | |
5560 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5561 | argv[idx_word]->arg, 1); | |
718e3744 | 5562 | } |
5563 | ||
d62a17ae | 5564 | ALIAS_HIDDEN( |
5565 | neighbor_default_originate_rmap, | |
5566 | neighbor_default_originate_rmap_hidden_cmd, | |
5567 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5568 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5569 | "Originate default route to this neighbor\n" | |
5570 | "Route-map to specify criteria to originate default\n" | |
5571 | "route-map name\n") | |
596c17ba | 5572 | |
718e3744 | 5573 | DEFUN (no_neighbor_default_originate, |
5574 | no_neighbor_default_originate_cmd, | |
a636c635 | 5575 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5576 | NO_STR |
5577 | NEIGHBOR_STR | |
5578 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5579 | "Originate default route to this neighbor\n" |
5580 | "Route-map to specify criteria to originate default\n" | |
5581 | "route-map name\n") | |
718e3744 | 5582 | { |
d62a17ae | 5583 | int idx_peer = 2; |
5584 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5585 | bgp_node_afi(vty), | |
5586 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5587 | } |
5588 | ||
d62a17ae | 5589 | ALIAS_HIDDEN( |
5590 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5592 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5593 | "Originate default route to this neighbor\n" | |
5594 | "Route-map to specify criteria to originate default\n" | |
5595 | "route-map name\n") | |
596c17ba | 5596 | |
6b0655a2 | 5597 | |
718e3744 | 5598 | /* Set neighbor's BGP port. */ |
d62a17ae | 5599 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5600 | const char *port_str) | |
5601 | { | |
5602 | struct peer *peer; | |
d7c0a89a | 5603 | uint16_t port; |
d62a17ae | 5604 | struct servent *sp; |
5605 | ||
5606 | peer = peer_lookup_vty(vty, ip_str); | |
5607 | if (!peer) | |
5608 | return CMD_WARNING_CONFIG_FAILED; | |
5609 | ||
5610 | if (!port_str) { | |
5611 | sp = getservbyname("bgp", "tcp"); | |
5612 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5613 | } else { | |
5614 | port = strtoul(port_str, NULL, 10); | |
5615 | } | |
718e3744 | 5616 | |
d62a17ae | 5617 | peer_port_set(peer, port); |
718e3744 | 5618 | |
d62a17ae | 5619 | return CMD_SUCCESS; |
718e3744 | 5620 | } |
5621 | ||
f418446b | 5622 | /* Set specified peer's BGP port. */ |
718e3744 | 5623 | DEFUN (neighbor_port, |
5624 | neighbor_port_cmd, | |
9ccf14f7 | 5625 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5626 | NEIGHBOR_STR |
5627 | NEIGHBOR_ADDR_STR | |
5628 | "Neighbor's BGP port\n" | |
5629 | "TCP port number\n") | |
5630 | { | |
d62a17ae | 5631 | int idx_ip = 1; |
5632 | int idx_number = 3; | |
5633 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5634 | argv[idx_number]->arg); | |
718e3744 | 5635 | } |
5636 | ||
5637 | DEFUN (no_neighbor_port, | |
5638 | no_neighbor_port_cmd, | |
9ccf14f7 | 5639 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5640 | NO_STR |
5641 | NEIGHBOR_STR | |
5642 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5643 | "Neighbor's BGP port\n" |
5644 | "TCP port number\n") | |
718e3744 | 5645 | { |
d62a17ae | 5646 | int idx_ip = 2; |
5647 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5648 | } |
5649 | ||
6b0655a2 | 5650 | |
718e3744 | 5651 | /* neighbor weight. */ |
d62a17ae | 5652 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5653 | safi_t safi, const char *weight_str) | |
718e3744 | 5654 | { |
d62a17ae | 5655 | int ret; |
5656 | struct peer *peer; | |
5657 | unsigned long weight; | |
718e3744 | 5658 | |
d62a17ae | 5659 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5660 | if (!peer) | |
5661 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5662 | |
d62a17ae | 5663 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5664 | |
d62a17ae | 5665 | ret = peer_weight_set(peer, afi, safi, weight); |
5666 | return bgp_vty_return(vty, ret); | |
718e3744 | 5667 | } |
5668 | ||
d62a17ae | 5669 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5670 | safi_t safi) | |
718e3744 | 5671 | { |
d62a17ae | 5672 | int ret; |
5673 | struct peer *peer; | |
718e3744 | 5674 | |
d62a17ae | 5675 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5676 | if (!peer) | |
5677 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5678 | |
d62a17ae | 5679 | ret = peer_weight_unset(peer, afi, safi); |
5680 | return bgp_vty_return(vty, ret); | |
718e3744 | 5681 | } |
5682 | ||
5683 | DEFUN (neighbor_weight, | |
5684 | neighbor_weight_cmd, | |
9ccf14f7 | 5685 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5686 | NEIGHBOR_STR |
5687 | NEIGHBOR_ADDR_STR2 | |
5688 | "Set default weight for routes from this neighbor\n" | |
5689 | "default weight\n") | |
5690 | { | |
d62a17ae | 5691 | int idx_peer = 1; |
5692 | int idx_number = 3; | |
5693 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5694 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5695 | } |
5696 | ||
d62a17ae | 5697 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5698 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5699 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5700 | "Set default weight for routes from this neighbor\n" | |
5701 | "default weight\n") | |
596c17ba | 5702 | |
718e3744 | 5703 | DEFUN (no_neighbor_weight, |
5704 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5705 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5706 | NO_STR |
5707 | NEIGHBOR_STR | |
5708 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5709 | "Set default weight for routes from this neighbor\n" |
5710 | "default weight\n") | |
718e3744 | 5711 | { |
d62a17ae | 5712 | int idx_peer = 2; |
5713 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5714 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5715 | } |
5716 | ||
d62a17ae | 5717 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5718 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5719 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5720 | "Set default weight for routes from this neighbor\n" | |
5721 | "default weight\n") | |
596c17ba | 5722 | |
6b0655a2 | 5723 | |
718e3744 | 5724 | /* Override capability negotiation. */ |
5725 | DEFUN (neighbor_override_capability, | |
5726 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5727 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5728 | NEIGHBOR_STR |
5729 | NEIGHBOR_ADDR_STR2 | |
5730 | "Override capability negotiation result\n") | |
5731 | { | |
d62a17ae | 5732 | int idx_peer = 1; |
5733 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5734 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5735 | } |
5736 | ||
5737 | DEFUN (no_neighbor_override_capability, | |
5738 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5740 | NO_STR |
5741 | NEIGHBOR_STR | |
5742 | NEIGHBOR_ADDR_STR2 | |
5743 | "Override capability negotiation result\n") | |
5744 | { | |
d62a17ae | 5745 | int idx_peer = 2; |
5746 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5747 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5748 | } |
6b0655a2 | 5749 | |
718e3744 | 5750 | DEFUN (neighbor_strict_capability, |
5751 | neighbor_strict_capability_cmd, | |
9fb964de | 5752 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5753 | NEIGHBOR_STR |
9fb964de | 5754 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5755 | "Strict capability negotiation match\n") |
5756 | { | |
9fb964de PM |
5757 | int idx_peer = 1; |
5758 | ||
5759 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5760 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5761 | } |
5762 | ||
5763 | DEFUN (no_neighbor_strict_capability, | |
5764 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5766 | NO_STR |
5767 | NEIGHBOR_STR | |
9fb964de | 5768 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5769 | "Strict capability negotiation match\n") |
5770 | { | |
9fb964de PM |
5771 | int idx_peer = 2; |
5772 | ||
5773 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5774 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5775 | } |
6b0655a2 | 5776 | |
d62a17ae | 5777 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5778 | const char *keep_str, const char *hold_str) | |
718e3744 | 5779 | { |
d62a17ae | 5780 | int ret; |
5781 | struct peer *peer; | |
d7c0a89a QY |
5782 | uint32_t keepalive; |
5783 | uint32_t holdtime; | |
718e3744 | 5784 | |
d62a17ae | 5785 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5786 | if (!peer) | |
5787 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5788 | |
d62a17ae | 5789 | keepalive = strtoul(keep_str, NULL, 10); |
5790 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5791 | |
d62a17ae | 5792 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5793 | |
d62a17ae | 5794 | return bgp_vty_return(vty, ret); |
718e3744 | 5795 | } |
6b0655a2 | 5796 | |
d62a17ae | 5797 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5798 | { |
d62a17ae | 5799 | int ret; |
5800 | struct peer *peer; | |
718e3744 | 5801 | |
d62a17ae | 5802 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5803 | if (!peer) | |
5804 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5805 | |
d62a17ae | 5806 | ret = peer_timers_unset(peer); |
718e3744 | 5807 | |
d62a17ae | 5808 | return bgp_vty_return(vty, ret); |
718e3744 | 5809 | } |
5810 | ||
5811 | DEFUN (neighbor_timers, | |
5812 | neighbor_timers_cmd, | |
9ccf14f7 | 5813 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5814 | NEIGHBOR_STR |
5815 | NEIGHBOR_ADDR_STR2 | |
5816 | "BGP per neighbor timers\n" | |
5817 | "Keepalive interval\n" | |
5818 | "Holdtime\n") | |
5819 | { | |
d62a17ae | 5820 | int idx_peer = 1; |
5821 | int idx_number = 3; | |
5822 | int idx_number_2 = 4; | |
5823 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5824 | argv[idx_number]->arg, | |
5825 | argv[idx_number_2]->arg); | |
718e3744 | 5826 | } |
5827 | ||
5828 | DEFUN (no_neighbor_timers, | |
5829 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5830 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5831 | NO_STR |
5832 | NEIGHBOR_STR | |
5833 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5834 | "BGP per neighbor timers\n" |
5835 | "Keepalive interval\n" | |
5836 | "Holdtime\n") | |
718e3744 | 5837 | { |
d62a17ae | 5838 | int idx_peer = 2; |
5839 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5840 | } |
6b0655a2 | 5841 | |
813d4307 | 5842 | |
d62a17ae | 5843 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5844 | const char *time_str) | |
718e3744 | 5845 | { |
d62a17ae | 5846 | int ret; |
5847 | struct peer *peer; | |
d7c0a89a | 5848 | uint32_t connect; |
718e3744 | 5849 | |
d62a17ae | 5850 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5851 | if (!peer) | |
5852 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5853 | |
d62a17ae | 5854 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5855 | |
d62a17ae | 5856 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5857 | |
d62a17ae | 5858 | return bgp_vty_return(vty, ret); |
718e3744 | 5859 | } |
5860 | ||
d62a17ae | 5861 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5862 | { |
d62a17ae | 5863 | int ret; |
5864 | struct peer *peer; | |
718e3744 | 5865 | |
d62a17ae | 5866 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5867 | if (!peer) | |
5868 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5869 | |
d62a17ae | 5870 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5871 | |
d62a17ae | 5872 | return bgp_vty_return(vty, ret); |
718e3744 | 5873 | } |
5874 | ||
5875 | DEFUN (neighbor_timers_connect, | |
5876 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5877 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5878 | NEIGHBOR_STR |
966f821c | 5879 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5880 | "BGP per neighbor timers\n" |
5881 | "BGP connect timer\n" | |
5882 | "Connect timer\n") | |
5883 | { | |
d62a17ae | 5884 | int idx_peer = 1; |
5885 | int idx_number = 4; | |
5886 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5887 | argv[idx_number]->arg); | |
718e3744 | 5888 | } |
5889 | ||
5890 | DEFUN (no_neighbor_timers_connect, | |
5891 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5892 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5893 | NO_STR |
5894 | NEIGHBOR_STR | |
966f821c | 5895 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5896 | "BGP per neighbor timers\n" |
8334fd5a DW |
5897 | "BGP connect timer\n" |
5898 | "Connect timer\n") | |
718e3744 | 5899 | { |
d62a17ae | 5900 | int idx_peer = 2; |
5901 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5902 | } |
5903 | ||
6b0655a2 | 5904 | |
d62a17ae | 5905 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5906 | const char *time_str, int set) | |
718e3744 | 5907 | { |
d62a17ae | 5908 | int ret; |
5909 | struct peer *peer; | |
d7c0a89a | 5910 | uint32_t routeadv = 0; |
718e3744 | 5911 | |
d62a17ae | 5912 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5913 | if (!peer) | |
5914 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5915 | |
d62a17ae | 5916 | if (time_str) |
5917 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5918 | |
d62a17ae | 5919 | if (set) |
5920 | ret = peer_advertise_interval_set(peer, routeadv); | |
5921 | else | |
5922 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5923 | |
d62a17ae | 5924 | return bgp_vty_return(vty, ret); |
718e3744 | 5925 | } |
5926 | ||
5927 | DEFUN (neighbor_advertise_interval, | |
5928 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5929 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5930 | NEIGHBOR_STR |
966f821c | 5931 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5932 | "Minimum interval between sending BGP routing updates\n" |
5933 | "time in seconds\n") | |
5934 | { | |
d62a17ae | 5935 | int idx_peer = 1; |
5936 | int idx_number = 3; | |
5937 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5938 | argv[idx_number]->arg, 1); | |
718e3744 | 5939 | } |
5940 | ||
5941 | DEFUN (no_neighbor_advertise_interval, | |
5942 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5943 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5944 | NO_STR |
5945 | NEIGHBOR_STR | |
966f821c | 5946 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5947 | "Minimum interval between sending BGP routing updates\n" |
5948 | "time in seconds\n") | |
718e3744 | 5949 | { |
d62a17ae | 5950 | int idx_peer = 2; |
5951 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5952 | } |
5953 | ||
6b0655a2 | 5954 | |
518f0eb1 DS |
5955 | /* Time to wait before processing route-map updates */ |
5956 | DEFUN (bgp_set_route_map_delay_timer, | |
5957 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5958 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5959 | SET_STR |
5960 | "BGP route-map delay timer\n" | |
5961 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5962 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5963 | { |
d62a17ae | 5964 | int idx_number = 3; |
d7c0a89a | 5965 | uint32_t rmap_delay_timer; |
d62a17ae | 5966 | |
5967 | if (argv[idx_number]->arg) { | |
5968 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5969 | bm->rmap_update_timer = rmap_delay_timer; | |
5970 | ||
5971 | /* if the dynamic update handling is being disabled, and a timer | |
5972 | * is | |
5973 | * running, stop the timer and act as if the timer has already | |
5974 | * fired. | |
5975 | */ | |
5976 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5977 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5978 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5979 | NULL, 0); | |
5980 | } | |
5981 | return CMD_SUCCESS; | |
5982 | } else { | |
5983 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5984 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5985 | } |
518f0eb1 DS |
5986 | } |
5987 | ||
5988 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5989 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5990 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5991 | NO_STR |
3a2d747c | 5992 | BGP_STR |
518f0eb1 | 5993 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5994 | "Reset to default time to wait for processing route-map changes\n" |
5995 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5996 | { |
518f0eb1 | 5997 | |
d62a17ae | 5998 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5999 | |
d62a17ae | 6000 | return CMD_SUCCESS; |
518f0eb1 DS |
6001 | } |
6002 | ||
f414725f | 6003 | |
718e3744 | 6004 | /* neighbor interface */ |
d62a17ae | 6005 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6006 | const char *str) | |
718e3744 | 6007 | { |
d62a17ae | 6008 | struct peer *peer; |
718e3744 | 6009 | |
d62a17ae | 6010 | peer = peer_lookup_vty(vty, ip_str); |
6011 | if (!peer || peer->conf_if) { | |
6012 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6013 | return CMD_WARNING_CONFIG_FAILED; | |
6014 | } | |
718e3744 | 6015 | |
d62a17ae | 6016 | if (str) |
6017 | peer_interface_set(peer, str); | |
6018 | else | |
6019 | peer_interface_unset(peer); | |
718e3744 | 6020 | |
d62a17ae | 6021 | return CMD_SUCCESS; |
718e3744 | 6022 | } |
6023 | ||
6024 | DEFUN (neighbor_interface, | |
6025 | neighbor_interface_cmd, | |
9ccf14f7 | 6026 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6027 | NEIGHBOR_STR |
6028 | NEIGHBOR_ADDR_STR | |
6029 | "Interface\n" | |
6030 | "Interface name\n") | |
6031 | { | |
d62a17ae | 6032 | int idx_ip = 1; |
6033 | int idx_word = 3; | |
6034 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6035 | } |
6036 | ||
6037 | DEFUN (no_neighbor_interface, | |
6038 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6039 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6040 | NO_STR |
6041 | NEIGHBOR_STR | |
16cedbb0 | 6042 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6043 | "Interface\n" |
6044 | "Interface name\n") | |
6045 | { | |
d62a17ae | 6046 | int idx_peer = 2; |
6047 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6048 | } |
6b0655a2 | 6049 | |
718e3744 | 6050 | DEFUN (neighbor_distribute_list, |
6051 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6052 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6053 | NEIGHBOR_STR |
6054 | NEIGHBOR_ADDR_STR2 | |
6055 | "Filter updates to/from this neighbor\n" | |
6056 | "IP access-list number\n" | |
6057 | "IP access-list number (expanded range)\n" | |
6058 | "IP Access-list name\n" | |
6059 | "Filter incoming updates\n" | |
6060 | "Filter outgoing updates\n") | |
6061 | { | |
d62a17ae | 6062 | int idx_peer = 1; |
6063 | int idx_acl = 3; | |
6064 | int direct, ret; | |
6065 | struct peer *peer; | |
a8206004 | 6066 | |
d62a17ae | 6067 | const char *pstr = argv[idx_peer]->arg; |
6068 | const char *acl = argv[idx_acl]->arg; | |
6069 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6070 | |
d62a17ae | 6071 | peer = peer_and_group_lookup_vty(vty, pstr); |
6072 | if (!peer) | |
6073 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6074 | |
d62a17ae | 6075 | /* Check filter direction. */ |
6076 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6077 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6078 | direct, acl); | |
a8206004 | 6079 | |
d62a17ae | 6080 | return bgp_vty_return(vty, ret); |
718e3744 | 6081 | } |
6082 | ||
d62a17ae | 6083 | ALIAS_HIDDEN( |
6084 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6085 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6086 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6087 | "Filter updates to/from this neighbor\n" | |
6088 | "IP access-list number\n" | |
6089 | "IP access-list number (expanded range)\n" | |
6090 | "IP Access-list name\n" | |
6091 | "Filter incoming updates\n" | |
6092 | "Filter outgoing updates\n") | |
596c17ba | 6093 | |
718e3744 | 6094 | DEFUN (no_neighbor_distribute_list, |
6095 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6096 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6097 | NO_STR |
6098 | NEIGHBOR_STR | |
6099 | NEIGHBOR_ADDR_STR2 | |
6100 | "Filter updates to/from this neighbor\n" | |
6101 | "IP access-list number\n" | |
6102 | "IP access-list number (expanded range)\n" | |
6103 | "IP Access-list name\n" | |
6104 | "Filter incoming updates\n" | |
6105 | "Filter outgoing updates\n") | |
6106 | { | |
d62a17ae | 6107 | int idx_peer = 2; |
6108 | int direct, ret; | |
6109 | struct peer *peer; | |
a8206004 | 6110 | |
d62a17ae | 6111 | const char *pstr = argv[idx_peer]->arg; |
6112 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6113 | |
d62a17ae | 6114 | peer = peer_and_group_lookup_vty(vty, pstr); |
6115 | if (!peer) | |
6116 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6117 | |
d62a17ae | 6118 | /* Check filter direction. */ |
6119 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6120 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6121 | direct); | |
a8206004 | 6122 | |
d62a17ae | 6123 | return bgp_vty_return(vty, ret); |
718e3744 | 6124 | } |
6b0655a2 | 6125 | |
d62a17ae | 6126 | ALIAS_HIDDEN( |
6127 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6128 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6129 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6130 | "Filter updates to/from this neighbor\n" | |
6131 | "IP access-list number\n" | |
6132 | "IP access-list number (expanded range)\n" | |
6133 | "IP Access-list name\n" | |
6134 | "Filter incoming updates\n" | |
6135 | "Filter outgoing updates\n") | |
596c17ba | 6136 | |
718e3744 | 6137 | /* Set prefix list to the peer. */ |
d62a17ae | 6138 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6139 | afi_t afi, safi_t safi, | |
6140 | const char *name_str, | |
6141 | const char *direct_str) | |
718e3744 | 6142 | { |
d62a17ae | 6143 | int ret; |
d62a17ae | 6144 | int direct = FILTER_IN; |
cf9ac8bf | 6145 | struct peer *peer; |
718e3744 | 6146 | |
d62a17ae | 6147 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6148 | if (!peer) | |
6149 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6150 | |
d62a17ae | 6151 | /* Check filter direction. */ |
6152 | if (strncmp(direct_str, "i", 1) == 0) | |
6153 | direct = FILTER_IN; | |
6154 | else if (strncmp(direct_str, "o", 1) == 0) | |
6155 | direct = FILTER_OUT; | |
718e3744 | 6156 | |
d62a17ae | 6157 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6158 | |
d62a17ae | 6159 | return bgp_vty_return(vty, ret); |
718e3744 | 6160 | } |
6161 | ||
d62a17ae | 6162 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6163 | afi_t afi, safi_t safi, | |
6164 | const char *direct_str) | |
718e3744 | 6165 | { |
d62a17ae | 6166 | int ret; |
6167 | struct peer *peer; | |
6168 | int direct = FILTER_IN; | |
718e3744 | 6169 | |
d62a17ae | 6170 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6171 | if (!peer) | |
6172 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6173 | |
d62a17ae | 6174 | /* Check filter direction. */ |
6175 | if (strncmp(direct_str, "i", 1) == 0) | |
6176 | direct = FILTER_IN; | |
6177 | else if (strncmp(direct_str, "o", 1) == 0) | |
6178 | direct = FILTER_OUT; | |
718e3744 | 6179 | |
d62a17ae | 6180 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6181 | |
d62a17ae | 6182 | return bgp_vty_return(vty, ret); |
718e3744 | 6183 | } |
6184 | ||
6185 | DEFUN (neighbor_prefix_list, | |
6186 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6187 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6188 | NEIGHBOR_STR |
6189 | NEIGHBOR_ADDR_STR2 | |
6190 | "Filter updates to/from this neighbor\n" | |
6191 | "Name of a prefix list\n" | |
6192 | "Filter incoming updates\n" | |
6193 | "Filter outgoing updates\n") | |
6194 | { | |
d62a17ae | 6195 | int idx_peer = 1; |
6196 | int idx_word = 3; | |
6197 | int idx_in_out = 4; | |
6198 | return peer_prefix_list_set_vty( | |
6199 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6200 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6201 | } |
6202 | ||
d62a17ae | 6203 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6204 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6205 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6206 | "Filter updates to/from this neighbor\n" | |
6207 | "Name of a prefix list\n" | |
6208 | "Filter incoming updates\n" | |
6209 | "Filter outgoing updates\n") | |
596c17ba | 6210 | |
718e3744 | 6211 | DEFUN (no_neighbor_prefix_list, |
6212 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6213 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6214 | NO_STR |
6215 | NEIGHBOR_STR | |
6216 | NEIGHBOR_ADDR_STR2 | |
6217 | "Filter updates to/from this neighbor\n" | |
6218 | "Name of a prefix list\n" | |
6219 | "Filter incoming updates\n" | |
6220 | "Filter outgoing updates\n") | |
6221 | { | |
d62a17ae | 6222 | int idx_peer = 2; |
6223 | int idx_in_out = 5; | |
6224 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6225 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6226 | argv[idx_in_out]->arg); | |
718e3744 | 6227 | } |
6b0655a2 | 6228 | |
d62a17ae | 6229 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6230 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6231 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6232 | "Filter updates to/from this neighbor\n" | |
6233 | "Name of a prefix list\n" | |
6234 | "Filter incoming updates\n" | |
6235 | "Filter outgoing updates\n") | |
596c17ba | 6236 | |
d62a17ae | 6237 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6238 | safi_t safi, const char *name_str, | |
6239 | const char *direct_str) | |
718e3744 | 6240 | { |
d62a17ae | 6241 | int ret; |
6242 | struct peer *peer; | |
6243 | int direct = FILTER_IN; | |
718e3744 | 6244 | |
d62a17ae | 6245 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6246 | if (!peer) | |
6247 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6248 | |
d62a17ae | 6249 | /* Check filter direction. */ |
6250 | if (strncmp(direct_str, "i", 1) == 0) | |
6251 | direct = FILTER_IN; | |
6252 | else if (strncmp(direct_str, "o", 1) == 0) | |
6253 | direct = FILTER_OUT; | |
718e3744 | 6254 | |
d62a17ae | 6255 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6256 | |
d62a17ae | 6257 | return bgp_vty_return(vty, ret); |
718e3744 | 6258 | } |
6259 | ||
d62a17ae | 6260 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6261 | safi_t safi, const char *direct_str) | |
718e3744 | 6262 | { |
d62a17ae | 6263 | int ret; |
6264 | struct peer *peer; | |
6265 | int direct = FILTER_IN; | |
718e3744 | 6266 | |
d62a17ae | 6267 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6268 | if (!peer) | |
6269 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6270 | |
d62a17ae | 6271 | /* Check filter direction. */ |
6272 | if (strncmp(direct_str, "i", 1) == 0) | |
6273 | direct = FILTER_IN; | |
6274 | else if (strncmp(direct_str, "o", 1) == 0) | |
6275 | direct = FILTER_OUT; | |
718e3744 | 6276 | |
d62a17ae | 6277 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6278 | |
d62a17ae | 6279 | return bgp_vty_return(vty, ret); |
718e3744 | 6280 | } |
6281 | ||
6282 | DEFUN (neighbor_filter_list, | |
6283 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6284 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6285 | NEIGHBOR_STR |
6286 | NEIGHBOR_ADDR_STR2 | |
6287 | "Establish BGP filters\n" | |
6288 | "AS path access-list name\n" | |
6289 | "Filter incoming routes\n" | |
6290 | "Filter outgoing routes\n") | |
6291 | { | |
d62a17ae | 6292 | int idx_peer = 1; |
6293 | int idx_word = 3; | |
6294 | int idx_in_out = 4; | |
6295 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6296 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6297 | argv[idx_in_out]->arg); | |
718e3744 | 6298 | } |
6299 | ||
d62a17ae | 6300 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6301 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6302 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6303 | "Establish BGP filters\n" | |
6304 | "AS path access-list name\n" | |
6305 | "Filter incoming routes\n" | |
6306 | "Filter outgoing routes\n") | |
596c17ba | 6307 | |
718e3744 | 6308 | DEFUN (no_neighbor_filter_list, |
6309 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6310 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6311 | NO_STR |
6312 | NEIGHBOR_STR | |
6313 | NEIGHBOR_ADDR_STR2 | |
6314 | "Establish BGP filters\n" | |
6315 | "AS path access-list name\n" | |
6316 | "Filter incoming routes\n" | |
6317 | "Filter outgoing routes\n") | |
6318 | { | |
d62a17ae | 6319 | int idx_peer = 2; |
6320 | int idx_in_out = 5; | |
6321 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6322 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6323 | argv[idx_in_out]->arg); | |
718e3744 | 6324 | } |
6b0655a2 | 6325 | |
d62a17ae | 6326 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6327 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6328 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6329 | "Establish BGP filters\n" | |
6330 | "AS path access-list name\n" | |
6331 | "Filter incoming routes\n" | |
6332 | "Filter outgoing routes\n") | |
596c17ba | 6333 | |
718e3744 | 6334 | /* Set route-map to the peer. */ |
d62a17ae | 6335 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6336 | afi_t afi, safi_t safi, const char *name_str, | |
6337 | const char *direct_str) | |
718e3744 | 6338 | { |
d62a17ae | 6339 | int ret; |
6340 | struct peer *peer; | |
6341 | int direct = RMAP_IN; | |
1de27621 | 6342 | struct route_map *route_map; |
718e3744 | 6343 | |
d62a17ae | 6344 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6345 | if (!peer) | |
6346 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6347 | |
d62a17ae | 6348 | /* Check filter direction. */ |
6349 | if (strncmp(direct_str, "in", 2) == 0) | |
6350 | direct = RMAP_IN; | |
6351 | else if (strncmp(direct_str, "o", 1) == 0) | |
6352 | direct = RMAP_OUT; | |
718e3744 | 6353 | |
1de27621 DA |
6354 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6355 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6356 | |
d62a17ae | 6357 | return bgp_vty_return(vty, ret); |
718e3744 | 6358 | } |
6359 | ||
d62a17ae | 6360 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6361 | afi_t afi, safi_t safi, | |
6362 | const char *direct_str) | |
718e3744 | 6363 | { |
d62a17ae | 6364 | int ret; |
6365 | struct peer *peer; | |
6366 | int direct = RMAP_IN; | |
718e3744 | 6367 | |
d62a17ae | 6368 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6369 | if (!peer) | |
6370 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6371 | |
d62a17ae | 6372 | /* Check filter direction. */ |
6373 | if (strncmp(direct_str, "in", 2) == 0) | |
6374 | direct = RMAP_IN; | |
6375 | else if (strncmp(direct_str, "o", 1) == 0) | |
6376 | direct = RMAP_OUT; | |
718e3744 | 6377 | |
d62a17ae | 6378 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6379 | |
d62a17ae | 6380 | return bgp_vty_return(vty, ret); |
718e3744 | 6381 | } |
6382 | ||
6383 | DEFUN (neighbor_route_map, | |
6384 | neighbor_route_map_cmd, | |
9ccf14f7 | 6385 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6386 | NEIGHBOR_STR |
6387 | NEIGHBOR_ADDR_STR2 | |
6388 | "Apply route map to neighbor\n" | |
6389 | "Name of route map\n" | |
6390 | "Apply map to incoming routes\n" | |
2a3d5731 | 6391 | "Apply map to outbound routes\n") |
718e3744 | 6392 | { |
d62a17ae | 6393 | int idx_peer = 1; |
6394 | int idx_word = 3; | |
6395 | int idx_in_out = 4; | |
6396 | return peer_route_map_set_vty( | |
6397 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6398 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6399 | } |
6400 | ||
d62a17ae | 6401 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6402 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6403 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6404 | "Apply route map to neighbor\n" | |
6405 | "Name of route map\n" | |
6406 | "Apply map to incoming routes\n" | |
6407 | "Apply map to outbound routes\n") | |
596c17ba | 6408 | |
718e3744 | 6409 | DEFUN (no_neighbor_route_map, |
6410 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6412 | NO_STR |
6413 | NEIGHBOR_STR | |
6414 | NEIGHBOR_ADDR_STR2 | |
6415 | "Apply route map to neighbor\n" | |
6416 | "Name of route map\n" | |
6417 | "Apply map to incoming routes\n" | |
2a3d5731 | 6418 | "Apply map to outbound routes\n") |
718e3744 | 6419 | { |
d62a17ae | 6420 | int idx_peer = 2; |
6421 | int idx_in_out = 5; | |
6422 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6423 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6424 | argv[idx_in_out]->arg); | |
718e3744 | 6425 | } |
6b0655a2 | 6426 | |
d62a17ae | 6427 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6428 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6429 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6430 | "Apply route map to neighbor\n" | |
6431 | "Name of route map\n" | |
6432 | "Apply map to incoming routes\n" | |
6433 | "Apply map to outbound routes\n") | |
596c17ba | 6434 | |
718e3744 | 6435 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6436 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6437 | afi_t afi, safi_t safi, | |
6438 | const char *name_str) | |
718e3744 | 6439 | { |
d62a17ae | 6440 | int ret; |
6441 | struct peer *peer; | |
1de27621 | 6442 | struct route_map *route_map; |
718e3744 | 6443 | |
d62a17ae | 6444 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6445 | if (!peer) | |
6446 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6447 | |
1de27621 DA |
6448 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6449 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6450 | |
d62a17ae | 6451 | return bgp_vty_return(vty, ret); |
718e3744 | 6452 | } |
6453 | ||
6454 | /* Unset route-map from the peer. */ | |
d62a17ae | 6455 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6456 | afi_t afi, safi_t safi) | |
718e3744 | 6457 | { |
d62a17ae | 6458 | int ret; |
6459 | struct peer *peer; | |
718e3744 | 6460 | |
d62a17ae | 6461 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6462 | if (!peer) | |
6463 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6464 | |
d62a17ae | 6465 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6466 | |
d62a17ae | 6467 | return bgp_vty_return(vty, ret); |
718e3744 | 6468 | } |
6469 | ||
6470 | DEFUN (neighbor_unsuppress_map, | |
6471 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6472 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6473 | NEIGHBOR_STR |
6474 | NEIGHBOR_ADDR_STR2 | |
6475 | "Route-map to selectively unsuppress suppressed routes\n" | |
6476 | "Name of route map\n") | |
6477 | { | |
d62a17ae | 6478 | int idx_peer = 1; |
6479 | int idx_word = 3; | |
6480 | return peer_unsuppress_map_set_vty( | |
6481 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6482 | argv[idx_word]->arg); | |
718e3744 | 6483 | } |
6484 | ||
d62a17ae | 6485 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6486 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6487 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6488 | "Route-map to selectively unsuppress suppressed routes\n" | |
6489 | "Name of route map\n") | |
596c17ba | 6490 | |
718e3744 | 6491 | DEFUN (no_neighbor_unsuppress_map, |
6492 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6493 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6494 | NO_STR |
6495 | NEIGHBOR_STR | |
6496 | NEIGHBOR_ADDR_STR2 | |
6497 | "Route-map to selectively unsuppress suppressed routes\n" | |
6498 | "Name of route map\n") | |
6499 | { | |
d62a17ae | 6500 | int idx_peer = 2; |
6501 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6502 | bgp_node_afi(vty), | |
6503 | bgp_node_safi(vty)); | |
718e3744 | 6504 | } |
6b0655a2 | 6505 | |
d62a17ae | 6506 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6507 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6508 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6509 | "Route-map to selectively unsuppress suppressed routes\n" | |
6510 | "Name of route map\n") | |
596c17ba | 6511 | |
d62a17ae | 6512 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6513 | afi_t afi, safi_t safi, | |
6514 | const char *num_str, | |
6515 | const char *threshold_str, int warning, | |
6516 | const char *restart_str) | |
718e3744 | 6517 | { |
d62a17ae | 6518 | int ret; |
6519 | struct peer *peer; | |
d7c0a89a QY |
6520 | uint32_t max; |
6521 | uint8_t threshold; | |
6522 | uint16_t restart; | |
718e3744 | 6523 | |
d62a17ae | 6524 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6525 | if (!peer) | |
6526 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6527 | |
d62a17ae | 6528 | max = strtoul(num_str, NULL, 10); |
6529 | if (threshold_str) | |
6530 | threshold = atoi(threshold_str); | |
6531 | else | |
6532 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6533 | |
d62a17ae | 6534 | if (restart_str) |
6535 | restart = atoi(restart_str); | |
6536 | else | |
6537 | restart = 0; | |
0a486e5f | 6538 | |
d62a17ae | 6539 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6540 | restart); | |
718e3744 | 6541 | |
d62a17ae | 6542 | return bgp_vty_return(vty, ret); |
718e3744 | 6543 | } |
6544 | ||
d62a17ae | 6545 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6546 | afi_t afi, safi_t safi) | |
718e3744 | 6547 | { |
d62a17ae | 6548 | int ret; |
6549 | struct peer *peer; | |
718e3744 | 6550 | |
d62a17ae | 6551 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6552 | if (!peer) | |
6553 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6554 | |
d62a17ae | 6555 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6556 | |
d62a17ae | 6557 | return bgp_vty_return(vty, ret); |
718e3744 | 6558 | } |
6559 | ||
fde246e8 DA |
6560 | /* Maximum number of prefix to be sent to the neighbor. */ |
6561 | DEFUN(neighbor_maximum_prefix_out, | |
6562 | neighbor_maximum_prefix_out_cmd, | |
6563 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6564 | NEIGHBOR_STR | |
6565 | NEIGHBOR_ADDR_STR2 | |
6566 | "Maximum number of prefixes to be sent to this peer\n" | |
6567 | "Maximum no. of prefix limit\n") | |
6568 | { | |
6569 | int idx_peer = 1; | |
6570 | int idx_number = 3; | |
6571 | struct peer *peer; | |
6572 | uint32_t max; | |
6573 | afi_t afi = bgp_node_afi(vty); | |
6574 | safi_t safi = bgp_node_safi(vty); | |
6575 | ||
6576 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6577 | if (!peer) | |
6578 | return CMD_WARNING_CONFIG_FAILED; | |
6579 | ||
6580 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6581 | ||
6582 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6583 | peer->pmax_out[afi][safi] = max; | |
6584 | ||
6585 | return CMD_SUCCESS; | |
6586 | } | |
6587 | ||
6588 | DEFUN(no_neighbor_maximum_prefix_out, | |
6589 | no_neighbor_maximum_prefix_out_cmd, | |
6590 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6591 | NO_STR | |
6592 | NEIGHBOR_STR | |
6593 | NEIGHBOR_ADDR_STR2 | |
6594 | "Maximum number of prefixes to be sent to this peer\n") | |
6595 | { | |
6596 | int idx_peer = 2; | |
6597 | struct peer *peer; | |
6598 | afi_t afi = bgp_node_afi(vty); | |
6599 | safi_t safi = bgp_node_safi(vty); | |
6600 | ||
6601 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6602 | if (!peer) | |
6603 | return CMD_WARNING_CONFIG_FAILED; | |
6604 | ||
6605 | peer->pmax_out[afi][safi] = 0; | |
6606 | ||
6607 | return CMD_SUCCESS; | |
6608 | } | |
6609 | ||
718e3744 | 6610 | /* Maximum number of prefix configuration. prefix count is different |
6611 | for each peer configuration. So this configuration can be set for | |
6612 | each peer configuration. */ | |
6613 | DEFUN (neighbor_maximum_prefix, | |
6614 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6615 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6616 | NEIGHBOR_STR |
6617 | NEIGHBOR_ADDR_STR2 | |
6618 | "Maximum number of prefix accept from this peer\n" | |
6619 | "maximum no. of prefix limit\n") | |
6620 | { | |
d62a17ae | 6621 | int idx_peer = 1; |
6622 | int idx_number = 3; | |
6623 | return peer_maximum_prefix_set_vty( | |
6624 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6625 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6626 | } |
6627 | ||
d62a17ae | 6628 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6629 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6630 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6631 | "Maximum number of prefix accept from this peer\n" | |
6632 | "maximum no. of prefix limit\n") | |
596c17ba | 6633 | |
e0701b79 | 6634 | DEFUN (neighbor_maximum_prefix_threshold, |
6635 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6636 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6637 | NEIGHBOR_STR |
6638 | NEIGHBOR_ADDR_STR2 | |
6639 | "Maximum number of prefix accept from this peer\n" | |
6640 | "maximum no. of prefix limit\n" | |
6641 | "Threshold value (%) at which to generate a warning msg\n") | |
6642 | { | |
d62a17ae | 6643 | int idx_peer = 1; |
6644 | int idx_number = 3; | |
6645 | int idx_number_2 = 4; | |
6646 | return peer_maximum_prefix_set_vty( | |
6647 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6648 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6649 | } |
e0701b79 | 6650 | |
d62a17ae | 6651 | ALIAS_HIDDEN( |
6652 | neighbor_maximum_prefix_threshold, | |
6653 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6654 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6655 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6656 | "Maximum number of prefix accept from this peer\n" | |
6657 | "maximum no. of prefix limit\n" | |
6658 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6659 | |
718e3744 | 6660 | DEFUN (neighbor_maximum_prefix_warning, |
6661 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6662 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6663 | NEIGHBOR_STR |
6664 | NEIGHBOR_ADDR_STR2 | |
6665 | "Maximum number of prefix accept from this peer\n" | |
6666 | "maximum no. of prefix limit\n" | |
6667 | "Only give warning message when limit is exceeded\n") | |
6668 | { | |
d62a17ae | 6669 | int idx_peer = 1; |
6670 | int idx_number = 3; | |
6671 | return peer_maximum_prefix_set_vty( | |
6672 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6673 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6674 | } |
6675 | ||
d62a17ae | 6676 | ALIAS_HIDDEN( |
6677 | neighbor_maximum_prefix_warning, | |
6678 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6679 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6680 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6681 | "Maximum number of prefix accept from this peer\n" | |
6682 | "maximum no. of prefix limit\n" | |
6683 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6684 | |
e0701b79 | 6685 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6686 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6687 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6688 | NEIGHBOR_STR |
6689 | NEIGHBOR_ADDR_STR2 | |
6690 | "Maximum number of prefix accept from this peer\n" | |
6691 | "maximum no. of prefix limit\n" | |
6692 | "Threshold value (%) at which to generate a warning msg\n" | |
6693 | "Only give warning message when limit is exceeded\n") | |
6694 | { | |
d62a17ae | 6695 | int idx_peer = 1; |
6696 | int idx_number = 3; | |
6697 | int idx_number_2 = 4; | |
6698 | return peer_maximum_prefix_set_vty( | |
6699 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6700 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6701 | } |
6702 | ||
d62a17ae | 6703 | ALIAS_HIDDEN( |
6704 | neighbor_maximum_prefix_threshold_warning, | |
6705 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6706 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6707 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6708 | "Maximum number of prefix accept from this peer\n" | |
6709 | "maximum no. of prefix limit\n" | |
6710 | "Threshold value (%) at which to generate a warning msg\n" | |
6711 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6712 | |
0a486e5f | 6713 | DEFUN (neighbor_maximum_prefix_restart, |
6714 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6715 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6716 | NEIGHBOR_STR |
6717 | NEIGHBOR_ADDR_STR2 | |
6718 | "Maximum number of prefix accept from this peer\n" | |
6719 | "maximum no. of prefix limit\n" | |
6720 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6721 | "Restart interval in minutes\n") |
0a486e5f | 6722 | { |
d62a17ae | 6723 | int idx_peer = 1; |
6724 | int idx_number = 3; | |
6725 | int idx_number_2 = 5; | |
6726 | return peer_maximum_prefix_set_vty( | |
6727 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6728 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6729 | } |
6730 | ||
d62a17ae | 6731 | ALIAS_HIDDEN( |
6732 | neighbor_maximum_prefix_restart, | |
6733 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6734 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6735 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6736 | "Maximum number of prefix accept from this peer\n" | |
6737 | "maximum no. of prefix limit\n" | |
6738 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6739 | "Restart interval in minutes\n") |
596c17ba | 6740 | |
0a486e5f | 6741 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6742 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6743 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6744 | NEIGHBOR_STR |
6745 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6746 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6747 | "maximum no. of prefix limit\n" |
6748 | "Threshold value (%) at which to generate a warning msg\n" | |
6749 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6750 | "Restart interval in minutes\n") |
0a486e5f | 6751 | { |
d62a17ae | 6752 | int idx_peer = 1; |
6753 | int idx_number = 3; | |
6754 | int idx_number_2 = 4; | |
6755 | int idx_number_3 = 6; | |
6756 | return peer_maximum_prefix_set_vty( | |
6757 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6758 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6759 | argv[idx_number_3]->arg); | |
6760 | } | |
6761 | ||
6762 | ALIAS_HIDDEN( | |
6763 | neighbor_maximum_prefix_threshold_restart, | |
6764 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6765 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6766 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6767 | "Maximum number of prefixes to accept from this peer\n" | |
6768 | "maximum no. of prefix limit\n" | |
6769 | "Threshold value (%) at which to generate a warning msg\n" | |
6770 | "Restart bgp connection after limit is exceeded\n" | |
6771 | "Restart interval in minutes\n") | |
596c17ba | 6772 | |
718e3744 | 6773 | DEFUN (no_neighbor_maximum_prefix, |
6774 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6775 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6776 | NO_STR |
6777 | NEIGHBOR_STR | |
6778 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6779 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6780 | "maximum no. of prefix limit\n" |
6781 | "Threshold value (%) at which to generate a warning msg\n" | |
6782 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6783 | "Restart interval in minutes\n" |
31500417 | 6784 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6785 | { |
d62a17ae | 6786 | int idx_peer = 2; |
6787 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6788 | bgp_node_afi(vty), | |
6789 | bgp_node_safi(vty)); | |
718e3744 | 6790 | } |
e52702f2 | 6791 | |
d62a17ae | 6792 | ALIAS_HIDDEN( |
6793 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6794 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6795 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6796 | "Maximum number of prefixes to accept from this peer\n" | |
6797 | "maximum no. of prefix limit\n" | |
6798 | "Threshold value (%) at which to generate a warning msg\n" | |
6799 | "Restart bgp connection after limit is exceeded\n" | |
6800 | "Restart interval in minutes\n" | |
6801 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6802 | |
718e3744 | 6803 | |
718e3744 | 6804 | /* "neighbor allowas-in" */ |
6805 | DEFUN (neighbor_allowas_in, | |
6806 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6807 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6808 | NEIGHBOR_STR |
6809 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6810 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6811 | "Number of occurrences of AS number\n" |
fd8503f5 | 6812 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6813 | { |
d62a17ae | 6814 | int idx_peer = 1; |
6815 | int idx_number_origin = 3; | |
6816 | int ret; | |
6817 | int origin = 0; | |
6818 | struct peer *peer; | |
6819 | int allow_num = 0; | |
6820 | ||
6821 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6822 | if (!peer) | |
6823 | return CMD_WARNING_CONFIG_FAILED; | |
6824 | ||
6825 | if (argc <= idx_number_origin) | |
6826 | allow_num = 3; | |
6827 | else { | |
6828 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6829 | origin = 1; | |
6830 | else | |
6831 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6832 | } | |
6833 | ||
6834 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6835 | allow_num, origin); | |
6836 | ||
6837 | return bgp_vty_return(vty, ret); | |
6838 | } | |
6839 | ||
6840 | ALIAS_HIDDEN( | |
6841 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6842 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6843 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6844 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6845 | "Number of occurrences of AS number\n" |
d62a17ae | 6846 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6847 | |
718e3744 | 6848 | DEFUN (no_neighbor_allowas_in, |
6849 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6850 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6851 | NO_STR |
6852 | NEIGHBOR_STR | |
6853 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6854 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6855 | "Number of occurrences of AS number\n" |
fd8503f5 | 6856 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6857 | { |
d62a17ae | 6858 | int idx_peer = 2; |
6859 | int ret; | |
6860 | struct peer *peer; | |
718e3744 | 6861 | |
d62a17ae | 6862 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6863 | if (!peer) | |
6864 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6865 | |
d62a17ae | 6866 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6867 | bgp_node_safi(vty)); | |
718e3744 | 6868 | |
d62a17ae | 6869 | return bgp_vty_return(vty, ret); |
718e3744 | 6870 | } |
6b0655a2 | 6871 | |
d62a17ae | 6872 | ALIAS_HIDDEN( |
6873 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6874 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6875 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6876 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6877 | "Number of occurrences of AS number\n" |
d62a17ae | 6878 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6879 | |
fa411a21 NH |
6880 | DEFUN (neighbor_ttl_security, |
6881 | neighbor_ttl_security_cmd, | |
7ebe625c | 6882 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6883 | NEIGHBOR_STR |
7ebe625c | 6884 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6885 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6886 | "Specify the maximum number of hops to the BGP peer\n" |
6887 | "Number of hops to BGP peer\n") | |
fa411a21 | 6888 | { |
d62a17ae | 6889 | int idx_peer = 1; |
6890 | int idx_number = 4; | |
6891 | struct peer *peer; | |
6892 | int gtsm_hops; | |
6893 | ||
6894 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6895 | if (!peer) | |
6896 | return CMD_WARNING_CONFIG_FAILED; | |
6897 | ||
6898 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6899 | ||
7ebe625c QY |
6900 | /* |
6901 | * If 'neighbor swpX', then this is for directly connected peers, | |
6902 | * we should not accept a ttl-security hops value greater than 1. | |
6903 | */ | |
6904 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6905 | vty_out(vty, | |
6906 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6907 | argv[idx_peer]->arg); | |
6908 | return CMD_WARNING_CONFIG_FAILED; | |
6909 | } | |
6910 | ||
d62a17ae | 6911 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6912 | } |
6913 | ||
6914 | DEFUN (no_neighbor_ttl_security, | |
6915 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6917 | NO_STR |
6918 | NEIGHBOR_STR | |
7ebe625c | 6919 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6920 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6921 | "Specify the maximum number of hops to the BGP peer\n" |
6922 | "Number of hops to BGP peer\n") | |
fa411a21 | 6923 | { |
d62a17ae | 6924 | int idx_peer = 2; |
6925 | struct peer *peer; | |
fa411a21 | 6926 | |
d62a17ae | 6927 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6928 | if (!peer) | |
6929 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6930 | |
d62a17ae | 6931 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6932 | } |
6b0655a2 | 6933 | |
adbac85e DW |
6934 | DEFUN (neighbor_addpath_tx_all_paths, |
6935 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6936 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6937 | NEIGHBOR_STR |
6938 | NEIGHBOR_ADDR_STR2 | |
6939 | "Use addpath to advertise all paths to a neighbor\n") | |
6940 | { | |
d62a17ae | 6941 | int idx_peer = 1; |
6942 | struct peer *peer; | |
adbac85e | 6943 | |
d62a17ae | 6944 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6945 | if (!peer) | |
6946 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6947 | |
dcc68b5e MS |
6948 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6949 | BGP_ADDPATH_ALL); | |
6950 | return CMD_SUCCESS; | |
adbac85e DW |
6951 | } |
6952 | ||
d62a17ae | 6953 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6954 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6955 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6956 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6957 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6958 | |
adbac85e DW |
6959 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6960 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6961 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6962 | NO_STR |
6963 | NEIGHBOR_STR | |
6964 | NEIGHBOR_ADDR_STR2 | |
6965 | "Use addpath to advertise all paths to a neighbor\n") | |
6966 | { | |
d62a17ae | 6967 | int idx_peer = 2; |
dcc68b5e MS |
6968 | struct peer *peer; |
6969 | ||
6970 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6971 | if (!peer) | |
6972 | return CMD_WARNING_CONFIG_FAILED; | |
6973 | ||
6974 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6975 | != BGP_ADDPATH_ALL) { | |
6976 | vty_out(vty, | |
6977 | "%% Peer not currently configured to transmit all paths."); | |
6978 | return CMD_WARNING_CONFIG_FAILED; | |
6979 | } | |
6980 | ||
6981 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6982 | BGP_ADDPATH_NONE); | |
6983 | ||
6984 | return CMD_SUCCESS; | |
adbac85e DW |
6985 | } |
6986 | ||
d62a17ae | 6987 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6988 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6989 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6990 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6991 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6992 | |
06370dac DW |
6993 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6994 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6995 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6996 | NEIGHBOR_STR |
6997 | NEIGHBOR_ADDR_STR2 | |
6998 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6999 | { | |
d62a17ae | 7000 | int idx_peer = 1; |
7001 | struct peer *peer; | |
06370dac | 7002 | |
d62a17ae | 7003 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7004 | if (!peer) | |
7005 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7006 | |
dcc68b5e MS |
7007 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7008 | BGP_ADDPATH_BEST_PER_AS); | |
7009 | ||
7010 | return CMD_SUCCESS; | |
06370dac DW |
7011 | } |
7012 | ||
d62a17ae | 7013 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7014 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7015 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7016 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7017 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7018 | |
06370dac DW |
7019 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7020 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7022 | NO_STR |
7023 | NEIGHBOR_STR | |
7024 | NEIGHBOR_ADDR_STR2 | |
7025 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7026 | { | |
d62a17ae | 7027 | int idx_peer = 2; |
dcc68b5e MS |
7028 | struct peer *peer; |
7029 | ||
7030 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7031 | if (!peer) | |
7032 | return CMD_WARNING_CONFIG_FAILED; | |
7033 | ||
7034 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7035 | != BGP_ADDPATH_BEST_PER_AS) { | |
7036 | vty_out(vty, | |
7037 | "%% Peer not currently configured to transmit all best path per as."); | |
7038 | return CMD_WARNING_CONFIG_FAILED; | |
7039 | } | |
7040 | ||
7041 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7042 | BGP_ADDPATH_NONE); | |
7043 | ||
7044 | return CMD_SUCCESS; | |
06370dac DW |
7045 | } |
7046 | ||
d62a17ae | 7047 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7048 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7049 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7050 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7051 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7052 | |
2b31007c RZ |
7053 | DEFPY( |
7054 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7055 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7056 | NEIGHBOR_STR | |
7057 | NEIGHBOR_ADDR_STR2 | |
7058 | "Detect AS loops before sending to neighbor\n") | |
7059 | { | |
7060 | struct peer *peer; | |
7061 | ||
7062 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7063 | if (!peer) | |
7064 | return CMD_WARNING_CONFIG_FAILED; | |
7065 | ||
7066 | peer->as_path_loop_detection = true; | |
7067 | ||
7068 | return CMD_SUCCESS; | |
7069 | } | |
7070 | ||
7071 | DEFPY( | |
7072 | no_neighbor_aspath_loop_detection, | |
7073 | no_neighbor_aspath_loop_detection_cmd, | |
7074 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7075 | NO_STR | |
7076 | NEIGHBOR_STR | |
7077 | NEIGHBOR_ADDR_STR2 | |
7078 | "Detect AS loops before sending to neighbor\n") | |
7079 | { | |
7080 | struct peer *peer; | |
7081 | ||
7082 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7083 | if (!peer) | |
7084 | return CMD_WARNING_CONFIG_FAILED; | |
7085 | ||
7086 | peer->as_path_loop_detection = false; | |
7087 | ||
7088 | return CMD_SUCCESS; | |
7089 | } | |
7090 | ||
b9c7bc5a PZ |
7091 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7092 | struct ecommunity **list) | |
ddb5b488 | 7093 | { |
b9c7bc5a PZ |
7094 | struct ecommunity *ecom = NULL; |
7095 | struct ecommunity *ecomadd; | |
ddb5b488 | 7096 | |
b9c7bc5a | 7097 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7098 | |
b9c7bc5a PZ |
7099 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7100 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7101 | if (!ecomadd) { | |
7102 | vty_out(vty, "Malformed community-list value\n"); | |
7103 | if (ecom) | |
7104 | ecommunity_free(&ecom); | |
7105 | return CMD_WARNING_CONFIG_FAILED; | |
7106 | } | |
ddb5b488 | 7107 | |
b9c7bc5a PZ |
7108 | if (ecom) { |
7109 | ecommunity_merge(ecom, ecomadd); | |
7110 | ecommunity_free(&ecomadd); | |
7111 | } else { | |
7112 | ecom = ecomadd; | |
7113 | } | |
7114 | } | |
7115 | ||
7116 | if (*list) { | |
7117 | ecommunity_free(&*list); | |
ddb5b488 | 7118 | } |
b9c7bc5a PZ |
7119 | *list = ecom; |
7120 | ||
7121 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7122 | } |
7123 | ||
0ca70ba5 DS |
7124 | /* |
7125 | * v2vimport is true if we are handling a `import vrf ...` command | |
7126 | */ | |
7127 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7128 | { |
0ca70ba5 DS |
7129 | afi_t afi; |
7130 | ||
ddb5b488 | 7131 | switch (vty->node) { |
b9c7bc5a | 7132 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7133 | afi = AFI_IP; |
7134 | break; | |
b9c7bc5a | 7135 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7136 | afi = AFI_IP6; |
7137 | break; | |
ddb5b488 PZ |
7138 | default: |
7139 | vty_out(vty, | |
b9c7bc5a | 7140 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7141 | return AFI_MAX; |
ddb5b488 | 7142 | } |
69b07479 | 7143 | |
0ca70ba5 DS |
7144 | if (!v2vimport) { |
7145 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7146 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7147 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7148 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7149 | vty_out(vty, | |
7150 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7151 | return AFI_MAX; | |
7152 | } | |
7153 | } else { | |
7154 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7155 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7156 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7157 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7158 | vty_out(vty, | |
7159 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7160 | return AFI_MAX; | |
7161 | } | |
7162 | } | |
7163 | return afi; | |
ddb5b488 PZ |
7164 | } |
7165 | ||
b9c7bc5a PZ |
7166 | DEFPY (af_rd_vpn_export, |
7167 | af_rd_vpn_export_cmd, | |
7168 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7169 | NO_STR | |
ddb5b488 | 7170 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7171 | "Between current address-family and vpn\n" |
7172 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7173 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7174 | { | |
7175 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7176 | struct prefix_rd prd; | |
7177 | int ret; | |
ddb5b488 | 7178 | afi_t afi; |
b9c7bc5a PZ |
7179 | int idx = 0; |
7180 | int yes = 1; | |
ddb5b488 | 7181 | |
b9c7bc5a | 7182 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7183 | yes = 0; |
b9c7bc5a PZ |
7184 | |
7185 | if (yes) { | |
7186 | ret = str2prefix_rd(rd_str, &prd); | |
7187 | if (!ret) { | |
7188 | vty_out(vty, "%% Malformed rd\n"); | |
7189 | return CMD_WARNING_CONFIG_FAILED; | |
7190 | } | |
ddb5b488 PZ |
7191 | } |
7192 | ||
0ca70ba5 | 7193 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7194 | if (afi == AFI_MAX) |
7195 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7196 | |
69b07479 DS |
7197 | /* |
7198 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7199 | */ | |
7200 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7201 | bgp_get_default(), bgp); | |
ddb5b488 | 7202 | |
69b07479 DS |
7203 | if (yes) { |
7204 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7205 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7206 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7207 | } else { | |
7208 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7209 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7210 | } |
7211 | ||
69b07479 DS |
7212 | /* post-change: re-export vpn routes */ |
7213 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7214 | bgp_get_default(), bgp); | |
7215 | ||
ddb5b488 PZ |
7216 | return CMD_SUCCESS; |
7217 | } | |
7218 | ||
b9c7bc5a PZ |
7219 | ALIAS (af_rd_vpn_export, |
7220 | af_no_rd_vpn_export_cmd, | |
7221 | "no rd vpn export", | |
ddb5b488 | 7222 | NO_STR |
b9c7bc5a PZ |
7223 | "Specify route distinguisher\n" |
7224 | "Between current address-family and vpn\n" | |
7225 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7226 | |
b9c7bc5a PZ |
7227 | DEFPY (af_label_vpn_export, |
7228 | af_label_vpn_export_cmd, | |
e70e9f8e | 7229 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7230 | NO_STR |
ddb5b488 | 7231 | "label value for VRF\n" |
b9c7bc5a PZ |
7232 | "Between current address-family and vpn\n" |
7233 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7234 | "Label Value <0-1048575>\n" |
7235 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7236 | { |
7237 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7238 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7239 | afi_t afi; |
b9c7bc5a PZ |
7240 | int idx = 0; |
7241 | int yes = 1; | |
7242 | ||
7243 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7244 | yes = 0; |
ddb5b488 | 7245 | |
21a16cc2 PZ |
7246 | /* If "no ...", squash trailing parameter */ |
7247 | if (!yes) | |
7248 | label_auto = NULL; | |
7249 | ||
e70e9f8e PZ |
7250 | if (yes) { |
7251 | if (!label_auto) | |
7252 | label = label_val; /* parser should force unsigned */ | |
7253 | } | |
ddb5b488 | 7254 | |
0ca70ba5 | 7255 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7256 | if (afi == AFI_MAX) |
7257 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7258 | |
e70e9f8e | 7259 | |
69b07479 DS |
7260 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7261 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7262 | /* no change */ | |
7263 | return CMD_SUCCESS; | |
e70e9f8e | 7264 | |
69b07479 DS |
7265 | /* |
7266 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7267 | */ | |
7268 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7269 | bgp_get_default(), bgp); | |
7270 | ||
7271 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7272 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7273 | ||
7274 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7275 | ||
7276 | /* | |
7277 | * label has previously been automatically | |
7278 | * assigned by labelpool: release it | |
7279 | * | |
7280 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7281 | * means the automatic assignment is in flight | |
7282 | * and therefore the labelpool callback must | |
7283 | * detect that the auto label is not needed. | |
7284 | */ | |
7285 | ||
7286 | bgp_lp_release(LP_TYPE_VRF, | |
7287 | &bgp->vpn_policy[afi], | |
7288 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7289 | } |
69b07479 DS |
7290 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7291 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7292 | } | |
ddb5b488 | 7293 | |
69b07479 DS |
7294 | bgp->vpn_policy[afi].tovpn_label = label; |
7295 | if (label_auto) { | |
7296 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7297 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7298 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7299 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7300 | } |
7301 | ||
69b07479 DS |
7302 | /* post-change: re-export vpn routes */ |
7303 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7304 | bgp_get_default(), bgp); | |
7305 | ||
ddb5b488 PZ |
7306 | return CMD_SUCCESS; |
7307 | } | |
7308 | ||
b9c7bc5a PZ |
7309 | ALIAS (af_label_vpn_export, |
7310 | af_no_label_vpn_export_cmd, | |
7311 | "no label vpn export", | |
7312 | NO_STR | |
7313 | "label value for VRF\n" | |
7314 | "Between current address-family and vpn\n" | |
7315 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7316 | |
b9c7bc5a PZ |
7317 | DEFPY (af_nexthop_vpn_export, |
7318 | af_nexthop_vpn_export_cmd, | |
7319 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
7320 | NO_STR | |
ddb5b488 | 7321 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7322 | "Between current address-family and vpn\n" |
7323 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7324 | "IPv4 prefix\n" |
7325 | "IPv6 prefix\n") | |
7326 | { | |
7327 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7328 | afi_t afi; |
ddb5b488 | 7329 | struct prefix p; |
b9c7bc5a PZ |
7330 | int idx = 0; |
7331 | int yes = 1; | |
ddb5b488 | 7332 | |
b9c7bc5a | 7333 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7334 | yes = 0; |
b9c7bc5a PZ |
7335 | |
7336 | if (yes) { | |
7337 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
7338 | return CMD_WARNING_CONFIG_FAILED; | |
7339 | } | |
ddb5b488 | 7340 | |
0ca70ba5 | 7341 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7342 | if (afi == AFI_MAX) |
7343 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7344 | |
69b07479 DS |
7345 | /* |
7346 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7347 | */ | |
7348 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7349 | bgp_get_default(), bgp); | |
ddb5b488 | 7350 | |
69b07479 DS |
7351 | if (yes) { |
7352 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
7353 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7354 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7355 | } else { | |
7356 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7357 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7358 | } |
7359 | ||
69b07479 DS |
7360 | /* post-change: re-export vpn routes */ |
7361 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7362 | bgp_get_default(), bgp); | |
7363 | ||
ddb5b488 PZ |
7364 | return CMD_SUCCESS; |
7365 | } | |
7366 | ||
b9c7bc5a PZ |
7367 | ALIAS (af_nexthop_vpn_export, |
7368 | af_no_nexthop_vpn_export_cmd, | |
7369 | "no nexthop vpn export", | |
ddb5b488 | 7370 | NO_STR |
b9c7bc5a PZ |
7371 | "Specify next hop to use for VRF advertised prefixes\n" |
7372 | "Between current address-family and vpn\n" | |
7373 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7374 | |
b9c7bc5a | 7375 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7376 | { |
b9c7bc5a PZ |
7377 | if (!strcmp(dstr, "import")) { |
7378 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7379 | } else if (!strcmp(dstr, "export")) { | |
7380 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7381 | } else if (!strcmp(dstr, "both")) { | |
7382 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7383 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7384 | } else { | |
7385 | vty_out(vty, "%% direction parse error\n"); | |
7386 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7387 | } |
ddb5b488 PZ |
7388 | return CMD_SUCCESS; |
7389 | } | |
7390 | ||
b9c7bc5a PZ |
7391 | DEFPY (af_rt_vpn_imexport, |
7392 | af_rt_vpn_imexport_cmd, | |
7393 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7394 | NO_STR | |
7395 | "Specify route target list\n" | |
ddb5b488 | 7396 | "Specify route target list\n" |
b9c7bc5a PZ |
7397 | "Between current address-family and vpn\n" |
7398 | "For routes leaked from vpn to current address-family: match any\n" | |
7399 | "For routes leaked from current address-family to vpn: set\n" | |
7400 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7401 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7402 | { | |
7403 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7404 | int ret; | |
7405 | struct ecommunity *ecom = NULL; | |
7406 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7407 | vpn_policy_direction_t dir; |
7408 | afi_t afi; | |
7409 | int idx = 0; | |
b9c7bc5a | 7410 | int yes = 1; |
ddb5b488 | 7411 | |
b9c7bc5a | 7412 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7413 | yes = 0; |
b9c7bc5a | 7414 | |
0ca70ba5 | 7415 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7416 | if (afi == AFI_MAX) |
7417 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7418 | |
b9c7bc5a | 7419 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7420 | if (ret != CMD_SUCCESS) |
7421 | return ret; | |
7422 | ||
b9c7bc5a PZ |
7423 | if (yes) { |
7424 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7425 | vty_out(vty, "%% Missing RTLIST\n"); | |
7426 | return CMD_WARNING_CONFIG_FAILED; | |
7427 | } | |
7428 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7429 | if (ret != CMD_SUCCESS) { | |
7430 | return ret; | |
7431 | } | |
ddb5b488 PZ |
7432 | } |
7433 | ||
69b07479 DS |
7434 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7435 | if (!dodir[dir]) | |
ddb5b488 | 7436 | continue; |
ddb5b488 | 7437 | |
69b07479 | 7438 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7439 | |
69b07479 DS |
7440 | if (yes) { |
7441 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7442 | ecommunity_free( | |
7443 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7444 | bgp->vpn_policy[afi].rtlist[dir] = | |
7445 | ecommunity_dup(ecom); | |
7446 | } else { | |
7447 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7448 | ecommunity_free( | |
7449 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7450 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7451 | } |
69b07479 DS |
7452 | |
7453 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7454 | } |
69b07479 | 7455 | |
d555f3e9 PZ |
7456 | if (ecom) |
7457 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7458 | |
7459 | return CMD_SUCCESS; | |
7460 | } | |
7461 | ||
b9c7bc5a PZ |
7462 | ALIAS (af_rt_vpn_imexport, |
7463 | af_no_rt_vpn_imexport_cmd, | |
7464 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7465 | NO_STR |
7466 | "Specify route target list\n" | |
b9c7bc5a PZ |
7467 | "Specify route target list\n" |
7468 | "Between current address-family and vpn\n" | |
7469 | "For routes leaked from vpn to current address-family\n" | |
7470 | "For routes leaked from current address-family to vpn\n" | |
7471 | "both import and export\n") | |
7472 | ||
7473 | DEFPY (af_route_map_vpn_imexport, | |
7474 | af_route_map_vpn_imexport_cmd, | |
7475 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7476 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7477 | NO_STR | |
ddb5b488 | 7478 | "Specify route map\n" |
b9c7bc5a PZ |
7479 | "Between current address-family and vpn\n" |
7480 | "For routes leaked from vpn to current address-family\n" | |
7481 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7482 | "name of route-map\n") |
7483 | { | |
7484 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7485 | int ret; | |
7486 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7487 | vpn_policy_direction_t dir; |
7488 | afi_t afi; | |
ddb5b488 | 7489 | int idx = 0; |
b9c7bc5a | 7490 | int yes = 1; |
ddb5b488 | 7491 | |
b9c7bc5a | 7492 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7493 | yes = 0; |
b9c7bc5a | 7494 | |
0ca70ba5 | 7495 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7496 | if (afi == AFI_MAX) |
7497 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7498 | |
b9c7bc5a | 7499 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7500 | if (ret != CMD_SUCCESS) |
7501 | return ret; | |
7502 | ||
69b07479 DS |
7503 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7504 | if (!dodir[dir]) | |
ddb5b488 | 7505 | continue; |
ddb5b488 | 7506 | |
69b07479 | 7507 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7508 | |
69b07479 DS |
7509 | if (yes) { |
7510 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7511 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7512 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7513 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7514 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7515 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7516 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7517 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7518 | return CMD_SUCCESS; | |
7519 | } else { | |
7520 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7521 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7522 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7523 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7524 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7525 | } |
69b07479 DS |
7526 | |
7527 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7528 | } |
7529 | ||
7530 | return CMD_SUCCESS; | |
7531 | } | |
7532 | ||
b9c7bc5a PZ |
7533 | ALIAS (af_route_map_vpn_imexport, |
7534 | af_no_route_map_vpn_imexport_cmd, | |
7535 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7536 | NO_STR |
7537 | "Specify route map\n" | |
b9c7bc5a PZ |
7538 | "Between current address-family and vpn\n" |
7539 | "For routes leaked from vpn to current address-family\n" | |
7540 | "For routes leaked from current address-family to vpn\n") | |
7541 | ||
bb4f6190 DS |
7542 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
7543 | "[no] import vrf route-map RMAP$rmap_str", | |
7544 | NO_STR | |
7545 | "Import routes from another VRF\n" | |
7546 | "Vrf routes being filtered\n" | |
7547 | "Specify route map\n" | |
7548 | "name of route-map\n") | |
7549 | { | |
7550 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7551 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7552 | afi_t afi; | |
7553 | int idx = 0; | |
7554 | int yes = 1; | |
7555 | struct bgp *bgp_default; | |
7556 | ||
7557 | if (argv_find(argv, argc, "no", &idx)) | |
7558 | yes = 0; | |
7559 | ||
0ca70ba5 | 7560 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7561 | if (afi == AFI_MAX) |
7562 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7563 | |
7564 | bgp_default = bgp_get_default(); | |
7565 | if (!bgp_default) { | |
7566 | int32_t ret; | |
7567 | as_t as = bgp->as; | |
7568 | ||
7569 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7570 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7571 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7572 | |
7573 | if (ret) { | |
7574 | vty_out(vty, | |
7575 | "VRF default is not configured as a bgp instance\n"); | |
7576 | return CMD_WARNING; | |
7577 | } | |
7578 | } | |
7579 | ||
69b07479 | 7580 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7581 | |
69b07479 DS |
7582 | if (yes) { |
7583 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7584 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7585 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7586 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7587 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7588 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7589 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7590 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7591 | return CMD_SUCCESS; | |
7592 | } else { | |
7593 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7594 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7595 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7596 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7597 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
7598 | } |
7599 | ||
69b07479 DS |
7600 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7601 | ||
bb4f6190 DS |
7602 | return CMD_SUCCESS; |
7603 | } | |
7604 | ||
7605 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
7606 | "no import vrf route-map", | |
7607 | NO_STR | |
7608 | "Import routes from another VRF\n" | |
7609 | "Vrf routes being filtered\n" | |
7610 | "Specify route map\n") | |
7611 | ||
4d1b335c DA |
7612 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7613 | "[no] import vrf VIEWVRFNAME$import_name", | |
7614 | NO_STR | |
7615 | "Import routes from another VRF\n" | |
7616 | "VRF to import from\n" | |
7617 | "The name of the VRF\n") | |
12a844a5 DS |
7618 | { |
7619 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7620 | struct listnode *node; | |
79ef8664 DS |
7621 | struct bgp *vrf_bgp, *bgp_default; |
7622 | int32_t ret = 0; | |
7623 | as_t as = bgp->as; | |
12a844a5 DS |
7624 | bool remove = false; |
7625 | int32_t idx = 0; | |
7626 | char *vname; | |
a8dadcf6 | 7627 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7628 | safi_t safi; |
7629 | afi_t afi; | |
7630 | ||
867f0cca | 7631 | if (import_name == NULL) { |
7632 | vty_out(vty, "%% Missing import name\n"); | |
7633 | return CMD_WARNING; | |
7634 | } | |
7635 | ||
12a844a5 DS |
7636 | if (argv_find(argv, argc, "no", &idx)) |
7637 | remove = true; | |
7638 | ||
0ca70ba5 DS |
7639 | afi = vpn_policy_getafi(vty, bgp, true); |
7640 | if (afi == AFI_MAX) | |
7641 | return CMD_WARNING_CONFIG_FAILED; | |
7642 | ||
12a844a5 DS |
7643 | safi = bgp_node_safi(vty); |
7644 | ||
25679caa | 7645 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7646 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7647 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7648 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7649 | remove ? "unimport" : "import", import_name); | |
7650 | return CMD_WARNING; | |
7651 | } | |
7652 | ||
79ef8664 DS |
7653 | bgp_default = bgp_get_default(); |
7654 | if (!bgp_default) { | |
7655 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7656 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7657 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7658 | |
7659 | if (ret) { | |
7660 | vty_out(vty, | |
7661 | "VRF default is not configured as a bgp instance\n"); | |
7662 | return CMD_WARNING; | |
7663 | } | |
7664 | } | |
7665 | ||
12a844a5 DS |
7666 | vrf_bgp = bgp_lookup_by_name(import_name); |
7667 | if (!vrf_bgp) { | |
5742e42b | 7668 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7669 | vrf_bgp = bgp_default; |
7670 | else | |
0fb8d6e6 | 7671 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7672 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7673 | |
6e2c7fe6 | 7674 | if (ret) { |
020a3f60 DS |
7675 | vty_out(vty, |
7676 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7677 | import_name); |
7678 | return CMD_WARNING; | |
7679 | } | |
12a844a5 DS |
7680 | } |
7681 | ||
12a844a5 | 7682 | if (remove) { |
44338987 | 7683 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7684 | } else { |
44338987 | 7685 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7686 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7687 | vname)) { | |
7688 | if (strcmp(vname, import_name) == 0) | |
7689 | return CMD_WARNING; | |
7690 | } | |
7691 | ||
44338987 | 7692 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7693 | } |
7694 | ||
7695 | return CMD_SUCCESS; | |
7696 | } | |
7697 | ||
b9c7bc5a PZ |
7698 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7699 | DEFPY (bgp_imexport_vpn, | |
7700 | bgp_imexport_vpn_cmd, | |
7701 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7702 | NO_STR |
7703 | "Import routes to this address-family\n" | |
7704 | "Export routes from this address-family\n" | |
7705 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7706 | { |
7707 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7708 | int previous_state; |
ddb5b488 | 7709 | afi_t afi; |
b9c7bc5a | 7710 | safi_t safi; |
ddb5b488 | 7711 | int idx = 0; |
b9c7bc5a PZ |
7712 | int yes = 1; |
7713 | int flag; | |
7714 | vpn_policy_direction_t dir; | |
ddb5b488 | 7715 | |
b9c7bc5a | 7716 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7717 | yes = 0; |
ddb5b488 | 7718 | |
b9c7bc5a PZ |
7719 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7720 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7721 | |
b9c7bc5a PZ |
7722 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7723 | return CMD_WARNING_CONFIG_FAILED; | |
7724 | } | |
ddb5b488 | 7725 | |
b9c7bc5a PZ |
7726 | afi = bgp_node_afi(vty); |
7727 | safi = bgp_node_safi(vty); | |
7728 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7729 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7730 | return CMD_WARNING_CONFIG_FAILED; | |
7731 | } | |
ddb5b488 | 7732 | |
b9c7bc5a PZ |
7733 | if (!strcmp(direction_str, "import")) { |
7734 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7735 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7736 | } else if (!strcmp(direction_str, "export")) { | |
7737 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7738 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7739 | } else { | |
7740 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7741 | return CMD_WARNING_CONFIG_FAILED; | |
7742 | } | |
7743 | ||
7744 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7745 | |
b9c7bc5a PZ |
7746 | if (yes) { |
7747 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7748 | if (!previous_state) { | |
7749 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7750 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7751 | } | |
b9c7bc5a PZ |
7752 | } else { |
7753 | if (previous_state) { | |
7754 | /* trigger un-export current vrf */ | |
7755 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7756 | } | |
7757 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7758 | } |
7759 | ||
7760 | return CMD_SUCCESS; | |
7761 | } | |
7762 | ||
301ad80a PG |
7763 | DEFPY (af_routetarget_import, |
7764 | af_routetarget_import_cmd, | |
7765 | "[no] <rt|route-target> redirect import RTLIST...", | |
7766 | NO_STR | |
7767 | "Specify route target list\n" | |
7768 | "Specify route target list\n" | |
7769 | "Flow-spec redirect type route target\n" | |
7770 | "Import routes to this address-family\n" | |
7771 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7772 | { | |
7773 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7774 | int ret; | |
7775 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7776 | afi_t afi; |
7777 | int idx = 0; | |
7778 | int yes = 1; | |
7779 | ||
7780 | if (argv_find(argv, argc, "no", &idx)) | |
7781 | yes = 0; | |
7782 | ||
0ca70ba5 | 7783 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7784 | if (afi == AFI_MAX) |
7785 | return CMD_WARNING_CONFIG_FAILED; | |
7786 | ||
301ad80a PG |
7787 | if (yes) { |
7788 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7789 | vty_out(vty, "%% Missing RTLIST\n"); | |
7790 | return CMD_WARNING_CONFIG_FAILED; | |
7791 | } | |
7792 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7793 | if (ret != CMD_SUCCESS) | |
7794 | return ret; | |
7795 | } | |
69b07479 DS |
7796 | |
7797 | if (yes) { | |
7798 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7799 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7800 | .import_redirect_rtlist); |
69b07479 DS |
7801 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7802 | ecommunity_dup(ecom); | |
7803 | } else { | |
7804 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7805 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7806 | .import_redirect_rtlist); |
69b07479 | 7807 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7808 | } |
69b07479 | 7809 | |
301ad80a PG |
7810 | if (ecom) |
7811 | ecommunity_free(&ecom); | |
7812 | ||
7813 | return CMD_SUCCESS; | |
7814 | } | |
7815 | ||
505e5056 | 7816 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7817 | address_family_ipv4_safi_cmd, |
7818 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7819 | "Enter Address Family command mode\n" | |
7820 | "Address Family\n" | |
7821 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7822 | { |
f51bae9c | 7823 | |
d62a17ae | 7824 | if (argc == 3) { |
2131d5cf | 7825 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7826 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7827 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7828 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7829 | && safi != SAFI_EVPN) { |
31947174 MK |
7830 | vty_out(vty, |
7831 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7832 | return CMD_WARNING_CONFIG_FAILED; |
7833 | } | |
d62a17ae | 7834 | vty->node = bgp_node_type(AFI_IP, safi); |
7835 | } else | |
7836 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7837 | |
d62a17ae | 7838 | return CMD_SUCCESS; |
718e3744 | 7839 | } |
7840 | ||
505e5056 | 7841 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7842 | address_family_ipv6_safi_cmd, |
7843 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7844 | "Enter Address Family command mode\n" | |
7845 | "Address Family\n" | |
7846 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7847 | { |
d62a17ae | 7848 | if (argc == 3) { |
2131d5cf | 7849 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7850 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7851 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7852 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7853 | && safi != SAFI_EVPN) { |
31947174 MK |
7854 | vty_out(vty, |
7855 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7856 | return CMD_WARNING_CONFIG_FAILED; |
7857 | } | |
d62a17ae | 7858 | vty->node = bgp_node_type(AFI_IP6, safi); |
7859 | } else | |
7860 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7861 | |
d62a17ae | 7862 | return CMD_SUCCESS; |
25ffbdc1 | 7863 | } |
718e3744 | 7864 | |
d6902373 | 7865 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7866 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7867 | address_family_vpnv4_cmd, |
8334fd5a | 7868 | "address-family vpnv4 [unicast]", |
718e3744 | 7869 | "Enter Address Family command mode\n" |
8c3deaae | 7870 | "Address Family\n" |
3a2d747c | 7871 | "Address Family modifier\n") |
718e3744 | 7872 | { |
d62a17ae | 7873 | vty->node = BGP_VPNV4_NODE; |
7874 | return CMD_SUCCESS; | |
718e3744 | 7875 | } |
7876 | ||
505e5056 | 7877 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7878 | address_family_vpnv6_cmd, |
8334fd5a | 7879 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7880 | "Enter Address Family command mode\n" |
8c3deaae | 7881 | "Address Family\n" |
3a2d747c | 7882 | "Address Family modifier\n") |
8ecd3266 | 7883 | { |
d62a17ae | 7884 | vty->node = BGP_VPNV6_NODE; |
7885 | return CMD_SUCCESS; | |
8ecd3266 | 7886 | } |
64e4a6c5 | 7887 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7888 | |
505e5056 | 7889 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7890 | address_family_evpn_cmd, |
7111c1a0 | 7891 | "address-family l2vpn evpn", |
4e0b7b6d | 7892 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7893 | "Address Family\n" |
7894 | "Address Family modifier\n") | |
4e0b7b6d | 7895 | { |
2131d5cf | 7896 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7897 | vty->node = BGP_EVPN_NODE; |
7898 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7899 | } |
7900 | ||
505e5056 | 7901 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7902 | exit_address_family_cmd, |
7903 | "exit-address-family", | |
7904 | "Exit from Address Family configuration mode\n") | |
7905 | { | |
d62a17ae | 7906 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7907 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7908 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7909 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7910 | || vty->node == BGP_EVPN_NODE |
7911 | || vty->node == BGP_FLOWSPECV4_NODE | |
7912 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7913 | vty->node = BGP_NODE; |
7914 | return CMD_SUCCESS; | |
718e3744 | 7915 | } |
6b0655a2 | 7916 | |
8ad7271d | 7917 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7918 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7919 | const char *ip_str, afi_t afi, safi_t safi, | |
7920 | struct prefix_rd *prd) | |
7921 | { | |
7922 | int ret; | |
7923 | struct prefix match; | |
7924 | struct bgp_node *rn; | |
7925 | struct bgp_node *rm; | |
7926 | struct bgp *bgp; | |
7927 | struct bgp_table *table; | |
7928 | struct bgp_table *rib; | |
7929 | ||
7930 | /* BGP structure lookup. */ | |
7931 | if (view_name) { | |
7932 | bgp = bgp_lookup_by_name(view_name); | |
7933 | if (bgp == NULL) { | |
7934 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7935 | view_name); | |
7936 | return CMD_WARNING; | |
7937 | } | |
7938 | } else { | |
7939 | bgp = bgp_get_default(); | |
7940 | if (bgp == NULL) { | |
7941 | vty_out(vty, "%% No BGP process is configured\n"); | |
7942 | return CMD_WARNING; | |
7943 | } | |
7944 | } | |
7945 | ||
7946 | /* Check IP address argument. */ | |
7947 | ret = str2prefix(ip_str, &match); | |
7948 | if (!ret) { | |
7949 | vty_out(vty, "%% address is malformed\n"); | |
7950 | return CMD_WARNING; | |
7951 | } | |
7952 | ||
7953 | match.family = afi2family(afi); | |
7954 | rib = bgp->rib[afi][safi]; | |
7955 | ||
7956 | if (safi == SAFI_MPLS_VPN) { | |
7957 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7958 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7959 | continue; | |
7960 | ||
67009e22 DS |
7961 | table = bgp_node_get_bgp_table_info(rn); |
7962 | if (table != NULL) { | |
7963 | ||
d62a17ae | 7964 | if ((rm = bgp_node_match(table, &match)) |
7965 | != NULL) { | |
7966 | if (rm->p.prefixlen | |
7967 | == match.prefixlen) { | |
343cdb61 | 7968 | SET_FLAG(rm->flags, |
d62a17ae | 7969 | BGP_NODE_USER_CLEAR); |
7970 | bgp_process(bgp, rm, afi, safi); | |
7971 | } | |
7972 | bgp_unlock_node(rm); | |
7973 | } | |
7974 | } | |
7975 | } | |
7976 | } else { | |
7977 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7978 | if (rn->p.prefixlen == match.prefixlen) { | |
7979 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7980 | bgp_process(bgp, rn, afi, safi); | |
7981 | } | |
7982 | bgp_unlock_node(rn); | |
7983 | } | |
7984 | } | |
7985 | ||
7986 | return CMD_SUCCESS; | |
8ad7271d DS |
7987 | } |
7988 | ||
b09b5ae0 | 7989 | /* one clear bgp command to rule them all */ |
718e3744 | 7990 | DEFUN (clear_ip_bgp_all, |
7991 | clear_ip_bgp_all_cmd, | |
453c92f6 | 7992 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 7993 | CLEAR_STR |
7994 | IP_STR | |
7995 | BGP_STR | |
838758ac | 7996 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7997 | BGP_AFI_HELP_STR |
fd5e7b70 | 7998 | "Address Family\n" |
510afcd6 | 7999 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8000 | "Address Family modifier\n" |
b09b5ae0 | 8001 | "Clear all peers\n" |
453c92f6 | 8002 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8003 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8004 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8005 | "Clear peers with the AS number\n" |
8006 | "Clear all external peers\n" | |
718e3744 | 8007 | "Clear all members of peer-group\n" |
b09b5ae0 | 8008 | "BGP peer-group name\n" |
b09b5ae0 DW |
8009 | BGP_SOFT_STR |
8010 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8011 | BGP_SOFT_OUT_STR |
8012 | BGP_SOFT_IN_STR | |
8013 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8014 | BGP_SOFT_OUT_STR) |
718e3744 | 8015 | { |
d62a17ae | 8016 | char *vrf = NULL; |
8017 | ||
dc912615 DS |
8018 | afi_t afi = AFI_UNSPEC; |
8019 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8020 | enum clear_sort clr_sort = clear_peer; |
8021 | enum bgp_clear_type clr_type; | |
8022 | char *clr_arg = NULL; | |
8023 | ||
8024 | int idx = 0; | |
8025 | ||
8026 | /* clear [ip] bgp */ | |
8027 | if (argv_find(argv, argc, "ip", &idx)) | |
8028 | afi = AFI_IP; | |
8029 | ||
9a8bdf1c PG |
8030 | /* [<vrf> VIEWVRFNAME] */ |
8031 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8032 | vrf = argv[idx + 1]->arg; | |
8033 | idx += 2; | |
8034 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8035 | vrf = NULL; | |
8036 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8037 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8038 | vrf = argv[idx + 1]->arg; |
8039 | idx += 2; | |
8040 | } | |
d62a17ae | 8041 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8042 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8043 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8044 | ||
d7b9898c | 8045 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8046 | if (argv_find(argv, argc, "*", &idx)) { |
8047 | clr_sort = clear_all; | |
8048 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8049 | clr_sort = clear_peer; | |
8050 | clr_arg = argv[idx]->arg; | |
8051 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8052 | clr_sort = clear_peer; | |
8053 | clr_arg = argv[idx]->arg; | |
8054 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8055 | clr_sort = clear_group; | |
8056 | idx++; | |
8057 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8058 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8059 | clr_sort = clear_peer; |
8060 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8061 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8062 | clr_sort = clear_peer; | |
8063 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8064 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8065 | clr_sort = clear_as; | |
8066 | clr_arg = argv[idx]->arg; | |
8067 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8068 | clr_sort = clear_external; | |
8069 | } | |
8070 | ||
8071 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8072 | if (argv_find(argv, argc, "soft", &idx)) { | |
8073 | if (argv_find(argv, argc, "in", &idx) | |
8074 | || argv_find(argv, argc, "out", &idx)) | |
8075 | clr_type = strmatch(argv[idx]->text, "in") | |
8076 | ? BGP_CLEAR_SOFT_IN | |
8077 | : BGP_CLEAR_SOFT_OUT; | |
8078 | else | |
8079 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8080 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8081 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8082 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8083 | : BGP_CLEAR_SOFT_IN; | |
8084 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8085 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8086 | } else | |
8087 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8088 | ||
8089 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8090 | } |
01080f7c | 8091 | |
8ad7271d DS |
8092 | DEFUN (clear_ip_bgp_prefix, |
8093 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8094 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8095 | CLEAR_STR |
8096 | IP_STR | |
8097 | BGP_STR | |
838758ac | 8098 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8099 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8100 | "IPv4 prefix\n") |
8ad7271d | 8101 | { |
d62a17ae | 8102 | char *vrf = NULL; |
8103 | char *prefix = NULL; | |
8ad7271d | 8104 | |
d62a17ae | 8105 | int idx = 0; |
01080f7c | 8106 | |
d62a17ae | 8107 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8108 | if (argv_find(argv, argc, "vrf", &idx)) { |
8109 | vrf = argv[idx + 1]->arg; | |
8110 | idx += 2; | |
8111 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8112 | vrf = NULL; | |
8113 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8114 | /* [<view> VIEWVRFNAME] */ | |
8115 | vrf = argv[idx + 1]->arg; | |
8116 | idx += 2; | |
8117 | } | |
0c7b1b01 | 8118 | |
d62a17ae | 8119 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8120 | |
d62a17ae | 8121 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8122 | } |
8ad7271d | 8123 | |
b09b5ae0 DW |
8124 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8125 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8126 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8127 | CLEAR_STR |
3a2d747c | 8128 | IP_STR |
718e3744 | 8129 | BGP_STR |
8c3deaae | 8130 | "Address Family\n" |
46f296b4 | 8131 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8132 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8133 | "IPv6 prefix\n") |
718e3744 | 8134 | { |
9b475e76 PG |
8135 | int idx_safi = 0; |
8136 | int idx_ipv6_prefix = 0; | |
8137 | safi_t safi = SAFI_UNICAST; | |
8138 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8139 | argv[idx_ipv6_prefix]->arg : NULL; | |
8140 | ||
8141 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8142 | return bgp_clear_prefix( |
9b475e76 PG |
8143 | vty, NULL, prefix, AFI_IP6, |
8144 | safi, NULL); | |
838758ac | 8145 | } |
01080f7c | 8146 | |
b09b5ae0 DW |
8147 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8148 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8149 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8150 | CLEAR_STR |
3a2d747c | 8151 | IP_STR |
718e3744 | 8152 | BGP_STR |
838758ac | 8153 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8154 | "Address Family\n" |
46f296b4 | 8155 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8156 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8157 | "IPv6 prefix\n") |
718e3744 | 8158 | { |
9b475e76 | 8159 | int idx_safi = 0; |
9a8bdf1c | 8160 | int idx_vrfview = 0; |
9b475e76 PG |
8161 | int idx_ipv6_prefix = 0; |
8162 | safi_t safi = SAFI_UNICAST; | |
8163 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8164 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8165 | char *vrfview = NULL; |
9b475e76 | 8166 | |
9a8bdf1c PG |
8167 | /* [<view|vrf> VIEWVRFNAME] */ |
8168 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8169 | vrfview = argv[idx_vrfview + 1]->arg; | |
8170 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8171 | vrfview = NULL; | |
8172 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8173 | /* [<view> VIEWVRFNAME] */ | |
8174 | vrfview = argv[idx_vrfview + 1]->arg; | |
8175 | } | |
9b475e76 PG |
8176 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8177 | ||
d62a17ae | 8178 | return bgp_clear_prefix( |
9b475e76 PG |
8179 | vty, vrfview, prefix, |
8180 | AFI_IP6, safi, NULL); | |
718e3744 | 8181 | } |
8182 | ||
b09b5ae0 DW |
8183 | DEFUN (show_bgp_views, |
8184 | show_bgp_views_cmd, | |
d6e3c605 | 8185 | "show [ip] bgp views", |
b09b5ae0 | 8186 | SHOW_STR |
d6e3c605 | 8187 | IP_STR |
01080f7c | 8188 | BGP_STR |
b09b5ae0 | 8189 | "Show the defined BGP views\n") |
01080f7c | 8190 | { |
d62a17ae | 8191 | struct list *inst = bm->bgp; |
8192 | struct listnode *node; | |
8193 | struct bgp *bgp; | |
01080f7c | 8194 | |
d62a17ae | 8195 | vty_out(vty, "Defined BGP views:\n"); |
8196 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8197 | /* Skip VRFs. */ | |
8198 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8199 | continue; | |
8200 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8201 | bgp->as); | |
8202 | } | |
e52702f2 | 8203 | |
d62a17ae | 8204 | return CMD_SUCCESS; |
e0081f70 ML |
8205 | } |
8206 | ||
8386ac43 | 8207 | DEFUN (show_bgp_vrfs, |
8208 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8209 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8210 | SHOW_STR |
d6e3c605 | 8211 | IP_STR |
8386ac43 | 8212 | BGP_STR |
8213 | "Show BGP VRFs\n" | |
9973d184 | 8214 | JSON_STR) |
8386ac43 | 8215 | { |
fe1dc5a3 | 8216 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8217 | struct list *inst = bm->bgp; |
8218 | struct listnode *node; | |
8219 | struct bgp *bgp; | |
9f049418 | 8220 | bool uj = use_json(argc, argv); |
d62a17ae | 8221 | json_object *json = NULL; |
8222 | json_object *json_vrfs = NULL; | |
8223 | int count = 0; | |
d62a17ae | 8224 | |
d62a17ae | 8225 | if (uj) { |
8226 | json = json_object_new_object(); | |
8227 | json_vrfs = json_object_new_object(); | |
8228 | } | |
8229 | ||
8230 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8231 | const char *name, *type; | |
8232 | struct peer *peer; | |
7fe96307 | 8233 | struct listnode *node2, *nnode2; |
d62a17ae | 8234 | int peers_cfg, peers_estb; |
8235 | json_object *json_vrf = NULL; | |
d62a17ae | 8236 | |
8237 | /* Skip Views. */ | |
8238 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8239 | continue; | |
8240 | ||
8241 | count++; | |
efb4077a | 8242 | if (!uj && count == 1) { |
fe1dc5a3 | 8243 | vty_out(vty, |
efb4077a | 8244 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8245 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8246 | "#PeersEstb", "Name"); |
8247 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8248 | "L3-VNI", "RouterMAC", "Interface"); | |
8249 | } | |
d62a17ae | 8250 | |
8251 | peers_cfg = peers_estb = 0; | |
8252 | if (uj) | |
8253 | json_vrf = json_object_new_object(); | |
8254 | ||
8255 | ||
7fe96307 | 8256 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8257 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8258 | continue; | |
8259 | peers_cfg++; | |
8260 | if (peer->status == Established) | |
8261 | peers_estb++; | |
8262 | } | |
8263 | ||
8264 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8265 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8266 | type = "DFLT"; |
8267 | } else { | |
8268 | name = bgp->name; | |
8269 | type = "VRF"; | |
8270 | } | |
8271 | ||
a8bf7d9c | 8272 | |
d62a17ae | 8273 | if (uj) { |
a4d82a8a PZ |
8274 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8275 | ? -1 | |
8276 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8277 | json_object_string_add(json_vrf, "type", type); |
8278 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8279 | json_object_string_add(json_vrf, "routerId", | |
8280 | inet_ntoa(bgp->router_id)); | |
8281 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8282 | peers_cfg); | |
8283 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8284 | peers_estb); | |
8285 | ||
fe1dc5a3 | 8286 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8287 | json_object_string_add( |
8288 | json_vrf, "rmac", | |
8289 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8290 | json_object_string_add(json_vrf, "interface", |
8291 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8292 | bgp->vrf_id)); | |
d62a17ae | 8293 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8294 | } else { |
fe1dc5a3 | 8295 | vty_out(vty, |
efb4077a | 8296 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8297 | type, |
8298 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8299 | : (int)bgp->vrf_id, | |
8300 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8301 | peers_estb, name); |
8302 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8303 | bgp->l3vni, | |
8304 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8305 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8306 | bgp->vrf_id)); | |
8307 | } | |
d62a17ae | 8308 | } |
8309 | ||
8310 | if (uj) { | |
8311 | json_object_object_add(json, "vrfs", json_vrfs); | |
8312 | ||
8313 | json_object_int_add(json, "totalVrfs", count); | |
8314 | ||
996c9314 LB |
8315 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8316 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8317 | json_object_free(json); |
8318 | } else { | |
8319 | if (count) | |
8320 | vty_out(vty, | |
8321 | "\nTotal number of VRFs (including default): %d\n", | |
8322 | count); | |
8323 | } | |
8324 | ||
8325 | return CMD_SUCCESS; | |
8386ac43 | 8326 | } |
8327 | ||
48ecf8f5 DS |
8328 | DEFUN (show_bgp_mac_hash, |
8329 | show_bgp_mac_hash_cmd, | |
8330 | "show bgp mac hash", | |
8331 | SHOW_STR | |
8332 | BGP_STR | |
8333 | "Mac Address\n" | |
8334 | "Mac Address database\n") | |
8335 | { | |
8336 | bgp_mac_dump_table(vty); | |
8337 | ||
8338 | return CMD_SUCCESS; | |
8339 | } | |
acf71666 | 8340 | |
e3b78da8 | 8341 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8342 | { |
0291c246 | 8343 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8344 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8345 | |
60466a63 | 8346 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8347 | tip->refcnt); |
8348 | } | |
8349 | ||
8350 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8351 | { | |
8352 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8353 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8354 | |
8355 | vty_out(vty, "Tunnel-ip database:\n"); | |
8356 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8357 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8358 | vty); |
8359 | } | |
8360 | ||
15c81ca4 DS |
8361 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8362 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8363 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8364 | "martian next-hops\n" |
8365 | "martian next-hop database\n") | |
acf71666 | 8366 | { |
0291c246 | 8367 | struct bgp *bgp = NULL; |
15c81ca4 | 8368 | int idx = 0; |
9a8bdf1c PG |
8369 | char *name = NULL; |
8370 | ||
8371 | /* [<vrf> VIEWVRFNAME] */ | |
8372 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8373 | name = argv[idx + 1]->arg; | |
8374 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8375 | name = NULL; | |
8376 | } else if (argv_find(argv, argc, "view", &idx)) | |
8377 | /* [<view> VIEWVRFNAME] */ | |
8378 | name = argv[idx + 1]->arg; | |
8379 | if (name) | |
8380 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8381 | else |
8382 | bgp = bgp_get_default(); | |
acf71666 | 8383 | |
acf71666 MK |
8384 | if (!bgp) { |
8385 | vty_out(vty, "%% No BGP process is configured\n"); | |
8386 | return CMD_WARNING; | |
8387 | } | |
8388 | bgp_show_martian_nexthops(vty, bgp); | |
8389 | ||
8390 | return CMD_SUCCESS; | |
8391 | } | |
8392 | ||
f412b39a | 8393 | DEFUN (show_bgp_memory, |
4bf6a362 | 8394 | show_bgp_memory_cmd, |
7fa12b13 | 8395 | "show [ip] bgp memory", |
4bf6a362 | 8396 | SHOW_STR |
3a2d747c | 8397 | IP_STR |
4bf6a362 PJ |
8398 | BGP_STR |
8399 | "Global BGP memory statistics\n") | |
8400 | { | |
d62a17ae | 8401 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8402 | unsigned long count; | |
8403 | ||
8404 | /* RIB related usage stats */ | |
8405 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8406 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8407 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8408 | count * sizeof(struct bgp_node))); | |
8409 | ||
8410 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8411 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8412 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8413 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8414 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8415 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8416 | count, | |
4b7e6066 DS |
8417 | mtype_memstr( |
8418 | memstrbuf, sizeof(memstrbuf), | |
8419 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8420 | |
8421 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8422 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8423 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8424 | count * sizeof(struct bgp_static))); | |
8425 | ||
8426 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8427 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8428 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8429 | count * sizeof(struct bpacket))); | |
8430 | ||
8431 | /* Adj-In/Out */ | |
8432 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8433 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8434 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8435 | count * sizeof(struct bgp_adj_in))); | |
8436 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8437 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8438 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8439 | count * sizeof(struct bgp_adj_out))); | |
8440 | ||
8441 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8442 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8443 | count, | |
8444 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8445 | count * sizeof(struct bgp_nexthop_cache))); | |
8446 | ||
8447 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8448 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8449 | count, | |
8450 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8451 | count * sizeof(struct bgp_damp_info))); | |
8452 | ||
8453 | /* Attributes */ | |
8454 | count = attr_count(); | |
8455 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8456 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8457 | count * sizeof(struct attr))); | |
8458 | ||
8459 | if ((count = attr_unknown_count())) | |
8460 | vty_out(vty, "%ld unknown attributes\n", count); | |
8461 | ||
8462 | /* AS_PATH attributes */ | |
8463 | count = aspath_count(); | |
8464 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8465 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8466 | count * sizeof(struct aspath))); | |
8467 | ||
8468 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8469 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8470 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8471 | count * sizeof(struct assegment))); | |
8472 | ||
8473 | /* Other attributes */ | |
8474 | if ((count = community_count())) | |
8475 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8476 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8477 | count * sizeof(struct community))); | |
d62a17ae | 8478 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8479 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8480 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8481 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8482 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8483 | vty_out(vty, | |
8484 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8485 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8486 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8487 | |
8488 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8489 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8490 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8491 | count * sizeof(struct cluster_list))); | |
8492 | ||
8493 | /* Peer related usage */ | |
8494 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8495 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8496 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8497 | count * sizeof(struct peer))); | |
8498 | ||
8499 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8500 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8501 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8502 | count * sizeof(struct peer_group))); | |
8503 | ||
8504 | /* Other */ | |
d62a17ae | 8505 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8506 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8507 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8508 | count * sizeof(regex_t))); | |
d62a17ae | 8509 | return CMD_SUCCESS; |
4bf6a362 | 8510 | } |
fee0f4c6 | 8511 | |
57a9c8a8 DS |
8512 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8513 | { | |
8514 | json_object *bestpath = json_object_new_object(); | |
8515 | ||
8516 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
8517 | json_object_string_add(bestpath, "asPath", "ignore"); | |
8518 | ||
8519 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
8520 | json_object_string_add(bestpath, "asPath", "confed"); | |
8521 | ||
8522 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
8523 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
8524 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
8525 | "as-set"); |
8526 | else | |
a4d82a8a | 8527 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8528 | "true"); |
8529 | } else | |
a4d82a8a | 8530 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
8531 | |
8532 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
8533 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
8534 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
8535 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8536 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8537 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
8538 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
8539 | json_object_string_add(bestpath, "med", | |
8540 | "missing-as-worst"); | |
8541 | else | |
8542 | json_object_string_add(bestpath, "med", "true"); | |
8543 | } | |
8544 | ||
8545 | json_object_object_add(json, "bestPath", bestpath); | |
8546 | } | |
8547 | ||
3577f1c5 DD |
8548 | /* Print the error code/subcode for why the peer is down */ |
8549 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8550 | json_object *json_peer, bool use_json) | |
8551 | { | |
8552 | const char *code_str; | |
8553 | const char *subcode_str; | |
8554 | ||
8555 | if (use_json) { | |
8556 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8557 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8558 | char errorcodesubcode_hexstr[5]; | |
8559 | char errorcodesubcode_str[256]; | |
8560 | ||
8561 | code_str = bgp_notify_code_str(peer->notify.code); | |
8562 | subcode_str = bgp_notify_subcode_str( | |
8563 | peer->notify.code, | |
8564 | peer->notify.subcode); | |
8565 | ||
8566 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
8567 | peer->notify.code, peer->notify.subcode); | |
8568 | json_object_string_add(json_peer, | |
8569 | "lastErrorCodeSubcode", | |
8570 | errorcodesubcode_hexstr); | |
8571 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8572 | code_str, subcode_str); | |
8573 | json_object_string_add(json_peer, | |
8574 | "lastNotificationReason", | |
8575 | errorcodesubcode_str); | |
8576 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8577 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8578 | && (peer->notify.subcode | |
8579 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8580 | || peer->notify.subcode | |
8581 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8582 | && peer->notify.length) { | |
8583 | char msgbuf[1024]; | |
8584 | const char *msg_str; | |
8585 | ||
8586 | msg_str = bgp_notify_admin_message( | |
8587 | msgbuf, sizeof(msgbuf), | |
8588 | (uint8_t *)peer->notify.data, | |
8589 | peer->notify.length); | |
8590 | if (msg_str) | |
8591 | json_object_string_add( | |
8592 | json_peer, | |
8593 | "lastShutdownDescription", | |
8594 | msg_str); | |
8595 | } | |
8596 | ||
c258527b | 8597 | } |
3577f1c5 DD |
8598 | json_object_string_add(json_peer, "lastResetDueTo", |
8599 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8600 | json_object_int_add(json_peer, "lastResetCode", |
8601 | peer->last_reset); | |
3577f1c5 DD |
8602 | } else { |
8603 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8604 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8605 | code_str = bgp_notify_code_str(peer->notify.code); | |
8606 | subcode_str = | |
8607 | bgp_notify_subcode_str(peer->notify.code, | |
8608 | peer->notify.subcode); | |
8609 | vty_out(vty, " Notification %s (%s%s)\n", | |
8610 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8611 | ? "sent" | |
8612 | : "received", | |
8613 | code_str, subcode_str); | |
8614 | } else { | |
8615 | vty_out(vty, " %s\n", | |
8616 | peer_down_str[(int)peer->last_reset]); | |
8617 | } | |
8618 | } | |
8619 | } | |
8620 | ||
8621 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8622 | safi_t safi) | |
8623 | { | |
8624 | return ((peer->status != Established) || | |
8625 | !peer->afc_recv[afi][safi]); | |
8626 | } | |
8627 | ||
8628 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8629 | struct peer *peer, json_object *json_peer, | |
8630 | int max_neighbor_width, bool use_json) | |
8631 | { | |
8632 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8633 | int len; | |
8634 | ||
8635 | if (use_json) { | |
8636 | if (peer_dynamic_neighbor(peer)) | |
8637 | json_object_boolean_true_add(json_peer, | |
8638 | "dynamicPeer"); | |
8639 | if (peer->hostname) | |
8640 | json_object_string_add(json_peer, "hostname", | |
8641 | peer->hostname); | |
8642 | ||
8643 | if (peer->domainname) | |
8644 | json_object_string_add(json_peer, "domainname", | |
8645 | peer->domainname); | |
8646 | json_object_int_add(json_peer, "connectionsEstablished", | |
8647 | peer->established); | |
8648 | json_object_int_add(json_peer, "connectionsDropped", | |
8649 | peer->dropped); | |
8650 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8651 | use_json, json_peer); | |
8652 | if (peer->status == Established) | |
8653 | json_object_string_add(json_peer, "lastResetDueTo", | |
8654 | "AFI/SAFI Not Negotiated"); | |
8655 | else | |
8656 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8657 | } else { | |
8658 | dn_flag[1] = '\0'; | |
8659 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8660 | if (peer->hostname | |
8661 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8662 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8663 | peer->hostname, peer->host); | |
8664 | else | |
8665 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8666 | ||
8667 | /* pad the neighbor column with spaces */ | |
8668 | if (len < max_neighbor_width) | |
8669 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8670 | " "); | |
8671 | vty_out(vty, "%7d %7d %8s", peer->established, | |
8672 | peer->dropped, | |
8673 | peer_uptime(peer->uptime, timebuf, | |
8674 | BGP_UPTIME_LEN, 0, NULL)); | |
8675 | if (peer->status == Established) | |
8676 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8677 | else | |
8678 | bgp_show_peer_reset(vty, peer, NULL, | |
8679 | false); | |
8680 | } | |
8681 | } | |
c258527b | 8682 | |
3577f1c5 | 8683 | |
718e3744 | 8684 | /* Show BGP peer's summary information. */ |
d62a17ae | 8685 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8686 | bool show_failed, bool use_json) |
d62a17ae | 8687 | { |
8688 | struct peer *peer; | |
8689 | struct listnode *node, *nnode; | |
8690 | unsigned int count = 0, dn_count = 0; | |
8691 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8692 | char neighbor_buf[VTY_BUFSIZ]; | |
8693 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8694 | int len, failed_count = 0; |
d62a17ae | 8695 | int max_neighbor_width = 0; |
8696 | int pfx_rcd_safi; | |
3c13337d | 8697 | json_object *json = NULL; |
d62a17ae | 8698 | json_object *json_peer = NULL; |
8699 | json_object *json_peers = NULL; | |
50e05855 | 8700 | struct peer_af *paf; |
d62a17ae | 8701 | |
8702 | /* labeled-unicast routes are installed in the unicast table so in order | |
8703 | * to | |
8704 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8705 | */ | |
3577f1c5 | 8706 | |
d62a17ae | 8707 | if (safi == SAFI_LABELED_UNICAST) |
8708 | pfx_rcd_safi = SAFI_UNICAST; | |
8709 | else | |
8710 | pfx_rcd_safi = safi; | |
8711 | ||
8712 | if (use_json) { | |
3c13337d | 8713 | json = json_object_new_object(); |
d62a17ae | 8714 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8715 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8716 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8717 | continue; | |
8718 | ||
8719 | if (peer->afc[afi][safi]) { | |
8720 | /* See if we have at least a single failed peer */ | |
8721 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8722 | failed_count++; | |
8723 | count++; | |
8724 | } | |
8725 | if (peer_dynamic_neighbor(peer)) | |
8726 | dn_count++; | |
8727 | } | |
c258527b | 8728 | |
d62a17ae | 8729 | } else { |
8730 | /* Loop over all neighbors that will be displayed to determine | |
8731 | * how many | |
8732 | * characters are needed for the Neighbor column | |
8733 | */ | |
8734 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8735 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8736 | continue; | |
8737 | ||
8738 | if (peer->afc[afi][safi]) { | |
8739 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8740 | if (peer_dynamic_neighbor(peer)) | |
8741 | dn_flag[0] = '*'; | |
8742 | ||
8743 | if (peer->hostname | |
8744 | && bgp_flag_check(bgp, | |
8745 | BGP_FLAG_SHOW_HOSTNAME)) | |
8746 | sprintf(neighbor_buf, "%s%s(%s) ", | |
8747 | dn_flag, peer->hostname, | |
8748 | peer->host); | |
8749 | else | |
8750 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8751 | peer->host); | |
8752 | ||
8753 | len = strlen(neighbor_buf); | |
8754 | ||
8755 | if (len > max_neighbor_width) | |
8756 | max_neighbor_width = len; | |
c258527b | 8757 | |
3577f1c5 DD |
8758 | /* See if we have at least a single failed peer */ |
8759 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8760 | failed_count++; | |
8761 | count++; | |
d62a17ae | 8762 | } |
8763 | } | |
f933309e | 8764 | |
d62a17ae | 8765 | /* Originally we displayed the Neighbor column as 16 |
8766 | * characters wide so make that the default | |
8767 | */ | |
8768 | if (max_neighbor_width < neighbor_col_default_width) | |
8769 | max_neighbor_width = neighbor_col_default_width; | |
8770 | } | |
f933309e | 8771 | |
3577f1c5 DD |
8772 | if (show_failed && !failed_count) { |
8773 | if (use_json) { | |
8774 | json_object_int_add(json, "failedPeersCount", 0); | |
8775 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8776 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8777 | |
8778 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8779 | json, JSON_C_TO_STRING_PRETTY)); | |
8780 | json_object_free(json); | |
8781 | } else { | |
8782 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8783 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8784 | } | |
8785 | return CMD_SUCCESS; | |
8786 | } | |
c258527b | 8787 | |
3577f1c5 | 8788 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8789 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8790 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8791 | continue; | |
8792 | ||
ea47320b DL |
8793 | if (!peer->afc[afi][safi]) |
8794 | continue; | |
d62a17ae | 8795 | |
ea47320b DL |
8796 | if (!count) { |
8797 | unsigned long ents; | |
8798 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8799 | int64_t vrf_id_ui; |
d62a17ae | 8800 | |
a4d82a8a PZ |
8801 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8802 | ? -1 | |
8803 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8804 | |
8805 | /* Usage summary and header */ | |
8806 | if (use_json) { | |
8807 | json_object_string_add( | |
8808 | json, "routerId", | |
8809 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8810 | json_object_int_add(json, "as", bgp->as); |
8811 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8812 | json_object_string_add( |
8813 | json, "vrfName", | |
8814 | (bgp->inst_type | |
8815 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8816 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8817 | : bgp->name); |
8818 | } else { | |
8819 | vty_out(vty, | |
8820 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8821 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8822 | bgp->vrf_id == VRF_UNKNOWN |
8823 | ? -1 | |
8824 | : (int)bgp->vrf_id); | |
ea47320b DL |
8825 | vty_out(vty, "\n"); |
8826 | } | |
d62a17ae | 8827 | |
ea47320b | 8828 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8829 | if (use_json) { |
ea47320b | 8830 | json_object_int_add( |
60466a63 | 8831 | json, "updateDelayLimit", |
ea47320b | 8832 | bgp->v_update_delay); |
d62a17ae | 8833 | |
ea47320b DL |
8834 | if (bgp->v_update_delay |
8835 | != bgp->v_establish_wait) | |
d62a17ae | 8836 | json_object_int_add( |
8837 | json, | |
ea47320b DL |
8838 | "updateDelayEstablishWait", |
8839 | bgp->v_establish_wait); | |
d62a17ae | 8840 | |
60466a63 | 8841 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8842 | json_object_string_add( |
8843 | json, | |
8844 | "updateDelayFirstNeighbor", | |
8845 | bgp->update_delay_begin_time); | |
8846 | json_object_boolean_true_add( | |
8847 | json, | |
8848 | "updateDelayInProgress"); | |
8849 | } else { | |
8850 | if (bgp->update_delay_over) { | |
d62a17ae | 8851 | json_object_string_add( |
8852 | json, | |
8853 | "updateDelayFirstNeighbor", | |
8854 | bgp->update_delay_begin_time); | |
ea47320b | 8855 | json_object_string_add( |
d62a17ae | 8856 | json, |
ea47320b DL |
8857 | "updateDelayBestpathResumed", |
8858 | bgp->update_delay_end_time); | |
8859 | json_object_string_add( | |
d62a17ae | 8860 | json, |
ea47320b DL |
8861 | "updateDelayZebraUpdateResume", |
8862 | bgp->update_delay_zebra_resume_time); | |
8863 | json_object_string_add( | |
8864 | json, | |
8865 | "updateDelayPeerUpdateResume", | |
8866 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8867 | } |
ea47320b DL |
8868 | } |
8869 | } else { | |
8870 | vty_out(vty, | |
8871 | "Read-only mode update-delay limit: %d seconds\n", | |
8872 | bgp->v_update_delay); | |
8873 | if (bgp->v_update_delay | |
8874 | != bgp->v_establish_wait) | |
d62a17ae | 8875 | vty_out(vty, |
ea47320b DL |
8876 | " Establish wait: %d seconds\n", |
8877 | bgp->v_establish_wait); | |
d62a17ae | 8878 | |
60466a63 | 8879 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8880 | vty_out(vty, |
8881 | " First neighbor established: %s\n", | |
8882 | bgp->update_delay_begin_time); | |
8883 | vty_out(vty, | |
8884 | " Delay in progress\n"); | |
8885 | } else { | |
8886 | if (bgp->update_delay_over) { | |
d62a17ae | 8887 | vty_out(vty, |
8888 | " First neighbor established: %s\n", | |
8889 | bgp->update_delay_begin_time); | |
8890 | vty_out(vty, | |
ea47320b DL |
8891 | " Best-paths resumed: %s\n", |
8892 | bgp->update_delay_end_time); | |
8893 | vty_out(vty, | |
8894 | " zebra update resumed: %s\n", | |
8895 | bgp->update_delay_zebra_resume_time); | |
8896 | vty_out(vty, | |
8897 | " peers update resumed: %s\n", | |
8898 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8899 | } |
8900 | } | |
8901 | } | |
ea47320b | 8902 | } |
d62a17ae | 8903 | |
ea47320b DL |
8904 | if (use_json) { |
8905 | if (bgp_maxmed_onstartup_configured(bgp) | |
8906 | && bgp->maxmed_active) | |
8907 | json_object_boolean_true_add( | |
60466a63 | 8908 | json, "maxMedOnStartup"); |
ea47320b DL |
8909 | if (bgp->v_maxmed_admin) |
8910 | json_object_boolean_true_add( | |
60466a63 | 8911 | json, "maxMedAdministrative"); |
d62a17ae | 8912 | |
ea47320b DL |
8913 | json_object_int_add( |
8914 | json, "tableVersion", | |
60466a63 | 8915 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8916 | |
60466a63 QY |
8917 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8918 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8919 | json_object_int_add( |
8920 | json, "ribMemory", | |
8921 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8922 | |
210ec2a0 | 8923 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8924 | json_object_int_add(json, "peerCount", ents); |
8925 | json_object_int_add(json, "peerMemory", | |
8926 | ents * sizeof(struct peer)); | |
d62a17ae | 8927 | |
ea47320b DL |
8928 | if ((ents = listcount(bgp->group))) { |
8929 | json_object_int_add( | |
60466a63 | 8930 | json, "peerGroupCount", ents); |
ea47320b DL |
8931 | json_object_int_add( |
8932 | json, "peerGroupMemory", | |
996c9314 LB |
8933 | ents * sizeof(struct |
8934 | peer_group)); | |
ea47320b | 8935 | } |
d62a17ae | 8936 | |
ea47320b DL |
8937 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8938 | BGP_CONFIG_DAMPENING)) | |
8939 | json_object_boolean_true_add( | |
60466a63 | 8940 | json, "dampeningEnabled"); |
ea47320b DL |
8941 | } else { |
8942 | if (bgp_maxmed_onstartup_configured(bgp) | |
8943 | && bgp->maxmed_active) | |
d62a17ae | 8944 | vty_out(vty, |
ea47320b DL |
8945 | "Max-med on-startup active\n"); |
8946 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8947 | vty_out(vty, |
ea47320b | 8948 | "Max-med administrative active\n"); |
d62a17ae | 8949 | |
60466a63 QY |
8950 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8951 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8952 | |
60466a63 | 8953 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8954 | vty_out(vty, |
8955 | "RIB entries %ld, using %s of memory\n", | |
8956 | ents, | |
996c9314 LB |
8957 | mtype_memstr(memstrbuf, |
8958 | sizeof(memstrbuf), | |
8959 | ents * sizeof(struct | |
8960 | bgp_node))); | |
ea47320b DL |
8961 | |
8962 | /* Peer related usage */ | |
210ec2a0 | 8963 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8964 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8965 | ents, |
8966 | mtype_memstr( | |
60466a63 QY |
8967 | memstrbuf, sizeof(memstrbuf), |
8968 | ents * sizeof(struct peer))); | |
ea47320b DL |
8969 | |
8970 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8971 | vty_out(vty, |
ea47320b | 8972 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8973 | ents, |
8974 | mtype_memstr( | |
8975 | memstrbuf, | |
8976 | sizeof(memstrbuf), | |
996c9314 LB |
8977 | ents * sizeof(struct |
8978 | peer_group))); | |
d62a17ae | 8979 | |
ea47320b DL |
8980 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8981 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8982 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8983 | vty_out(vty, "\n"); |
d62a17ae | 8984 | |
ea47320b DL |
8985 | /* Subtract 8 here because 'Neighbor' is |
8986 | * 8 characters */ | |
8987 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8988 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8989 | " "); | |
3577f1c5 DD |
8990 | if (show_failed) |
8991 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8992 | else | |
8993 | vty_out(vty, | |
ea47320b | 8994 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 8995 | } |
ea47320b | 8996 | } |
d62a17ae | 8997 | |
ea47320b | 8998 | count++; |
3577f1c5 DD |
8999 | /* Works for both failed & successful cases */ |
9000 | if (peer_dynamic_neighbor(peer)) | |
9001 | dn_count++; | |
d62a17ae | 9002 | |
ea47320b | 9003 | if (use_json) { |
3577f1c5 DD |
9004 | json_peer = NULL; |
9005 | ||
9006 | if (show_failed && | |
9007 | bgp_has_peer_failed(peer, afi, safi)) { | |
9008 | json_peer = json_object_new_object(); | |
9009 | bgp_show_failed_summary(vty, bgp, peer, | |
9010 | json_peer, 0, use_json); | |
9011 | } else if (!show_failed) { | |
9012 | json_peer = json_object_new_object(); | |
9013 | if (peer_dynamic_neighbor(peer)) { | |
9014 | json_object_boolean_true_add(json_peer, | |
9015 | "dynamicPeer"); | |
9016 | } | |
d62a17ae | 9017 | |
3577f1c5 DD |
9018 | if (peer->hostname) |
9019 | json_object_string_add(json_peer, "hostname", | |
9020 | peer->hostname); | |
9021 | ||
9022 | if (peer->domainname) | |
9023 | json_object_string_add(json_peer, "domainname", | |
9024 | peer->domainname); | |
9025 | ||
9026 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9027 | json_object_int_add(json_peer, "version", 4); | |
9028 | json_object_int_add(json_peer, "msgRcvd", | |
9029 | PEER_TOTAL_RX(peer)); | |
9030 | json_object_int_add(json_peer, "msgSent", | |
9031 | PEER_TOTAL_TX(peer)); | |
9032 | ||
9033 | json_object_int_add(json_peer, "tableVersion", | |
9034 | peer->version[afi][safi]); | |
9035 | json_object_int_add(json_peer, "outq", | |
9036 | peer->obuf->count); | |
9037 | json_object_int_add(json_peer, "inq", 0); | |
9038 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9039 | use_json, json_peer); | |
9040 | ||
9041 | /* | |
9042 | * Adding "pfxRcd" field to match with the corresponding | |
9043 | * CLI. "prefixReceivedCount" will be deprecated in | |
9044 | * future. | |
9045 | */ | |
9046 | json_object_int_add(json_peer, "prefixReceivedCount", | |
9047 | peer->pcount[afi][pfx_rcd_safi]); | |
9048 | json_object_int_add(json_peer, "pfxRcd", | |
9049 | peer->pcount[afi][pfx_rcd_safi]); | |
9050 | ||
9051 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
9052 | if (paf && PAF_SUBGRP(paf)) | |
9053 | json_object_int_add(json_peer, | |
9054 | "pfxSnt", | |
9055 | (PAF_SUBGRP(paf))->scount); | |
9056 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9057 | json_object_string_add(json_peer, "state", | |
9058 | "Idle (Admin)"); | |
9059 | else if (peer->afc_recv[afi][safi]) | |
9060 | json_object_string_add( | |
9061 | json_peer, "state", | |
9062 | lookup_msg(bgp_status_msg, peer->status, | |
9063 | NULL)); | |
9064 | else if (CHECK_FLAG(peer->sflags, | |
9065 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9066 | json_object_string_add(json_peer, "state", | |
9067 | "Idle (PfxCt)"); | |
9068 | else | |
9069 | json_object_string_add( | |
9070 | json_peer, "state", | |
9071 | lookup_msg(bgp_status_msg, peer->status, | |
9072 | NULL)); | |
200116db DD |
9073 | json_object_int_add(json_peer, "connectionsEstablished", |
9074 | peer->established); | |
9075 | json_object_int_add(json_peer, "connectionsDropped", | |
9076 | peer->dropped); | |
b4e9dcba | 9077 | } |
3577f1c5 DD |
9078 | /* Avoid creating empty peer dicts in JSON */ |
9079 | if (json_peer == NULL) | |
9080 | continue; | |
ea47320b DL |
9081 | |
9082 | if (peer->conf_if) | |
60466a63 | 9083 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9084 | "interface"); |
9085 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9086 | json_object_string_add(json_peer, "idType", |
9087 | "ipv4"); | |
ea47320b | 9088 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9089 | json_object_string_add(json_peer, "idType", |
9090 | "ipv6"); | |
ea47320b DL |
9091 | json_object_object_add(json_peers, peer->host, |
9092 | json_peer); | |
9093 | } else { | |
3577f1c5 DD |
9094 | if (show_failed && |
9095 | bgp_has_peer_failed(peer, afi, safi)) { | |
9096 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9097 | max_neighbor_width, | |
9098 | use_json); | |
9099 | } else if (!show_failed) { | |
9100 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9101 | if (peer_dynamic_neighbor(peer)) { | |
9102 | dn_flag[0] = '*'; | |
9103 | } | |
d62a17ae | 9104 | |
3577f1c5 DD |
9105 | if (peer->hostname |
9106 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
9107 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
9108 | peer->hostname, peer->host); | |
d62a17ae | 9109 | else |
3577f1c5 DD |
9110 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9111 | ||
9112 | /* pad the neighbor column with spaces */ | |
9113 | if (len < max_neighbor_width) | |
9114 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9115 | " "); | |
9116 | ||
9117 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", | |
9118 | peer->as, PEER_TOTAL_RX(peer), | |
9119 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
9120 | 0, peer->obuf->count, | |
9121 | peer_uptime(peer->uptime, timebuf, | |
9122 | BGP_UPTIME_LEN, 0, NULL)); | |
9123 | ||
9124 | if (peer->status == Established) | |
9125 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
9126 | vty_out(vty, " %12" PRIu32, |
9127 | peer->pcount | |
9128 | [afi] | |
9129 | [pfx_rcd_safi]); | |
3577f1c5 DD |
9130 | else |
9131 | vty_out(vty, " NoNeg"); | |
9132 | else { | |
9133 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9134 | vty_out(vty, " Idle (Admin)"); | |
9135 | else if (CHECK_FLAG( | |
9136 | peer->sflags, | |
9137 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9138 | vty_out(vty, " Idle (PfxCt)"); | |
9139 | else | |
9140 | vty_out(vty, " %12s", | |
9141 | lookup_msg(bgp_status_msg, | |
9142 | peer->status, NULL)); | |
9143 | } | |
9144 | vty_out(vty, "\n"); | |
d62a17ae | 9145 | } |
3577f1c5 | 9146 | |
d62a17ae | 9147 | } |
9148 | } | |
f933309e | 9149 | |
d62a17ae | 9150 | if (use_json) { |
9151 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9152 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9153 | json_object_int_add(json, "totalPeers", count); |
9154 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9155 | ||
3577f1c5 DD |
9156 | if (!show_failed) |
9157 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9158 | |
996c9314 LB |
9159 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9160 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9161 | json_object_free(json); |
9162 | } else { | |
9163 | if (count) | |
9164 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9165 | else { | |
d6ceaca3 | 9166 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9167 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9168 | } |
b05a1c8b | 9169 | |
d6ceaca3 | 9170 | if (dn_count) { |
d62a17ae | 9171 | vty_out(vty, "* - dynamic neighbor\n"); |
9172 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9173 | dn_count, bgp->dynamic_neighbors_limit); | |
9174 | } | |
9175 | } | |
1ff9a340 | 9176 | |
d62a17ae | 9177 | return CMD_SUCCESS; |
718e3744 | 9178 | } |
9179 | ||
d62a17ae | 9180 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9181 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9182 | { |
9183 | int is_first = 1; | |
9184 | int afi_wildcard = (afi == AFI_MAX); | |
9185 | int safi_wildcard = (safi == SAFI_MAX); | |
9186 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9187 | bool nbr_output = false; |
d62a17ae | 9188 | |
9189 | if (use_json && is_wildcard) | |
9190 | vty_out(vty, "{\n"); | |
9191 | if (afi_wildcard) | |
9192 | afi = 1; /* AFI_IP */ | |
9193 | while (afi < AFI_MAX) { | |
9194 | if (safi_wildcard) | |
9195 | safi = 1; /* SAFI_UNICAST */ | |
9196 | while (safi < SAFI_MAX) { | |
318cac96 | 9197 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9198 | nbr_output = true; |
f86897b9 | 9199 | |
d62a17ae | 9200 | if (is_wildcard) { |
9201 | /* | |
9202 | * So limit output to those afi/safi | |
9203 | * pairs that | |
9204 | * actualy have something interesting in | |
9205 | * them | |
9206 | */ | |
9207 | if (use_json) { | |
d62a17ae | 9208 | if (!is_first) |
9209 | vty_out(vty, ",\n"); | |
9210 | else | |
9211 | is_first = 0; | |
9212 | ||
9213 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9214 | get_afi_safi_str(afi, |
9215 | safi, | |
9216 | true)); | |
d62a17ae | 9217 | } else { |
9218 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9219 | get_afi_safi_str(afi, |
9220 | safi, | |
9221 | false)); | |
d62a17ae | 9222 | } |
9223 | } | |
3577f1c5 DD |
9224 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9225 | use_json); | |
d62a17ae | 9226 | } |
9227 | safi++; | |
d62a17ae | 9228 | if (!safi_wildcard) |
9229 | safi = SAFI_MAX; | |
9230 | } | |
9231 | afi++; | |
ee851c8c | 9232 | if (!afi_wildcard) |
d62a17ae | 9233 | afi = AFI_MAX; |
9234 | } | |
9235 | ||
9236 | if (use_json && is_wildcard) | |
9237 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9238 | else if (!nbr_output) { |
9239 | if (use_json) | |
9240 | vty_out(vty, "{}\n"); | |
9241 | else | |
9242 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9243 | } | |
d62a17ae | 9244 | } |
9245 | ||
9246 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9247 | safi_t safi, bool show_failed, |
9248 | bool use_json) | |
d62a17ae | 9249 | { |
9250 | struct listnode *node, *nnode; | |
9251 | struct bgp *bgp; | |
d62a17ae | 9252 | int is_first = 1; |
9f049418 | 9253 | bool nbr_output = false; |
d62a17ae | 9254 | |
9255 | if (use_json) | |
9256 | vty_out(vty, "{\n"); | |
9257 | ||
9258 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9259 | nbr_output = true; |
d62a17ae | 9260 | if (use_json) { |
d62a17ae | 9261 | if (!is_first) |
9262 | vty_out(vty, ",\n"); | |
9263 | else | |
9264 | is_first = 0; | |
9265 | ||
9266 | vty_out(vty, "\"%s\":", | |
9267 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9268 | ? VRF_DEFAULT_NAME |
d62a17ae | 9269 | : bgp->name); |
9270 | } else { | |
9271 | vty_out(vty, "\nInstance %s:\n", | |
9272 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9273 | ? VRF_DEFAULT_NAME |
d62a17ae | 9274 | : bgp->name); |
9275 | } | |
3577f1c5 DD |
9276 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9277 | use_json); | |
d62a17ae | 9278 | } |
9279 | ||
9280 | if (use_json) | |
9281 | vty_out(vty, "}\n"); | |
9f049418 DS |
9282 | else if (!nbr_output) |
9283 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9284 | } |
9285 | ||
9286 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9287 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9288 | { |
9289 | struct bgp *bgp; | |
9290 | ||
9291 | if (name) { | |
9292 | if (strmatch(name, "all")) { | |
9293 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9294 | show_failed, |
d62a17ae | 9295 | use_json); |
9296 | return CMD_SUCCESS; | |
9297 | } else { | |
9298 | bgp = bgp_lookup_by_name(name); | |
9299 | ||
9300 | if (!bgp) { | |
9301 | if (use_json) | |
9302 | vty_out(vty, "{}\n"); | |
9303 | else | |
9304 | vty_out(vty, | |
ca61fd25 | 9305 | "%% BGP instance not found\n"); |
d62a17ae | 9306 | return CMD_WARNING; |
9307 | } | |
9308 | ||
f86897b9 | 9309 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9310 | show_failed, use_json); |
d62a17ae | 9311 | return CMD_SUCCESS; |
9312 | } | |
9313 | } | |
9314 | ||
9315 | bgp = bgp_get_default(); | |
9316 | ||
9317 | if (bgp) | |
3577f1c5 DD |
9318 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9319 | use_json); | |
9f049418 | 9320 | else { |
ca61fd25 DS |
9321 | if (use_json) |
9322 | vty_out(vty, "{}\n"); | |
9323 | else | |
9324 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9325 | return CMD_WARNING; |
9326 | } | |
d62a17ae | 9327 | |
9328 | return CMD_SUCCESS; | |
4fb25c53 DW |
9329 | } |
9330 | ||
716b2d8a | 9331 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9332 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9333 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9334 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9335 | SHOW_STR |
9336 | IP_STR | |
9337 | BGP_STR | |
8386ac43 | 9338 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9339 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9340 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9341 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9342 | "Show only sessions not in Established state\n" |
9973d184 | 9343 | JSON_STR) |
718e3744 | 9344 | { |
d62a17ae | 9345 | char *vrf = NULL; |
9346 | afi_t afi = AFI_MAX; | |
9347 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9348 | bool show_failed = false; |
d62a17ae | 9349 | |
9350 | int idx = 0; | |
9351 | ||
9352 | /* show [ip] bgp */ | |
9353 | if (argv_find(argv, argc, "ip", &idx)) | |
9354 | afi = AFI_IP; | |
9a8bdf1c PG |
9355 | /* [<vrf> VIEWVRFNAME] */ |
9356 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9357 | vrf = argv[idx + 1]->arg; | |
9358 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9359 | vrf = NULL; | |
9360 | } else if (argv_find(argv, argc, "view", &idx)) | |
9361 | /* [<view> VIEWVRFNAME] */ | |
9362 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9363 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9364 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9365 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9366 | } | |
9367 | ||
3577f1c5 DD |
9368 | if (argv_find(argv, argc, "failed", &idx)) |
9369 | show_failed = true; | |
9370 | ||
9f049418 | 9371 | bool uj = use_json(argc, argv); |
d62a17ae | 9372 | |
3577f1c5 | 9373 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9374 | } |
9375 | ||
5cb5f4d0 | 9376 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9377 | { |
5cb5f4d0 DD |
9378 | if (for_json) |
9379 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9380 | else |
5cb5f4d0 | 9381 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9382 | } |
9383 | ||
d62a17ae | 9384 | |
9385 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9386 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9387 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9388 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9389 | bool use_json, json_object *json_pref) |
d62a17ae | 9390 | { |
9391 | /* Send-Mode */ | |
9392 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9393 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9394 | if (use_json) { | |
9395 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9396 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9397 | json_object_string_add(json_pref, "sendMode", | |
9398 | "advertisedAndReceived"); | |
9399 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9400 | json_object_string_add(json_pref, "sendMode", | |
9401 | "advertised"); | |
9402 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9403 | json_object_string_add(json_pref, "sendMode", | |
9404 | "received"); | |
9405 | } else { | |
9406 | vty_out(vty, " Send-mode: "); | |
9407 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9408 | vty_out(vty, "advertised"); | |
9409 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9410 | vty_out(vty, "%sreceived", | |
9411 | CHECK_FLAG(p->af_cap[afi][safi], | |
9412 | adv_smcap) | |
9413 | ? ", " | |
9414 | : ""); | |
9415 | vty_out(vty, "\n"); | |
9416 | } | |
9417 | } | |
9418 | ||
9419 | /* Receive-Mode */ | |
9420 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9421 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9422 | if (use_json) { | |
9423 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9424 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9425 | json_object_string_add(json_pref, "recvMode", | |
9426 | "advertisedAndReceived"); | |
9427 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9428 | json_object_string_add(json_pref, "recvMode", | |
9429 | "advertised"); | |
9430 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9431 | json_object_string_add(json_pref, "recvMode", | |
9432 | "received"); | |
9433 | } else { | |
9434 | vty_out(vty, " Receive-mode: "); | |
9435 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9436 | vty_out(vty, "advertised"); | |
9437 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9438 | vty_out(vty, "%sreceived", | |
9439 | CHECK_FLAG(p->af_cap[afi][safi], | |
9440 | adv_rmcap) | |
9441 | ? ", " | |
9442 | : ""); | |
9443 | vty_out(vty, "\n"); | |
9444 | } | |
9445 | } | |
9446 | } | |
9447 | ||
13909c4f DS |
9448 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9449 | struct peer *p, | |
9450 | bool use_json, | |
9451 | json_object *json) | |
2986cac2 | 9452 | { |
9453 | bool rbit_status = 0; | |
9454 | ||
9455 | if (!use_json) | |
9456 | vty_out(vty, "\n R bit : "); | |
9457 | ||
13909c4f DS |
9458 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9459 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9460 | && (p->status == Established)) { | |
2986cac2 | 9461 | |
9462 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
9463 | rbit_status = 1; | |
9464 | else | |
9465 | rbit_status = 0; | |
9466 | } | |
9467 | ||
9468 | if (rbit_status) { | |
9469 | if (use_json) | |
13909c4f | 9470 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9471 | else |
9472 | vty_out(vty, "True\n"); | |
9473 | } else { | |
9474 | if (use_json) | |
13909c4f | 9475 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9476 | else |
9477 | vty_out(vty, "False\n"); | |
9478 | } | |
9479 | } | |
9480 | ||
13909c4f DS |
9481 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9482 | struct peer *peer, | |
9483 | bool use_json, | |
9484 | json_object *json) | |
2986cac2 | 9485 | { |
2bb5d39b | 9486 | const char *mode = "NotApplicable"; |
2986cac2 | 9487 | |
9488 | if (!use_json) | |
9489 | vty_out(vty, "\n Remote GR Mode : "); | |
9490 | ||
13909c4f DS |
9491 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9492 | && (peer->status == Established)) { | |
2986cac2 | 9493 | |
13909c4f DS |
9494 | if ((peer->nsf_af_count == 0) |
9495 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9496 | |
2986cac2 | 9497 | mode = "Disable"; |
9498 | ||
13909c4f DS |
9499 | } else if (peer->nsf_af_count == 0 |
9500 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9501 | |
2986cac2 | 9502 | mode = "Helper"; |
9503 | ||
13909c4f DS |
9504 | } else if (peer->nsf_af_count != 0 |
9505 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9506 | |
2986cac2 | 9507 | mode = "Restart"; |
2986cac2 | 9508 | } |
9509 | } | |
9510 | ||
9511 | if (use_json) { | |
13909c4f | 9512 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9513 | } else |
9514 | vty_out(vty, mode, "\n"); | |
9515 | } | |
9516 | ||
13909c4f DS |
9517 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9518 | struct peer *p, | |
9519 | bool use_json, | |
9520 | json_object *json) | |
2986cac2 | 9521 | { |
9522 | const char *mode = "Invalid"; | |
9523 | ||
9524 | if (!use_json) | |
9525 | vty_out(vty, " Local GR Mode : "); | |
9526 | ||
9527 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9528 | mode = "Helper"; | |
9529 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9530 | mode = "Restart"; | |
9531 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9532 | mode = "Disable"; | |
2ba1fe69 | 9533 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9534 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9535 | mode = "Helper*"; | |
9536 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9537 | mode = "Restart*"; | |
9538 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9539 | mode = "Disable*"; | |
9540 | else | |
9541 | mode = "Invalid*"; | |
2ba1fe69 | 9542 | } |
2986cac2 | 9543 | |
9544 | if (use_json) { | |
13909c4f | 9545 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9546 | } else { |
9547 | vty_out(vty, mode, "\n"); | |
9548 | } | |
9549 | } | |
9550 | ||
13909c4f DS |
9551 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9552 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9553 | { |
2ba1fe69 | 9554 | afi_t afi; |
9555 | safi_t safi; | |
2986cac2 | 9556 | json_object *json_afi_safi = NULL; |
9557 | json_object *json_timer = NULL; | |
9558 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9559 | bool eor_flag = false; |
2986cac2 | 9560 | |
9561 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9562 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9563 | if (!peer->afc[afi][safi]) |
9564 | continue; | |
2986cac2 | 9565 | |
13909c4f DS |
9566 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9567 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9568 | continue; | |
9e3b51a7 | 9569 | |
13909c4f DS |
9570 | if (use_json) { |
9571 | json_afi_safi = json_object_new_object(); | |
9572 | json_endofrib_status = json_object_new_object(); | |
9573 | json_timer = json_object_new_object(); | |
9574 | } | |
2986cac2 | 9575 | |
13909c4f DS |
9576 | if (peer->eor_stime[afi][safi] |
9577 | >= peer->pkt_stime[afi][safi]) | |
9578 | eor_flag = true; | |
9579 | else | |
9580 | eor_flag = false; | |
2986cac2 | 9581 | |
13909c4f DS |
9582 | if (!use_json) { |
9583 | vty_out(vty, " %s :\n", | |
9584 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 9585 | |
13909c4f | 9586 | vty_out(vty, " F bit : "); |
698ba8d0 | 9587 | } |
2986cac2 | 9588 | |
13909c4f DS |
9589 | if (peer->nsf[afi][safi] |
9590 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9591 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9592 | |
13909c4f DS |
9593 | if (use_json) { |
9594 | json_object_boolean_true_add( | |
2986cac2 | 9595 | json_afi_safi, "fBit"); |
13909c4f DS |
9596 | } else |
9597 | vty_out(vty, "True\n"); | |
9598 | } else { | |
9599 | if (use_json) | |
9600 | json_object_boolean_false_add( | |
9601 | json_afi_safi, "fBit"); | |
9602 | else | |
9603 | vty_out(vty, "False\n"); | |
9604 | } | |
2986cac2 | 9605 | |
13909c4f DS |
9606 | if (!use_json) |
9607 | vty_out(vty, " End-of-RIB Received : "); | |
2986cac2 | 9608 | |
13909c4f DS |
9609 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9610 | PEER_STATUS_EOR_RECEIVED)) { | |
9611 | if (use_json) | |
9612 | json_object_boolean_true_add( | |
2986cac2 | 9613 | json_endofrib_status, |
13909c4f DS |
9614 | "endOfRibRecv"); |
9615 | else | |
9616 | vty_out(vty, "Yes\n"); | |
9617 | } else { | |
9618 | if (use_json) | |
9619 | json_object_boolean_false_add( | |
2986cac2 | 9620 | json_endofrib_status, |
13909c4f DS |
9621 | "endOfRibRecv"); |
9622 | else | |
9623 | vty_out(vty, "No\n"); | |
9624 | } | |
2986cac2 | 9625 | |
13909c4f DS |
9626 | if (!use_json) |
9627 | vty_out(vty, " End-of-RIB Send : "); | |
2986cac2 | 9628 | |
13909c4f DS |
9629 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9630 | PEER_STATUS_EOR_SEND)) { | |
9631 | if (use_json) { | |
9632 | json_object_boolean_true_add( | |
2986cac2 | 9633 | json_endofrib_status, |
13909c4f | 9634 | "endOfRibSend"); |
9e3b51a7 | 9635 | |
13909c4f DS |
9636 | PRINT_EOR_JSON(eor_flag); |
9637 | } else { | |
9638 | vty_out(vty, "Yes\n"); | |
9639 | vty_out(vty, | |
9e3b51a7 | 9640 | " EoRSentAfterUpdate : "); |
2986cac2 | 9641 | |
13909c4f DS |
9642 | PRINT_EOR(eor_flag); |
9643 | } | |
9644 | } else { | |
9645 | if (use_json) { | |
9646 | json_object_boolean_false_add( | |
2986cac2 | 9647 | json_endofrib_status, |
13909c4f DS |
9648 | "endOfRibSend"); |
9649 | json_object_boolean_false_add( | |
9e3b51a7 | 9650 | json_endofrib_status, |
13909c4f DS |
9651 | "endOfRibSentAfterUpdate"); |
9652 | } else { | |
9653 | vty_out(vty, "No\n"); | |
9654 | vty_out(vty, | |
9e3b51a7 | 9655 | " EoRSentAfterUpdate : "); |
13909c4f | 9656 | vty_out(vty, "No\n"); |
2986cac2 | 9657 | } |
13909c4f | 9658 | } |
2986cac2 | 9659 | |
13909c4f DS |
9660 | if (use_json) { |
9661 | json_object_int_add(json_timer, | |
9662 | "stalePathTimer", | |
9663 | peer->bgp->stalepath_time); | |
2986cac2 | 9664 | |
13909c4f DS |
9665 | if (peer->t_gr_stale != NULL) { |
9666 | json_object_int_add( | |
2986cac2 | 9667 | json_timer, |
9668 | "stalePathTimerRemaining", | |
9669 | thread_timer_remain_second( | |
13909c4f DS |
9670 | peer->t_gr_stale)); |
9671 | } | |
3a75afa4 | 9672 | |
13909c4f DS |
9673 | /* Display Configured Selection |
9674 | * Deferral only when when | |
9675 | * Gr mode is enabled. | |
9676 | */ | |
9677 | if (CHECK_FLAG(peer->flags, | |
9678 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9679 | json_object_int_add( | |
3a75afa4 | 9680 | json_timer, |
2986cac2 | 9681 | "selectionDeferralTimer", |
9682 | peer->bgp->stalepath_time); | |
13909c4f | 9683 | } |
2986cac2 | 9684 | |
13909c4f DS |
9685 | if (peer->bgp->gr_info[afi][safi] |
9686 | .t_select_deferral | |
9687 | != NULL) { | |
2986cac2 | 9688 | |
13909c4f | 9689 | json_object_int_add( |
2986cac2 | 9690 | json_timer, |
9691 | "selectionDeferralTimerRemaining", | |
9692 | thread_timer_remain_second( | |
13909c4f DS |
9693 | peer->bgp |
9694 | ->gr_info[afi] | |
9695 | [safi] | |
9696 | .t_select_deferral)); | |
9697 | } | |
9698 | } else { | |
9699 | vty_out(vty, " Timers:\n"); | |
2986cac2 | 9700 | |
13909c4f DS |
9701 | vty_out(vty, "%*s", 6, ""); |
9702 | vty_out(vty, | |
9703 | "Configured Stale Path Time(sec)%*s: %u\n", | |
9704 | 8, "", peer->bgp->stalepath_time); | |
2986cac2 | 9705 | |
13909c4f | 9706 | if (peer->t_gr_stale != NULL) { |
2986cac2 | 9707 | vty_out(vty, "%*s", 6, ""); |
9708 | vty_out(vty, | |
2986cac2 | 9709 | "Stale Path Remaining(sec)%*s: %ld\n", |
9710 | 14, "", | |
9711 | thread_timer_remain_second( | |
13909c4f DS |
9712 | peer->t_gr_stale)); |
9713 | } | |
9714 | /* Display Configured Selection | |
9715 | * Deferral only when when | |
9716 | * Gr mode is enabled. | |
9717 | */ | |
9718 | if (CHECK_FLAG(peer->flags, | |
9719 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9720 | vty_out(vty, "%*s", 6, ""); | |
9721 | vty_out(vty, | |
3a75afa4 | 9722 | "Configured Selection Deferral Time(sec): %u\n", |
9723 | peer->bgp->select_defer_time); | |
13909c4f | 9724 | } |
2986cac2 | 9725 | |
13909c4f DS |
9726 | if (peer->bgp->gr_info[afi][safi] |
9727 | .t_select_deferral | |
9728 | != NULL) { | |
2986cac2 | 9729 | |
13909c4f DS |
9730 | vty_out(vty, "%*s", 6, ""); |
9731 | vty_out(vty, | |
2986cac2 | 9732 | "Selection Deferral Time Remaining(sec) : %ld\n", |
9733 | thread_timer_remain_second( | |
13909c4f DS |
9734 | peer->bgp |
9735 | ->gr_info[afi] | |
9736 | [safi] | |
9737 | .t_select_deferral)); | |
2986cac2 | 9738 | } |
9739 | } | |
13909c4f DS |
9740 | if (use_json) { |
9741 | json_object_object_add(json_afi_safi, | |
9742 | "endOfRibStatus", | |
9743 | json_endofrib_status); | |
9744 | json_object_object_add(json_afi_safi, "timers", | |
9745 | json_timer); | |
9746 | json_object_object_add( | |
9747 | json, get_afi_safi_str(afi, safi, true), | |
9748 | json_afi_safi); | |
9749 | } | |
2986cac2 | 9750 | } |
9751 | } | |
9752 | } | |
9753 | ||
36235319 QY |
9754 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
9755 | struct peer *p, | |
9756 | bool use_json, | |
9757 | json_object *json) | |
2986cac2 | 9758 | { |
9759 | if (use_json) { | |
9760 | json_object *json_timer = NULL; | |
9761 | ||
9762 | json_timer = json_object_new_object(); | |
9763 | ||
13909c4f DS |
9764 | json_object_int_add(json_timer, "configuredRestartTimer", |
9765 | p->bgp->restart_time); | |
2986cac2 | 9766 | |
13909c4f DS |
9767 | json_object_int_add(json_timer, "receivedRestartTimer", |
9768 | p->v_gr_restart); | |
2986cac2 | 9769 | |
13909c4f DS |
9770 | if (p->t_gr_restart != NULL) |
9771 | json_object_int_add( | |
9772 | json_timer, "restartTimerRemaining", | |
9773 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 9774 | |
9775 | json_object_object_add(json, "timers", json_timer); | |
9776 | } else { | |
9777 | ||
9778 | vty_out(vty, " Timers :\n"); | |
13909c4f DS |
9779 | vty_out(vty, " Configured Restart Time(sec) : %u\n", |
9780 | p->bgp->restart_time); | |
2986cac2 | 9781 | |
13909c4f DS |
9782 | vty_out(vty, " Received Restart Time(sec) : %u\n", |
9783 | p->v_gr_restart); | |
9784 | if (p->t_gr_restart != NULL) | |
2986cac2 | 9785 | vty_out(vty, |
13909c4f DS |
9786 | " Restart Time Remaining(sec) : %ld\n", |
9787 | thread_timer_remain_second(p->t_gr_restart)); | |
36235319 QY |
9788 | if (p->t_gr_restart != NULL) { |
9789 | vty_out(vty, | |
9790 | " Restart Time Remaining(sec) : %ld\n", | |
9791 | thread_timer_remain_second(p->t_gr_restart)); | |
9792 | } | |
2986cac2 | 9793 | } |
9794 | } | |
9795 | ||
9796 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 9797 | bool use_json, json_object *json) |
2986cac2 | 9798 | { |
9799 | char buf[SU_ADDRSTRLEN] = {0}; | |
9800 | char dn_flag[2] = {0}; | |
9801 | char neighborAddr[INET6_ADDRSTRLEN] = {0}; | |
9802 | ||
2986cac2 | 9803 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
9804 | dn_flag[0] = '*'; | |
9805 | ||
9806 | if (p->conf_if) { | |
9807 | if (use_json) | |
13909c4f DS |
9808 | json_object_string_add( |
9809 | json, "neighborAddr", | |
2986cac2 | 9810 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
9811 | ? "none" |
9812 | : sockunion2str(&p->su, buf, | |
9813 | SU_ADDRSTRLEN)); | |
2986cac2 | 9814 | else |
13909c4f | 9815 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 9816 | BGP_PEER_SU_UNSPEC(p) |
9817 | ? "none" | |
9818 | : sockunion2str(&p->su, buf, | |
9819 | SU_ADDRSTRLEN)); | |
9820 | } else { | |
9821 | sprintf(neighborAddr, "%s%s", dn_flag, p->host); | |
9822 | ||
9823 | if (use_json) | |
36235319 QY |
9824 | json_object_string_add(json, "neighborAddr", |
9825 | neighborAddr); | |
2986cac2 | 9826 | else |
36235319 | 9827 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 9828 | } |
9829 | ||
9830 | /* more gr info in new format */ | |
9831 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9832 | } | |
9833 | ||
d62a17ae | 9834 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9835 | safi_t safi, bool use_json, |
d62a17ae | 9836 | json_object *json_neigh) |
9837 | { | |
0291c246 MK |
9838 | struct bgp_filter *filter; |
9839 | struct peer_af *paf; | |
9840 | char orf_pfx_name[BUFSIZ]; | |
9841 | int orf_pfx_count; | |
9842 | json_object *json_af = NULL; | |
9843 | json_object *json_prefA = NULL; | |
9844 | json_object *json_prefB = NULL; | |
9845 | json_object *json_addr = NULL; | |
d62a17ae | 9846 | |
9847 | if (use_json) { | |
9848 | json_addr = json_object_new_object(); | |
9849 | json_af = json_object_new_object(); | |
9850 | filter = &p->filter[afi][safi]; | |
9851 | ||
9852 | if (peer_group_active(p)) | |
9853 | json_object_string_add(json_addr, "peerGroupMember", | |
9854 | p->group->name); | |
9855 | ||
9856 | paf = peer_af_find(p, afi, safi); | |
9857 | if (paf && PAF_SUBGRP(paf)) { | |
9858 | json_object_int_add(json_addr, "updateGroupId", | |
9859 | PAF_UPDGRP(paf)->id); | |
9860 | json_object_int_add(json_addr, "subGroupId", | |
9861 | PAF_SUBGRP(paf)->id); | |
9862 | json_object_int_add(json_addr, "packetQueueLength", | |
9863 | bpacket_queue_virtual_length(paf)); | |
9864 | } | |
9865 | ||
9866 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9867 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9868 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9869 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9870 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9871 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9872 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9873 | json_object_int_add(json_af, "orfType", | |
9874 | ORF_TYPE_PREFIX); | |
9875 | json_prefA = json_object_new_object(); | |
9876 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
9877 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
9878 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9879 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9880 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
9881 | use_json, json_prefA); | |
9882 | json_object_object_add(json_af, "orfPrefixList", | |
9883 | json_prefA); | |
9884 | } | |
9885 | ||
9886 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9887 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9888 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9889 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9890 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9891 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9892 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9893 | json_object_int_add(json_af, "orfOldType", | |
9894 | ORF_TYPE_PREFIX_OLD); | |
9895 | json_prefB = json_object_new_object(); | |
9896 | bgp_show_peer_afi_orf_cap( | |
9897 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9898 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9899 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9900 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9901 | json_prefB); | |
9902 | json_object_object_add(json_af, "orfOldPrefixList", | |
9903 | json_prefB); | |
9904 | } | |
9905 | ||
9906 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9907 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9908 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9909 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9910 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9911 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9912 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9913 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9914 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9915 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9916 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9917 | json_object_object_add(json_addr, "afDependentCap", | |
9918 | json_af); | |
9919 | else | |
9920 | json_object_free(json_af); | |
9921 | ||
9922 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9923 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9924 | NULL, afi, orf_pfx_name, use_json); | |
9925 | ||
9926 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9927 | PEER_STATUS_ORF_PREFIX_SEND) | |
9928 | || orf_pfx_count) { | |
9929 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9930 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9931 | json_object_boolean_true_add(json_neigh, | |
9932 | "orfSent"); | |
9933 | if (orf_pfx_count) | |
9934 | json_object_int_add(json_addr, "orfRecvCounter", | |
9935 | orf_pfx_count); | |
9936 | } | |
9937 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9938 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9939 | json_object_string_add( | |
9940 | json_addr, "orfFirstUpdate", | |
9941 | "deferredUntilORFOrRouteRefreshRecvd"); | |
9942 | ||
9943 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9944 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9945 | json_object_boolean_true_add(json_addr, | |
9946 | "routeReflectorClient"); | |
9947 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9948 | PEER_FLAG_RSERVER_CLIENT)) | |
9949 | json_object_boolean_true_add(json_addr, | |
9950 | "routeServerClient"); | |
9951 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9952 | json_object_boolean_true_add(json_addr, | |
9953 | "inboundSoftConfigPermit"); | |
9954 | ||
9955 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9956 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9957 | json_object_boolean_true_add( | |
9958 | json_addr, | |
9959 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
9960 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9961 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9962 | json_object_boolean_true_add( | |
9963 | json_addr, | |
9964 | "privateAsNumsReplacedInUpdatesToNbr"); | |
9965 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9966 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9967 | json_object_boolean_true_add( | |
9968 | json_addr, | |
9969 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
9970 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9971 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9972 | json_object_boolean_true_add( | |
9973 | json_addr, | |
9974 | "privateAsNumsRemovedInUpdatesToNbr"); | |
9975 | ||
dcc68b5e MS |
9976 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9977 | json_object_boolean_true_add( | |
9978 | json_addr, | |
9979 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9980 | ->type_json_name); | |
d62a17ae | 9981 | |
9982 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9983 | json_object_string_add(json_addr, | |
9984 | "overrideASNsInOutboundUpdates", | |
9985 | "ifAspathEqualRemoteAs"); | |
9986 | ||
9987 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9988 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9989 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9990 | json_object_boolean_true_add(json_addr, | |
9991 | "routerAlwaysNextHop"); | |
9992 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9993 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9994 | json_object_boolean_true_add( | |
9995 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
9996 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9997 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9998 | json_object_boolean_true_add( | |
9999 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10000 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10001 | json_object_boolean_true_add( | |
10002 | json_addr, "unchangedMedPropogatedToNbr"); | |
10003 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10004 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10005 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10006 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10007 | PEER_FLAG_SEND_COMMUNITY) | |
10008 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10009 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10010 | json_object_string_add(json_addr, | |
10011 | "commAttriSentToNbr", | |
10012 | "extendedAndStandard"); | |
10013 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10014 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10015 | json_object_string_add(json_addr, | |
10016 | "commAttriSentToNbr", | |
10017 | "extended"); | |
10018 | else | |
10019 | json_object_string_add(json_addr, | |
10020 | "commAttriSentToNbr", | |
10021 | "standard"); | |
10022 | } | |
10023 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10024 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10025 | if (p->default_rmap[afi][safi].name) | |
10026 | json_object_string_add( | |
10027 | json_addr, "defaultRouteMap", | |
10028 | p->default_rmap[afi][safi].name); | |
10029 | ||
10030 | if (paf && PAF_SUBGRP(paf) | |
10031 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10032 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10033 | json_object_boolean_true_add(json_addr, | |
10034 | "defaultSent"); | |
10035 | else | |
10036 | json_object_boolean_true_add(json_addr, | |
10037 | "defaultNotSent"); | |
10038 | } | |
10039 | ||
dff8f48d | 10040 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10041 | if (is_evpn_enabled()) |
60466a63 QY |
10042 | json_object_boolean_true_add( |
10043 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10044 | } |
10045 | ||
d62a17ae | 10046 | if (filter->plist[FILTER_IN].name |
10047 | || filter->dlist[FILTER_IN].name | |
10048 | || filter->aslist[FILTER_IN].name | |
10049 | || filter->map[RMAP_IN].name) | |
10050 | json_object_boolean_true_add(json_addr, | |
10051 | "inboundPathPolicyConfig"); | |
10052 | if (filter->plist[FILTER_OUT].name | |
10053 | || filter->dlist[FILTER_OUT].name | |
10054 | || filter->aslist[FILTER_OUT].name | |
10055 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10056 | json_object_boolean_true_add( | |
10057 | json_addr, "outboundPathPolicyConfig"); | |
10058 | ||
10059 | /* prefix-list */ | |
10060 | if (filter->plist[FILTER_IN].name) | |
10061 | json_object_string_add(json_addr, | |
10062 | "incomingUpdatePrefixFilterList", | |
10063 | filter->plist[FILTER_IN].name); | |
10064 | if (filter->plist[FILTER_OUT].name) | |
10065 | json_object_string_add(json_addr, | |
10066 | "outgoingUpdatePrefixFilterList", | |
10067 | filter->plist[FILTER_OUT].name); | |
10068 | ||
10069 | /* distribute-list */ | |
10070 | if (filter->dlist[FILTER_IN].name) | |
10071 | json_object_string_add( | |
10072 | json_addr, "incomingUpdateNetworkFilterList", | |
10073 | filter->dlist[FILTER_IN].name); | |
10074 | if (filter->dlist[FILTER_OUT].name) | |
10075 | json_object_string_add( | |
10076 | json_addr, "outgoingUpdateNetworkFilterList", | |
10077 | filter->dlist[FILTER_OUT].name); | |
10078 | ||
10079 | /* filter-list. */ | |
10080 | if (filter->aslist[FILTER_IN].name) | |
10081 | json_object_string_add(json_addr, | |
10082 | "incomingUpdateAsPathFilterList", | |
10083 | filter->aslist[FILTER_IN].name); | |
10084 | if (filter->aslist[FILTER_OUT].name) | |
10085 | json_object_string_add(json_addr, | |
10086 | "outgoingUpdateAsPathFilterList", | |
10087 | filter->aslist[FILTER_OUT].name); | |
10088 | ||
10089 | /* route-map. */ | |
10090 | if (filter->map[RMAP_IN].name) | |
10091 | json_object_string_add( | |
10092 | json_addr, "routeMapForIncomingAdvertisements", | |
10093 | filter->map[RMAP_IN].name); | |
10094 | if (filter->map[RMAP_OUT].name) | |
10095 | json_object_string_add( | |
10096 | json_addr, "routeMapForOutgoingAdvertisements", | |
10097 | filter->map[RMAP_OUT].name); | |
10098 | ||
9dac9fc8 DA |
10099 | /* ebgp-requires-policy (inbound) */ |
10100 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10101 | && !bgp_inbound_policy_exists(p, filter)) | |
10102 | json_object_string_add( | |
10103 | json_addr, "inboundEbgpRequiresPolicy", | |
10104 | "Inbound updates discarded due to missing policy"); | |
10105 | ||
10106 | /* ebgp-requires-policy (outbound) */ | |
10107 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10108 | && (!bgp_outbound_policy_exists(p, filter))) | |
10109 | json_object_string_add( | |
10110 | json_addr, "outboundEbgpRequiresPolicy", | |
10111 | "Outbound updates discarded due to missing policy"); | |
10112 | ||
d62a17ae | 10113 | /* unsuppress-map */ |
10114 | if (filter->usmap.name) | |
10115 | json_object_string_add(json_addr, | |
10116 | "selectiveUnsuppressRouteMap", | |
10117 | filter->usmap.name); | |
10118 | ||
10119 | /* Receive prefix count */ | |
10120 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10121 | p->pcount[afi][safi]); | |
50e05855 AD |
10122 | if (paf && PAF_SUBGRP(paf)) |
10123 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10124 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10125 | |
fde246e8 DA |
10126 | /* Maximum prefix */ |
10127 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10128 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10129 | p->pmax_out[afi][safi]); | |
10130 | ||
d62a17ae | 10131 | /* Maximum prefix */ |
10132 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10133 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10134 | p->pmax[afi][safi]); | |
10135 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10136 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10137 | json_object_boolean_true_add( | |
10138 | json_addr, "prefixAllowedMaxWarning"); | |
10139 | json_object_int_add(json_addr, | |
10140 | "prefixAllowedWarningThresh", | |
10141 | p->pmax_threshold[afi][safi]); | |
10142 | if (p->pmax_restart[afi][safi]) | |
10143 | json_object_int_add( | |
10144 | json_addr, | |
10145 | "prefixAllowedRestartIntervalMsecs", | |
10146 | p->pmax_restart[afi][safi] * 60000); | |
10147 | } | |
2986cac2 | 10148 | json_object_object_add(json_neigh, |
36235319 | 10149 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10150 | json_addr); |
10151 | ||
10152 | } else { | |
10153 | filter = &p->filter[afi][safi]; | |
10154 | ||
10155 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10156 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10157 | |
10158 | if (peer_group_active(p)) | |
10159 | vty_out(vty, " %s peer-group member\n", | |
10160 | p->group->name); | |
10161 | ||
10162 | paf = peer_af_find(p, afi, safi); | |
10163 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10164 | vty_out(vty, " Update group %" PRIu64 |
10165 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10166 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10167 | vty_out(vty, " Packet Queue length %d\n", | |
10168 | bpacket_queue_virtual_length(paf)); | |
10169 | } else { | |
10170 | vty_out(vty, " Not part of any update group\n"); | |
10171 | } | |
10172 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10173 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10174 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10175 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10176 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10177 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10178 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10179 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10180 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10181 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10182 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10183 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10184 | ||
10185 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10186 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10187 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10188 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10189 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10190 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10191 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10192 | vty_out(vty, | |
10193 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10194 | ORF_TYPE_PREFIX); | |
10195 | bgp_show_peer_afi_orf_cap( | |
10196 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10197 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10198 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10199 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10200 | } | |
10201 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10202 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10203 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10204 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10205 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10206 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10207 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10208 | vty_out(vty, | |
10209 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10210 | ORF_TYPE_PREFIX_OLD); | |
10211 | bgp_show_peer_afi_orf_cap( | |
10212 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10213 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10214 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10215 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10216 | } | |
10217 | ||
10218 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
10219 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
10220 | NULL, afi, orf_pfx_name, use_json); | |
10221 | ||
10222 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10223 | PEER_STATUS_ORF_PREFIX_SEND) | |
10224 | || orf_pfx_count) { | |
10225 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10226 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10227 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10228 | vty_out(vty, " sent;"); | |
10229 | if (orf_pfx_count) | |
10230 | vty_out(vty, " received (%d entries)", | |
10231 | orf_pfx_count); | |
10232 | vty_out(vty, "\n"); | |
10233 | } | |
10234 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10235 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10236 | vty_out(vty, | |
10237 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10238 | ||
10239 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10240 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10241 | vty_out(vty, " Route-Reflector Client\n"); | |
10242 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10243 | PEER_FLAG_RSERVER_CLIENT)) | |
10244 | vty_out(vty, " Route-Server Client\n"); | |
10245 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10246 | vty_out(vty, | |
10247 | " Inbound soft reconfiguration allowed\n"); | |
10248 | ||
10249 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10250 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10251 | vty_out(vty, | |
10252 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10253 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10254 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10255 | vty_out(vty, | |
10256 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10257 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10258 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10259 | vty_out(vty, | |
10260 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10261 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10262 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10263 | vty_out(vty, | |
10264 | " Private AS numbers removed in updates to this neighbor\n"); | |
10265 | ||
dcc68b5e MS |
10266 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10267 | vty_out(vty, " %s\n", | |
10268 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10269 | ->human_description); | |
d62a17ae | 10270 | |
10271 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10272 | vty_out(vty, | |
10273 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10274 | ||
10275 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10276 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10277 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10278 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10279 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10280 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10281 | vty_out(vty, | |
10282 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10283 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10284 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10285 | vty_out(vty, | |
10286 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10287 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10288 | vty_out(vty, | |
10289 | " MED is propagated unchanged to this neighbor\n"); | |
10290 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10291 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10292 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10293 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10294 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10295 | vty_out(vty, | |
10296 | " Community attribute sent to this neighbor"); | |
10297 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10298 | PEER_FLAG_SEND_COMMUNITY) | |
10299 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10300 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10301 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10302 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10303 | vty_out(vty, "(all)\n"); | |
10304 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10305 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10306 | vty_out(vty, "(large)\n"); | |
10307 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10308 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10309 | vty_out(vty, "(extended)\n"); | |
10310 | else | |
10311 | vty_out(vty, "(standard)\n"); | |
10312 | } | |
10313 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10314 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10315 | vty_out(vty, " Default information originate,"); | |
10316 | ||
10317 | if (p->default_rmap[afi][safi].name) | |
10318 | vty_out(vty, " default route-map %s%s,", | |
10319 | p->default_rmap[afi][safi].map ? "*" | |
10320 | : "", | |
10321 | p->default_rmap[afi][safi].name); | |
10322 | if (paf && PAF_SUBGRP(paf) | |
10323 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10324 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10325 | vty_out(vty, " default sent\n"); | |
10326 | else | |
10327 | vty_out(vty, " default not sent\n"); | |
10328 | } | |
10329 | ||
dff8f48d MK |
10330 | /* advertise-vni-all */ |
10331 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10332 | if (is_evpn_enabled()) |
dff8f48d MK |
10333 | vty_out(vty, " advertise-all-vni\n"); |
10334 | } | |
10335 | ||
d62a17ae | 10336 | if (filter->plist[FILTER_IN].name |
10337 | || filter->dlist[FILTER_IN].name | |
10338 | || filter->aslist[FILTER_IN].name | |
10339 | || filter->map[RMAP_IN].name) | |
10340 | vty_out(vty, " Inbound path policy configured\n"); | |
10341 | if (filter->plist[FILTER_OUT].name | |
10342 | || filter->dlist[FILTER_OUT].name | |
10343 | || filter->aslist[FILTER_OUT].name | |
10344 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10345 | vty_out(vty, " Outbound path policy configured\n"); | |
10346 | ||
10347 | /* prefix-list */ | |
10348 | if (filter->plist[FILTER_IN].name) | |
10349 | vty_out(vty, | |
10350 | " Incoming update prefix filter list is %s%s\n", | |
10351 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10352 | filter->plist[FILTER_IN].name); | |
10353 | if (filter->plist[FILTER_OUT].name) | |
10354 | vty_out(vty, | |
10355 | " Outgoing update prefix filter list is %s%s\n", | |
10356 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10357 | filter->plist[FILTER_OUT].name); | |
10358 | ||
10359 | /* distribute-list */ | |
10360 | if (filter->dlist[FILTER_IN].name) | |
10361 | vty_out(vty, | |
10362 | " Incoming update network filter list is %s%s\n", | |
10363 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10364 | filter->dlist[FILTER_IN].name); | |
10365 | if (filter->dlist[FILTER_OUT].name) | |
10366 | vty_out(vty, | |
10367 | " Outgoing update network filter list is %s%s\n", | |
10368 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10369 | filter->dlist[FILTER_OUT].name); | |
10370 | ||
10371 | /* filter-list. */ | |
10372 | if (filter->aslist[FILTER_IN].name) | |
10373 | vty_out(vty, | |
10374 | " Incoming update AS path filter list is %s%s\n", | |
10375 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10376 | filter->aslist[FILTER_IN].name); | |
10377 | if (filter->aslist[FILTER_OUT].name) | |
10378 | vty_out(vty, | |
10379 | " Outgoing update AS path filter list is %s%s\n", | |
10380 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10381 | filter->aslist[FILTER_OUT].name); | |
10382 | ||
10383 | /* route-map. */ | |
10384 | if (filter->map[RMAP_IN].name) | |
10385 | vty_out(vty, | |
10386 | " Route map for incoming advertisements is %s%s\n", | |
10387 | filter->map[RMAP_IN].map ? "*" : "", | |
10388 | filter->map[RMAP_IN].name); | |
10389 | if (filter->map[RMAP_OUT].name) | |
10390 | vty_out(vty, | |
10391 | " Route map for outgoing advertisements is %s%s\n", | |
10392 | filter->map[RMAP_OUT].map ? "*" : "", | |
10393 | filter->map[RMAP_OUT].name); | |
10394 | ||
9dac9fc8 DA |
10395 | /* ebgp-requires-policy (inbound) */ |
10396 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10397 | && !bgp_inbound_policy_exists(p, filter)) | |
10398 | vty_out(vty, | |
10399 | " Inbound updates discarded due to missing policy\n"); | |
10400 | ||
10401 | /* ebgp-requires-policy (outbound) */ | |
10402 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10403 | && !bgp_outbound_policy_exists(p, filter)) | |
10404 | vty_out(vty, | |
10405 | " Outbound updates discarded due to missing policy\n"); | |
10406 | ||
d62a17ae | 10407 | /* unsuppress-map */ |
10408 | if (filter->usmap.name) | |
10409 | vty_out(vty, | |
10410 | " Route map for selective unsuppress is %s%s\n", | |
10411 | filter->usmap.map ? "*" : "", | |
10412 | filter->usmap.name); | |
10413 | ||
10414 | /* Receive prefix count */ | |
a0a87037 DA |
10415 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10416 | p->pcount[afi][safi]); | |
d62a17ae | 10417 | |
fde246e8 DA |
10418 | /* maximum-prefix-out */ |
10419 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10420 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10421 | vty_out(vty, | |
10422 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10423 | p->pmax_out[afi][safi]); | |
10424 | ||
d62a17ae | 10425 | /* Maximum prefix */ |
10426 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10427 | vty_out(vty, |
10428 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10429 | p->pmax[afi][safi], |
10430 | CHECK_FLAG(p->af_flags[afi][safi], | |
10431 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10432 | ? " (warning-only)" | |
10433 | : ""); | |
10434 | vty_out(vty, " Threshold for warning message %d%%", | |
10435 | p->pmax_threshold[afi][safi]); | |
10436 | if (p->pmax_restart[afi][safi]) | |
10437 | vty_out(vty, ", restart interval %d min", | |
10438 | p->pmax_restart[afi][safi]); | |
10439 | vty_out(vty, "\n"); | |
10440 | } | |
10441 | ||
10442 | vty_out(vty, "\n"); | |
10443 | } | |
10444 | } | |
10445 | ||
9f049418 | 10446 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10447 | json_object *json) |
718e3744 | 10448 | { |
d62a17ae | 10449 | struct bgp *bgp; |
10450 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10451 | char timebuf[BGP_UPTIME_LEN]; | |
10452 | char dn_flag[2]; | |
d62a17ae | 10453 | afi_t afi; |
10454 | safi_t safi; | |
d7c0a89a QY |
10455 | uint16_t i; |
10456 | uint8_t *msg; | |
d62a17ae | 10457 | json_object *json_neigh = NULL; |
10458 | time_t epoch_tbuf; | |
718e3744 | 10459 | |
d62a17ae | 10460 | bgp = p->bgp; |
10461 | ||
10462 | if (use_json) | |
10463 | json_neigh = json_object_new_object(); | |
10464 | ||
10465 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10466 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10467 | dn_flag[0] = '*'; | |
10468 | ||
10469 | if (!use_json) { | |
10470 | if (p->conf_if) /* Configured interface name. */ | |
10471 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10472 | BGP_PEER_SU_UNSPEC(p) | |
10473 | ? "None" | |
10474 | : sockunion2str(&p->su, buf, | |
10475 | SU_ADDRSTRLEN)); | |
10476 | else /* Configured IP address. */ | |
10477 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10478 | p->host); | |
10479 | } | |
10480 | ||
10481 | if (use_json) { | |
10482 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10483 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10484 | "none"); | |
10485 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10486 | json_object_string_add( | |
10487 | json_neigh, "bgpNeighborAddr", | |
10488 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10489 | ||
10490 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10491 | ||
10492 | if (p->change_local_as) | |
10493 | json_object_int_add(json_neigh, "localAs", | |
10494 | p->change_local_as); | |
10495 | else | |
10496 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10497 | ||
10498 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10499 | json_object_boolean_true_add(json_neigh, | |
10500 | "localAsNoPrepend"); | |
10501 | ||
10502 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10503 | json_object_boolean_true_add(json_neigh, | |
10504 | "localAsReplaceAs"); | |
10505 | } else { | |
10506 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10507 | || (p->as_type == AS_INTERNAL)) | |
10508 | vty_out(vty, "remote AS %u, ", p->as); | |
10509 | else | |
10510 | vty_out(vty, "remote AS Unspecified, "); | |
10511 | vty_out(vty, "local AS %u%s%s, ", | |
10512 | p->change_local_as ? p->change_local_as : p->local_as, | |
10513 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10514 | ? " no-prepend" | |
10515 | : "", | |
10516 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10517 | ? " replace-as" | |
10518 | : ""); | |
10519 | } | |
faa16034 DS |
10520 | /* peer type internal or confed-internal */ |
10521 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10522 | if (use_json) { |
10523 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10524 | json_object_boolean_true_add( | |
10525 | json_neigh, "nbrConfedInternalLink"); | |
10526 | else | |
10527 | json_object_boolean_true_add(json_neigh, | |
10528 | "nbrInternalLink"); | |
10529 | } else { | |
10530 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10531 | vty_out(vty, "confed-internal link\n"); | |
10532 | else | |
10533 | vty_out(vty, "internal link\n"); | |
10534 | } | |
faa16034 DS |
10535 | /* peer type external or confed-external */ |
10536 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10537 | if (use_json) { |
10538 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10539 | json_object_boolean_true_add( | |
10540 | json_neigh, "nbrConfedExternalLink"); | |
10541 | else | |
10542 | json_object_boolean_true_add(json_neigh, | |
10543 | "nbrExternalLink"); | |
10544 | } else { | |
10545 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10546 | vty_out(vty, "confed-external link\n"); | |
10547 | else | |
10548 | vty_out(vty, "external link\n"); | |
10549 | } | |
faa16034 DS |
10550 | } else { |
10551 | if (use_json) | |
10552 | json_object_boolean_true_add(json_neigh, | |
10553 | "nbrUnspecifiedLink"); | |
10554 | else | |
10555 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10556 | } |
10557 | ||
10558 | /* Description. */ | |
10559 | if (p->desc) { | |
10560 | if (use_json) | |
10561 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10562 | else | |
10563 | vty_out(vty, " Description: %s\n", p->desc); | |
10564 | } | |
10565 | ||
10566 | if (p->hostname) { | |
10567 | if (use_json) { | |
10568 | if (p->hostname) | |
10569 | json_object_string_add(json_neigh, "hostname", | |
10570 | p->hostname); | |
10571 | ||
10572 | if (p->domainname) | |
10573 | json_object_string_add(json_neigh, "domainname", | |
10574 | p->domainname); | |
10575 | } else { | |
10576 | if (p->domainname && (p->domainname[0] != '\0')) | |
10577 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10578 | p->domainname); | |
10579 | else | |
10580 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10581 | } | |
10582 | } | |
10583 | ||
10584 | /* Peer-group */ | |
10585 | if (p->group) { | |
10586 | if (use_json) { | |
10587 | json_object_string_add(json_neigh, "peerGroup", | |
10588 | p->group->name); | |
10589 | ||
10590 | if (dn_flag[0]) { | |
10591 | struct prefix prefix, *range = NULL; | |
10592 | ||
10593 | sockunion2hostprefix(&(p->su), &prefix); | |
10594 | range = peer_group_lookup_dynamic_neighbor_range( | |
10595 | p->group, &prefix); | |
10596 | ||
10597 | if (range) { | |
10598 | prefix2str(range, buf1, sizeof(buf1)); | |
10599 | json_object_string_add( | |
10600 | json_neigh, | |
10601 | "peerSubnetRangeGroup", buf1); | |
10602 | } | |
10603 | } | |
10604 | } else { | |
10605 | vty_out(vty, | |
10606 | " Member of peer-group %s for session parameters\n", | |
10607 | p->group->name); | |
10608 | ||
10609 | if (dn_flag[0]) { | |
10610 | struct prefix prefix, *range = NULL; | |
10611 | ||
10612 | sockunion2hostprefix(&(p->su), &prefix); | |
10613 | range = peer_group_lookup_dynamic_neighbor_range( | |
10614 | p->group, &prefix); | |
10615 | ||
10616 | if (range) { | |
10617 | prefix2str(range, buf1, sizeof(buf1)); | |
10618 | vty_out(vty, | |
10619 | " Belongs to the subnet range group: %s\n", | |
10620 | buf1); | |
10621 | } | |
10622 | } | |
10623 | } | |
10624 | } | |
10625 | ||
10626 | if (use_json) { | |
10627 | /* Administrative shutdown. */ | |
10628 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10629 | json_object_boolean_true_add(json_neigh, | |
10630 | "adminShutDown"); | |
10631 | ||
10632 | /* BGP Version. */ | |
10633 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10634 | json_object_string_add( | |
10635 | json_neigh, "remoteRouterId", | |
10636 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10637 | json_object_string_add( |
10638 | json_neigh, "localRouterId", | |
10639 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10640 | sizeof(buf1))); | |
d62a17ae | 10641 | |
10642 | /* Confederation */ | |
10643 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10644 | && bgp_confederation_peers_check(bgp, p->as)) | |
10645 | json_object_boolean_true_add(json_neigh, | |
10646 | "nbrCommonAdmin"); | |
10647 | ||
10648 | /* Status. */ | |
10649 | json_object_string_add( | |
10650 | json_neigh, "bgpState", | |
10651 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10652 | ||
10653 | if (p->status == Established) { | |
10654 | time_t uptime; | |
d62a17ae | 10655 | |
10656 | uptime = bgp_clock(); | |
10657 | uptime -= p->uptime; | |
d62a17ae | 10658 | epoch_tbuf = time(NULL) - uptime; |
10659 | ||
d3c7efed DS |
10660 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10661 | uptime * 1000); | |
d62a17ae | 10662 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10663 | peer_uptime(p->uptime, timebuf, | |
10664 | BGP_UPTIME_LEN, 0, | |
10665 | NULL)); | |
10666 | json_object_int_add(json_neigh, | |
10667 | "bgpTimerUpEstablishedEpoch", | |
10668 | epoch_tbuf); | |
10669 | } | |
10670 | ||
10671 | else if (p->status == Active) { | |
10672 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10673 | json_object_string_add(json_neigh, "bgpStateIs", | |
10674 | "passive"); | |
10675 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10676 | json_object_string_add(json_neigh, "bgpStateIs", | |
10677 | "passiveNSF"); | |
10678 | } | |
10679 | ||
10680 | /* read timer */ | |
10681 | time_t uptime; | |
10682 | struct tm *tm; | |
10683 | ||
10684 | uptime = bgp_clock(); | |
10685 | uptime -= p->readtime; | |
10686 | tm = gmtime(&uptime); | |
10687 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
10688 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10689 | + (tm->tm_hour * 3600000)); | |
10690 | ||
10691 | uptime = bgp_clock(); | |
10692 | uptime -= p->last_write; | |
10693 | tm = gmtime(&uptime); | |
10694 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
10695 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10696 | + (tm->tm_hour * 3600000)); | |
10697 | ||
10698 | uptime = bgp_clock(); | |
10699 | uptime -= p->update_time; | |
10700 | tm = gmtime(&uptime); | |
10701 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
10702 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10703 | + (tm->tm_hour * 3600000)); | |
10704 | ||
10705 | /* Configured timer values. */ | |
10706 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10707 | p->v_holdtime * 1000); | |
10708 | json_object_int_add(json_neigh, | |
10709 | "bgpTimerKeepAliveIntervalMsecs", | |
10710 | p->v_keepalive * 1000); | |
b90a8e13 | 10711 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10712 | json_object_int_add(json_neigh, |
10713 | "bgpTimerConfiguredHoldTimeMsecs", | |
10714 | p->holdtime * 1000); | |
10715 | json_object_int_add( | |
10716 | json_neigh, | |
10717 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10718 | p->keepalive * 1000); | |
5d5393b9 DL |
10719 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10720 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10721 | json_object_int_add(json_neigh, |
10722 | "bgpTimerConfiguredHoldTimeMsecs", | |
10723 | bgp->default_holdtime); | |
10724 | json_object_int_add( | |
10725 | json_neigh, | |
10726 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10727 | bgp->default_keepalive); | |
d62a17ae | 10728 | } |
10729 | } else { | |
10730 | /* Administrative shutdown. */ | |
10731 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10732 | vty_out(vty, " Administratively shut down\n"); | |
10733 | ||
10734 | /* BGP Version. */ | |
10735 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10736 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10737 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10738 | vty_out(vty, ", local router ID %s\n", |
10739 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10740 | sizeof(buf1))); | |
d62a17ae | 10741 | |
10742 | /* Confederation */ | |
10743 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10744 | && bgp_confederation_peers_check(bgp, p->as)) | |
10745 | vty_out(vty, | |
10746 | " Neighbor under common administration\n"); | |
10747 | ||
10748 | /* Status. */ | |
10749 | vty_out(vty, " BGP state = %s", | |
10750 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10751 | ||
10752 | if (p->status == Established) | |
10753 | vty_out(vty, ", up for %8s", | |
10754 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10755 | 0, NULL)); | |
10756 | ||
10757 | else if (p->status == Active) { | |
10758 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10759 | vty_out(vty, " (passive)"); | |
10760 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10761 | vty_out(vty, " (NSF passive)"); | |
10762 | } | |
10763 | vty_out(vty, "\n"); | |
10764 | ||
10765 | /* read timer */ | |
10766 | vty_out(vty, " Last read %s", | |
10767 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10768 | NULL)); | |
10769 | vty_out(vty, ", Last write %s\n", | |
10770 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10771 | NULL)); | |
10772 | ||
10773 | /* Configured timer values. */ | |
10774 | vty_out(vty, | |
10775 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10776 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10777 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10778 | vty_out(vty, " Configured hold time is %d", |
10779 | p->holdtime); | |
10780 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10781 | p->keepalive); | |
5d5393b9 DL |
10782 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10783 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10784 | vty_out(vty, " Configured hold time is %d", |
10785 | bgp->default_holdtime); | |
10786 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10787 | bgp->default_keepalive); | |
d62a17ae | 10788 | } |
10789 | } | |
10790 | /* Capability. */ | |
10791 | if (p->status == Established) { | |
10792 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10793 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10794 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10795 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10796 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10797 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10798 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10799 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10800 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10801 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10802 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10803 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10804 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10805 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10806 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10807 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10808 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10809 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10810 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10811 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10812 | if (use_json) { | |
10813 | json_object *json_cap = NULL; | |
10814 | ||
10815 | json_cap = json_object_new_object(); | |
10816 | ||
10817 | /* AS4 */ | |
10818 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10819 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10820 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10821 | && CHECK_FLAG(p->cap, | |
10822 | PEER_CAP_AS4_RCV)) | |
10823 | json_object_string_add( | |
10824 | json_cap, "4byteAs", | |
10825 | "advertisedAndReceived"); | |
10826 | else if (CHECK_FLAG(p->cap, | |
10827 | PEER_CAP_AS4_ADV)) | |
10828 | json_object_string_add( | |
10829 | json_cap, "4byteAs", | |
10830 | "advertised"); | |
10831 | else if (CHECK_FLAG(p->cap, | |
10832 | PEER_CAP_AS4_RCV)) | |
10833 | json_object_string_add( | |
10834 | json_cap, "4byteAs", | |
10835 | "received"); | |
10836 | } | |
10837 | ||
10838 | /* AddPath */ | |
10839 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10840 | || CHECK_FLAG(p->cap, | |
10841 | PEER_CAP_ADDPATH_ADV)) { | |
10842 | json_object *json_add = NULL; | |
10843 | const char *print_store; | |
10844 | ||
10845 | json_add = json_object_new_object(); | |
10846 | ||
05c7a1cc QY |
10847 | FOREACH_AFI_SAFI (afi, safi) { |
10848 | json_object *json_sub = NULL; | |
10849 | json_sub = | |
10850 | json_object_new_object(); | |
5cb5f4d0 DD |
10851 | print_store = get_afi_safi_str( |
10852 | afi, safi, true); | |
d62a17ae | 10853 | |
05c7a1cc QY |
10854 | if (CHECK_FLAG( |
10855 | p->af_cap[afi] | |
10856 | [safi], | |
10857 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10858 | || CHECK_FLAG( | |
10859 | p->af_cap[afi] | |
10860 | [safi], | |
10861 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10862 | if (CHECK_FLAG( |
10863 | p->af_cap | |
10864 | [afi] | |
10865 | [safi], | |
10866 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10867 | && CHECK_FLAG( |
d62a17ae | 10868 | p->af_cap |
10869 | [afi] | |
10870 | [safi], | |
05c7a1cc QY |
10871 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
10872 | json_object_boolean_true_add( | |
10873 | json_sub, | |
10874 | "txAdvertisedAndReceived"); | |
10875 | else if ( | |
10876 | CHECK_FLAG( | |
10877 | p->af_cap | |
10878 | [afi] | |
10879 | [safi], | |
10880 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
10881 | json_object_boolean_true_add( | |
10882 | json_sub, | |
10883 | "txAdvertised"); | |
10884 | else if ( | |
10885 | CHECK_FLAG( | |
10886 | p->af_cap | |
10887 | [afi] | |
10888 | [safi], | |
10889 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10890 | json_object_boolean_true_add( | |
10891 | json_sub, | |
10892 | "txReceived"); | |
10893 | } | |
d62a17ae | 10894 | |
05c7a1cc QY |
10895 | if (CHECK_FLAG( |
10896 | p->af_cap[afi] | |
10897 | [safi], | |
10898 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10899 | || CHECK_FLAG( | |
10900 | p->af_cap[afi] | |
10901 | [safi], | |
10902 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10903 | if (CHECK_FLAG( |
10904 | p->af_cap | |
10905 | [afi] | |
10906 | [safi], | |
10907 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10908 | && CHECK_FLAG( |
d62a17ae | 10909 | p->af_cap |
10910 | [afi] | |
10911 | [safi], | |
10912 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10913 | json_object_boolean_true_add( |
10914 | json_sub, | |
10915 | "rxAdvertisedAndReceived"); | |
10916 | else if ( | |
10917 | CHECK_FLAG( | |
10918 | p->af_cap | |
10919 | [afi] | |
10920 | [safi], | |
10921 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10922 | json_object_boolean_true_add( | |
10923 | json_sub, | |
10924 | "rxAdvertised"); | |
10925 | else if ( | |
10926 | CHECK_FLAG( | |
10927 | p->af_cap | |
10928 | [afi] | |
10929 | [safi], | |
10930 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10931 | json_object_boolean_true_add( | |
10932 | json_sub, | |
10933 | "rxReceived"); | |
d62a17ae | 10934 | } |
10935 | ||
05c7a1cc QY |
10936 | if (CHECK_FLAG( |
10937 | p->af_cap[afi] | |
10938 | [safi], | |
10939 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10940 | || CHECK_FLAG( | |
10941 | p->af_cap[afi] | |
10942 | [safi], | |
10943 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
10944 | || CHECK_FLAG( | |
10945 | p->af_cap[afi] | |
10946 | [safi], | |
10947 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10948 | || CHECK_FLAG( | |
10949 | p->af_cap[afi] | |
10950 | [safi], | |
10951 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10952 | json_object_object_add( | |
10953 | json_add, | |
10954 | print_store, | |
10955 | json_sub); | |
10956 | else | |
10957 | json_object_free( | |
10958 | json_sub); | |
10959 | } | |
10960 | ||
d62a17ae | 10961 | json_object_object_add( |
10962 | json_cap, "addPath", json_add); | |
10963 | } | |
10964 | ||
10965 | /* Dynamic */ | |
10966 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10967 | || CHECK_FLAG(p->cap, | |
10968 | PEER_CAP_DYNAMIC_ADV)) { | |
10969 | if (CHECK_FLAG(p->cap, | |
10970 | PEER_CAP_DYNAMIC_ADV) | |
10971 | && CHECK_FLAG(p->cap, | |
10972 | PEER_CAP_DYNAMIC_RCV)) | |
10973 | json_object_string_add( | |
10974 | json_cap, "dynamic", | |
10975 | "advertisedAndReceived"); | |
10976 | else if (CHECK_FLAG( | |
10977 | p->cap, | |
10978 | PEER_CAP_DYNAMIC_ADV)) | |
10979 | json_object_string_add( | |
10980 | json_cap, "dynamic", | |
10981 | "advertised"); | |
10982 | else if (CHECK_FLAG( | |
10983 | p->cap, | |
10984 | PEER_CAP_DYNAMIC_RCV)) | |
10985 | json_object_string_add( | |
10986 | json_cap, "dynamic", | |
10987 | "received"); | |
10988 | } | |
10989 | ||
10990 | /* Extended nexthop */ | |
10991 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10992 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10993 | json_object *json_nxt = NULL; | |
10994 | const char *print_store; | |
10995 | ||
10996 | ||
10997 | if (CHECK_FLAG(p->cap, | |
10998 | PEER_CAP_ENHE_ADV) | |
10999 | && CHECK_FLAG(p->cap, | |
11000 | PEER_CAP_ENHE_RCV)) | |
11001 | json_object_string_add( | |
11002 | json_cap, | |
11003 | "extendedNexthop", | |
11004 | "advertisedAndReceived"); | |
11005 | else if (CHECK_FLAG(p->cap, | |
11006 | PEER_CAP_ENHE_ADV)) | |
11007 | json_object_string_add( | |
11008 | json_cap, | |
11009 | "extendedNexthop", | |
11010 | "advertised"); | |
11011 | else if (CHECK_FLAG(p->cap, | |
11012 | PEER_CAP_ENHE_RCV)) | |
11013 | json_object_string_add( | |
11014 | json_cap, | |
11015 | "extendedNexthop", | |
11016 | "received"); | |
11017 | ||
11018 | if (CHECK_FLAG(p->cap, | |
11019 | PEER_CAP_ENHE_RCV)) { | |
11020 | json_nxt = | |
11021 | json_object_new_object(); | |
11022 | ||
11023 | for (safi = SAFI_UNICAST; | |
11024 | safi < SAFI_MAX; safi++) { | |
11025 | if (CHECK_FLAG( | |
11026 | p->af_cap | |
11027 | [AFI_IP] | |
11028 | [safi], | |
11029 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11030 | print_store = get_afi_safi_str( |
d62a17ae | 11031 | AFI_IP, |
5cb5f4d0 | 11032 | safi, true); |
d62a17ae | 11033 | json_object_string_add( |
11034 | json_nxt, | |
11035 | print_store, | |
54f29523 | 11036 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11037 | } |
11038 | } | |
11039 | json_object_object_add( | |
11040 | json_cap, | |
11041 | "extendedNexthopFamililesByPeer", | |
11042 | json_nxt); | |
11043 | } | |
11044 | } | |
11045 | ||
11046 | /* Route Refresh */ | |
11047 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11048 | || CHECK_FLAG(p->cap, | |
11049 | PEER_CAP_REFRESH_NEW_RCV) | |
11050 | || CHECK_FLAG(p->cap, | |
11051 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11052 | if (CHECK_FLAG(p->cap, | |
11053 | PEER_CAP_REFRESH_ADV) | |
11054 | && (CHECK_FLAG( | |
11055 | p->cap, | |
11056 | PEER_CAP_REFRESH_NEW_RCV) | |
11057 | || CHECK_FLAG( | |
11058 | p->cap, | |
11059 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11060 | if (CHECK_FLAG( | |
11061 | p->cap, | |
11062 | PEER_CAP_REFRESH_OLD_RCV) | |
11063 | && CHECK_FLAG( | |
11064 | p->cap, | |
11065 | PEER_CAP_REFRESH_NEW_RCV)) | |
11066 | json_object_string_add( | |
11067 | json_cap, | |
11068 | "routeRefresh", | |
11069 | "advertisedAndReceivedOldNew"); | |
11070 | else { | |
11071 | if (CHECK_FLAG( | |
11072 | p->cap, | |
11073 | PEER_CAP_REFRESH_OLD_RCV)) | |
11074 | json_object_string_add( | |
11075 | json_cap, | |
11076 | "routeRefresh", | |
11077 | "advertisedAndReceivedOld"); | |
11078 | else | |
11079 | json_object_string_add( | |
11080 | json_cap, | |
11081 | "routeRefresh", | |
11082 | "advertisedAndReceivedNew"); | |
11083 | } | |
11084 | } else if ( | |
11085 | CHECK_FLAG( | |
11086 | p->cap, | |
11087 | PEER_CAP_REFRESH_ADV)) | |
11088 | json_object_string_add( | |
11089 | json_cap, | |
11090 | "routeRefresh", | |
11091 | "advertised"); | |
11092 | else if ( | |
11093 | CHECK_FLAG( | |
11094 | p->cap, | |
11095 | PEER_CAP_REFRESH_NEW_RCV) | |
11096 | || CHECK_FLAG( | |
11097 | p->cap, | |
11098 | PEER_CAP_REFRESH_OLD_RCV)) | |
11099 | json_object_string_add( | |
11100 | json_cap, | |
11101 | "routeRefresh", | |
11102 | "received"); | |
11103 | } | |
11104 | ||
11105 | /* Multiprotocol Extensions */ | |
11106 | json_object *json_multi = NULL; | |
11107 | json_multi = json_object_new_object(); | |
11108 | ||
05c7a1cc QY |
11109 | FOREACH_AFI_SAFI (afi, safi) { |
11110 | if (p->afc_adv[afi][safi] | |
11111 | || p->afc_recv[afi][safi]) { | |
11112 | json_object *json_exten = NULL; | |
11113 | json_exten = | |
11114 | json_object_new_object(); | |
11115 | ||
d62a17ae | 11116 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11117 | && p->afc_recv[afi][safi]) |
11118 | json_object_boolean_true_add( | |
11119 | json_exten, | |
11120 | "advertisedAndReceived"); | |
11121 | else if (p->afc_adv[afi][safi]) | |
11122 | json_object_boolean_true_add( | |
11123 | json_exten, | |
11124 | "advertised"); | |
11125 | else if (p->afc_recv[afi][safi]) | |
11126 | json_object_boolean_true_add( | |
11127 | json_exten, | |
11128 | "received"); | |
d62a17ae | 11129 | |
05c7a1cc QY |
11130 | json_object_object_add( |
11131 | json_multi, | |
5cb5f4d0 DD |
11132 | get_afi_safi_str(afi, |
11133 | safi, | |
11134 | true), | |
05c7a1cc | 11135 | json_exten); |
d62a17ae | 11136 | } |
11137 | } | |
11138 | json_object_object_add( | |
11139 | json_cap, "multiprotocolExtensions", | |
11140 | json_multi); | |
11141 | ||
d77114b7 | 11142 | /* Hostname capabilities */ |
60466a63 | 11143 | json_object *json_hname = NULL; |
d77114b7 MK |
11144 | |
11145 | json_hname = json_object_new_object(); | |
11146 | ||
11147 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11148 | json_object_string_add( | |
60466a63 QY |
11149 | json_hname, "advHostName", |
11150 | bgp->peer_self->hostname | |
11151 | ? bgp->peer_self | |
11152 | ->hostname | |
d77114b7 MK |
11153 | : "n/a"); |
11154 | json_object_string_add( | |
60466a63 QY |
11155 | json_hname, "advDomainName", |
11156 | bgp->peer_self->domainname | |
11157 | ? bgp->peer_self | |
11158 | ->domainname | |
d77114b7 MK |
11159 | : "n/a"); |
11160 | } | |
11161 | ||
11162 | ||
11163 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11164 | json_object_string_add( | |
60466a63 QY |
11165 | json_hname, "rcvHostName", |
11166 | p->hostname ? p->hostname | |
11167 | : "n/a"); | |
d77114b7 | 11168 | json_object_string_add( |
60466a63 QY |
11169 | json_hname, "rcvDomainName", |
11170 | p->domainname ? p->domainname | |
11171 | : "n/a"); | |
d77114b7 MK |
11172 | } |
11173 | ||
60466a63 | 11174 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11175 | json_hname); |
11176 | ||
d62a17ae | 11177 | /* Gracefull Restart */ |
11178 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11179 | || CHECK_FLAG(p->cap, | |
11180 | PEER_CAP_RESTART_ADV)) { | |
11181 | if (CHECK_FLAG(p->cap, | |
11182 | PEER_CAP_RESTART_ADV) | |
11183 | && CHECK_FLAG(p->cap, | |
11184 | PEER_CAP_RESTART_RCV)) | |
11185 | json_object_string_add( | |
11186 | json_cap, | |
11187 | "gracefulRestart", | |
11188 | "advertisedAndReceived"); | |
11189 | else if (CHECK_FLAG( | |
11190 | p->cap, | |
11191 | PEER_CAP_RESTART_ADV)) | |
11192 | json_object_string_add( | |
11193 | json_cap, | |
11194 | "gracefulRestartCapability", | |
11195 | "advertised"); | |
11196 | else if (CHECK_FLAG( | |
11197 | p->cap, | |
11198 | PEER_CAP_RESTART_RCV)) | |
11199 | json_object_string_add( | |
11200 | json_cap, | |
11201 | "gracefulRestartCapability", | |
11202 | "received"); | |
11203 | ||
11204 | if (CHECK_FLAG(p->cap, | |
11205 | PEER_CAP_RESTART_RCV)) { | |
11206 | int restart_af_count = 0; | |
11207 | json_object *json_restart = | |
11208 | NULL; | |
11209 | json_restart = | |
11210 | json_object_new_object(); | |
11211 | ||
11212 | json_object_int_add( | |
11213 | json_cap, | |
11214 | "gracefulRestartRemoteTimerMsecs", | |
11215 | p->v_gr_restart * 1000); | |
11216 | ||
05c7a1cc QY |
11217 | FOREACH_AFI_SAFI (afi, safi) { |
11218 | if (CHECK_FLAG( | |
11219 | p->af_cap | |
11220 | [afi] | |
11221 | [safi], | |
11222 | PEER_CAP_RESTART_AF_RCV)) { | |
11223 | json_object * | |
11224 | json_sub = | |
11225 | NULL; | |
11226 | json_sub = | |
11227 | json_object_new_object(); | |
11228 | ||
d62a17ae | 11229 | if (CHECK_FLAG( |
11230 | p->af_cap | |
11231 | [afi] | |
11232 | [safi], | |
05c7a1cc QY |
11233 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11234 | json_object_boolean_true_add( | |
11235 | json_sub, | |
11236 | "preserved"); | |
11237 | restart_af_count++; | |
11238 | json_object_object_add( | |
11239 | json_restart, | |
5cb5f4d0 | 11240 | get_afi_safi_str( |
05c7a1cc | 11241 | afi, |
5cb5f4d0 DD |
11242 | safi, |
11243 | true), | |
05c7a1cc | 11244 | json_sub); |
d62a17ae | 11245 | } |
11246 | } | |
11247 | if (!restart_af_count) { | |
11248 | json_object_string_add( | |
11249 | json_cap, | |
11250 | "addressFamiliesByPeer", | |
11251 | "none"); | |
11252 | json_object_free( | |
11253 | json_restart); | |
11254 | } else | |
11255 | json_object_object_add( | |
11256 | json_cap, | |
11257 | "addressFamiliesByPeer", | |
11258 | json_restart); | |
11259 | } | |
11260 | } | |
11261 | json_object_object_add(json_neigh, | |
11262 | "neighborCapabilities", | |
11263 | json_cap); | |
11264 | } else { | |
11265 | vty_out(vty, " Neighbor capabilities:\n"); | |
11266 | ||
11267 | /* AS4 */ | |
11268 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11269 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11270 | vty_out(vty, " 4 Byte AS:"); | |
11271 | if (CHECK_FLAG(p->cap, | |
11272 | PEER_CAP_AS4_ADV)) | |
11273 | vty_out(vty, " advertised"); | |
11274 | if (CHECK_FLAG(p->cap, | |
11275 | PEER_CAP_AS4_RCV)) | |
11276 | vty_out(vty, " %sreceived", | |
11277 | CHECK_FLAG( | |
11278 | p->cap, | |
11279 | PEER_CAP_AS4_ADV) | |
11280 | ? "and " | |
11281 | : ""); | |
11282 | vty_out(vty, "\n"); | |
11283 | } | |
11284 | ||
11285 | /* AddPath */ | |
11286 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11287 | || CHECK_FLAG(p->cap, | |
11288 | PEER_CAP_ADDPATH_ADV)) { | |
11289 | vty_out(vty, " AddPath:\n"); | |
11290 | ||
05c7a1cc QY |
11291 | FOREACH_AFI_SAFI (afi, safi) { |
11292 | if (CHECK_FLAG( | |
11293 | p->af_cap[afi] | |
11294 | [safi], | |
11295 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11296 | || CHECK_FLAG( | |
11297 | p->af_cap[afi] | |
11298 | [safi], | |
11299 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11300 | vty_out(vty, | |
11301 | " %s: TX ", | |
5cb5f4d0 | 11302 | get_afi_safi_str( |
05c7a1cc | 11303 | afi, |
5cb5f4d0 DD |
11304 | safi, |
11305 | false)); | |
05c7a1cc | 11306 | |
d62a17ae | 11307 | if (CHECK_FLAG( |
11308 | p->af_cap | |
11309 | [afi] | |
11310 | [safi], | |
05c7a1cc | 11311 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11312 | vty_out(vty, |
05c7a1cc | 11313 | "advertised %s", |
5cb5f4d0 | 11314 | get_afi_safi_str( |
d62a17ae | 11315 | afi, |
5cb5f4d0 DD |
11316 | safi, |
11317 | false)); | |
d62a17ae | 11318 | |
05c7a1cc QY |
11319 | if (CHECK_FLAG( |
11320 | p->af_cap | |
11321 | [afi] | |
11322 | [safi], | |
11323 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11324 | vty_out(vty, | |
11325 | "%sreceived", | |
11326 | CHECK_FLAG( | |
11327 | p->af_cap | |
11328 | [afi] | |
11329 | [safi], | |
11330 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11331 | ? " and " | |
11332 | : ""); | |
d62a17ae | 11333 | |
05c7a1cc QY |
11334 | vty_out(vty, "\n"); |
11335 | } | |
d62a17ae | 11336 | |
05c7a1cc QY |
11337 | if (CHECK_FLAG( |
11338 | p->af_cap[afi] | |
11339 | [safi], | |
11340 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11341 | || CHECK_FLAG( | |
11342 | p->af_cap[afi] | |
11343 | [safi], | |
11344 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11345 | vty_out(vty, | |
11346 | " %s: RX ", | |
5cb5f4d0 | 11347 | get_afi_safi_str( |
05c7a1cc | 11348 | afi, |
5cb5f4d0 DD |
11349 | safi, |
11350 | false)); | |
d62a17ae | 11351 | |
11352 | if (CHECK_FLAG( | |
11353 | p->af_cap | |
11354 | [afi] | |
11355 | [safi], | |
05c7a1cc | 11356 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11357 | vty_out(vty, |
05c7a1cc | 11358 | "advertised %s", |
5cb5f4d0 | 11359 | get_afi_safi_str( |
d62a17ae | 11360 | afi, |
5cb5f4d0 DD |
11361 | safi, |
11362 | false)); | |
d62a17ae | 11363 | |
05c7a1cc QY |
11364 | if (CHECK_FLAG( |
11365 | p->af_cap | |
11366 | [afi] | |
11367 | [safi], | |
11368 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11369 | vty_out(vty, |
05c7a1cc QY |
11370 | "%sreceived", |
11371 | CHECK_FLAG( | |
11372 | p->af_cap | |
11373 | [afi] | |
11374 | [safi], | |
11375 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11376 | ? " and " | |
11377 | : ""); | |
11378 | ||
11379 | vty_out(vty, "\n"); | |
d62a17ae | 11380 | } |
05c7a1cc | 11381 | } |
d62a17ae | 11382 | } |
11383 | ||
11384 | /* Dynamic */ | |
11385 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11386 | || CHECK_FLAG(p->cap, | |
11387 | PEER_CAP_DYNAMIC_ADV)) { | |
11388 | vty_out(vty, " Dynamic:"); | |
11389 | if (CHECK_FLAG(p->cap, | |
11390 | PEER_CAP_DYNAMIC_ADV)) | |
11391 | vty_out(vty, " advertised"); | |
11392 | if (CHECK_FLAG(p->cap, | |
11393 | PEER_CAP_DYNAMIC_RCV)) | |
11394 | vty_out(vty, " %sreceived", | |
11395 | CHECK_FLAG( | |
11396 | p->cap, | |
11397 | PEER_CAP_DYNAMIC_ADV) | |
11398 | ? "and " | |
11399 | : ""); | |
11400 | vty_out(vty, "\n"); | |
11401 | } | |
11402 | ||
11403 | /* Extended nexthop */ | |
11404 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11405 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11406 | vty_out(vty, " Extended nexthop:"); | |
11407 | if (CHECK_FLAG(p->cap, | |
11408 | PEER_CAP_ENHE_ADV)) | |
11409 | vty_out(vty, " advertised"); | |
11410 | if (CHECK_FLAG(p->cap, | |
11411 | PEER_CAP_ENHE_RCV)) | |
11412 | vty_out(vty, " %sreceived", | |
11413 | CHECK_FLAG( | |
11414 | p->cap, | |
11415 | PEER_CAP_ENHE_ADV) | |
11416 | ? "and " | |
11417 | : ""); | |
11418 | vty_out(vty, "\n"); | |
11419 | ||
11420 | if (CHECK_FLAG(p->cap, | |
11421 | PEER_CAP_ENHE_RCV)) { | |
11422 | vty_out(vty, | |
11423 | " Address families by peer:\n "); | |
11424 | for (safi = SAFI_UNICAST; | |
11425 | safi < SAFI_MAX; safi++) | |
11426 | if (CHECK_FLAG( | |
11427 | p->af_cap | |
11428 | [AFI_IP] | |
11429 | [safi], | |
11430 | PEER_CAP_ENHE_AF_RCV)) | |
11431 | vty_out(vty, | |
11432 | " %s\n", | |
5cb5f4d0 | 11433 | get_afi_safi_str( |
d62a17ae | 11434 | AFI_IP, |
5cb5f4d0 DD |
11435 | safi, |
11436 | false)); | |
d62a17ae | 11437 | } |
11438 | } | |
11439 | ||
11440 | /* Route Refresh */ | |
11441 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11442 | || CHECK_FLAG(p->cap, | |
11443 | PEER_CAP_REFRESH_NEW_RCV) | |
11444 | || CHECK_FLAG(p->cap, | |
11445 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11446 | vty_out(vty, " Route refresh:"); | |
11447 | if (CHECK_FLAG(p->cap, | |
11448 | PEER_CAP_REFRESH_ADV)) | |
11449 | vty_out(vty, " advertised"); | |
11450 | if (CHECK_FLAG(p->cap, | |
11451 | PEER_CAP_REFRESH_NEW_RCV) | |
11452 | || CHECK_FLAG( | |
11453 | p->cap, | |
11454 | PEER_CAP_REFRESH_OLD_RCV)) | |
11455 | vty_out(vty, " %sreceived(%s)", | |
11456 | CHECK_FLAG( | |
11457 | p->cap, | |
11458 | PEER_CAP_REFRESH_ADV) | |
11459 | ? "and " | |
11460 | : "", | |
11461 | (CHECK_FLAG( | |
11462 | p->cap, | |
11463 | PEER_CAP_REFRESH_OLD_RCV) | |
11464 | && CHECK_FLAG( | |
11465 | p->cap, | |
11466 | PEER_CAP_REFRESH_NEW_RCV)) | |
11467 | ? "old & new" | |
11468 | : CHECK_FLAG( | |
11469 | p->cap, | |
11470 | PEER_CAP_REFRESH_OLD_RCV) | |
11471 | ? "old" | |
11472 | : "new"); | |
11473 | ||
11474 | vty_out(vty, "\n"); | |
11475 | } | |
11476 | ||
11477 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11478 | FOREACH_AFI_SAFI (afi, safi) |
11479 | if (p->afc_adv[afi][safi] | |
11480 | || p->afc_recv[afi][safi]) { | |
11481 | vty_out(vty, | |
11482 | " Address Family %s:", | |
5cb5f4d0 DD |
11483 | get_afi_safi_str( |
11484 | afi, | |
11485 | safi, | |
11486 | false)); | |
05c7a1cc | 11487 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11488 | vty_out(vty, |
05c7a1cc QY |
11489 | " advertised"); |
11490 | if (p->afc_recv[afi][safi]) | |
11491 | vty_out(vty, | |
11492 | " %sreceived", | |
11493 | p->afc_adv[afi] | |
11494 | [safi] | |
11495 | ? "and " | |
11496 | : ""); | |
11497 | vty_out(vty, "\n"); | |
11498 | } | |
d62a17ae | 11499 | |
11500 | /* Hostname capability */ | |
60466a63 | 11501 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11502 | |
11503 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11504 | vty_out(vty, |
11505 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11506 | bgp->peer_self->hostname |
11507 | ? bgp->peer_self | |
11508 | ->hostname | |
d77114b7 | 11509 | : "n/a", |
60466a63 QY |
11510 | bgp->peer_self->domainname |
11511 | ? bgp->peer_self | |
11512 | ->domainname | |
d77114b7 MK |
11513 | : "n/a"); |
11514 | } else { | |
11515 | vty_out(vty, " not advertised"); | |
d62a17ae | 11516 | } |
11517 | ||
d77114b7 | 11518 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11519 | vty_out(vty, |
11520 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11521 | p->hostname ? p->hostname |
11522 | : "n/a", | |
11523 | p->domainname ? p->domainname | |
11524 | : "n/a"); | |
d77114b7 MK |
11525 | } else { |
11526 | vty_out(vty, " not received"); | |
11527 | } | |
11528 | ||
11529 | vty_out(vty, "\n"); | |
11530 | ||
d62a17ae | 11531 | /* Gracefull Restart */ |
11532 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11533 | || CHECK_FLAG(p->cap, | |
11534 | PEER_CAP_RESTART_ADV)) { | |
11535 | vty_out(vty, | |
11536 | " Graceful Restart Capabilty:"); | |
11537 | if (CHECK_FLAG(p->cap, | |
11538 | PEER_CAP_RESTART_ADV)) | |
11539 | vty_out(vty, " advertised"); | |
11540 | if (CHECK_FLAG(p->cap, | |
11541 | PEER_CAP_RESTART_RCV)) | |
11542 | vty_out(vty, " %sreceived", | |
11543 | CHECK_FLAG( | |
11544 | p->cap, | |
11545 | PEER_CAP_RESTART_ADV) | |
11546 | ? "and " | |
11547 | : ""); | |
11548 | vty_out(vty, "\n"); | |
11549 | ||
11550 | if (CHECK_FLAG(p->cap, | |
11551 | PEER_CAP_RESTART_RCV)) { | |
11552 | int restart_af_count = 0; | |
11553 | ||
11554 | vty_out(vty, | |
11555 | " Remote Restart timer is %d seconds\n", | |
11556 | p->v_gr_restart); | |
11557 | vty_out(vty, | |
11558 | " Address families by peer:\n "); | |
11559 | ||
05c7a1cc QY |
11560 | FOREACH_AFI_SAFI (afi, safi) |
11561 | if (CHECK_FLAG( | |
11562 | p->af_cap | |
11563 | [afi] | |
11564 | [safi], | |
11565 | PEER_CAP_RESTART_AF_RCV)) { | |
11566 | vty_out(vty, | |
11567 | "%s%s(%s)", | |
11568 | restart_af_count | |
11569 | ? ", " | |
11570 | : "", | |
5cb5f4d0 | 11571 | get_afi_safi_str( |
05c7a1cc | 11572 | afi, |
5cb5f4d0 DD |
11573 | safi, |
11574 | false), | |
05c7a1cc QY |
11575 | CHECK_FLAG( |
11576 | p->af_cap | |
11577 | [afi] | |
11578 | [safi], | |
11579 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11580 | ? "preserved" | |
11581 | : "not preserved"); | |
11582 | restart_af_count++; | |
11583 | } | |
d62a17ae | 11584 | if (!restart_af_count) |
11585 | vty_out(vty, "none"); | |
11586 | vty_out(vty, "\n"); | |
11587 | } | |
2986cac2 | 11588 | } /* Gracefull Restart */ |
d62a17ae | 11589 | } |
11590 | } | |
11591 | } | |
11592 | ||
11593 | /* graceful restart information */ | |
d62a17ae | 11594 | json_object *json_grace = NULL; |
11595 | json_object *json_grace_send = NULL; | |
11596 | json_object *json_grace_recv = NULL; | |
11597 | int eor_send_af_count = 0; | |
11598 | int eor_receive_af_count = 0; | |
11599 | ||
11600 | if (use_json) { | |
11601 | json_grace = json_object_new_object(); | |
11602 | json_grace_send = json_object_new_object(); | |
11603 | json_grace_recv = json_object_new_object(); | |
11604 | ||
36235319 QY |
11605 | if ((p->status == Established) |
11606 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11607 | FOREACH_AFI_SAFI (afi, safi) { |
11608 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11609 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11610 | json_object_boolean_true_add( |
11611 | json_grace_send, | |
5cb5f4d0 DD |
11612 | get_afi_safi_str(afi, |
11613 | safi, | |
11614 | true)); | |
05c7a1cc | 11615 | eor_send_af_count++; |
d62a17ae | 11616 | } |
11617 | } | |
05c7a1cc QY |
11618 | FOREACH_AFI_SAFI (afi, safi) { |
11619 | if (CHECK_FLAG( | |
36235319 QY |
11620 | p->af_sflags[afi][safi], |
11621 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11622 | json_object_boolean_true_add( |
11623 | json_grace_recv, | |
5cb5f4d0 DD |
11624 | get_afi_safi_str(afi, |
11625 | safi, | |
11626 | true)); | |
05c7a1cc | 11627 | eor_receive_af_count++; |
d62a17ae | 11628 | } |
11629 | } | |
11630 | } | |
36235319 QY |
11631 | json_object_object_add(json_grace, "endOfRibSend", |
11632 | json_grace_send); | |
11633 | json_object_object_add(json_grace, "endOfRibRecv", | |
11634 | json_grace_recv); | |
d62a17ae | 11635 | |
d62a17ae | 11636 | |
11637 | if (p->t_gr_restart) | |
11638 | json_object_int_add(json_grace, | |
11639 | "gracefulRestartTimerMsecs", | |
11640 | thread_timer_remain_second( | |
11641 | p->t_gr_restart) | |
11642 | * 1000); | |
11643 | ||
11644 | if (p->t_gr_stale) | |
11645 | json_object_int_add( | |
11646 | json_grace, | |
11647 | "gracefulStalepathTimerMsecs", | |
11648 | thread_timer_remain_second( | |
11649 | p->t_gr_stale) | |
11650 | * 1000); | |
2986cac2 | 11651 | /* more gr info in new format */ |
11652 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11653 | json_grace); |
d62a17ae | 11654 | json_object_object_add( |
11655 | json_neigh, "gracefulRestartInfo", json_grace); | |
11656 | } else { | |
2986cac2 | 11657 | vty_out(vty, " Graceful restart informations:\n"); |
36235319 QY |
11658 | if ((p->status == Established) |
11659 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11660 | |
d62a17ae | 11661 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11662 | FOREACH_AFI_SAFI (afi, safi) { |
11663 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11664 | PEER_STATUS_EOR_SEND)) { | |
11665 | vty_out(vty, "%s%s", | |
11666 | eor_send_af_count ? ", " | |
11667 | : "", | |
36235319 QY |
11668 | get_afi_safi_str( |
11669 | afi, safi, | |
11670 | false)); | |
05c7a1cc | 11671 | eor_send_af_count++; |
d62a17ae | 11672 | } |
11673 | } | |
11674 | vty_out(vty, "\n"); | |
11675 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11676 | FOREACH_AFI_SAFI (afi, safi) { |
11677 | if (CHECK_FLAG( | |
11678 | p->af_sflags[afi][safi], | |
11679 | PEER_STATUS_EOR_RECEIVED)) { | |
11680 | vty_out(vty, "%s%s", | |
11681 | eor_receive_af_count | |
11682 | ? ", " | |
11683 | : "", | |
5cb5f4d0 DD |
11684 | get_afi_safi_str(afi, |
11685 | safi, | |
11686 | false)); | |
05c7a1cc | 11687 | eor_receive_af_count++; |
d62a17ae | 11688 | } |
11689 | } | |
11690 | vty_out(vty, "\n"); | |
11691 | } | |
11692 | ||
11693 | if (p->t_gr_restart) | |
11694 | vty_out(vty, | |
11695 | " The remaining time of restart timer is %ld\n", | |
11696 | thread_timer_remain_second( | |
11697 | p->t_gr_restart)); | |
11698 | ||
11699 | if (p->t_gr_stale) | |
11700 | vty_out(vty, | |
11701 | " The remaining time of stalepath timer is %ld\n", | |
11702 | thread_timer_remain_second( | |
11703 | p->t_gr_stale)); | |
2986cac2 | 11704 | |
11705 | /* more gr info in new format */ | |
11706 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11707 | } |
2986cac2 | 11708 | |
d62a17ae | 11709 | if (use_json) { |
11710 | json_object *json_stat = NULL; | |
11711 | json_stat = json_object_new_object(); | |
11712 | /* Packet counts. */ | |
11713 | json_object_int_add(json_stat, "depthInq", 0); | |
11714 | json_object_int_add(json_stat, "depthOutq", | |
11715 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
11716 | json_object_int_add(json_stat, "opensSent", |
11717 | atomic_load_explicit(&p->open_out, | |
11718 | memory_order_relaxed)); | |
11719 | json_object_int_add(json_stat, "opensRecv", | |
11720 | atomic_load_explicit(&p->open_in, | |
11721 | memory_order_relaxed)); | |
d62a17ae | 11722 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11723 | atomic_load_explicit(&p->notify_out, |
11724 | memory_order_relaxed)); | |
d62a17ae | 11725 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11726 | atomic_load_explicit(&p->notify_in, |
11727 | memory_order_relaxed)); | |
11728 | json_object_int_add(json_stat, "updatesSent", | |
11729 | atomic_load_explicit(&p->update_out, | |
11730 | memory_order_relaxed)); | |
11731 | json_object_int_add(json_stat, "updatesRecv", | |
11732 | atomic_load_explicit(&p->update_in, | |
11733 | memory_order_relaxed)); | |
d62a17ae | 11734 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11735 | atomic_load_explicit(&p->keepalive_out, |
11736 | memory_order_relaxed)); | |
d62a17ae | 11737 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11738 | atomic_load_explicit(&p->keepalive_in, |
11739 | memory_order_relaxed)); | |
d62a17ae | 11740 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11741 | atomic_load_explicit(&p->refresh_out, |
11742 | memory_order_relaxed)); | |
d62a17ae | 11743 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11744 | atomic_load_explicit(&p->refresh_in, |
11745 | memory_order_relaxed)); | |
d62a17ae | 11746 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11747 | atomic_load_explicit(&p->dynamic_cap_out, |
11748 | memory_order_relaxed)); | |
d62a17ae | 11749 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11750 | atomic_load_explicit(&p->dynamic_cap_in, |
11751 | memory_order_relaxed)); | |
11752 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11753 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11754 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11755 | } else { | |
11756 | /* Packet counts. */ | |
11757 | vty_out(vty, " Message statistics:\n"); | |
11758 | vty_out(vty, " Inq depth is 0\n"); | |
11759 | vty_out(vty, " Outq depth is %lu\n", | |
11760 | (unsigned long)p->obuf->count); | |
11761 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
11762 | vty_out(vty, " Opens: %10d %10d\n", |
11763 | atomic_load_explicit(&p->open_out, | |
11764 | memory_order_relaxed), | |
11765 | atomic_load_explicit(&p->open_in, | |
11766 | memory_order_relaxed)); | |
11767 | vty_out(vty, " Notifications: %10d %10d\n", | |
11768 | atomic_load_explicit(&p->notify_out, | |
11769 | memory_order_relaxed), | |
11770 | atomic_load_explicit(&p->notify_in, | |
11771 | memory_order_relaxed)); | |
11772 | vty_out(vty, " Updates: %10d %10d\n", | |
11773 | atomic_load_explicit(&p->update_out, | |
11774 | memory_order_relaxed), | |
11775 | atomic_load_explicit(&p->update_in, | |
11776 | memory_order_relaxed)); | |
11777 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11778 | atomic_load_explicit(&p->keepalive_out, | |
11779 | memory_order_relaxed), | |
11780 | atomic_load_explicit(&p->keepalive_in, | |
11781 | memory_order_relaxed)); | |
11782 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11783 | atomic_load_explicit(&p->refresh_out, | |
11784 | memory_order_relaxed), | |
11785 | atomic_load_explicit(&p->refresh_in, | |
11786 | memory_order_relaxed)); | |
d62a17ae | 11787 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11788 | atomic_load_explicit(&p->dynamic_cap_out, |
11789 | memory_order_relaxed), | |
11790 | atomic_load_explicit(&p->dynamic_cap_in, | |
11791 | memory_order_relaxed)); | |
11792 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11793 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11794 | } |
11795 | ||
11796 | if (use_json) { | |
11797 | /* advertisement-interval */ | |
11798 | json_object_int_add(json_neigh, | |
11799 | "minBtwnAdvertisementRunsTimerMsecs", | |
11800 | p->v_routeadv * 1000); | |
11801 | ||
11802 | /* Update-source. */ | |
11803 | if (p->update_if || p->update_source) { | |
11804 | if (p->update_if) | |
11805 | json_object_string_add(json_neigh, | |
11806 | "updateSource", | |
11807 | p->update_if); | |
11808 | else if (p->update_source) | |
11809 | json_object_string_add( | |
11810 | json_neigh, "updateSource", | |
11811 | sockunion2str(p->update_source, buf1, | |
11812 | SU_ADDRSTRLEN)); | |
11813 | } | |
11814 | } else { | |
11815 | /* advertisement-interval */ | |
11816 | vty_out(vty, | |
11817 | " Minimum time between advertisement runs is %d seconds\n", | |
11818 | p->v_routeadv); | |
11819 | ||
11820 | /* Update-source. */ | |
11821 | if (p->update_if || p->update_source) { | |
11822 | vty_out(vty, " Update source is "); | |
11823 | if (p->update_if) | |
11824 | vty_out(vty, "%s", p->update_if); | |
11825 | else if (p->update_source) | |
11826 | vty_out(vty, "%s", | |
11827 | sockunion2str(p->update_source, buf1, | |
11828 | SU_ADDRSTRLEN)); | |
11829 | vty_out(vty, "\n"); | |
11830 | } | |
11831 | ||
11832 | vty_out(vty, "\n"); | |
11833 | } | |
11834 | ||
11835 | /* Address Family Information */ | |
11836 | json_object *json_hold = NULL; | |
11837 | ||
11838 | if (use_json) | |
11839 | json_hold = json_object_new_object(); | |
11840 | ||
05c7a1cc QY |
11841 | FOREACH_AFI_SAFI (afi, safi) |
11842 | if (p->afc[afi][safi]) | |
11843 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11844 | json_hold); | |
d62a17ae | 11845 | |
11846 | if (use_json) { | |
11847 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11848 | json_hold); | |
11849 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11850 | p->established); | |
11851 | json_object_int_add(json_neigh, "connectionsDropped", | |
11852 | p->dropped); | |
11853 | } else | |
11854 | vty_out(vty, " Connections established %d; dropped %d\n", | |
11855 | p->established, p->dropped); | |
11856 | ||
11857 | if (!p->last_reset) { | |
11858 | if (use_json) | |
11859 | json_object_string_add(json_neigh, "lastReset", | |
11860 | "never"); | |
11861 | else | |
11862 | vty_out(vty, " Last reset never\n"); | |
11863 | } else { | |
11864 | if (use_json) { | |
11865 | time_t uptime; | |
11866 | struct tm *tm; | |
11867 | ||
11868 | uptime = bgp_clock(); | |
11869 | uptime -= p->resettime; | |
11870 | tm = gmtime(&uptime); | |
11871 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
11872 | (tm->tm_sec * 1000) | |
11873 | + (tm->tm_min * 60000) | |
11874 | + (tm->tm_hour * 3600000)); | |
3577f1c5 | 11875 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 11876 | } else { |
11877 | vty_out(vty, " Last reset %s, ", | |
11878 | peer_uptime(p->resettime, timebuf, | |
11879 | BGP_UPTIME_LEN, 0, NULL)); | |
11880 | ||
3577f1c5 | 11881 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 11882 | if (p->last_reset_cause_size) { |
11883 | msg = p->last_reset_cause; | |
11884 | vty_out(vty, | |
11885 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
11886 | for (i = 1; i <= p->last_reset_cause_size; | |
11887 | i++) { | |
11888 | vty_out(vty, "%02X", *msg++); | |
11889 | ||
11890 | if (i != p->last_reset_cause_size) { | |
11891 | if (i % 16 == 0) { | |
11892 | vty_out(vty, "\n "); | |
11893 | } else if (i % 4 == 0) { | |
11894 | vty_out(vty, " "); | |
11895 | } | |
11896 | } | |
11897 | } | |
11898 | vty_out(vty, "\n"); | |
11899 | } | |
11900 | } | |
11901 | } | |
11902 | ||
11903 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11904 | if (use_json) | |
11905 | json_object_boolean_true_add(json_neigh, | |
11906 | "prefixesConfigExceedMax"); | |
11907 | else | |
11908 | vty_out(vty, | |
11909 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11910 | ||
11911 | if (p->t_pmax_restart) { | |
11912 | if (use_json) { | |
11913 | json_object_boolean_true_add( | |
11914 | json_neigh, "reducePrefixNumFrom"); | |
11915 | json_object_int_add(json_neigh, | |
11916 | "restartInTimerMsec", | |
11917 | thread_timer_remain_second( | |
11918 | p->t_pmax_restart) | |
11919 | * 1000); | |
11920 | } else | |
11921 | vty_out(vty, | |
11922 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
11923 | p->host, thread_timer_remain_second( |
11924 | p->t_pmax_restart)); | |
d62a17ae | 11925 | } else { |
11926 | if (use_json) | |
11927 | json_object_boolean_true_add( | |
11928 | json_neigh, | |
11929 | "reducePrefixNumAndClearIpBgp"); | |
11930 | else | |
11931 | vty_out(vty, | |
11932 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
11933 | p->host); | |
11934 | } | |
11935 | } | |
11936 | ||
11937 | /* EBGP Multihop and GTSM */ | |
11938 | if (p->sort != BGP_PEER_IBGP) { | |
11939 | if (use_json) { | |
11940 | if (p->gtsm_hops > 0) | |
11941 | json_object_int_add(json_neigh, | |
11942 | "externalBgpNbrMaxHopsAway", | |
11943 | p->gtsm_hops); | |
c8d6f0d6 | 11944 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11945 | json_object_int_add(json_neigh, |
11946 | "externalBgpNbrMaxHopsAway", | |
11947 | p->ttl); | |
11948 | } else { | |
11949 | if (p->gtsm_hops > 0) | |
11950 | vty_out(vty, | |
11951 | " External BGP neighbor may be up to %d hops away.\n", | |
11952 | p->gtsm_hops); | |
c8d6f0d6 | 11953 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11954 | vty_out(vty, |
11955 | " External BGP neighbor may be up to %d hops away.\n", | |
11956 | p->ttl); | |
11957 | } | |
11958 | } else { | |
11959 | if (p->gtsm_hops > 0) { | |
11960 | if (use_json) | |
11961 | json_object_int_add(json_neigh, | |
11962 | "internalBgpNbrMaxHopsAway", | |
11963 | p->gtsm_hops); | |
11964 | else | |
11965 | vty_out(vty, | |
11966 | " Internal BGP neighbor may be up to %d hops away.\n", | |
11967 | p->gtsm_hops); | |
11968 | } | |
11969 | } | |
11970 | ||
11971 | /* Local address. */ | |
11972 | if (p->su_local) { | |
11973 | if (use_json) { | |
11974 | json_object_string_add(json_neigh, "hostLocal", | |
11975 | sockunion2str(p->su_local, buf1, | |
11976 | SU_ADDRSTRLEN)); | |
11977 | json_object_int_add(json_neigh, "portLocal", | |
11978 | ntohs(p->su_local->sin.sin_port)); | |
11979 | } else | |
11980 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
11981 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
11982 | ntohs(p->su_local->sin.sin_port)); | |
11983 | } | |
11984 | ||
11985 | /* Remote address. */ | |
11986 | if (p->su_remote) { | |
11987 | if (use_json) { | |
11988 | json_object_string_add(json_neigh, "hostForeign", | |
11989 | sockunion2str(p->su_remote, buf1, | |
11990 | SU_ADDRSTRLEN)); | |
11991 | json_object_int_add(json_neigh, "portForeign", | |
11992 | ntohs(p->su_remote->sin.sin_port)); | |
11993 | } else | |
11994 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
11995 | sockunion2str(p->su_remote, buf1, | |
11996 | SU_ADDRSTRLEN), | |
11997 | ntohs(p->su_remote->sin.sin_port)); | |
11998 | } | |
11999 | ||
12000 | /* Nexthop display. */ | |
12001 | if (p->su_local) { | |
12002 | if (use_json) { | |
12003 | json_object_string_add(json_neigh, "nexthop", | |
12004 | inet_ntop(AF_INET, | |
12005 | &p->nexthop.v4, buf1, | |
12006 | sizeof(buf1))); | |
12007 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12008 | inet_ntop(AF_INET6, | |
12009 | &p->nexthop.v6_global, | |
12010 | buf1, sizeof(buf1))); | |
12011 | json_object_string_add(json_neigh, "nexthopLocal", | |
12012 | inet_ntop(AF_INET6, | |
12013 | &p->nexthop.v6_local, | |
12014 | buf1, sizeof(buf1))); | |
12015 | if (p->shared_network) | |
12016 | json_object_string_add(json_neigh, | |
12017 | "bgpConnection", | |
12018 | "sharedNetwork"); | |
12019 | else | |
12020 | json_object_string_add(json_neigh, | |
12021 | "bgpConnection", | |
12022 | "nonSharedNetwork"); | |
12023 | } else { | |
12024 | vty_out(vty, "Nexthop: %s\n", | |
12025 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12026 | sizeof(buf1))); | |
12027 | vty_out(vty, "Nexthop global: %s\n", | |
12028 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12029 | sizeof(buf1))); | |
12030 | vty_out(vty, "Nexthop local: %s\n", | |
12031 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12032 | sizeof(buf1))); | |
12033 | vty_out(vty, "BGP connection: %s\n", | |
12034 | p->shared_network ? "shared network" | |
12035 | : "non shared network"); | |
12036 | } | |
12037 | } | |
12038 | ||
12039 | /* Timer information. */ | |
12040 | if (use_json) { | |
12041 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12042 | p->v_connect); | |
12043 | if (p->status == Established && p->rtt) | |
12044 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12045 | p->rtt); | |
12046 | if (p->t_start) | |
12047 | json_object_int_add( | |
12048 | json_neigh, "nextStartTimerDueInMsecs", | |
12049 | thread_timer_remain_second(p->t_start) * 1000); | |
12050 | if (p->t_connect) | |
12051 | json_object_int_add( | |
12052 | json_neigh, "nextConnectTimerDueInMsecs", | |
12053 | thread_timer_remain_second(p->t_connect) | |
12054 | * 1000); | |
12055 | if (p->t_routeadv) { | |
12056 | json_object_int_add(json_neigh, "mraiInterval", | |
12057 | p->v_routeadv); | |
12058 | json_object_int_add( | |
12059 | json_neigh, "mraiTimerExpireInMsecs", | |
12060 | thread_timer_remain_second(p->t_routeadv) | |
12061 | * 1000); | |
12062 | } | |
12063 | if (p->password) | |
12064 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12065 | 1); | |
12066 | ||
12067 | if (p->t_read) | |
12068 | json_object_string_add(json_neigh, "readThread", "on"); | |
12069 | else | |
12070 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12071 | |
12072 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12073 | json_object_string_add(json_neigh, "writeThread", "on"); |
12074 | else | |
12075 | json_object_string_add(json_neigh, "writeThread", | |
12076 | "off"); | |
12077 | } else { | |
12078 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12079 | p->v_connect); | |
12080 | if (p->status == Established && p->rtt) | |
12081 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12082 | p->rtt); | |
12083 | if (p->t_start) | |
12084 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12085 | thread_timer_remain_second(p->t_start)); | |
12086 | if (p->t_connect) | |
12087 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12088 | thread_timer_remain_second(p->t_connect)); | |
12089 | if (p->t_routeadv) | |
12090 | vty_out(vty, | |
12091 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12092 | p->v_routeadv, | |
12093 | thread_timer_remain_second(p->t_routeadv)); | |
12094 | if (p->password) | |
12095 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12096 | ||
cac9e917 | 12097 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12098 | p->t_read ? "on" : "off", |
12099 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12100 | ? "on" | |
cac9e917 | 12101 | : "off", p->fd); |
d62a17ae | 12102 | } |
12103 | ||
12104 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12105 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12106 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12107 | ||
12108 | if (!use_json) | |
12109 | vty_out(vty, "\n"); | |
12110 | ||
12111 | /* BFD information. */ | |
12112 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12113 | ||
12114 | if (use_json) { | |
12115 | if (p->conf_if) /* Configured interface name. */ | |
12116 | json_object_object_add(json, p->conf_if, json_neigh); | |
12117 | else /* Configured IP address. */ | |
12118 | json_object_object_add(json, p->host, json_neigh); | |
12119 | } | |
12120 | } | |
12121 | ||
36235319 QY |
12122 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12123 | enum show_type type, | |
12124 | union sockunion *su, | |
12125 | const char *conf_if, afi_t afi, | |
12126 | bool use_json, json_object *json) | |
2986cac2 | 12127 | { |
12128 | struct listnode *node, *nnode; | |
12129 | struct peer *peer; | |
12130 | int find = 0; | |
12131 | safi_t safi = SAFI_UNICAST; | |
12132 | json_object *json_neighbor = NULL; | |
12133 | ||
12134 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12135 | ||
12136 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12137 | continue; | |
12138 | ||
12139 | if ((peer->afc[afi][safi]) == 0) | |
12140 | continue; | |
12141 | ||
12142 | if (use_json) | |
12143 | json_neighbor = json_object_new_object(); | |
12144 | ||
2ba1fe69 | 12145 | if (type == show_all) { |
2986cac2 | 12146 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12147 | json_neighbor); |
2986cac2 | 12148 | |
12149 | if (use_json) | |
13909c4f DS |
12150 | json_object_object_add(json, peer->host, |
12151 | json_neighbor); | |
2986cac2 | 12152 | |
2ba1fe69 | 12153 | } else if (type == show_peer) { |
2986cac2 | 12154 | if (conf_if) { |
12155 | if ((peer->conf_if | |
13909c4f DS |
12156 | && !strcmp(peer->conf_if, conf_if)) |
12157 | || (peer->hostname | |
2986cac2 | 12158 | && !strcmp(peer->hostname, conf_if))) { |
12159 | find = 1; | |
13909c4f DS |
12160 | bgp_show_peer_gr_status(vty, peer, |
12161 | use_json, | |
12162 | json_neighbor); | |
2986cac2 | 12163 | } |
12164 | } else { | |
12165 | if (sockunion_same(&peer->su, su)) { | |
12166 | find = 1; | |
13909c4f DS |
12167 | bgp_show_peer_gr_status(vty, peer, |
12168 | use_json, | |
12169 | json_neighbor); | |
2986cac2 | 12170 | } |
12171 | } | |
13909c4f DS |
12172 | if (use_json && find) |
12173 | json_object_object_add(json, peer->host, | |
12174 | json_neighbor); | |
2986cac2 | 12175 | } |
12176 | ||
12177 | if (find) | |
12178 | break; | |
12179 | } | |
12180 | ||
12181 | if (type == show_peer && !find) { | |
12182 | if (use_json) | |
13909c4f | 12183 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12184 | else |
12185 | vty_out(vty, "%% No such neighbor\n"); | |
12186 | } | |
12187 | if (use_json) { | |
13909c4f DS |
12188 | vty_out(vty, "%s\n", |
12189 | json_object_to_json_string_ext( | |
12190 | json, JSON_C_TO_STRING_PRETTY)); | |
2986cac2 | 12191 | } else { |
12192 | vty_out(vty, "\n"); | |
12193 | } | |
12194 | ||
12195 | return CMD_SUCCESS; | |
12196 | } | |
12197 | ||
d62a17ae | 12198 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12199 | enum show_type type, union sockunion *su, | |
9f049418 | 12200 | const char *conf_if, bool use_json, |
d62a17ae | 12201 | json_object *json) |
12202 | { | |
12203 | struct listnode *node, *nnode; | |
12204 | struct peer *peer; | |
12205 | int find = 0; | |
9f049418 | 12206 | bool nbr_output = false; |
d1927ebe AS |
12207 | afi_t afi = AFI_MAX; |
12208 | safi_t safi = SAFI_MAX; | |
12209 | ||
12210 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12211 | afi = AFI_IP; | |
12212 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12213 | afi = AFI_IP6; | |
12214 | } | |
d62a17ae | 12215 | |
12216 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12217 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12218 | continue; | |
12219 | ||
12220 | switch (type) { | |
12221 | case show_all: | |
12222 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12223 | nbr_output = true; |
d62a17ae | 12224 | break; |
12225 | case show_peer: | |
12226 | if (conf_if) { | |
12227 | if ((peer->conf_if | |
12228 | && !strcmp(peer->conf_if, conf_if)) | |
12229 | || (peer->hostname | |
12230 | && !strcmp(peer->hostname, conf_if))) { | |
12231 | find = 1; | |
12232 | bgp_show_peer(vty, peer, use_json, | |
12233 | json); | |
12234 | } | |
12235 | } else { | |
12236 | if (sockunion_same(&peer->su, su)) { | |
12237 | find = 1; | |
12238 | bgp_show_peer(vty, peer, use_json, | |
12239 | json); | |
12240 | } | |
12241 | } | |
12242 | break; | |
d1927ebe AS |
12243 | case show_ipv4_peer: |
12244 | case show_ipv6_peer: | |
12245 | FOREACH_SAFI (safi) { | |
12246 | if (peer->afc[afi][safi]) { | |
12247 | if (conf_if) { | |
12248 | if ((peer->conf_if | |
12249 | && !strcmp(peer->conf_if, conf_if)) | |
12250 | || (peer->hostname | |
12251 | && !strcmp(peer->hostname, conf_if))) { | |
12252 | find = 1; | |
12253 | bgp_show_peer(vty, peer, use_json, | |
12254 | json); | |
12255 | break; | |
12256 | } | |
12257 | } else { | |
12258 | if (sockunion_same(&peer->su, su)) { | |
12259 | find = 1; | |
12260 | bgp_show_peer(vty, peer, use_json, | |
12261 | json); | |
12262 | break; | |
12263 | } | |
12264 | } | |
12265 | } | |
12266 | } | |
12267 | break; | |
12268 | case show_ipv4_all: | |
12269 | case show_ipv6_all: | |
12270 | FOREACH_SAFI (safi) { | |
12271 | if (peer->afc[afi][safi]) { | |
12272 | bgp_show_peer(vty, peer, use_json, json); | |
12273 | nbr_output = true; | |
12274 | break; | |
12275 | } | |
12276 | } | |
12277 | break; | |
d62a17ae | 12278 | } |
12279 | } | |
12280 | ||
d1927ebe AS |
12281 | if ((type == show_peer || type == show_ipv4_peer || |
12282 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12283 | if (use_json) |
12284 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12285 | else | |
88b7d255 | 12286 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12287 | } |
12288 | ||
d1927ebe AS |
12289 | if (type != show_peer && type != show_ipv4_peer && |
12290 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12291 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12292 | |
d62a17ae | 12293 | if (use_json) { |
996c9314 LB |
12294 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12295 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12296 | } else { |
12297 | vty_out(vty, "\n"); | |
12298 | } | |
12299 | ||
12300 | return CMD_SUCCESS; | |
12301 | } | |
12302 | ||
36235319 QY |
12303 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12304 | enum show_type type, | |
12305 | const char *ip_str, | |
12306 | afi_t afi, bool use_json) | |
2986cac2 | 12307 | { |
12308 | ||
12309 | int ret; | |
12310 | struct bgp *bgp; | |
12311 | union sockunion su; | |
12312 | json_object *json = NULL; | |
12313 | ||
12314 | bgp = bgp_get_default(); | |
12315 | ||
13909c4f DS |
12316 | if (!bgp) |
12317 | return; | |
2986cac2 | 12318 | |
13909c4f DS |
12319 | if (!use_json) |
12320 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12321 | NULL); | |
2986cac2 | 12322 | |
13909c4f DS |
12323 | json = json_object_new_object(); |
12324 | if (ip_str) { | |
12325 | ret = str2sockunion(ip_str, &su); | |
12326 | if (ret < 0) | |
12327 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, | |
12328 | ip_str, afi, | |
12329 | use_json, json); | |
12330 | else | |
12331 | bgp_show_neighbor_graceful_restart( | |
12332 | vty, bgp, type, &su, NULL, afi, use_json, json); | |
12333 | } else | |
12334 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
12335 | afi, use_json, json); | |
12336 | json_object_free(json); | |
2986cac2 | 12337 | } |
12338 | ||
d62a17ae | 12339 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12340 | enum show_type type, |
12341 | const char *ip_str, | |
9f049418 | 12342 | bool use_json) |
d62a17ae | 12343 | { |
0291c246 MK |
12344 | struct listnode *node, *nnode; |
12345 | struct bgp *bgp; | |
71aedaa3 | 12346 | union sockunion su; |
0291c246 | 12347 | json_object *json = NULL; |
71aedaa3 | 12348 | int ret, is_first = 1; |
9f049418 | 12349 | bool nbr_output = false; |
d62a17ae | 12350 | |
12351 | if (use_json) | |
12352 | vty_out(vty, "{\n"); | |
12353 | ||
12354 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12355 | nbr_output = true; |
d62a17ae | 12356 | if (use_json) { |
12357 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12358 | flog_err( |
e50f7cfd | 12359 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12360 | "Unable to allocate memory for JSON object"); |
12361 | vty_out(vty, | |
12362 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12363 | return; | |
12364 | } | |
12365 | ||
12366 | json_object_int_add(json, "vrfId", | |
12367 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12368 | ? -1 |
12369 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12370 | json_object_string_add( |
12371 | json, "vrfName", | |
12372 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12373 | ? VRF_DEFAULT_NAME |
d62a17ae | 12374 | : bgp->name); |
12375 | ||
12376 | if (!is_first) | |
12377 | vty_out(vty, ",\n"); | |
12378 | else | |
12379 | is_first = 0; | |
12380 | ||
12381 | vty_out(vty, "\"%s\":", | |
12382 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12383 | ? VRF_DEFAULT_NAME |
d62a17ae | 12384 | : bgp->name); |
12385 | } else { | |
12386 | vty_out(vty, "\nInstance %s:\n", | |
12387 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12388 | ? VRF_DEFAULT_NAME |
d62a17ae | 12389 | : bgp->name); |
12390 | } | |
71aedaa3 | 12391 | |
d1927ebe AS |
12392 | if (type == show_peer || type == show_ipv4_peer || |
12393 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12394 | ret = str2sockunion(ip_str, &su); |
12395 | if (ret < 0) | |
12396 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12397 | use_json, json); | |
12398 | else | |
12399 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12400 | use_json, json); | |
12401 | } else { | |
d1927ebe | 12402 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12403 | use_json, json); |
12404 | } | |
b77004d6 | 12405 | json_object_free(json); |
d62a17ae | 12406 | } |
12407 | ||
01cbfd04 | 12408 | if (use_json) { |
d62a17ae | 12409 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12410 | json_object_free(json); |
12411 | } | |
9f049418 DS |
12412 | else if (!nbr_output) |
12413 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12414 | } |
12415 | ||
12416 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12417 | enum show_type type, const char *ip_str, | |
9f049418 | 12418 | bool use_json) |
d62a17ae | 12419 | { |
12420 | int ret; | |
12421 | struct bgp *bgp; | |
12422 | union sockunion su; | |
12423 | json_object *json = NULL; | |
12424 | ||
12425 | if (name) { | |
12426 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12427 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12428 | use_json); | |
d62a17ae | 12429 | return CMD_SUCCESS; |
12430 | } else { | |
12431 | bgp = bgp_lookup_by_name(name); | |
12432 | if (!bgp) { | |
12433 | if (use_json) { | |
12434 | json = json_object_new_object(); | |
d62a17ae | 12435 | vty_out(vty, "%s\n", |
12436 | json_object_to_json_string_ext( | |
12437 | json, | |
12438 | JSON_C_TO_STRING_PRETTY)); | |
12439 | json_object_free(json); | |
12440 | } else | |
12441 | vty_out(vty, | |
9f049418 | 12442 | "%% BGP instance not found\n"); |
d62a17ae | 12443 | |
12444 | return CMD_WARNING; | |
12445 | } | |
12446 | } | |
12447 | } else { | |
12448 | bgp = bgp_get_default(); | |
12449 | } | |
12450 | ||
12451 | if (bgp) { | |
12452 | json = json_object_new_object(); | |
12453 | if (ip_str) { | |
12454 | ret = str2sockunion(ip_str, &su); | |
12455 | if (ret < 0) | |
12456 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12457 | use_json, json); | |
12458 | else | |
12459 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12460 | use_json, json); | |
12461 | } else { | |
12462 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12463 | json); | |
12464 | } | |
12465 | json_object_free(json); | |
ca61fd25 DS |
12466 | } else { |
12467 | if (use_json) | |
12468 | vty_out(vty, "{}\n"); | |
12469 | else | |
12470 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12471 | } |
12472 | ||
12473 | return CMD_SUCCESS; | |
4fb25c53 DW |
12474 | } |
12475 | ||
2986cac2 | 12476 | |
12477 | ||
12478 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12479 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12480 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12481 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12482 | SHOW_STR | |
12483 | BGP_STR | |
12484 | IP_STR | |
12485 | IPV6_STR | |
12486 | NEIGHBOR_STR | |
12487 | "Neighbor to display information about\n" | |
12488 | "Neighbor to display information about\n" | |
12489 | "Neighbor on BGP configured interface\n" | |
12490 | GR_SHOW | |
12491 | JSON_STR) | |
12492 | { | |
12493 | char *sh_arg = NULL; | |
12494 | enum show_type sh_type; | |
12495 | int idx = 0; | |
12496 | afi_t afi = AFI_MAX; | |
2986cac2 | 12497 | bool uj = use_json(argc, argv); |
12498 | ||
36235319 | 12499 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12500 | afi = AFI_MAX; |
12501 | ||
12502 | idx++; | |
12503 | ||
12504 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12505 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12506 | || argv_find(argv, argc, "WORD", &idx)) { | |
12507 | sh_type = show_peer; | |
12508 | sh_arg = argv[idx]->arg; | |
12509 | } else | |
12510 | sh_type = show_all; | |
12511 | ||
12512 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12513 | return CMD_SUCCESS; | |
12514 | ||
12515 | ||
36235319 QY |
12516 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12517 | afi, uj); | |
2986cac2 | 12518 | } |
12519 | ||
716b2d8a | 12520 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12521 | DEFUN (show_ip_bgp_neighbors, |
12522 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12523 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12524 | SHOW_STR |
12525 | IP_STR | |
12526 | BGP_STR | |
f2a8972b | 12527 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12528 | "Address Family\n" |
12529 | "Address Family\n" | |
718e3744 | 12530 | "Detailed information on TCP and BGP neighbor connections\n" |
12531 | "Neighbor to display information about\n" | |
a80beece | 12532 | "Neighbor to display information about\n" |
91d37724 | 12533 | "Neighbor on BGP configured interface\n" |
9973d184 | 12534 | JSON_STR) |
718e3744 | 12535 | { |
d62a17ae | 12536 | char *vrf = NULL; |
12537 | char *sh_arg = NULL; | |
12538 | enum show_type sh_type; | |
d1927ebe | 12539 | afi_t afi = AFI_MAX; |
718e3744 | 12540 | |
9f049418 | 12541 | bool uj = use_json(argc, argv); |
718e3744 | 12542 | |
d62a17ae | 12543 | int idx = 0; |
718e3744 | 12544 | |
9a8bdf1c PG |
12545 | /* [<vrf> VIEWVRFNAME] */ |
12546 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12547 | vrf = argv[idx + 1]->arg; | |
12548 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12549 | vrf = NULL; | |
12550 | } else if (argv_find(argv, argc, "view", &idx)) | |
12551 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12552 | vrf = argv[idx + 1]->arg; |
718e3744 | 12553 | |
d62a17ae | 12554 | idx++; |
d1927ebe AS |
12555 | |
12556 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12557 | sh_type = show_ipv4_all; | |
12558 | afi = AFI_IP; | |
12559 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12560 | sh_type = show_ipv6_all; | |
12561 | afi = AFI_IP6; | |
12562 | } else { | |
12563 | sh_type = show_all; | |
12564 | } | |
12565 | ||
d62a17ae | 12566 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12567 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12568 | || argv_find(argv, argc, "WORD", &idx)) { | |
12569 | sh_type = show_peer; | |
12570 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12571 | } |
12572 | ||
12573 | if (sh_type == show_peer && afi == AFI_IP) { | |
12574 | sh_type = show_ipv4_peer; | |
12575 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12576 | sh_type = show_ipv6_peer; | |
12577 | } | |
856ca177 | 12578 | |
d62a17ae | 12579 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12580 | } |
12581 | ||
716b2d8a | 12582 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12583 | paths' and `show ip mbgp paths'. Those functions results are the |
12584 | same.*/ | |
f412b39a | 12585 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12586 | show_ip_bgp_paths_cmd, |
46f296b4 | 12587 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12588 | SHOW_STR |
12589 | IP_STR | |
12590 | BGP_STR | |
46f296b4 | 12591 | BGP_SAFI_HELP_STR |
718e3744 | 12592 | "Path information\n") |
12593 | { | |
d62a17ae | 12594 | vty_out(vty, "Address Refcnt Path\n"); |
12595 | aspath_print_all_vty(vty); | |
12596 | return CMD_SUCCESS; | |
718e3744 | 12597 | } |
12598 | ||
718e3744 | 12599 | #include "hash.h" |
12600 | ||
e3b78da8 | 12601 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12602 | struct vty *vty) |
718e3744 | 12603 | { |
d62a17ae | 12604 | struct community *com; |
718e3744 | 12605 | |
e3b78da8 | 12606 | com = (struct community *)bucket->data; |
3f65c5b1 | 12607 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12608 | community_str(com, false)); |
718e3744 | 12609 | } |
12610 | ||
12611 | /* Show BGP's community internal data. */ | |
f412b39a | 12612 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12613 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12614 | "show [ip] bgp community-info", |
718e3744 | 12615 | SHOW_STR |
12616 | IP_STR | |
12617 | BGP_STR | |
12618 | "List all bgp community information\n") | |
12619 | { | |
d62a17ae | 12620 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12621 | |
d62a17ae | 12622 | hash_iterate(community_hash(), |
e3b78da8 | 12623 | (void (*)(struct hash_bucket *, |
d62a17ae | 12624 | void *))community_show_all_iterator, |
12625 | vty); | |
718e3744 | 12626 | |
d62a17ae | 12627 | return CMD_SUCCESS; |
718e3744 | 12628 | } |
12629 | ||
e3b78da8 | 12630 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12631 | struct vty *vty) |
57d187bc | 12632 | { |
d62a17ae | 12633 | struct lcommunity *lcom; |
57d187bc | 12634 | |
e3b78da8 | 12635 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12636 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12637 | lcommunity_str(lcom, false)); |
57d187bc JS |
12638 | } |
12639 | ||
12640 | /* Show BGP's community internal data. */ | |
12641 | DEFUN (show_ip_bgp_lcommunity_info, | |
12642 | show_ip_bgp_lcommunity_info_cmd, | |
12643 | "show ip bgp large-community-info", | |
12644 | SHOW_STR | |
12645 | IP_STR | |
12646 | BGP_STR | |
12647 | "List all bgp large-community information\n") | |
12648 | { | |
d62a17ae | 12649 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12650 | |
d62a17ae | 12651 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12652 | (void (*)(struct hash_bucket *, |
d62a17ae | 12653 | void *))lcommunity_show_all_iterator, |
12654 | vty); | |
57d187bc | 12655 | |
d62a17ae | 12656 | return CMD_SUCCESS; |
57d187bc | 12657 | } |
2986cac2 | 12658 | /* Graceful Restart */ |
12659 | ||
12660 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
12661 | struct bgp *bgp, |
12662 | bool use_json, | |
12663 | json_object *json) | |
2986cac2 | 12664 | { |
57d187bc JS |
12665 | |
12666 | ||
2986cac2 | 12667 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12668 | ||
7318ae88 | 12669 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 12670 | |
12671 | switch (bgp_global_gr_mode) { | |
12672 | ||
12673 | case GLOBAL_HELPER: | |
13909c4f | 12674 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12675 | break; |
12676 | ||
12677 | case GLOBAL_GR: | |
13909c4f | 12678 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12679 | break; |
12680 | ||
12681 | case GLOBAL_DISABLE: | |
13909c4f | 12682 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12683 | break; |
12684 | ||
12685 | case GLOBAL_INVALID: | |
2986cac2 | 12686 | vty_out(vty, |
2ba1fe69 | 12687 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12688 | break; |
12689 | } | |
12690 | vty_out(vty, "\n"); | |
12691 | } | |
12692 | ||
36235319 QY |
12693 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
12694 | enum show_type type, | |
12695 | const char *ip_str, | |
12696 | afi_t afi, bool use_json) | |
2986cac2 | 12697 | { |
12698 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12699 | afi = AFI_IP; | |
12700 | ||
12701 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12702 | ||
36235319 QY |
12703 | bgp_show_neighbor_graceful_restart_vty( |
12704 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 12705 | afi++; |
12706 | } | |
12707 | } else if (afi != AFI_MAX) { | |
36235319 QY |
12708 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
12709 | use_json); | |
2986cac2 | 12710 | } else { |
12711 | return CMD_ERR_INCOMPLETE; | |
12712 | } | |
12713 | ||
12714 | return CMD_SUCCESS; | |
12715 | } | |
12716 | /* Graceful Restart */ | |
12717 | ||
f412b39a | 12718 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12719 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12720 | "show [ip] bgp attribute-info", |
718e3744 | 12721 | SHOW_STR |
12722 | IP_STR | |
12723 | BGP_STR | |
12724 | "List all bgp attribute information\n") | |
12725 | { | |
d62a17ae | 12726 | attr_show_all(vty); |
12727 | return CMD_SUCCESS; | |
718e3744 | 12728 | } |
6b0655a2 | 12729 | |
03915806 CS |
12730 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12731 | afi_t afi, safi_t safi, | |
12732 | bool use_json, json_object *json) | |
53089bec | 12733 | { |
12734 | struct bgp *bgp; | |
12735 | struct listnode *node; | |
12736 | char *vname; | |
12737 | char buf1[INET6_ADDRSTRLEN]; | |
12738 | char *ecom_str; | |
12739 | vpn_policy_direction_t dir; | |
12740 | ||
03915806 | 12741 | if (json) { |
b46dfd20 DS |
12742 | json_object *json_import_vrfs = NULL; |
12743 | json_object *json_export_vrfs = NULL; | |
12744 | ||
b46dfd20 DS |
12745 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12746 | ||
53089bec | 12747 | if (!bgp) { |
b46dfd20 DS |
12748 | vty_out(vty, "%s\n", |
12749 | json_object_to_json_string_ext( | |
12750 | json, | |
12751 | JSON_C_TO_STRING_PRETTY)); | |
12752 | json_object_free(json); | |
12753 | ||
53089bec | 12754 | return CMD_WARNING; |
12755 | } | |
b46dfd20 | 12756 | |
94d4c685 DS |
12757 | /* Provide context for the block */ |
12758 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12759 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12760 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12761 | |
b46dfd20 DS |
12762 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12763 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12764 | json_object_string_add(json, "importFromVrfs", "none"); | |
12765 | json_object_string_add(json, "importRts", "none"); | |
12766 | } else { | |
6ce24e52 DS |
12767 | json_import_vrfs = json_object_new_array(); |
12768 | ||
b46dfd20 DS |
12769 | for (ALL_LIST_ELEMENTS_RO( |
12770 | bgp->vpn_policy[afi].import_vrf, | |
12771 | node, vname)) | |
12772 | json_object_array_add(json_import_vrfs, | |
12773 | json_object_new_string(vname)); | |
12774 | ||
b20875ea CS |
12775 | json_object_object_add(json, "importFromVrfs", |
12776 | json_import_vrfs); | |
b46dfd20 | 12777 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12778 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12779 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12780 | bgp->vpn_policy[afi].rtlist[dir], |
12781 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12782 | json_object_string_add(json, "importRts", |
12783 | ecom_str); | |
12784 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12785 | } else | |
12786 | json_object_string_add(json, "importRts", | |
12787 | "none"); | |
b46dfd20 DS |
12788 | } |
12789 | ||
12790 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12791 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12792 | json_object_string_add(json, "exportToVrfs", "none"); | |
12793 | json_object_string_add(json, "routeDistinguisher", | |
12794 | "none"); | |
12795 | json_object_string_add(json, "exportRts", "none"); | |
12796 | } else { | |
6ce24e52 DS |
12797 | json_export_vrfs = json_object_new_array(); |
12798 | ||
b46dfd20 DS |
12799 | for (ALL_LIST_ELEMENTS_RO( |
12800 | bgp->vpn_policy[afi].export_vrf, | |
12801 | node, vname)) | |
12802 | json_object_array_add(json_export_vrfs, | |
12803 | json_object_new_string(vname)); | |
12804 | json_object_object_add(json, "exportToVrfs", | |
12805 | json_export_vrfs); | |
12806 | json_object_string_add(json, "routeDistinguisher", | |
12807 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12808 | buf1, RD_ADDRSTRLEN)); | |
12809 | ||
12810 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12811 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12812 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12813 | bgp->vpn_policy[afi].rtlist[dir], |
12814 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12815 | json_object_string_add(json, "exportRts", |
12816 | ecom_str); | |
12817 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12818 | } else | |
12819 | json_object_string_add(json, "exportRts", | |
12820 | "none"); | |
b46dfd20 DS |
12821 | } |
12822 | ||
03915806 CS |
12823 | if (use_json) { |
12824 | vty_out(vty, "%s\n", | |
12825 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12826 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12827 | json_object_free(json); |
12828 | } | |
53089bec | 12829 | } else { |
b46dfd20 DS |
12830 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12831 | ||
53089bec | 12832 | if (!bgp) { |
b46dfd20 | 12833 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12834 | return CMD_WARNING; |
12835 | } | |
53089bec | 12836 | |
b46dfd20 DS |
12837 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12838 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12839 | vty_out(vty, | |
12840 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12841 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12842 | else { |
12843 | vty_out(vty, | |
12844 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 12845 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12846 | |
12847 | for (ALL_LIST_ELEMENTS_RO( | |
12848 | bgp->vpn_policy[afi].import_vrf, | |
12849 | node, vname)) | |
12850 | vty_out(vty, " %s\n", vname); | |
12851 | ||
12852 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
12853 | ecom_str = NULL; |
12854 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
12855 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12856 | bgp->vpn_policy[afi].rtlist[dir], |
12857 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 12858 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 12859 | |
b20875ea CS |
12860 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
12861 | } else | |
12862 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12863 | } |
53089bec | 12864 | |
b46dfd20 DS |
12865 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12866 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12867 | vty_out(vty, | |
12868 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 12869 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12870 | else { |
12871 | vty_out(vty, | |
04c9077f | 12872 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 12873 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12874 | |
12875 | for (ALL_LIST_ELEMENTS_RO( | |
12876 | bgp->vpn_policy[afi].export_vrf, | |
12877 | node, vname)) | |
12878 | vty_out(vty, " %s\n", vname); | |
12879 | ||
12880 | vty_out(vty, "RD: %s\n", | |
12881 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12882 | buf1, RD_ADDRSTRLEN)); | |
12883 | ||
12884 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12885 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12886 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12887 | bgp->vpn_policy[afi].rtlist[dir], |
12888 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12889 | vty_out(vty, "Export RT: %s\n", ecom_str); |
12890 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12891 | } else | |
12892 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12893 | } |
53089bec | 12894 | } |
12895 | ||
12896 | return CMD_SUCCESS; | |
12897 | } | |
12898 | ||
03915806 CS |
12899 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
12900 | safi_t safi, bool use_json) | |
12901 | { | |
12902 | struct listnode *node, *nnode; | |
12903 | struct bgp *bgp; | |
12904 | char *vrf_name = NULL; | |
12905 | json_object *json = NULL; | |
12906 | json_object *json_vrf = NULL; | |
12907 | json_object *json_vrfs = NULL; | |
12908 | ||
12909 | if (use_json) { | |
12910 | json = json_object_new_object(); | |
12911 | json_vrfs = json_object_new_object(); | |
12912 | } | |
12913 | ||
12914 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
12915 | ||
12916 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
12917 | vrf_name = bgp->name; | |
12918 | ||
12919 | if (use_json) { | |
12920 | json_vrf = json_object_new_object(); | |
12921 | } else { | |
12922 | vty_out(vty, "\nInstance %s:\n", | |
12923 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12924 | ? VRF_DEFAULT_NAME : bgp->name); | |
12925 | } | |
12926 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
12927 | if (use_json) { | |
12928 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12929 | json_object_object_add(json_vrfs, | |
12930 | VRF_DEFAULT_NAME, json_vrf); | |
12931 | else | |
12932 | json_object_object_add(json_vrfs, vrf_name, | |
12933 | json_vrf); | |
12934 | } | |
12935 | } | |
12936 | ||
12937 | if (use_json) { | |
12938 | json_object_object_add(json, "vrfs", json_vrfs); | |
12939 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
12940 | JSON_C_TO_STRING_PRETTY)); | |
12941 | json_object_free(json); | |
12942 | } | |
12943 | ||
12944 | return CMD_SUCCESS; | |
12945 | } | |
12946 | ||
53089bec | 12947 | /* "show [ip] bgp route-leak" command. */ |
12948 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
12949 | show_ip_bgp_route_leak_cmd, |
12950 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
12951 | SHOW_STR |
12952 | IP_STR | |
12953 | BGP_STR | |
12954 | BGP_INSTANCE_HELP_STR | |
12955 | BGP_AFI_HELP_STR | |
12956 | BGP_SAFI_HELP_STR | |
12957 | "Route leaking information\n" | |
12958 | JSON_STR) | |
53089bec | 12959 | { |
12960 | char *vrf = NULL; | |
12961 | afi_t afi = AFI_MAX; | |
12962 | safi_t safi = SAFI_MAX; | |
12963 | ||
9f049418 | 12964 | bool uj = use_json(argc, argv); |
53089bec | 12965 | int idx = 0; |
03915806 | 12966 | json_object *json = NULL; |
53089bec | 12967 | |
12968 | /* show [ip] bgp */ | |
12969 | if (argv_find(argv, argc, "ip", &idx)) { | |
12970 | afi = AFI_IP; | |
12971 | safi = SAFI_UNICAST; | |
12972 | } | |
12973 | /* [vrf VIEWVRFNAME] */ | |
12974 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
12975 | vty_out(vty, |
12976 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 12977 | return CMD_WARNING; |
12978 | } | |
12979 | ||
9a8bdf1c PG |
12980 | if (argv_find(argv, argc, "vrf", &idx)) { |
12981 | vrf = argv[idx + 1]->arg; | |
12982 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12983 | vrf = NULL; | |
12984 | } | |
53089bec | 12985 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
12986 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
12987 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
12988 | } | |
12989 | ||
12990 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
12991 | vty_out(vty, |
12992 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 12993 | return CMD_WARNING; |
12994 | } | |
12995 | ||
03915806 CS |
12996 | if (vrf && strmatch(vrf, "all")) |
12997 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
12998 | ||
12999 | if (uj) | |
13000 | json = json_object_new_object(); | |
13001 | ||
13002 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13003 | } |
13004 | ||
d62a17ae | 13005 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13006 | safi_t safi) | |
f186de26 | 13007 | { |
d62a17ae | 13008 | struct listnode *node, *nnode; |
13009 | struct bgp *bgp; | |
f186de26 | 13010 | |
d62a17ae | 13011 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13012 | vty_out(vty, "\nInstance %s:\n", | |
13013 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13014 | ? VRF_DEFAULT_NAME |
d62a17ae | 13015 | : bgp->name); |
13016 | update_group_show(bgp, afi, safi, vty, 0); | |
13017 | } | |
f186de26 | 13018 | } |
13019 | ||
d62a17ae | 13020 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13021 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13022 | { |
d62a17ae | 13023 | struct bgp *bgp; |
4fb25c53 | 13024 | |
d62a17ae | 13025 | if (name) { |
13026 | if (strmatch(name, "all")) { | |
13027 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13028 | return CMD_SUCCESS; | |
13029 | } else { | |
13030 | bgp = bgp_lookup_by_name(name); | |
13031 | } | |
13032 | } else { | |
13033 | bgp = bgp_get_default(); | |
13034 | } | |
4fb25c53 | 13035 | |
d62a17ae | 13036 | if (bgp) |
13037 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13038 | return CMD_SUCCESS; | |
4fb25c53 DW |
13039 | } |
13040 | ||
8fe8a7f6 DS |
13041 | DEFUN (show_ip_bgp_updgrps, |
13042 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13043 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13044 | SHOW_STR |
13045 | IP_STR | |
13046 | BGP_STR | |
13047 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13048 | BGP_AFI_HELP_STR |
9bedbb1e | 13049 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13050 | "Detailed info about dynamic update groups\n" |
13051 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13052 | { |
d62a17ae | 13053 | char *vrf = NULL; |
13054 | afi_t afi = AFI_IP6; | |
13055 | safi_t safi = SAFI_UNICAST; | |
13056 | uint64_t subgrp_id = 0; | |
13057 | ||
13058 | int idx = 0; | |
13059 | ||
13060 | /* show [ip] bgp */ | |
13061 | if (argv_find(argv, argc, "ip", &idx)) | |
13062 | afi = AFI_IP; | |
9a8bdf1c PG |
13063 | /* [<vrf> VIEWVRFNAME] */ |
13064 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13065 | vrf = argv[idx + 1]->arg; | |
13066 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13067 | vrf = NULL; | |
13068 | } else if (argv_find(argv, argc, "view", &idx)) | |
13069 | /* [<view> VIEWVRFNAME] */ | |
13070 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13071 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13072 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13073 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13074 | } | |
5bf15956 | 13075 | |
d62a17ae | 13076 | /* get subgroup id, if provided */ |
13077 | idx = argc - 1; | |
13078 | if (argv[idx]->type == VARIABLE_TKN) | |
13079 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13080 | |
d62a17ae | 13081 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13082 | } |
13083 | ||
f186de26 | 13084 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13085 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13086 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13087 | SHOW_STR |
716b2d8a | 13088 | IP_STR |
f186de26 | 13089 | BGP_STR |
13090 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13091 | "Detailed info about dynamic update groups\n") |
f186de26 | 13092 | { |
d62a17ae | 13093 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13094 | return CMD_SUCCESS; | |
f186de26 | 13095 | } |
13096 | ||
43d3f4fc DS |
13097 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13098 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13099 | "show [ip] bgp l2vpn evpn update-groups", | |
13100 | SHOW_STR | |
13101 | IP_STR | |
13102 | BGP_STR | |
13103 | "l2vpn address family\n" | |
13104 | "evpn sub-address family\n" | |
13105 | "Detailed info about dynamic update groups\n") | |
13106 | { | |
13107 | char *vrf = NULL; | |
13108 | uint64_t subgrp_id = 0; | |
13109 | ||
13110 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13111 | return CMD_SUCCESS; | |
13112 | } | |
13113 | ||
5bf15956 DW |
13114 | DEFUN (show_bgp_updgrps_stats, |
13115 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13116 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13117 | SHOW_STR |
716b2d8a | 13118 | IP_STR |
3f9c7369 | 13119 | BGP_STR |
0c7b1b01 | 13120 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13121 | "Statistics\n") |
13122 | { | |
d62a17ae | 13123 | struct bgp *bgp; |
3f9c7369 | 13124 | |
d62a17ae | 13125 | bgp = bgp_get_default(); |
13126 | if (bgp) | |
13127 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13128 | |
d62a17ae | 13129 | return CMD_SUCCESS; |
3f9c7369 DS |
13130 | } |
13131 | ||
8386ac43 | 13132 | DEFUN (show_bgp_instance_updgrps_stats, |
13133 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13134 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13135 | SHOW_STR |
716b2d8a | 13136 | IP_STR |
8386ac43 | 13137 | BGP_STR |
13138 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13139 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13140 | "Statistics\n") |
13141 | { | |
d62a17ae | 13142 | int idx_word = 3; |
13143 | struct bgp *bgp; | |
8386ac43 | 13144 | |
d62a17ae | 13145 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13146 | if (bgp) | |
13147 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13148 | |
d62a17ae | 13149 | return CMD_SUCCESS; |
8386ac43 | 13150 | } |
13151 | ||
d62a17ae | 13152 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13153 | afi_t afi, safi_t safi, | |
13154 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13155 | { |
d62a17ae | 13156 | struct bgp *bgp; |
8386ac43 | 13157 | |
d62a17ae | 13158 | if (name) |
13159 | bgp = bgp_lookup_by_name(name); | |
13160 | else | |
13161 | bgp = bgp_get_default(); | |
8386ac43 | 13162 | |
d62a17ae | 13163 | if (bgp) { |
13164 | if (!strcmp(what, "advertise-queue")) | |
13165 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13166 | subgrp_id); | |
13167 | else if (!strcmp(what, "advertised-routes")) | |
13168 | update_group_show_advertised(bgp, afi, safi, vty, | |
13169 | subgrp_id); | |
13170 | else if (!strcmp(what, "packet-queue")) | |
13171 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13172 | subgrp_id); | |
13173 | } | |
3f9c7369 DS |
13174 | } |
13175 | ||
dc64bdec QY |
13176 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13177 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13178 | "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", | |
13179 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13180 | BGP_SAFI_HELP_STR | |
13181 | "Detailed info about dynamic update groups\n" | |
13182 | "Specific subgroup to display info for\n" | |
13183 | "Advertisement queue\n" | |
13184 | "Announced routes\n" | |
13185 | "Packet queue\n") | |
3f9c7369 | 13186 | { |
dc64bdec QY |
13187 | uint64_t subgrp_id = 0; |
13188 | afi_t afiz; | |
13189 | safi_t safiz; | |
13190 | if (sgid) | |
13191 | subgrp_id = strtoull(sgid, NULL, 10); | |
13192 | ||
13193 | if (!ip && !afi) | |
13194 | afiz = AFI_IP6; | |
13195 | if (!ip && afi) | |
13196 | afiz = bgp_vty_afi_from_str(afi); | |
13197 | if (ip && !afi) | |
13198 | afiz = AFI_IP; | |
13199 | if (ip && afi) { | |
13200 | afiz = bgp_vty_afi_from_str(afi); | |
13201 | if (afiz != AFI_IP) | |
13202 | vty_out(vty, | |
13203 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13204 | return CMD_WARNING; | |
13205 | } | |
d62a17ae | 13206 | |
dc64bdec | 13207 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13208 | |
dc64bdec | 13209 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13210 | return CMD_SUCCESS; |
13211 | } | |
13212 | ||
d62a17ae | 13213 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13214 | { | |
13215 | struct listnode *node, *nnode; | |
13216 | struct prefix *range; | |
13217 | struct peer *conf; | |
13218 | struct peer *peer; | |
13219 | char buf[PREFIX2STR_BUFFER]; | |
13220 | afi_t afi; | |
13221 | safi_t safi; | |
13222 | const char *peer_status; | |
13223 | const char *af_str; | |
13224 | int lr_count; | |
13225 | int dynamic; | |
13226 | int af_cfgd; | |
13227 | ||
13228 | conf = group->conf; | |
13229 | ||
13230 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13231 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13232 | group->name, conf->as); | |
d62a17ae | 13233 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13234 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13235 | group->name, group->bgp->as); | |
d62a17ae | 13236 | } else { |
13237 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13238 | } | |
f14e6fdb | 13239 | |
d62a17ae | 13240 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13241 | vty_out(vty, " Peer-group type is internal\n"); | |
13242 | else | |
13243 | vty_out(vty, " Peer-group type is external\n"); | |
13244 | ||
13245 | /* Display AFs configured. */ | |
13246 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13247 | FOREACH_AFI_SAFI (afi, safi) { |
13248 | if (conf->afc[afi][safi]) { | |
13249 | af_cfgd = 1; | |
5cb5f4d0 | 13250 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13251 | } |
05c7a1cc | 13252 | } |
d62a17ae | 13253 | if (!af_cfgd) |
13254 | vty_out(vty, " none\n"); | |
13255 | else | |
13256 | vty_out(vty, "\n"); | |
13257 | ||
13258 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13259 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13260 | if (afi == AFI_IP) | |
13261 | af_str = "IPv4"; | |
13262 | else if (afi == AFI_IP6) | |
13263 | af_str = "IPv6"; | |
13264 | else | |
13265 | af_str = "???"; | |
13266 | lr_count = listcount(group->listen_range[afi]); | |
13267 | if (lr_count) { | |
13268 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13269 | af_str); | |
13270 | ||
13271 | ||
13272 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13273 | nnode, range)) { | |
13274 | prefix2str(range, buf, sizeof(buf)); | |
13275 | vty_out(vty, " %s\n", buf); | |
13276 | } | |
13277 | } | |
13278 | } | |
f14e6fdb | 13279 | |
d62a17ae | 13280 | /* Display group members and their status */ |
13281 | if (listcount(group->peer)) { | |
13282 | vty_out(vty, " Peer-group members:\n"); | |
13283 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13284 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13285 | peer_status = "Idle (Admin)"; | |
13286 | else if (CHECK_FLAG(peer->sflags, | |
13287 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13288 | peer_status = "Idle (PfxCt)"; | |
13289 | else | |
13290 | peer_status = lookup_msg(bgp_status_msg, | |
13291 | peer->status, NULL); | |
13292 | ||
13293 | dynamic = peer_dynamic_neighbor(peer); | |
13294 | vty_out(vty, " %s %s %s \n", peer->host, | |
13295 | dynamic ? "(dynamic)" : "", peer_status); | |
13296 | } | |
13297 | } | |
f14e6fdb | 13298 | |
d62a17ae | 13299 | return CMD_SUCCESS; |
13300 | } | |
13301 | ||
ff9959b0 QY |
13302 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13303 | const char *group_name) | |
d62a17ae | 13304 | { |
ff9959b0 | 13305 | struct bgp *bgp; |
d62a17ae | 13306 | struct listnode *node, *nnode; |
13307 | struct peer_group *group; | |
ff9959b0 QY |
13308 | bool found = false; |
13309 | ||
13310 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13311 | ||
13312 | if (!bgp) { | |
9f049418 | 13313 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13314 | return CMD_WARNING; |
13315 | } | |
d62a17ae | 13316 | |
13317 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13318 | if (group_name) { |
13319 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13320 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13321 | found = true; |
13322 | break; | |
d62a17ae | 13323 | } |
ff9959b0 QY |
13324 | } else { |
13325 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13326 | } |
f14e6fdb | 13327 | } |
f14e6fdb | 13328 | |
ff9959b0 | 13329 | if (group_name && !found) |
d62a17ae | 13330 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13331 | |
d62a17ae | 13332 | return CMD_SUCCESS; |
f14e6fdb DS |
13333 | } |
13334 | ||
f14e6fdb DS |
13335 | DEFUN (show_ip_bgp_peer_groups, |
13336 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13337 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13338 | SHOW_STR |
13339 | IP_STR | |
13340 | BGP_STR | |
8386ac43 | 13341 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13342 | "Detailed information on BGP peer groups\n" |
13343 | "Peer group name\n") | |
f14e6fdb | 13344 | { |
d62a17ae | 13345 | char *vrf, *pg; |
d62a17ae | 13346 | int idx = 0; |
f14e6fdb | 13347 | |
a4d82a8a PZ |
13348 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13349 | : NULL; | |
d62a17ae | 13350 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13351 | |
ff9959b0 | 13352 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13353 | } |
3f9c7369 | 13354 | |
d6e3c605 | 13355 | |
718e3744 | 13356 | /* Redistribute VTY commands. */ |
13357 | ||
718e3744 | 13358 | DEFUN (bgp_redistribute_ipv4, |
13359 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13360 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13361 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13362 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13363 | { |
d62a17ae | 13364 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13365 | int idx_protocol = 1; | |
13366 | int type; | |
718e3744 | 13367 | |
d62a17ae | 13368 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13369 | if (type < 0) { | |
13370 | vty_out(vty, "%% Invalid route type\n"); | |
13371 | return CMD_WARNING_CONFIG_FAILED; | |
13372 | } | |
7f323236 | 13373 | |
d62a17ae | 13374 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13375 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13376 | } |
13377 | ||
d62a17ae | 13378 | ALIAS_HIDDEN( |
13379 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13380 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13381 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13382 | |
718e3744 | 13383 | DEFUN (bgp_redistribute_ipv4_rmap, |
13384 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13385 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13386 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13387 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13388 | "Route map reference\n" |
13389 | "Pointer to route-map entries\n") | |
13390 | { | |
d62a17ae | 13391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13392 | int idx_protocol = 1; | |
13393 | int idx_word = 3; | |
13394 | int type; | |
13395 | struct bgp_redist *red; | |
e923dd62 | 13396 | bool changed; |
1de27621 DA |
13397 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13398 | vty, argv[idx_word]->arg); | |
718e3744 | 13399 | |
d62a17ae | 13400 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13401 | if (type < 0) { | |
13402 | vty_out(vty, "%% Invalid route type\n"); | |
13403 | return CMD_WARNING_CONFIG_FAILED; | |
13404 | } | |
718e3744 | 13405 | |
d62a17ae | 13406 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13407 | changed = |
13408 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13409 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13410 | } |
13411 | ||
d62a17ae | 13412 | ALIAS_HIDDEN( |
13413 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13414 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13415 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13416 | "Route map reference\n" | |
13417 | "Pointer to route-map entries\n") | |
596c17ba | 13418 | |
718e3744 | 13419 | DEFUN (bgp_redistribute_ipv4_metric, |
13420 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13421 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13422 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13423 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13424 | "Metric for redistributed routes\n" |
13425 | "Default metric\n") | |
13426 | { | |
d62a17ae | 13427 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13428 | int idx_protocol = 1; | |
13429 | int idx_number = 3; | |
13430 | int type; | |
d7c0a89a | 13431 | uint32_t metric; |
d62a17ae | 13432 | struct bgp_redist *red; |
e923dd62 | 13433 | bool changed; |
d62a17ae | 13434 | |
13435 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13436 | if (type < 0) { | |
13437 | vty_out(vty, "%% Invalid route type\n"); | |
13438 | return CMD_WARNING_CONFIG_FAILED; | |
13439 | } | |
13440 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13441 | ||
13442 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13443 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13444 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13445 | } |
13446 | ||
13447 | ALIAS_HIDDEN( | |
13448 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13449 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13450 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13451 | "Metric for redistributed routes\n" | |
13452 | "Default metric\n") | |
596c17ba | 13453 | |
718e3744 | 13454 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13455 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13456 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13457 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13458 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13459 | "Route map reference\n" |
13460 | "Pointer to route-map entries\n" | |
13461 | "Metric for redistributed routes\n" | |
13462 | "Default metric\n") | |
13463 | { | |
d62a17ae | 13464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13465 | int idx_protocol = 1; | |
13466 | int idx_word = 3; | |
13467 | int idx_number = 5; | |
13468 | int type; | |
d7c0a89a | 13469 | uint32_t metric; |
d62a17ae | 13470 | struct bgp_redist *red; |
e923dd62 | 13471 | bool changed; |
1de27621 DA |
13472 | struct route_map *route_map = |
13473 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13474 | |
13475 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13476 | if (type < 0) { | |
13477 | vty_out(vty, "%% Invalid route type\n"); | |
13478 | return CMD_WARNING_CONFIG_FAILED; | |
13479 | } | |
13480 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13481 | ||
13482 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13483 | changed = |
13484 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13485 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13486 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13487 | } |
13488 | ||
13489 | ALIAS_HIDDEN( | |
13490 | bgp_redistribute_ipv4_rmap_metric, | |
13491 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13492 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13493 | " route-map WORD metric (0-4294967295)", | |
13494 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13495 | "Route map reference\n" | |
13496 | "Pointer to route-map entries\n" | |
13497 | "Metric for redistributed routes\n" | |
13498 | "Default metric\n") | |
596c17ba | 13499 | |
718e3744 | 13500 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13501 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13502 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13503 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13504 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13505 | "Metric for redistributed routes\n" |
13506 | "Default metric\n" | |
13507 | "Route map reference\n" | |
13508 | "Pointer to route-map entries\n") | |
13509 | { | |
d62a17ae | 13510 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13511 | int idx_protocol = 1; | |
13512 | int idx_number = 3; | |
13513 | int idx_word = 5; | |
13514 | int type; | |
d7c0a89a | 13515 | uint32_t metric; |
d62a17ae | 13516 | struct bgp_redist *red; |
e923dd62 | 13517 | bool changed; |
1de27621 DA |
13518 | struct route_map *route_map = |
13519 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13520 | |
13521 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13522 | if (type < 0) { | |
13523 | vty_out(vty, "%% Invalid route type\n"); | |
13524 | return CMD_WARNING_CONFIG_FAILED; | |
13525 | } | |
13526 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13527 | ||
13528 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13529 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13530 | changed |= |
13531 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13532 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13533 | } |
13534 | ||
13535 | ALIAS_HIDDEN( | |
13536 | bgp_redistribute_ipv4_metric_rmap, | |
13537 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13538 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13539 | " metric (0-4294967295) route-map WORD", | |
13540 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13541 | "Metric for redistributed routes\n" | |
13542 | "Default metric\n" | |
13543 | "Route map reference\n" | |
13544 | "Pointer to route-map entries\n") | |
596c17ba | 13545 | |
7c8ff89e DS |
13546 | DEFUN (bgp_redistribute_ipv4_ospf, |
13547 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13548 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13549 | "Redistribute information from another routing protocol\n" |
13550 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13551 | "Non-main Kernel Routing Table\n" |
13552 | "Instance ID/Table ID\n") | |
7c8ff89e | 13553 | { |
d62a17ae | 13554 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13555 | int idx_ospf_table = 1; | |
13556 | int idx_number = 2; | |
d7c0a89a QY |
13557 | unsigned short instance; |
13558 | unsigned short protocol; | |
7c8ff89e | 13559 | |
d62a17ae | 13560 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13561 | |
d62a17ae | 13562 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13563 | protocol = ZEBRA_ROUTE_OSPF; | |
13564 | else | |
13565 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13566 | |
d62a17ae | 13567 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13568 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13569 | } |
13570 | ||
d62a17ae | 13571 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13572 | "redistribute <ospf|table> (1-65535)", | |
13573 | "Redistribute information from another routing protocol\n" | |
13574 | "Open Shortest Path First (OSPFv2)\n" | |
13575 | "Non-main Kernel Routing Table\n" | |
13576 | "Instance ID/Table ID\n") | |
596c17ba | 13577 | |
7c8ff89e DS |
13578 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13579 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13580 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13581 | "Redistribute information from another routing protocol\n" |
13582 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13583 | "Non-main Kernel Routing Table\n" |
13584 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13585 | "Route map reference\n" |
13586 | "Pointer to route-map entries\n") | |
13587 | { | |
d62a17ae | 13588 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13589 | int idx_ospf_table = 1; | |
13590 | int idx_number = 2; | |
13591 | int idx_word = 4; | |
13592 | struct bgp_redist *red; | |
d7c0a89a | 13593 | unsigned short instance; |
d62a17ae | 13594 | int protocol; |
e923dd62 | 13595 | bool changed; |
1de27621 DA |
13596 | struct route_map *route_map = |
13597 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13598 | |
13599 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13600 | protocol = ZEBRA_ROUTE_OSPF; | |
13601 | else | |
13602 | protocol = ZEBRA_ROUTE_TABLE; | |
13603 | ||
13604 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13605 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13606 | changed = |
13607 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13608 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13609 | } |
13610 | ||
13611 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13612 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13613 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13614 | "Redistribute information from another routing protocol\n" | |
13615 | "Open Shortest Path First (OSPFv2)\n" | |
13616 | "Non-main Kernel Routing Table\n" | |
13617 | "Instance ID/Table ID\n" | |
13618 | "Route map reference\n" | |
13619 | "Pointer to route-map entries\n") | |
596c17ba | 13620 | |
7c8ff89e DS |
13621 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13622 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13623 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13624 | "Redistribute information from another routing protocol\n" |
13625 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13626 | "Non-main Kernel Routing Table\n" |
13627 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13628 | "Metric for redistributed routes\n" |
13629 | "Default metric\n") | |
13630 | { | |
d62a17ae | 13631 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13632 | int idx_ospf_table = 1; | |
13633 | int idx_number = 2; | |
13634 | int idx_number_2 = 4; | |
d7c0a89a | 13635 | uint32_t metric; |
d62a17ae | 13636 | struct bgp_redist *red; |
d7c0a89a | 13637 | unsigned short instance; |
d62a17ae | 13638 | int protocol; |
e923dd62 | 13639 | bool changed; |
d62a17ae | 13640 | |
13641 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13642 | protocol = ZEBRA_ROUTE_OSPF; | |
13643 | else | |
13644 | protocol = ZEBRA_ROUTE_TABLE; | |
13645 | ||
13646 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13647 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13648 | ||
13649 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13650 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13651 | metric); | |
13652 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13653 | } |
13654 | ||
13655 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13656 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13657 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13658 | "Redistribute information from another routing protocol\n" | |
13659 | "Open Shortest Path First (OSPFv2)\n" | |
13660 | "Non-main Kernel Routing Table\n" | |
13661 | "Instance ID/Table ID\n" | |
13662 | "Metric for redistributed routes\n" | |
13663 | "Default metric\n") | |
596c17ba | 13664 | |
7c8ff89e DS |
13665 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13666 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13667 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13668 | "Redistribute information from another routing protocol\n" |
13669 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13670 | "Non-main Kernel Routing Table\n" |
13671 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13672 | "Route map reference\n" |
13673 | "Pointer to route-map entries\n" | |
13674 | "Metric for redistributed routes\n" | |
13675 | "Default metric\n") | |
13676 | { | |
d62a17ae | 13677 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13678 | int idx_ospf_table = 1; | |
13679 | int idx_number = 2; | |
13680 | int idx_word = 4; | |
13681 | int idx_number_2 = 6; | |
d7c0a89a | 13682 | uint32_t metric; |
d62a17ae | 13683 | struct bgp_redist *red; |
d7c0a89a | 13684 | unsigned short instance; |
d62a17ae | 13685 | int protocol; |
e923dd62 | 13686 | bool changed; |
1de27621 DA |
13687 | struct route_map *route_map = |
13688 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13689 | |
13690 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13691 | protocol = ZEBRA_ROUTE_OSPF; | |
13692 | else | |
13693 | protocol = ZEBRA_ROUTE_TABLE; | |
13694 | ||
13695 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13696 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13697 | ||
13698 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13699 | changed = |
13700 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13701 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13702 | metric); | |
13703 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13704 | } |
13705 | ||
13706 | ALIAS_HIDDEN( | |
13707 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13708 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13709 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13710 | "Redistribute information from another routing protocol\n" | |
13711 | "Open Shortest Path First (OSPFv2)\n" | |
13712 | "Non-main Kernel Routing Table\n" | |
13713 | "Instance ID/Table ID\n" | |
13714 | "Route map reference\n" | |
13715 | "Pointer to route-map entries\n" | |
13716 | "Metric for redistributed routes\n" | |
13717 | "Default metric\n") | |
596c17ba | 13718 | |
7c8ff89e DS |
13719 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13720 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13721 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13722 | "Redistribute information from another routing protocol\n" |
13723 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13724 | "Non-main Kernel Routing Table\n" |
13725 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13726 | "Metric for redistributed routes\n" |
13727 | "Default metric\n" | |
13728 | "Route map reference\n" | |
13729 | "Pointer to route-map entries\n") | |
13730 | { | |
d62a17ae | 13731 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13732 | int idx_ospf_table = 1; | |
13733 | int idx_number = 2; | |
13734 | int idx_number_2 = 4; | |
13735 | int idx_word = 6; | |
d7c0a89a | 13736 | uint32_t metric; |
d62a17ae | 13737 | struct bgp_redist *red; |
d7c0a89a | 13738 | unsigned short instance; |
d62a17ae | 13739 | int protocol; |
e923dd62 | 13740 | bool changed; |
1de27621 DA |
13741 | struct route_map *route_map = |
13742 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13743 | |
13744 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13745 | protocol = ZEBRA_ROUTE_OSPF; | |
13746 | else | |
13747 | protocol = ZEBRA_ROUTE_TABLE; | |
13748 | ||
13749 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13750 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13751 | ||
13752 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13753 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13754 | metric); | |
1de27621 DA |
13755 | changed |= |
13756 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13757 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13758 | } |
13759 | ||
13760 | ALIAS_HIDDEN( | |
13761 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13762 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13763 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13764 | "Redistribute information from another routing protocol\n" | |
13765 | "Open Shortest Path First (OSPFv2)\n" | |
13766 | "Non-main Kernel Routing Table\n" | |
13767 | "Instance ID/Table ID\n" | |
13768 | "Metric for redistributed routes\n" | |
13769 | "Default metric\n" | |
13770 | "Route map reference\n" | |
13771 | "Pointer to route-map entries\n") | |
596c17ba | 13772 | |
7c8ff89e DS |
13773 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13774 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13775 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13776 | NO_STR |
13777 | "Redistribute information from another routing protocol\n" | |
13778 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13779 | "Non-main Kernel Routing Table\n" |
31500417 DW |
13780 | "Instance ID/Table ID\n" |
13781 | "Metric for redistributed routes\n" | |
13782 | "Default metric\n" | |
13783 | "Route map reference\n" | |
13784 | "Pointer to route-map entries\n") | |
7c8ff89e | 13785 | { |
d62a17ae | 13786 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13787 | int idx_ospf_table = 2; | |
13788 | int idx_number = 3; | |
d7c0a89a | 13789 | unsigned short instance; |
d62a17ae | 13790 | int protocol; |
13791 | ||
13792 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13793 | protocol = ZEBRA_ROUTE_OSPF; | |
13794 | else | |
13795 | protocol = ZEBRA_ROUTE_TABLE; | |
13796 | ||
13797 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13798 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13799 | } | |
13800 | ||
13801 | ALIAS_HIDDEN( | |
13802 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13803 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13804 | NO_STR |
13805 | "Redistribute information from another routing protocol\n" | |
13806 | "Open Shortest Path First (OSPFv2)\n" | |
13807 | "Non-main Kernel Routing Table\n" | |
13808 | "Instance ID/Table ID\n" | |
13809 | "Metric for redistributed routes\n" | |
13810 | "Default metric\n" | |
13811 | "Route map reference\n" | |
13812 | "Pointer to route-map entries\n") | |
596c17ba | 13813 | |
718e3744 | 13814 | DEFUN (no_bgp_redistribute_ipv4, |
13815 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13816 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13817 | NO_STR |
13818 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13819 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13820 | "Metric for redistributed routes\n" |
13821 | "Default metric\n" | |
13822 | "Route map reference\n" | |
13823 | "Pointer to route-map entries\n") | |
718e3744 | 13824 | { |
d62a17ae | 13825 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13826 | int idx_protocol = 2; | |
13827 | int type; | |
13828 | ||
13829 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13830 | if (type < 0) { | |
13831 | vty_out(vty, "%% Invalid route type\n"); | |
13832 | return CMD_WARNING_CONFIG_FAILED; | |
13833 | } | |
13834 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13835 | } | |
13836 | ||
13837 | ALIAS_HIDDEN( | |
13838 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13839 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13840 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13841 | NO_STR |
13842 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13843 | "Metric for redistributed routes\n" | |
13844 | "Default metric\n" | |
13845 | "Route map reference\n" | |
13846 | "Pointer to route-map entries\n") | |
596c17ba | 13847 | |
718e3744 | 13848 | DEFUN (bgp_redistribute_ipv6, |
13849 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 13850 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 13851 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13852 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 13853 | { |
d62a17ae | 13854 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13855 | int idx_protocol = 1; | |
13856 | int type; | |
718e3744 | 13857 | |
d62a17ae | 13858 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13859 | if (type < 0) { | |
13860 | vty_out(vty, "%% Invalid route type\n"); | |
13861 | return CMD_WARNING_CONFIG_FAILED; | |
13862 | } | |
718e3744 | 13863 | |
d62a17ae | 13864 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13865 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 13866 | } |
13867 | ||
13868 | DEFUN (bgp_redistribute_ipv6_rmap, | |
13869 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 13870 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13871 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13872 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13873 | "Route map reference\n" |
13874 | "Pointer to route-map entries\n") | |
13875 | { | |
d62a17ae | 13876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13877 | int idx_protocol = 1; | |
13878 | int idx_word = 3; | |
13879 | int type; | |
13880 | struct bgp_redist *red; | |
e923dd62 | 13881 | bool changed; |
1de27621 DA |
13882 | struct route_map *route_map = |
13883 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 13884 | |
d62a17ae | 13885 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13886 | if (type < 0) { | |
13887 | vty_out(vty, "%% Invalid route type\n"); | |
13888 | return CMD_WARNING_CONFIG_FAILED; | |
13889 | } | |
718e3744 | 13890 | |
d62a17ae | 13891 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13892 | changed = |
13893 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13894 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13895 | } |
13896 | ||
13897 | DEFUN (bgp_redistribute_ipv6_metric, | |
13898 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 13899 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13900 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13901 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13902 | "Metric for redistributed routes\n" |
13903 | "Default metric\n") | |
13904 | { | |
d62a17ae | 13905 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13906 | int idx_protocol = 1; | |
13907 | int idx_number = 3; | |
13908 | int type; | |
d7c0a89a | 13909 | uint32_t metric; |
d62a17ae | 13910 | struct bgp_redist *red; |
e923dd62 | 13911 | bool changed; |
d62a17ae | 13912 | |
13913 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13914 | if (type < 0) { | |
13915 | vty_out(vty, "%% Invalid route type\n"); | |
13916 | return CMD_WARNING_CONFIG_FAILED; | |
13917 | } | |
13918 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13919 | |
d62a17ae | 13920 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13921 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
13922 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13923 | } |
13924 | ||
13925 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
13926 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 13927 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13928 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13929 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13930 | "Route map reference\n" |
13931 | "Pointer to route-map entries\n" | |
13932 | "Metric for redistributed routes\n" | |
13933 | "Default metric\n") | |
13934 | { | |
d62a17ae | 13935 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13936 | int idx_protocol = 1; | |
13937 | int idx_word = 3; | |
13938 | int idx_number = 5; | |
13939 | int type; | |
d7c0a89a | 13940 | uint32_t metric; |
d62a17ae | 13941 | struct bgp_redist *red; |
e923dd62 | 13942 | bool changed; |
1de27621 DA |
13943 | struct route_map *route_map = |
13944 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13945 | |
13946 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13947 | if (type < 0) { | |
13948 | vty_out(vty, "%% Invalid route type\n"); | |
13949 | return CMD_WARNING_CONFIG_FAILED; | |
13950 | } | |
13951 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13952 | |
d62a17ae | 13953 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13954 | changed = |
13955 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13956 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
13957 | metric); | |
13958 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13959 | } |
13960 | ||
13961 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
13962 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 13963 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13964 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13965 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13966 | "Metric for redistributed routes\n" |
13967 | "Default metric\n" | |
13968 | "Route map reference\n" | |
13969 | "Pointer to route-map entries\n") | |
13970 | { | |
d62a17ae | 13971 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13972 | int idx_protocol = 1; | |
13973 | int idx_number = 3; | |
13974 | int idx_word = 5; | |
13975 | int type; | |
d7c0a89a | 13976 | uint32_t metric; |
d62a17ae | 13977 | struct bgp_redist *red; |
e923dd62 | 13978 | bool changed; |
1de27621 DA |
13979 | struct route_map *route_map = |
13980 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13981 | |
13982 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13983 | if (type < 0) { | |
13984 | vty_out(vty, "%% Invalid route type\n"); | |
13985 | return CMD_WARNING_CONFIG_FAILED; | |
13986 | } | |
13987 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13988 | |
d62a17ae | 13989 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13990 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
13991 | metric); | |
1de27621 DA |
13992 | changed |= |
13993 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13994 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13995 | } |
13996 | ||
13997 | DEFUN (no_bgp_redistribute_ipv6, | |
13998 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 13999 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14000 | NO_STR |
14001 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14002 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14003 | "Metric for redistributed routes\n" |
14004 | "Default metric\n" | |
14005 | "Route map reference\n" | |
14006 | "Pointer to route-map entries\n") | |
718e3744 | 14007 | { |
d62a17ae | 14008 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14009 | int idx_protocol = 2; | |
14010 | int type; | |
718e3744 | 14011 | |
d62a17ae | 14012 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14013 | if (type < 0) { | |
14014 | vty_out(vty, "%% Invalid route type\n"); | |
14015 | return CMD_WARNING_CONFIG_FAILED; | |
14016 | } | |
718e3744 | 14017 | |
d62a17ae | 14018 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14019 | } | |
14020 | ||
dd65f45e DL |
14021 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14022 | afi_t afi, safi_t safi) | |
d62a17ae | 14023 | { |
14024 | int i; | |
14025 | ||
14026 | /* Unicast redistribution only. */ | |
14027 | if (safi != SAFI_UNICAST) | |
2b791107 | 14028 | return; |
d62a17ae | 14029 | |
14030 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14031 | /* Redistribute BGP does not make sense. */ | |
14032 | if (i != ZEBRA_ROUTE_BGP) { | |
14033 | struct list *red_list; | |
14034 | struct listnode *node; | |
14035 | struct bgp_redist *red; | |
14036 | ||
14037 | red_list = bgp->redist[afi][i]; | |
14038 | if (!red_list) | |
14039 | continue; | |
14040 | ||
14041 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14042 | /* "redistribute" configuration. */ |
14043 | vty_out(vty, " redistribute %s", | |
14044 | zebra_route_string(i)); | |
14045 | if (red->instance) | |
14046 | vty_out(vty, " %d", red->instance); | |
14047 | if (red->redist_metric_flag) | |
14048 | vty_out(vty, " metric %u", | |
14049 | red->redist_metric); | |
14050 | if (red->rmap.name) | |
14051 | vty_out(vty, " route-map %s", | |
14052 | red->rmap.name); | |
14053 | vty_out(vty, "\n"); | |
14054 | } | |
14055 | } | |
14056 | } | |
718e3744 | 14057 | } |
6b0655a2 | 14058 | |
dd65f45e DL |
14059 | /* peer-group helpers for config-write */ |
14060 | ||
14061 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14062 | { | |
14063 | if (!peer_group_active(peer)) { | |
14064 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14065 | return !CHECK_FLAG(peer->flags, flag); | |
14066 | else | |
14067 | return !!CHECK_FLAG(peer->flags, flag); | |
14068 | } | |
14069 | ||
14070 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14071 | } | |
14072 | ||
14073 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14074 | uint32_t flag) | |
14075 | { | |
14076 | if (!peer_group_active(peer)) { | |
14077 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14078 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14079 | else | |
14080 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14081 | } | |
14082 | ||
14083 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14084 | } | |
14085 | ||
14086 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14087 | uint8_t type, int direct) | |
14088 | { | |
14089 | struct bgp_filter *filter; | |
14090 | ||
14091 | if (peer_group_active(peer)) | |
14092 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14093 | type); | |
14094 | ||
14095 | filter = &peer->filter[afi][safi]; | |
14096 | switch (type) { | |
14097 | case PEER_FT_DISTRIBUTE_LIST: | |
14098 | return !!(filter->dlist[direct].name); | |
14099 | case PEER_FT_FILTER_LIST: | |
14100 | return !!(filter->aslist[direct].name); | |
14101 | case PEER_FT_PREFIX_LIST: | |
14102 | return !!(filter->plist[direct].name); | |
14103 | case PEER_FT_ROUTE_MAP: | |
14104 | return !!(filter->map[direct].name); | |
14105 | case PEER_FT_UNSUPPRESS_MAP: | |
14106 | return !!(filter->usmap.name); | |
14107 | default: | |
14108 | return false; | |
14109 | } | |
14110 | } | |
14111 | ||
14112 | /* Return true if the addpath type is set for peer and different from | |
14113 | * peer-group. | |
14114 | */ | |
14115 | static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi) | |
14116 | { | |
14117 | enum bgp_addpath_strat type, g_type; | |
14118 | ||
14119 | type = peer->addpath_type[afi][safi]; | |
14120 | ||
14121 | if (type != BGP_ADDPATH_NONE) { | |
14122 | if (peer_group_active(peer)) { | |
14123 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14124 | ||
14125 | if (type != g_type) | |
14126 | return 1; | |
14127 | else | |
14128 | return 0; | |
14129 | } | |
14130 | ||
14131 | return 1; | |
14132 | } | |
14133 | ||
14134 | return 0; | |
14135 | } | |
14136 | ||
b9c7bc5a | 14137 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14138 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14139 | afi_t afi) |
14140 | { | |
b9c7bc5a | 14141 | int indent = 2; |
ddb5b488 | 14142 | |
8a066a70 PG |
14143 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
14144 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
14145 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
14146 | bgp->vpn_policy[afi] | |
bb4f6190 | 14147 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14148 | else |
14149 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14150 | bgp->vpn_policy[afi] | |
14151 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14152 | } | |
12a844a5 DS |
14153 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14154 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14155 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14156 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14157 | return; | |
14158 | ||
e70e9f8e PZ |
14159 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14160 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14161 | ||
14162 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14163 | ||
14164 | } else { | |
14165 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14166 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14167 | bgp->vpn_policy[afi].tovpn_label); | |
14168 | } | |
ddb5b488 PZ |
14169 | } |
14170 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14171 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14172 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14173 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14174 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14175 | sizeof(buf))); | |
14176 | } | |
14177 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14178 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14179 | ||
14180 | char buf[PREFIX_STRLEN]; | |
14181 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14182 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14183 | sizeof(buf))) { | |
14184 | ||
b9c7bc5a PZ |
14185 | vty_out(vty, "%*snexthop vpn export %s\n", |
14186 | indent, "", buf); | |
ddb5b488 PZ |
14187 | } |
14188 | } | |
14189 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14190 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14191 | && ecommunity_cmp( | |
14192 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14193 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14194 | ||
14195 | char *b = ecommunity_ecom2str( | |
14196 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14197 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14198 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14199 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14200 | } else { | |
14201 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14202 | char *b = ecommunity_ecom2str( | |
14203 | bgp->vpn_policy[afi] | |
14204 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14205 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14206 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14207 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14208 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14209 | } | |
14210 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14211 | char *b = ecommunity_ecom2str( | |
14212 | bgp->vpn_policy[afi] | |
14213 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14214 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14215 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14216 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14217 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14218 | } | |
14219 | } | |
bb4f6190 DS |
14220 | |
14221 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14222 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14223 | bgp->vpn_policy[afi] |
14224 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14225 | |
301ad80a PG |
14226 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14227 | char *b = ecommunity_ecom2str( | |
14228 | bgp->vpn_policy[afi] | |
14229 | .import_redirect_rtlist, | |
14230 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14231 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14232 | |
301ad80a PG |
14233 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14234 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14235 | } | |
ddb5b488 PZ |
14236 | } |
14237 | ||
dd65f45e DL |
14238 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14239 | afi_t afi, safi_t safi) | |
14240 | { | |
14241 | struct bgp_filter *filter; | |
14242 | char *addr; | |
14243 | ||
14244 | addr = peer->host; | |
14245 | filter = &peer->filter[afi][safi]; | |
14246 | ||
14247 | /* distribute-list. */ | |
14248 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14249 | FILTER_IN)) | |
14250 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14251 | filter->dlist[FILTER_IN].name); | |
14252 | ||
14253 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14254 | FILTER_OUT)) | |
14255 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14256 | filter->dlist[FILTER_OUT].name); | |
14257 | ||
14258 | /* prefix-list. */ | |
14259 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14260 | FILTER_IN)) | |
14261 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14262 | filter->plist[FILTER_IN].name); | |
14263 | ||
14264 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14265 | FILTER_OUT)) | |
14266 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14267 | filter->plist[FILTER_OUT].name); | |
14268 | ||
14269 | /* route-map. */ | |
14270 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14271 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14272 | filter->map[RMAP_IN].name); | |
14273 | ||
14274 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14275 | RMAP_OUT)) | |
14276 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14277 | filter->map[RMAP_OUT].name); | |
14278 | ||
14279 | /* unsuppress-map */ | |
14280 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14281 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14282 | filter->usmap.name); | |
14283 | ||
14284 | /* filter-list. */ | |
14285 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14286 | FILTER_IN)) | |
14287 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14288 | filter->aslist[FILTER_IN].name); | |
14289 | ||
14290 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14291 | FILTER_OUT)) | |
14292 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14293 | filter->aslist[FILTER_OUT].name); | |
14294 | } | |
14295 | ||
14296 | /* BGP peer configuration display function. */ | |
14297 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14298 | struct peer *peer) | |
14299 | { | |
14300 | struct peer *g_peer = NULL; | |
14301 | char buf[SU_ADDRSTRLEN]; | |
14302 | char *addr; | |
14303 | int if_pg_printed = false; | |
14304 | int if_ras_printed = false; | |
14305 | ||
14306 | /* Skip dynamic neighbors. */ | |
14307 | if (peer_dynamic_neighbor(peer)) | |
14308 | return; | |
14309 | ||
14310 | if (peer->conf_if) | |
14311 | addr = peer->conf_if; | |
14312 | else | |
14313 | addr = peer->host; | |
14314 | ||
14315 | /************************************ | |
14316 | ****** Global to the neighbor ****** | |
14317 | ************************************/ | |
14318 | if (peer->conf_if) { | |
14319 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14320 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14321 | else | |
14322 | vty_out(vty, " neighbor %s interface", addr); | |
14323 | ||
14324 | if (peer_group_active(peer)) { | |
14325 | vty_out(vty, " peer-group %s", peer->group->name); | |
14326 | if_pg_printed = true; | |
14327 | } else if (peer->as_type == AS_SPECIFIED) { | |
14328 | vty_out(vty, " remote-as %u", peer->as); | |
14329 | if_ras_printed = true; | |
14330 | } else if (peer->as_type == AS_INTERNAL) { | |
14331 | vty_out(vty, " remote-as internal"); | |
14332 | if_ras_printed = true; | |
14333 | } else if (peer->as_type == AS_EXTERNAL) { | |
14334 | vty_out(vty, " remote-as external"); | |
14335 | if_ras_printed = true; | |
14336 | } | |
14337 | ||
14338 | vty_out(vty, "\n"); | |
14339 | } | |
14340 | ||
14341 | /* remote-as and peer-group */ | |
14342 | /* peer is a member of a peer-group */ | |
14343 | if (peer_group_active(peer)) { | |
14344 | g_peer = peer->group->conf; | |
14345 | ||
14346 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14347 | if (peer->as_type == AS_SPECIFIED) { | |
14348 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14349 | addr, peer->as); | |
14350 | } else if (peer->as_type == AS_INTERNAL) { | |
14351 | vty_out(vty, | |
14352 | " neighbor %s remote-as internal\n", | |
14353 | addr); | |
14354 | } else if (peer->as_type == AS_EXTERNAL) { | |
14355 | vty_out(vty, | |
14356 | " neighbor %s remote-as external\n", | |
14357 | addr); | |
14358 | } | |
14359 | } | |
14360 | ||
14361 | /* For swpX peers we displayed the peer-group | |
14362 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14363 | if (!if_pg_printed) | |
14364 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14365 | peer->group->name); | |
14366 | } | |
14367 | ||
14368 | /* peer is NOT a member of a peer-group */ | |
14369 | else { | |
14370 | /* peer is a peer-group, declare the peer-group */ | |
14371 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14372 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14373 | } | |
14374 | ||
14375 | if (!if_ras_printed) { | |
14376 | if (peer->as_type == AS_SPECIFIED) { | |
14377 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14378 | addr, peer->as); | |
14379 | } else if (peer->as_type == AS_INTERNAL) { | |
14380 | vty_out(vty, | |
14381 | " neighbor %s remote-as internal\n", | |
14382 | addr); | |
14383 | } else if (peer->as_type == AS_EXTERNAL) { | |
14384 | vty_out(vty, | |
14385 | " neighbor %s remote-as external\n", | |
14386 | addr); | |
14387 | } | |
14388 | } | |
14389 | } | |
14390 | ||
14391 | /* local-as */ | |
14392 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14393 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14394 | peer->change_local_as); | |
14395 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14396 | vty_out(vty, " no-prepend"); | |
14397 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14398 | vty_out(vty, " replace-as"); | |
14399 | vty_out(vty, "\n"); | |
14400 | } | |
14401 | ||
14402 | /* description */ | |
14403 | if (peer->desc) { | |
14404 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14405 | } | |
14406 | ||
14407 | /* shutdown */ | |
14408 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14409 | if (peer->tx_shutdown_message) | |
14410 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14411 | peer->tx_shutdown_message); | |
14412 | else | |
14413 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14414 | } | |
14415 | ||
14416 | /* bfd */ | |
14417 | if (peer->bfd_info) { | |
14418 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14419 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14420 | } | |
14421 | } | |
14422 | ||
14423 | /* password */ | |
14424 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14425 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14426 | peer->password); | |
14427 | ||
14428 | /* neighbor solo */ | |
14429 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14430 | if (!peer_group_active(peer)) { | |
14431 | vty_out(vty, " neighbor %s solo\n", addr); | |
14432 | } | |
14433 | } | |
14434 | ||
14435 | /* BGP port */ | |
14436 | if (peer->port != BGP_PORT_DEFAULT) { | |
14437 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14438 | } | |
14439 | ||
14440 | /* Local interface name */ | |
14441 | if (peer->ifname) { | |
14442 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14443 | } | |
14444 | ||
14445 | /* passive */ | |
14446 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14447 | vty_out(vty, " neighbor %s passive\n", addr); | |
14448 | ||
14449 | /* ebgp-multihop */ | |
14450 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
14451 | && !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) { | |
14452 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { | |
14453 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14454 | peer->ttl); | |
14455 | } | |
14456 | } | |
14457 | ||
14458 | /* ttl-security hops */ | |
14459 | if (peer->gtsm_hops != 0) { | |
14460 | if (!peer_group_active(peer) | |
14461 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14462 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14463 | addr, peer->gtsm_hops); | |
14464 | } | |
14465 | } | |
14466 | ||
14467 | /* disable-connected-check */ | |
14468 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14469 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14470 | ||
14471 | /* enforce-first-as */ | |
14472 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14473 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14474 | ||
14475 | /* update-source */ | |
14476 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14477 | if (peer->update_source) | |
14478 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14479 | sockunion2str(peer->update_source, buf, | |
14480 | SU_ADDRSTRLEN)); | |
14481 | else if (peer->update_if) | |
14482 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14483 | peer->update_if); | |
14484 | } | |
14485 | ||
14486 | /* advertisement-interval */ | |
14487 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14488 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14489 | peer->routeadv); | |
14490 | ||
14491 | /* timers */ | |
14492 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14493 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14494 | peer->keepalive, peer->holdtime); | |
14495 | ||
14496 | /* timers connect */ | |
14497 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14498 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14499 | peer->connect); | |
5d5393b9 DL |
14500 | /* need special-case handling for changed default values due to |
14501 | * config profile / version (because there is no "timers bgp connect" | |
14502 | * command, we need to save this per-peer :/) | |
14503 | */ | |
14504 | else if (!peer_group_active(peer) && !peer->connect && | |
14505 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14506 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14507 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14508 | |
14509 | /* capability dynamic */ | |
14510 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14511 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14512 | ||
14513 | /* capability extended-nexthop */ | |
14514 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14515 | if (!peer->conf_if) { | |
14516 | if (CHECK_FLAG(peer->flags_invert, | |
14517 | PEER_FLAG_CAPABILITY_ENHE)) | |
14518 | vty_out(vty, | |
14519 | " no neighbor %s capability extended-nexthop\n", | |
14520 | addr); | |
14521 | else | |
14522 | vty_out(vty, | |
14523 | " neighbor %s capability extended-nexthop\n", | |
14524 | addr); | |
14525 | } | |
14526 | } | |
14527 | ||
14528 | /* dont-capability-negotiation */ | |
14529 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14530 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14531 | ||
14532 | /* override-capability */ | |
14533 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14534 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14535 | ||
14536 | /* strict-capability-match */ | |
14537 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14538 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14539 | ||
14540 | /* Sender side AS path loop detection. */ | |
14541 | if (peer->as_path_loop_detection) | |
14542 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14543 | addr); | |
cfd47646 | 14544 | |
14545 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14546 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14547 | |
14548 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14549 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14550 | vty_out(vty, |
14551 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14552 | } else if (CHECK_FLAG( |
14553 | peer->peer_gr_new_status_flag, | |
14554 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14555 | vty_out(vty, |
14556 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14557 | } else if ( |
14558 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14559 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14560 | && !(CHECK_FLAG( | |
14561 | peer->peer_gr_new_status_flag, | |
14562 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14563 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14564 | addr); | |
cfd47646 | 14565 | } |
14566 | } | |
dd65f45e DL |
14567 | } |
14568 | ||
14569 | /* BGP peer configuration display function. */ | |
14570 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14571 | struct peer *peer, afi_t afi, safi_t safi) | |
14572 | { | |
14573 | struct peer *g_peer = NULL; | |
14574 | char *addr; | |
14575 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14576 | ||
14577 | /* Skip dynamic neighbors. */ | |
14578 | if (peer_dynamic_neighbor(peer)) | |
14579 | return; | |
14580 | ||
14581 | if (peer->conf_if) | |
14582 | addr = peer->conf_if; | |
14583 | else | |
14584 | addr = peer->host; | |
14585 | ||
14586 | /************************************ | |
14587 | ****** Per AF to the neighbor ****** | |
14588 | ************************************/ | |
14589 | if (peer_group_active(peer)) { | |
14590 | g_peer = peer->group->conf; | |
14591 | ||
14592 | /* If the peer-group is active but peer is not, print a 'no | |
14593 | * activate' */ | |
14594 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14595 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14596 | } | |
14597 | ||
14598 | /* If the peer-group is not active but peer is, print an | |
14599 | 'activate' */ | |
14600 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14601 | vty_out(vty, " neighbor %s activate\n", addr); | |
14602 | } | |
14603 | } else { | |
14604 | if (peer->afc[afi][safi]) { | |
14605 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
14606 | if (bgp_flag_check(bgp, | |
14607 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
14608 | vty_out(vty, " neighbor %s activate\n", | |
14609 | addr); | |
14610 | } | |
14611 | } else | |
14612 | vty_out(vty, " neighbor %s activate\n", addr); | |
14613 | } else { | |
14614 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
14615 | if (!bgp_flag_check(bgp, | |
14616 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
14617 | vty_out(vty, | |
14618 | " no neighbor %s activate\n", | |
14619 | addr); | |
14620 | } | |
14621 | } | |
14622 | } | |
14623 | } | |
14624 | ||
14625 | /* addpath TX knobs */ | |
14626 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14627 | switch (peer->addpath_type[afi][safi]) { | |
14628 | case BGP_ADDPATH_ALL: | |
14629 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14630 | addr); | |
14631 | break; | |
14632 | case BGP_ADDPATH_BEST_PER_AS: | |
14633 | vty_out(vty, | |
14634 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14635 | addr); | |
14636 | break; | |
14637 | case BGP_ADDPATH_MAX: | |
14638 | case BGP_ADDPATH_NONE: | |
14639 | break; | |
14640 | } | |
14641 | } | |
14642 | ||
14643 | /* ORF capability. */ | |
14644 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14645 | || peergroup_af_flag_check(peer, afi, safi, | |
14646 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14647 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14648 | ||
14649 | if (peergroup_af_flag_check(peer, afi, safi, | |
14650 | PEER_FLAG_ORF_PREFIX_SM) | |
14651 | && peergroup_af_flag_check(peer, afi, safi, | |
14652 | PEER_FLAG_ORF_PREFIX_RM)) | |
14653 | vty_out(vty, " both"); | |
14654 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14655 | PEER_FLAG_ORF_PREFIX_SM)) | |
14656 | vty_out(vty, " send"); | |
14657 | else | |
14658 | vty_out(vty, " receive"); | |
14659 | vty_out(vty, "\n"); | |
14660 | } | |
14661 | ||
14662 | /* BGP flag dampening. */ | |
14663 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14664 | BGP_CONFIG_DAMPENING)) | |
14665 | bgp_config_write_damp(vty, afi, safi); | |
14666 | ||
14667 | /* Route reflector client. */ | |
14668 | if (peergroup_af_flag_check(peer, afi, safi, | |
14669 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14670 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14671 | } | |
14672 | ||
14673 | /* next-hop-self force */ | |
14674 | if (peergroup_af_flag_check(peer, afi, safi, | |
14675 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14676 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14677 | } | |
14678 | ||
14679 | /* next-hop-self */ | |
14680 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14681 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14682 | } | |
14683 | ||
14684 | /* remove-private-AS */ | |
14685 | if (peergroup_af_flag_check(peer, afi, safi, | |
14686 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14687 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14688 | addr); | |
14689 | } | |
14690 | ||
14691 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14692 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14693 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14694 | addr); | |
14695 | } | |
14696 | ||
14697 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14698 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14699 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14700 | } | |
14701 | ||
14702 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14703 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14704 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14705 | } | |
14706 | ||
14707 | /* as-override */ | |
14708 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14709 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14710 | } | |
14711 | ||
14712 | /* send-community print. */ | |
14713 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14714 | PEER_FLAG_SEND_COMMUNITY); | |
14715 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14716 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14717 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14718 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14719 | ||
14720 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14721 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14722 | } else { | |
14723 | if (flag_scomm) | |
14724 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14725 | if (flag_secomm) | |
14726 | vty_out(vty, | |
14727 | " no neighbor %s send-community extended\n", | |
14728 | addr); | |
14729 | ||
14730 | if (flag_slcomm) | |
14731 | vty_out(vty, " no neighbor %s send-community large\n", | |
14732 | addr); | |
14733 | } | |
14734 | ||
14735 | /* Default information */ | |
14736 | if (peergroup_af_flag_check(peer, afi, safi, | |
14737 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14738 | vty_out(vty, " neighbor %s default-originate", addr); | |
14739 | ||
14740 | if (peer->default_rmap[afi][safi].name) | |
14741 | vty_out(vty, " route-map %s", | |
14742 | peer->default_rmap[afi][safi].name); | |
14743 | ||
14744 | vty_out(vty, "\n"); | |
14745 | } | |
14746 | ||
14747 | /* Soft reconfiguration inbound. */ | |
14748 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14749 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14750 | addr); | |
14751 | } | |
14752 | ||
14753 | /* maximum-prefix. */ | |
14754 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14755 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14756 | peer->pmax[afi][safi]); | |
14757 | ||
14758 | if (peer->pmax_threshold[afi][safi] | |
14759 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14760 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14761 | if (peer_af_flag_check(peer, afi, safi, | |
14762 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14763 | vty_out(vty, " warning-only"); | |
14764 | if (peer->pmax_restart[afi][safi]) | |
14765 | vty_out(vty, " restart %u", | |
14766 | peer->pmax_restart[afi][safi]); | |
14767 | ||
14768 | vty_out(vty, "\n"); | |
14769 | } | |
14770 | ||
fde246e8 DA |
14771 | /* maximum-prefix-out */ |
14772 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14773 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14774 | addr, peer->pmax_out[afi][safi]); | |
14775 | ||
dd65f45e DL |
14776 | /* Route server client. */ |
14777 | if (peergroup_af_flag_check(peer, afi, safi, | |
14778 | PEER_FLAG_RSERVER_CLIENT)) { | |
14779 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14780 | } | |
14781 | ||
14782 | /* Nexthop-local unchanged. */ | |
14783 | if (peergroup_af_flag_check(peer, afi, safi, | |
14784 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14785 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14786 | } | |
14787 | ||
14788 | /* allowas-in <1-10> */ | |
14789 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14790 | if (peer_af_flag_check(peer, afi, safi, | |
14791 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14792 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14793 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14794 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14795 | } else { | |
14796 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14797 | peer->allowas_in[afi][safi]); | |
14798 | } | |
14799 | } | |
14800 | ||
14801 | /* weight */ | |
14802 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14803 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14804 | peer->weight[afi][safi]); | |
14805 | ||
14806 | /* Filter. */ | |
14807 | bgp_config_write_filter(vty, peer, afi, safi); | |
14808 | ||
14809 | /* atribute-unchanged. */ | |
14810 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14811 | || (safi != SAFI_EVPN | |
14812 | && peer_af_flag_check(peer, afi, safi, | |
14813 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14814 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14815 | ||
14816 | if (!peer_group_active(peer) | |
14817 | || peergroup_af_flag_check(peer, afi, safi, | |
14818 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14819 | || peergroup_af_flag_check(peer, afi, safi, | |
14820 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14821 | || peergroup_af_flag_check(peer, afi, safi, | |
14822 | PEER_FLAG_MED_UNCHANGED)) { | |
14823 | ||
14824 | vty_out(vty, | |
14825 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14826 | addr, | |
14827 | peer_af_flag_check(peer, afi, safi, | |
14828 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14829 | ? " as-path" | |
14830 | : "", | |
14831 | peer_af_flag_check(peer, afi, safi, | |
14832 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14833 | ? " next-hop" | |
14834 | : "", | |
14835 | peer_af_flag_check(peer, afi, safi, | |
14836 | PEER_FLAG_MED_UNCHANGED) | |
14837 | ? " med" | |
14838 | : ""); | |
14839 | } | |
14840 | } | |
14841 | } | |
14842 | ||
14843 | /* Address family based peer configuration display. */ | |
14844 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14845 | safi_t safi) | |
14846 | { | |
14847 | struct peer *peer; | |
14848 | struct peer_group *group; | |
14849 | struct listnode *node, *nnode; | |
14850 | ||
14851 | ||
14852 | vty_frame(vty, " !\n address-family "); | |
14853 | if (afi == AFI_IP) { | |
14854 | if (safi == SAFI_UNICAST) | |
14855 | vty_frame(vty, "ipv4 unicast"); | |
14856 | else if (safi == SAFI_LABELED_UNICAST) | |
14857 | vty_frame(vty, "ipv4 labeled-unicast"); | |
14858 | else if (safi == SAFI_MULTICAST) | |
14859 | vty_frame(vty, "ipv4 multicast"); | |
14860 | else if (safi == SAFI_MPLS_VPN) | |
14861 | vty_frame(vty, "ipv4 vpn"); | |
14862 | else if (safi == SAFI_ENCAP) | |
14863 | vty_frame(vty, "ipv4 encap"); | |
14864 | else if (safi == SAFI_FLOWSPEC) | |
14865 | vty_frame(vty, "ipv4 flowspec"); | |
14866 | } else if (afi == AFI_IP6) { | |
14867 | if (safi == SAFI_UNICAST) | |
14868 | vty_frame(vty, "ipv6 unicast"); | |
14869 | else if (safi == SAFI_LABELED_UNICAST) | |
14870 | vty_frame(vty, "ipv6 labeled-unicast"); | |
14871 | else if (safi == SAFI_MULTICAST) | |
14872 | vty_frame(vty, "ipv6 multicast"); | |
14873 | else if (safi == SAFI_MPLS_VPN) | |
14874 | vty_frame(vty, "ipv6 vpn"); | |
14875 | else if (safi == SAFI_ENCAP) | |
14876 | vty_frame(vty, "ipv6 encap"); | |
14877 | else if (safi == SAFI_FLOWSPEC) | |
14878 | vty_frame(vty, "ipv6 flowspec"); | |
14879 | } else if (afi == AFI_L2VPN) { | |
14880 | if (safi == SAFI_EVPN) | |
14881 | vty_frame(vty, "l2vpn evpn"); | |
14882 | } | |
14883 | vty_frame(vty, "\n"); | |
14884 | ||
14885 | bgp_config_write_distance(vty, bgp, afi, safi); | |
14886 | ||
14887 | bgp_config_write_network(vty, bgp, afi, safi); | |
14888 | ||
14889 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
14890 | ||
14891 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
14892 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
14893 | ||
14894 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14895 | /* Skip dynamic neighbors. */ | |
14896 | if (peer_dynamic_neighbor(peer)) | |
14897 | continue; | |
14898 | ||
14899 | /* Do not display doppelganger peers */ | |
14900 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14901 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
14902 | } | |
14903 | ||
14904 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
14905 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
14906 | ||
14907 | if (safi == SAFI_EVPN) | |
14908 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
14909 | ||
14910 | if (safi == SAFI_FLOWSPEC) | |
14911 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
14912 | ||
14913 | if (safi == SAFI_UNICAST) { | |
14914 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
14915 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14916 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
14917 | ||
14918 | vty_out(vty, " export vpn\n"); | |
14919 | } | |
14920 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14921 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
14922 | ||
14923 | vty_out(vty, " import vpn\n"); | |
14924 | } | |
14925 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14926 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14927 | char *name; | |
14928 | ||
14929 | for (ALL_LIST_ELEMENTS_RO( | |
14930 | bgp->vpn_policy[afi].import_vrf, node, | |
14931 | name)) | |
14932 | vty_out(vty, " import vrf %s\n", name); | |
14933 | } | |
14934 | } | |
14935 | ||
14936 | vty_endframe(vty, " exit-address-family\n"); | |
14937 | } | |
14938 | ||
14939 | int bgp_config_write(struct vty *vty) | |
14940 | { | |
14941 | struct bgp *bgp; | |
14942 | struct peer_group *group; | |
14943 | struct peer *peer; | |
14944 | struct listnode *node, *nnode; | |
14945 | struct listnode *mnode, *mnnode; | |
14946 | ||
14947 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
14948 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
14949 | bm->rmap_update_timer); | |
14950 | ||
14951 | /* BGP configuration. */ | |
14952 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
14953 | ||
14954 | /* skip all auto created vrf as they dont have user config */ | |
14955 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
14956 | continue; | |
14957 | ||
14958 | /* Router bgp ASN */ | |
14959 | vty_out(vty, "router bgp %u", bgp->as); | |
14960 | ||
14961 | if (bgp->name) | |
14962 | vty_out(vty, " %s %s", | |
14963 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
14964 | ? "view" : "vrf", bgp->name); | |
14965 | vty_out(vty, "\n"); | |
14966 | ||
14967 | /* BGP fast-external-failover. */ | |
14968 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
14969 | vty_out(vty, " no bgp fast-external-failover\n"); | |
14970 | ||
14971 | /* BGP router ID. */ | |
14972 | if (bgp->router_id_static.s_addr != 0) | |
14973 | vty_out(vty, " bgp router-id %s\n", | |
14974 | inet_ntoa(bgp->router_id_static)); | |
14975 | ||
14976 | /* BGP log-neighbor-changes. */ | |
14977 | if (!!bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
5d5393b9 | 14978 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e DL |
14979 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
14980 | bgp_flag_check(bgp, | |
14981 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
14982 | ? "" | |
14983 | : "no "); | |
14984 | ||
14985 | /* BGP configuration. */ | |
14986 | if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED)) | |
14987 | vty_out(vty, " bgp always-compare-med\n"); | |
14988 | ||
14989 | /* RFC8212 default eBGP policy. */ | |
14990 | if (bgp->ebgp_requires_policy | |
14991 | == DEFAULT_EBGP_POLICY_ENABLED) | |
14992 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
14993 | ||
14994 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
14995 | if (bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) | |
14996 | vty_out(vty, " bgp reject-as-sets\n"); | |
14997 | ||
14998 | /* BGP default ipv4-unicast. */ | |
14999 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)) | |
15000 | vty_out(vty, " no bgp default ipv4-unicast\n"); | |
15001 | ||
15002 | /* BGP default local-preference. */ | |
15003 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15004 | vty_out(vty, " bgp default local-preference %u\n", | |
15005 | bgp->default_local_pref); | |
15006 | ||
15007 | /* BGP default show-hostname */ | |
15008 | if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
5d5393b9 | 15009 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e DL |
15010 | vty_out(vty, " %sbgp default show-hostname\n", |
15011 | bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
15012 | ? "" | |
15013 | : "no "); | |
15014 | ||
15015 | /* BGP default subgroup-pkt-queue-max. */ | |
15016 | if (bgp->default_subgroup_pkt_queue_max | |
15017 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15018 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15019 | bgp->default_subgroup_pkt_queue_max); | |
15020 | ||
15021 | /* BGP client-to-client reflection. */ | |
15022 | if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
15023 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
15024 | ||
15025 | /* BGP cluster ID. */ | |
15026 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15027 | vty_out(vty, " bgp cluster-id %s\n", | |
15028 | inet_ntoa(bgp->cluster_id)); | |
15029 | ||
15030 | /* Disable ebgp connected nexthop check */ | |
15031 | if (bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
15032 | vty_out(vty, | |
15033 | " bgp disable-ebgp-connected-route-check\n"); | |
15034 | ||
15035 | /* Confederation identifier*/ | |
15036 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15037 | vty_out(vty, " bgp confederation identifier %u\n", | |
15038 | bgp->confed_id); | |
15039 | ||
15040 | /* Confederation peer */ | |
15041 | if (bgp->confed_peers_cnt > 0) { | |
15042 | int i; | |
15043 | ||
15044 | vty_out(vty, " bgp confederation peers"); | |
15045 | ||
15046 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15047 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15048 | ||
15049 | vty_out(vty, "\n"); | |
15050 | } | |
15051 | ||
15052 | /* BGP deterministic-med. */ | |
15053 | if (!!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
5d5393b9 | 15054 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e DL |
15055 | vty_out(vty, " %sbgp deterministic-med\n", |
15056 | bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
15057 | ? "" | |
15058 | : "no "); | |
15059 | ||
15060 | /* BGP update-delay. */ | |
15061 | bgp_config_write_update_delay(vty, bgp); | |
15062 | ||
15063 | if (bgp->v_maxmed_onstartup | |
15064 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15065 | vty_out(vty, " bgp max-med on-startup %u", | |
15066 | bgp->v_maxmed_onstartup); | |
15067 | if (bgp->maxmed_onstartup_value | |
15068 | != BGP_MAXMED_VALUE_DEFAULT) | |
15069 | vty_out(vty, " %u", | |
15070 | bgp->maxmed_onstartup_value); | |
15071 | vty_out(vty, "\n"); | |
15072 | } | |
15073 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15074 | vty_out(vty, " bgp max-med administrative"); | |
15075 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15076 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15077 | vty_out(vty, "\n"); | |
15078 | } | |
15079 | ||
15080 | /* write quanta */ | |
15081 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15082 | /* read quanta */ | |
15083 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15084 | ||
15085 | /* coalesce time */ | |
15086 | bgp_config_write_coalesce_time(vty, bgp); | |
15087 | ||
15088 | /* BGP graceful-restart. */ | |
15089 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15090 | vty_out(vty, | |
15091 | " bgp graceful-restart stalepath-time %u\n", | |
15092 | bgp->stalepath_time); | |
cfd47646 | 15093 | |
dd65f45e DL |
15094 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15095 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15096 | bgp->restart_time); | |
cfd47646 | 15097 | |
15098 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15099 | vty_out(vty, | |
15100 | " bgp graceful-restart select-defer-time %u\n", | |
15101 | bgp->select_defer_time); | |
15102 | ||
15103 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15104 | vty_out(vty, " bgp graceful-restart\n"); |
15105 | ||
cfd47646 | 15106 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15107 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15108 | ||
dd65f45e DL |
15109 | /* BGP graceful-shutdown */ |
15110 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
15111 | vty_out(vty, " bgp graceful-shutdown\n"); | |
15112 | ||
15113 | /* BGP graceful-restart Preserve State F bit. */ | |
15114 | if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD)) | |
15115 | vty_out(vty, | |
15116 | " bgp graceful-restart preserve-fw-state\n"); | |
15117 | ||
dc95985f | 15118 | /* Stale timer for RIB */ |
15119 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15120 | vty_out(vty, | |
15121 | " bgp graceful-restart rib-stale-time %u\n", | |
15122 | bgp->rib_stale_time); | |
15123 | ||
dd65f45e DL |
15124 | /* BGP bestpath method. */ |
15125 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
15126 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
15127 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
15128 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
15129 | ||
15130 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
15131 | if (bgp_flag_check(bgp, | |
15132 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
15133 | vty_out(vty, | |
15134 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15135 | } else { | |
15136 | vty_out(vty, | |
15137 | " bgp bestpath as-path multipath-relax\n"); | |
15138 | } | |
15139 | } | |
15140 | ||
15141 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
15142 | vty_out(vty, | |
15143 | " bgp route-reflector allow-outbound-policy\n"); | |
15144 | } | |
15145 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
15146 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
15147 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
15148 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
15149 | vty_out(vty, " bgp bestpath med"); | |
15150 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
15151 | vty_out(vty, " confed"); | |
15152 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
15153 | vty_out(vty, " missing-as-worst"); | |
15154 | vty_out(vty, "\n"); | |
15155 | } | |
15156 | ||
15157 | /* BGP network import check. */ | |
15158 | if (!!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
5d5393b9 | 15159 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e DL |
15160 | vty_out(vty, " %sbgp network import-check\n", |
15161 | bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
15162 | ? "" | |
15163 | : "no "); | |
15164 | ||
15165 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15166 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15167 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15168 | vty_out(vty, " timers bgp %u %u\n", |
15169 | bgp->default_keepalive, bgp->default_holdtime); | |
15170 | ||
15171 | /* peer-group */ | |
15172 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15173 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15174 | } | |
15175 | ||
15176 | /* Normal neighbor configuration. */ | |
15177 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15178 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15179 | bgp_config_write_peer_global(vty, bgp, peer); | |
15180 | } | |
15181 | ||
15182 | /* listen range and limit for dynamic BGP neighbors */ | |
15183 | bgp_config_write_listen(vty, bgp); | |
15184 | ||
15185 | /* | |
15186 | * BGP default autoshutdown neighbors | |
15187 | * | |
15188 | * This must be placed after any peer and peer-group | |
15189 | * configuration, to avoid setting all peers to shutdown after | |
15190 | * a daemon restart, which is undesired behavior. (see #2286) | |
15191 | */ | |
15192 | if (bgp->autoshutdown) | |
15193 | vty_out(vty, " bgp default shutdown\n"); | |
15194 | ||
15195 | /* IPv4 unicast configuration. */ | |
15196 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15197 | ||
15198 | /* IPv4 multicast configuration. */ | |
15199 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15200 | ||
15201 | /* IPv4 labeled-unicast configuration. */ | |
15202 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15203 | ||
15204 | /* IPv4 VPN configuration. */ | |
15205 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15206 | ||
15207 | /* ENCAPv4 configuration. */ | |
15208 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15209 | ||
15210 | /* FLOWSPEC v4 configuration. */ | |
15211 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15212 | ||
15213 | /* IPv6 unicast configuration. */ | |
15214 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15215 | ||
15216 | /* IPv6 multicast configuration. */ | |
15217 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15218 | ||
15219 | /* IPv6 labeled-unicast configuration. */ | |
15220 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15221 | SAFI_LABELED_UNICAST); | |
15222 | ||
15223 | /* IPv6 VPN configuration. */ | |
15224 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15225 | ||
15226 | /* ENCAPv6 configuration. */ | |
15227 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15228 | ||
15229 | /* FLOWSPEC v6 configuration. */ | |
15230 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15231 | ||
15232 | /* EVPN configuration. */ | |
15233 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15234 | ||
15235 | hook_call(bgp_inst_config_write, bgp, vty); | |
15236 | ||
15237 | #if ENABLE_BGP_VNC | |
15238 | bgp_rfapi_cfg_write(vty, bgp); | |
15239 | #endif | |
15240 | ||
15241 | vty_out(vty, "!\n"); | |
15242 | } | |
15243 | return 0; | |
15244 | } | |
15245 | ||
ddb5b488 | 15246 | |
718e3744 | 15247 | /* BGP node structure. */ |
d62a17ae | 15248 | static struct cmd_node bgp_node = { |
9d303b37 | 15249 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 15250 | }; |
15251 | ||
d62a17ae | 15252 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 15253 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15254 | }; |
15255 | ||
d62a17ae | 15256 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 15257 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15258 | }; |
15259 | ||
d62a17ae | 15260 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 15261 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15262 | }; |
15263 | ||
d62a17ae | 15264 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 15265 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15266 | }; |
15267 | ||
d62a17ae | 15268 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 15269 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 15270 | }; |
15271 | ||
d62a17ae | 15272 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 15273 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15274 | }; |
15275 | ||
d62a17ae | 15276 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
15277 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 15278 | |
d62a17ae | 15279 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
15280 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 15281 | |
d62a17ae | 15282 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
15283 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 15284 | |
d62a17ae | 15285 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
15286 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 15287 | |
7c40bf39 | 15288 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
15289 | "%s(config-router-af)# ", 1}; | |
15290 | ||
15291 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
15292 | "%s(config-router-af-vpnv6)# ", 1}; | |
15293 | ||
d62a17ae | 15294 | static void community_list_vty(void); |
1f8ae70b | 15295 | |
d62a17ae | 15296 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15297 | { |
d62a17ae | 15298 | struct bgp *bgp; |
15299 | struct peer *peer; | |
d62a17ae | 15300 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15301 | |
d62a17ae | 15302 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15303 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15304 | /* only provide suggestions on the appropriate input | |
15305 | * token type, | |
15306 | * they'll otherwise show up multiple times */ | |
15307 | enum cmd_token_type match_type; | |
15308 | char *name = peer->host; | |
d48ed3e0 | 15309 | |
d62a17ae | 15310 | if (peer->conf_if) { |
15311 | match_type = VARIABLE_TKN; | |
15312 | name = peer->conf_if; | |
15313 | } else if (strchr(peer->host, ':')) | |
15314 | match_type = IPV6_TKN; | |
15315 | else | |
15316 | match_type = IPV4_TKN; | |
d48ed3e0 | 15317 | |
d62a17ae | 15318 | if (token->type != match_type) |
15319 | continue; | |
d48ed3e0 | 15320 | |
d62a17ae | 15321 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15322 | } | |
d62a17ae | 15323 | } |
b8a815e5 DL |
15324 | } |
15325 | ||
15326 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15327 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15328 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15329 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15330 | {.completions = NULL}}; |
15331 | ||
47a306a0 DS |
15332 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15333 | { | |
15334 | struct bgp *bgp; | |
15335 | struct peer_group *group; | |
15336 | struct listnode *lnbgp, *lnpeer; | |
15337 | ||
15338 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15339 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15340 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15341 | group->name)); | |
15342 | } | |
15343 | } | |
15344 | ||
15345 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15346 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15347 | {.completions = NULL} }; | |
15348 | ||
d62a17ae | 15349 | void bgp_vty_init(void) |
15350 | { | |
15351 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15352 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15353 | |
15354 | /* Install bgp top node. */ | |
15355 | install_node(&bgp_node, bgp_config_write); | |
15356 | install_node(&bgp_ipv4_unicast_node, NULL); | |
15357 | install_node(&bgp_ipv4_multicast_node, NULL); | |
15358 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
15359 | install_node(&bgp_ipv6_unicast_node, NULL); | |
15360 | install_node(&bgp_ipv6_multicast_node, NULL); | |
15361 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
15362 | install_node(&bgp_vpnv4_node, NULL); | |
15363 | install_node(&bgp_vpnv6_node, NULL); | |
15364 | install_node(&bgp_evpn_node, NULL); | |
15365 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 15366 | install_node(&bgp_flowspecv4_node, NULL); |
15367 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 15368 | |
15369 | /* Install default VTY commands to new nodes. */ | |
15370 | install_default(BGP_NODE); | |
15371 | install_default(BGP_IPV4_NODE); | |
15372 | install_default(BGP_IPV4M_NODE); | |
15373 | install_default(BGP_IPV4L_NODE); | |
15374 | install_default(BGP_IPV6_NODE); | |
15375 | install_default(BGP_IPV6M_NODE); | |
15376 | install_default(BGP_IPV6L_NODE); | |
15377 | install_default(BGP_VPNV4_NODE); | |
15378 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15379 | install_default(BGP_FLOWSPECV4_NODE); |
15380 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15381 | install_default(BGP_EVPN_NODE); |
15382 | install_default(BGP_EVPN_VNI_NODE); | |
15383 | ||
8029b216 AK |
15384 | /* "bgp local-mac" hidden commands. */ |
15385 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15386 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15387 | ||
d62a17ae | 15388 | /* bgp route-map delay-timer commands. */ |
15389 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15390 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15391 | ||
15392 | /* Dummy commands (Currently not supported) */ | |
15393 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15394 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15395 | ||
15396 | /* "router bgp" commands. */ | |
15397 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15398 | ||
15399 | /* "no router bgp" commands. */ | |
15400 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15401 | ||
15402 | /* "bgp router-id" commands. */ | |
15403 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15404 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15405 | ||
15406 | /* "bgp cluster-id" commands. */ | |
15407 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15408 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15409 | ||
15410 | /* "bgp confederation" commands. */ | |
15411 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15412 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15413 | ||
15414 | /* "bgp confederation peers" commands. */ | |
15415 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15416 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15417 | ||
15418 | /* bgp max-med command */ | |
15419 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15420 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15421 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15422 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15423 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15424 | ||
15425 | /* bgp disable-ebgp-connected-nh-check */ | |
15426 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15427 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15428 | ||
15429 | /* bgp update-delay command */ | |
15430 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15431 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15432 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15433 | ||
15434 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15435 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15436 | |
15437 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15438 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15439 | ||
15440 | /* "maximum-paths" commands. */ | |
15441 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15442 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15443 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15444 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15445 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15446 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15447 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15448 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15449 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15450 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15451 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15452 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15453 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15454 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15455 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15456 | ||
15457 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15458 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15459 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15460 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15461 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15462 | ||
15463 | /* "timers bgp" commands. */ | |
15464 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15465 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15466 | ||
15467 | /* route-map delay-timer commands - per instance for backwards compat. | |
15468 | */ | |
15469 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15470 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15471 | ||
15472 | /* "bgp client-to-client reflection" commands */ | |
15473 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15474 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15475 | ||
15476 | /* "bgp always-compare-med" commands */ | |
15477 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15478 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15479 | ||
9dac9fc8 DA |
15480 | /* bgp ebgp-requires-policy */ |
15481 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15482 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15483 | ||
fb29348a DA |
15484 | /* bgp reject-as-sets */ |
15485 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15486 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15487 | ||
d62a17ae | 15488 | /* "bgp deterministic-med" commands */ |
15489 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15490 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15491 | ||
055679e9 | 15492 | /* "bgp graceful-restart" command */ |
36235319 QY |
15493 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15494 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15495 | |
15496 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15497 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15498 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15499 | |
15500 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15501 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15502 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15503 | |
15504 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15505 | install_element(BGP_NODE, | |
15506 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15507 | install_element(BGP_NODE, | |
15508 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15509 | ||
15510 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15511 | install_element(BGP_NODE, | |
15512 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15513 | install_element(BGP_NODE, | |
15514 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15515 | ||
d62a17ae | 15516 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15517 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15518 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15519 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15520 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15521 | install_element(BGP_NODE, |
15522 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15523 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15524 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15525 | ||
d6e3c15b | 15526 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15527 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15528 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15529 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15530 | |
7f323236 DW |
15531 | /* "bgp graceful-shutdown" commands */ |
15532 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15533 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15534 | ||
d62a17ae | 15535 | /* "bgp fast-external-failover" commands */ |
15536 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15537 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15538 | ||
d62a17ae | 15539 | /* "bgp bestpath compare-routerid" commands */ |
15540 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15541 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15542 | ||
15543 | /* "bgp bestpath as-path ignore" commands */ | |
15544 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15545 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15546 | ||
15547 | /* "bgp bestpath as-path confed" commands */ | |
15548 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15549 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15550 | ||
15551 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15552 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15553 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15554 | ||
15555 | /* "bgp log-neighbor-changes" commands */ | |
15556 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15557 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15558 | ||
15559 | /* "bgp bestpath med" commands */ | |
15560 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15561 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15562 | ||
15563 | /* "no bgp default ipv4-unicast" commands. */ | |
15564 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15565 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15566 | ||
15567 | /* "bgp network import-check" commands. */ | |
15568 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15569 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15570 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15571 | ||
15572 | /* "bgp default local-preference" commands. */ | |
15573 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15574 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15575 | ||
15576 | /* bgp default show-hostname */ | |
15577 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15578 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15579 | ||
15580 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15581 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15582 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15583 | ||
15584 | /* bgp ibgp-allow-policy-mods command */ | |
15585 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15586 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15587 | ||
15588 | /* "bgp listen limit" commands. */ | |
15589 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15590 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15591 | ||
15592 | /* "bgp listen range" commands. */ | |
15593 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15594 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15595 | ||
8175f54a | 15596 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15597 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15598 | ||
d62a17ae | 15599 | /* "neighbor remote-as" commands. */ |
15600 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15601 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15602 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15603 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15604 | install_element(BGP_NODE, | |
15605 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15606 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15607 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15608 | ||
15609 | /* "neighbor peer-group" commands. */ | |
15610 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15611 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15612 | install_element(BGP_NODE, | |
15613 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15614 | ||
15615 | /* "neighbor local-as" commands. */ | |
15616 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15617 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15618 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15619 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15620 | ||
15621 | /* "neighbor solo" commands. */ | |
15622 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15623 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15624 | ||
15625 | /* "neighbor password" commands. */ | |
15626 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15627 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15628 | ||
15629 | /* "neighbor activate" commands. */ | |
15630 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15631 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15632 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15633 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15634 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15635 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15636 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15637 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15638 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15639 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15640 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15641 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15642 | ||
15643 | /* "no neighbor activate" commands. */ | |
15644 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15645 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15646 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15647 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15648 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15649 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15650 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15651 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15652 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15653 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15654 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15655 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15656 | ||
15657 | /* "neighbor peer-group" set commands. */ | |
15658 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15659 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15660 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15661 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15662 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15663 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15664 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15665 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15666 | install_element(BGP_FLOWSPECV4_NODE, |
15667 | &neighbor_set_peer_group_hidden_cmd); | |
15668 | install_element(BGP_FLOWSPECV6_NODE, | |
15669 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15670 | |
15671 | /* "no neighbor peer-group unset" commands. */ | |
15672 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15673 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15674 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15675 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15676 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15677 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15678 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15679 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15680 | install_element(BGP_FLOWSPECV4_NODE, |
15681 | &no_neighbor_set_peer_group_hidden_cmd); | |
15682 | install_element(BGP_FLOWSPECV6_NODE, | |
15683 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15684 | |
15685 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15686 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15687 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15688 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15689 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15690 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15691 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15692 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15693 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15694 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15695 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15696 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15697 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15698 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15699 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15700 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15701 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15702 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15703 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15704 | install_element(BGP_FLOWSPECV4_NODE, |
15705 | &neighbor_soft_reconfiguration_cmd); | |
15706 | install_element(BGP_FLOWSPECV4_NODE, | |
15707 | &no_neighbor_soft_reconfiguration_cmd); | |
15708 | install_element(BGP_FLOWSPECV6_NODE, | |
15709 | &neighbor_soft_reconfiguration_cmd); | |
15710 | install_element(BGP_FLOWSPECV6_NODE, | |
15711 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15712 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15713 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15714 | |
15715 | /* "neighbor attribute-unchanged" commands. */ | |
15716 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15717 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15718 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15719 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15720 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15721 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15722 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15723 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15724 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15725 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15726 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15727 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15728 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15729 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15730 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15731 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15732 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15733 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15734 | ||
15735 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15736 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15737 | ||
15738 | /* "nexthop-local unchanged" commands */ | |
15739 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15740 | install_element(BGP_IPV6_NODE, | |
15741 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15742 | ||
15743 | /* "neighbor next-hop-self" commands. */ | |
15744 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15745 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15746 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15747 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15748 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15749 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15750 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15751 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15752 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15753 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15754 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15755 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15756 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15757 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15758 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15759 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15760 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15761 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15762 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15763 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15764 | |
15765 | /* "neighbor next-hop-self force" commands. */ | |
15766 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15767 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15768 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15769 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15770 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15771 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15772 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15773 | install_element(BGP_IPV4_NODE, | |
15774 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15775 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15776 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15777 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15778 | install_element(BGP_IPV4M_NODE, | |
15779 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15780 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
15781 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15782 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15783 | install_element(BGP_IPV4L_NODE, | |
15784 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15785 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
15786 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15787 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15788 | install_element(BGP_IPV6_NODE, | |
15789 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15790 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
15791 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15792 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15793 | install_element(BGP_IPV6M_NODE, | |
15794 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15795 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
15796 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15797 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15798 | install_element(BGP_IPV6L_NODE, | |
15799 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15800 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
15801 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15802 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15803 | install_element(BGP_VPNV4_NODE, | |
15804 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15805 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
15806 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15807 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15808 | install_element(BGP_VPNV6_NODE, | |
15809 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15810 | |
15811 | /* "neighbor as-override" commands. */ | |
15812 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
15813 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
15814 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
15815 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
15816 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
15817 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
15818 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
15819 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
15820 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
15821 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
15822 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
15823 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
15824 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
15825 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
15826 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
15827 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
15828 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
15829 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
15830 | ||
15831 | /* "neighbor remove-private-AS" commands. */ | |
15832 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
15833 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
15834 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
15835 | install_element(BGP_NODE, | |
15836 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
15837 | install_element(BGP_NODE, | |
15838 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
15839 | install_element(BGP_NODE, | |
15840 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
15841 | install_element(BGP_NODE, | |
15842 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15843 | install_element( | |
15844 | BGP_NODE, | |
15845 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15846 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
15847 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15848 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15849 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15850 | install_element(BGP_IPV4_NODE, | |
15851 | &neighbor_remove_private_as_replace_as_cmd); | |
15852 | install_element(BGP_IPV4_NODE, | |
15853 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15854 | install_element(BGP_IPV4_NODE, | |
15855 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15856 | install_element(BGP_IPV4_NODE, | |
15857 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15858 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
15859 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
15860 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
15861 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15862 | install_element(BGP_IPV4M_NODE, | |
15863 | &neighbor_remove_private_as_replace_as_cmd); | |
15864 | install_element(BGP_IPV4M_NODE, | |
15865 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15866 | install_element(BGP_IPV4M_NODE, | |
15867 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15868 | install_element(BGP_IPV4M_NODE, | |
15869 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15870 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
15871 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
15872 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
15873 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15874 | install_element(BGP_IPV4L_NODE, | |
15875 | &neighbor_remove_private_as_replace_as_cmd); | |
15876 | install_element(BGP_IPV4L_NODE, | |
15877 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15878 | install_element(BGP_IPV4L_NODE, | |
15879 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15880 | install_element(BGP_IPV4L_NODE, | |
15881 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15882 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
15883 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15884 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15885 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15886 | install_element(BGP_IPV6_NODE, | |
15887 | &neighbor_remove_private_as_replace_as_cmd); | |
15888 | install_element(BGP_IPV6_NODE, | |
15889 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15890 | install_element(BGP_IPV6_NODE, | |
15891 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15892 | install_element(BGP_IPV6_NODE, | |
15893 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15894 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
15895 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
15896 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
15897 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15898 | install_element(BGP_IPV6M_NODE, | |
15899 | &neighbor_remove_private_as_replace_as_cmd); | |
15900 | install_element(BGP_IPV6M_NODE, | |
15901 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15902 | install_element(BGP_IPV6M_NODE, | |
15903 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15904 | install_element(BGP_IPV6M_NODE, | |
15905 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15906 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
15907 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
15908 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
15909 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15910 | install_element(BGP_IPV6L_NODE, | |
15911 | &neighbor_remove_private_as_replace_as_cmd); | |
15912 | install_element(BGP_IPV6L_NODE, | |
15913 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15914 | install_element(BGP_IPV6L_NODE, | |
15915 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15916 | install_element(BGP_IPV6L_NODE, | |
15917 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15918 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
15919 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15920 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15921 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15922 | install_element(BGP_VPNV4_NODE, | |
15923 | &neighbor_remove_private_as_replace_as_cmd); | |
15924 | install_element(BGP_VPNV4_NODE, | |
15925 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15926 | install_element(BGP_VPNV4_NODE, | |
15927 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15928 | install_element(BGP_VPNV4_NODE, | |
15929 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15930 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
15931 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15932 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15933 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15934 | install_element(BGP_VPNV6_NODE, | |
15935 | &neighbor_remove_private_as_replace_as_cmd); | |
15936 | install_element(BGP_VPNV6_NODE, | |
15937 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15938 | install_element(BGP_VPNV6_NODE, | |
15939 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15940 | install_element(BGP_VPNV6_NODE, | |
15941 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15942 | ||
15943 | /* "neighbor send-community" commands.*/ | |
15944 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
15945 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
15946 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
15947 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
15948 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
15949 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
15950 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
15951 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
15952 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
15953 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
15954 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
15955 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
15956 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
15957 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
15958 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
15959 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
15960 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
15961 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
15962 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
15963 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
15964 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
15965 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
15966 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
15967 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
15968 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
15969 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
15970 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
15971 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
15972 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
15973 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
15974 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
15975 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
15976 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
15977 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
15978 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
15979 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
15980 | ||
15981 | /* "neighbor route-reflector" commands.*/ | |
15982 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
15983 | install_element(BGP_NODE, | |
15984 | &no_neighbor_route_reflector_client_hidden_cmd); | |
15985 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
15986 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
15987 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
15988 | install_element(BGP_IPV4M_NODE, | |
15989 | &no_neighbor_route_reflector_client_cmd); | |
15990 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
15991 | install_element(BGP_IPV4L_NODE, | |
15992 | &no_neighbor_route_reflector_client_cmd); | |
15993 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
15994 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
15995 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
15996 | install_element(BGP_IPV6M_NODE, | |
15997 | &no_neighbor_route_reflector_client_cmd); | |
15998 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
15999 | install_element(BGP_IPV6L_NODE, | |
16000 | &no_neighbor_route_reflector_client_cmd); | |
16001 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16002 | install_element(BGP_VPNV4_NODE, | |
16003 | &no_neighbor_route_reflector_client_cmd); | |
16004 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16005 | install_element(BGP_VPNV6_NODE, | |
16006 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16007 | install_element(BGP_FLOWSPECV4_NODE, |
16008 | &neighbor_route_reflector_client_cmd); | |
16009 | install_element(BGP_FLOWSPECV4_NODE, | |
16010 | &no_neighbor_route_reflector_client_cmd); | |
16011 | install_element(BGP_FLOWSPECV6_NODE, | |
16012 | &neighbor_route_reflector_client_cmd); | |
16013 | install_element(BGP_FLOWSPECV6_NODE, | |
16014 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16015 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16016 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16017 | ||
16018 | /* "neighbor route-server" commands.*/ | |
16019 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16020 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16021 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16022 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16023 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16024 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16025 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16026 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16027 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16028 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16029 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16030 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16031 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16032 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16033 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16034 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16035 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16036 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16037 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16038 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16039 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16040 | install_element(BGP_FLOWSPECV4_NODE, | |
16041 | &no_neighbor_route_server_client_cmd); | |
16042 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16043 | install_element(BGP_FLOWSPECV6_NODE, | |
16044 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16045 | |
16046 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16047 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16048 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16049 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16050 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16051 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16052 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16053 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16054 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16055 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16056 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16057 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16058 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16059 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16060 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16061 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16062 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16063 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16064 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16065 | ||
16066 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16067 | install_element(BGP_NODE, | |
16068 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16069 | install_element(BGP_NODE, | |
16070 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16071 | install_element(BGP_IPV4_NODE, | |
16072 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16073 | install_element(BGP_IPV4_NODE, | |
16074 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16075 | install_element(BGP_IPV4M_NODE, | |
16076 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16077 | install_element(BGP_IPV4M_NODE, | |
16078 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16079 | install_element(BGP_IPV4L_NODE, | |
16080 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16081 | install_element(BGP_IPV4L_NODE, | |
16082 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16083 | install_element(BGP_IPV6_NODE, | |
16084 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16085 | install_element(BGP_IPV6_NODE, | |
16086 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16087 | install_element(BGP_IPV6M_NODE, | |
16088 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16089 | install_element(BGP_IPV6M_NODE, | |
16090 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16091 | install_element(BGP_IPV6L_NODE, | |
16092 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16093 | install_element(BGP_IPV6L_NODE, | |
16094 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16095 | install_element(BGP_VPNV4_NODE, | |
16096 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16097 | install_element(BGP_VPNV4_NODE, | |
16098 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16099 | install_element(BGP_VPNV6_NODE, | |
16100 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16101 | install_element(BGP_VPNV6_NODE, | |
16102 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16103 | ||
2b31007c RZ |
16104 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16105 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16106 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16107 | ||
d62a17ae | 16108 | /* "neighbor passive" commands. */ |
16109 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16110 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16111 | ||
16112 | ||
16113 | /* "neighbor shutdown" commands. */ | |
16114 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16115 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16116 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16117 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16118 | ||
16119 | /* "neighbor capability extended-nexthop" commands.*/ | |
16120 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16121 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16122 | ||
16123 | /* "neighbor capability orf prefix-list" commands.*/ | |
16124 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16125 | install_element(BGP_NODE, | |
16126 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16127 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16128 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16129 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16130 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16131 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16132 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16133 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16134 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16135 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16136 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16137 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16138 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16139 | ||
16140 | /* "neighbor capability dynamic" commands.*/ | |
16141 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16142 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16143 | ||
16144 | /* "neighbor dont-capability-negotiate" commands. */ | |
16145 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16146 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16147 | ||
16148 | /* "neighbor ebgp-multihop" commands. */ | |
16149 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16150 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16151 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16152 | ||
16153 | /* "neighbor disable-connected-check" commands. */ | |
16154 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16155 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16156 | ||
47cbc09b PM |
16157 | /* "neighbor enforce-first-as" commands. */ |
16158 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16159 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16160 | ||
d62a17ae | 16161 | /* "neighbor description" commands. */ |
16162 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16163 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16164 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16165 | |
16166 | /* "neighbor update-source" commands. "*/ | |
16167 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16168 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16169 | ||
16170 | /* "neighbor default-originate" commands. */ | |
16171 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16172 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16173 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16174 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16175 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16176 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16177 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16178 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16179 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16180 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16181 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16182 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16183 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16184 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16185 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16186 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16187 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16188 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16189 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16190 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16191 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16192 | ||
16193 | /* "neighbor port" commands. */ | |
16194 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16195 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16196 | ||
16197 | /* "neighbor weight" commands. */ | |
16198 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16199 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16200 | ||
16201 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16202 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16203 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16204 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16205 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16206 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16207 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16208 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16209 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16210 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16211 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16212 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16213 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16214 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16215 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16216 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16217 | ||
16218 | /* "neighbor override-capability" commands. */ | |
16219 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16220 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16221 | ||
16222 | /* "neighbor strict-capability-match" commands. */ | |
16223 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16224 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16225 | ||
16226 | /* "neighbor timers" commands. */ | |
16227 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16228 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16229 | ||
16230 | /* "neighbor timers connect" commands. */ | |
16231 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16232 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16233 | ||
16234 | /* "neighbor advertisement-interval" commands. */ | |
16235 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16236 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16237 | ||
16238 | /* "neighbor interface" commands. */ | |
16239 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16240 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16241 | ||
16242 | /* "neighbor distribute" commands. */ | |
16243 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16244 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16245 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16246 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16247 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16248 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16249 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16250 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16251 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16252 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16253 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16254 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16255 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16256 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16257 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16258 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16259 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16260 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16261 | ||
16262 | /* "neighbor prefix-list" commands. */ | |
16263 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16264 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16265 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16266 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16267 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16268 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16269 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16270 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16271 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16272 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16273 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16274 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16275 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16276 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16277 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16278 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16279 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16280 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16281 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16282 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16283 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16284 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16285 | |
16286 | /* "neighbor filter-list" commands. */ | |
16287 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16288 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16289 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16290 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16291 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16292 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16293 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16294 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16295 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16296 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16297 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16298 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16299 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16300 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16301 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16302 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16303 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16304 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16305 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16306 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16307 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16308 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16309 | |
16310 | /* "neighbor route-map" commands. */ | |
16311 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16312 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16313 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16314 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16315 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16316 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16317 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16318 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16319 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16320 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16321 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16322 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16323 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16324 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16325 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16326 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16327 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16328 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16329 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16330 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16331 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16332 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16333 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16334 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16335 | |
16336 | /* "neighbor unsuppress-map" commands. */ | |
16337 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16338 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16339 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16340 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16341 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16342 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16343 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16344 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16345 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16346 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16347 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16348 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16349 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16350 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16351 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16352 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16353 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16354 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16355 | ||
fde246e8 DA |
16356 | /* neighbor maximum-prefix-out commands. */ |
16357 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16358 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16359 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16360 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16361 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16362 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16363 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16364 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16365 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16366 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16367 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16368 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16369 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16370 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16371 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16372 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16373 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16374 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16375 | ||
d62a17ae | 16376 | /* "neighbor maximum-prefix" commands. */ |
16377 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16378 | install_element(BGP_NODE, | |
16379 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16380 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16381 | install_element(BGP_NODE, | |
16382 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16383 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16384 | install_element(BGP_NODE, | |
16385 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16386 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16387 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16388 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16389 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16390 | install_element(BGP_IPV4_NODE, | |
16391 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16392 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16393 | install_element(BGP_IPV4_NODE, | |
16394 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16395 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16396 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16397 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16398 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16399 | install_element(BGP_IPV4M_NODE, | |
16400 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16401 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16402 | install_element(BGP_IPV4M_NODE, | |
16403 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16404 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16405 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16406 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16407 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16408 | install_element(BGP_IPV4L_NODE, | |
16409 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16410 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16411 | install_element(BGP_IPV4L_NODE, | |
16412 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16413 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16414 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16415 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16416 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16417 | install_element(BGP_IPV6_NODE, | |
16418 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16419 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16420 | install_element(BGP_IPV6_NODE, | |
16421 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16422 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16423 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16424 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16425 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16426 | install_element(BGP_IPV6M_NODE, | |
16427 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16428 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16429 | install_element(BGP_IPV6M_NODE, | |
16430 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16431 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16432 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16433 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16434 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16435 | install_element(BGP_IPV6L_NODE, | |
16436 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16437 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16438 | install_element(BGP_IPV6L_NODE, | |
16439 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16440 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16441 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16442 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16443 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16444 | install_element(BGP_VPNV4_NODE, | |
16445 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16446 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16447 | install_element(BGP_VPNV4_NODE, | |
16448 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16449 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16450 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16451 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16452 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16453 | install_element(BGP_VPNV6_NODE, | |
16454 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16455 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16456 | install_element(BGP_VPNV6_NODE, | |
16457 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16458 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16459 | ||
16460 | /* "neighbor allowas-in" */ | |
16461 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16462 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16463 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16464 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16465 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16466 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16467 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16468 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16469 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16470 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16471 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16472 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16473 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16474 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16475 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16476 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16477 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16478 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16479 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16480 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16481 | ||
16482 | /* address-family commands. */ | |
16483 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16484 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16485 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16486 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16487 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16488 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16489 | |
d62a17ae | 16490 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16491 | ||
16492 | /* "exit-address-family" command. */ | |
16493 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16494 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16495 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16496 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16497 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16498 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16499 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16500 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16501 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16502 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16503 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16504 | ||
16505 | /* "clear ip bgp commands" */ | |
16506 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16507 | ||
16508 | /* clear ip bgp prefix */ | |
16509 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16510 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16511 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16512 | ||
16513 | /* "show [ip] bgp summary" commands. */ | |
16514 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16515 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16516 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16517 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16518 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16519 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16520 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16521 | ||
16522 | /* "show [ip] bgp neighbors" commands. */ | |
16523 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16524 | ||
36235319 | 16525 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16526 | |
d62a17ae | 16527 | /* "show [ip] bgp peer-group" commands. */ |
16528 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16529 | ||
16530 | /* "show [ip] bgp paths" commands. */ | |
16531 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16532 | ||
16533 | /* "show [ip] bgp community" commands. */ | |
16534 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16535 | ||
16536 | /* "show ip bgp large-community" commands. */ | |
16537 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16538 | /* "show [ip] bgp attribute-info" commands. */ | |
16539 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16540 | /* "show [ip] bgp route-leak" command */ |
16541 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16542 | |
16543 | /* "redistribute" commands. */ | |
16544 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16545 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16546 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16547 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16548 | install_element(BGP_NODE, | |
16549 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16550 | install_element(BGP_NODE, | |
16551 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16552 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16553 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16554 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16555 | install_element(BGP_NODE, | |
16556 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16557 | install_element(BGP_NODE, | |
16558 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16559 | install_element(BGP_NODE, | |
16560 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16561 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16562 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16563 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16564 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16565 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16566 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16567 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16568 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16569 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16570 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16571 | install_element(BGP_IPV4_NODE, | |
16572 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16573 | install_element(BGP_IPV4_NODE, | |
16574 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16575 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16576 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16577 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16578 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16579 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16580 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16581 | ||
b9c7bc5a PZ |
16582 | /* import|export vpn [route-map WORD] */ |
16583 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16584 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16585 | |
12a844a5 DS |
16586 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16587 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16588 | ||
d62a17ae | 16589 | /* ttl_security commands */ |
16590 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16591 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16592 | ||
16593 | /* "show [ip] bgp memory" commands. */ | |
16594 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16595 | ||
acf71666 MK |
16596 | /* "show bgp martian next-hop" */ |
16597 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16598 | ||
48ecf8f5 DS |
16599 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16600 | ||
d62a17ae | 16601 | /* "show [ip] bgp views" commands. */ |
16602 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16603 | ||
16604 | /* "show [ip] bgp vrfs" commands. */ | |
16605 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16606 | ||
16607 | /* Community-list. */ | |
16608 | community_list_vty(); | |
ddb5b488 PZ |
16609 | |
16610 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16611 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16612 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16613 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16614 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16615 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16616 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16617 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16618 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16619 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16620 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16621 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16622 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16623 | |
301ad80a PG |
16624 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16625 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16626 | ||
b9c7bc5a PZ |
16627 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16628 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16629 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16630 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
16631 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
16632 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
16633 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
16634 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16635 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16636 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16637 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16638 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16639 | } |
6b0655a2 | 16640 | |
718e3744 | 16641 | #include "memory.h" |
16642 | #include "bgp_regex.h" | |
16643 | #include "bgp_clist.h" | |
16644 | #include "bgp_ecommunity.h" | |
16645 | ||
16646 | /* VTY functions. */ | |
16647 | ||
16648 | /* Direction value to string conversion. */ | |
d62a17ae | 16649 | static const char *community_direct_str(int direct) |
16650 | { | |
16651 | switch (direct) { | |
16652 | case COMMUNITY_DENY: | |
16653 | return "deny"; | |
16654 | case COMMUNITY_PERMIT: | |
16655 | return "permit"; | |
16656 | default: | |
16657 | return "unknown"; | |
16658 | } | |
718e3744 | 16659 | } |
16660 | ||
16661 | /* Display error string. */ | |
d62a17ae | 16662 | static void community_list_perror(struct vty *vty, int ret) |
16663 | { | |
16664 | switch (ret) { | |
16665 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16666 | vty_out(vty, "%% Can't find community-list\n"); | |
16667 | break; | |
16668 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16669 | vty_out(vty, "%% Malformed community-list value\n"); | |
16670 | break; | |
16671 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16672 | vty_out(vty, | |
16673 | "%% Community name conflict, previously defined as standard community\n"); | |
16674 | break; | |
16675 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16676 | vty_out(vty, | |
16677 | "%% Community name conflict, previously defined as expanded community\n"); | |
16678 | break; | |
16679 | } | |
718e3744 | 16680 | } |
16681 | ||
5bf15956 DW |
16682 | /* "community-list" keyword help string. */ |
16683 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16684 | ||
7336e101 SP |
16685 | /*community-list standard */ |
16686 | DEFUN (community_list_standard, | |
16687 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 16688 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 16689 | BGP_STR |
718e3744 | 16690 | COMMUNITY_LIST_STR |
16691 | "Community list number (standard)\n" | |
5bf15956 | 16692 | "Add an standard community-list entry\n" |
718e3744 | 16693 | "Community list name\n" |
2f8cc0e5 DA |
16694 | "Sequence number of an entry\n" |
16695 | "Sequence number\n" | |
718e3744 | 16696 | "Specify community to reject\n" |
16697 | "Specify community to accept\n" | |
16698 | COMMUNITY_VAL_STR) | |
16699 | { | |
d62a17ae | 16700 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16701 | char *seq = NULL; |
d62a17ae | 16702 | int direct = 0; |
16703 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16704 | int idx = 0; |
7336e101 | 16705 | |
2f8cc0e5 DA |
16706 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16707 | if (idx) | |
16708 | seq = argv[idx]->arg; | |
16709 | ||
16710 | idx = 0; | |
d62a17ae | 16711 | argv_find(argv, argc, "(1-99)", &idx); |
16712 | argv_find(argv, argc, "WORD", &idx); | |
16713 | cl_name_or_number = argv[idx]->arg; | |
16714 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16715 | : COMMUNITY_DENY; | |
16716 | argv_find(argv, argc, "AA:NN", &idx); | |
16717 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16718 | |
2f8cc0e5 DA |
16719 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16720 | direct, style); | |
42f914d4 | 16721 | |
d62a17ae | 16722 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16723 | |
d62a17ae | 16724 | if (ret < 0) { |
16725 | /* Display error string. */ | |
16726 | community_list_perror(vty, ret); | |
16727 | return CMD_WARNING_CONFIG_FAILED; | |
16728 | } | |
42f914d4 | 16729 | |
d62a17ae | 16730 | return CMD_SUCCESS; |
718e3744 | 16731 | } |
16732 | ||
7336e101 SP |
16733 | DEFUN (no_community_list_standard_all, |
16734 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 16735 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16736 | NO_STR |
16737 | BGP_STR | |
16738 | COMMUNITY_LIST_STR | |
16739 | "Community list number (standard)\n" | |
16740 | "Add an standard community-list entry\n" | |
16741 | "Community list name\n" | |
2f8cc0e5 DA |
16742 | "Sequence number of an entry\n" |
16743 | "Sequence number\n" | |
7336e101 SP |
16744 | "Specify community to reject\n" |
16745 | "Specify community to accept\n" | |
16746 | COMMUNITY_VAL_STR) | |
718e3744 | 16747 | { |
d62a17ae | 16748 | char *cl_name_or_number = NULL; |
174b5cb9 | 16749 | char *str = NULL; |
d62a17ae | 16750 | int direct = 0; |
16751 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 16752 | char *seq = NULL; |
d62a17ae | 16753 | int idx = 0; |
7336e101 | 16754 | |
2f8cc0e5 DA |
16755 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16756 | if (idx) | |
16757 | seq = argv[idx]->arg; | |
16758 | ||
16759 | idx = 0; | |
174b5cb9 DA |
16760 | argv_find(argv, argc, "permit", &idx); |
16761 | argv_find(argv, argc, "deny", &idx); | |
16762 | ||
16763 | if (idx) { | |
16764 | direct = argv_find(argv, argc, "permit", &idx) | |
16765 | ? COMMUNITY_PERMIT | |
16766 | : COMMUNITY_DENY; | |
16767 | ||
16768 | idx = 0; | |
16769 | argv_find(argv, argc, "AA:NN", &idx); | |
16770 | str = argv_concat(argv, argc, idx); | |
16771 | } | |
16772 | ||
16773 | idx = 0; | |
d62a17ae | 16774 | argv_find(argv, argc, "(1-99)", &idx); |
16775 | argv_find(argv, argc, "WORD", &idx); | |
16776 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16777 | |
2f8cc0e5 | 16778 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16779 | direct, style); |
42f914d4 | 16780 | |
d62a17ae | 16781 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16782 | |
d62a17ae | 16783 | if (ret < 0) { |
16784 | community_list_perror(vty, ret); | |
16785 | return CMD_WARNING_CONFIG_FAILED; | |
16786 | } | |
42f914d4 | 16787 | |
d62a17ae | 16788 | return CMD_SUCCESS; |
718e3744 | 16789 | } |
7336e101 | 16790 | |
174b5cb9 DA |
16791 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
16792 | "no bgp community-list <(1-99)|standard WORD>", | |
16793 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
16794 | "Community list number (standard)\n" | |
16795 | "Add an standard community-list entry\n" | |
16796 | "Community list name\n") | |
16797 | ||
7336e101 SP |
16798 | /*community-list expanded */ |
16799 | DEFUN (community_list_expanded_all, | |
16800 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16801 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16802 | BGP_STR |
16803 | COMMUNITY_LIST_STR | |
718e3744 | 16804 | "Community list number (expanded)\n" |
5bf15956 | 16805 | "Add an expanded community-list entry\n" |
718e3744 | 16806 | "Community list name\n" |
2f8cc0e5 DA |
16807 | "Sequence number of an entry\n" |
16808 | "Sequence number\n" | |
718e3744 | 16809 | "Specify community to reject\n" |
16810 | "Specify community to accept\n" | |
16811 | COMMUNITY_VAL_STR) | |
16812 | { | |
d62a17ae | 16813 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16814 | char *seq = NULL; |
d62a17ae | 16815 | int direct = 0; |
16816 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16817 | int idx = 0; |
7b9a4750 | 16818 | |
2f8cc0e5 DA |
16819 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16820 | if (idx) | |
16821 | seq = argv[idx]->arg; | |
16822 | ||
16823 | idx = 0; | |
16824 | ||
d62a17ae | 16825 | argv_find(argv, argc, "(100-500)", &idx); |
16826 | argv_find(argv, argc, "WORD", &idx); | |
16827 | cl_name_or_number = argv[idx]->arg; | |
16828 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16829 | : COMMUNITY_DENY; | |
16830 | argv_find(argv, argc, "AA:NN", &idx); | |
16831 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16832 | |
2f8cc0e5 DA |
16833 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16834 | direct, style); | |
42f914d4 | 16835 | |
d62a17ae | 16836 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16837 | |
d62a17ae | 16838 | if (ret < 0) { |
16839 | /* Display error string. */ | |
16840 | community_list_perror(vty, ret); | |
16841 | return CMD_WARNING_CONFIG_FAILED; | |
16842 | } | |
42f914d4 | 16843 | |
d62a17ae | 16844 | return CMD_SUCCESS; |
718e3744 | 16845 | } |
16846 | ||
7336e101 SP |
16847 | DEFUN (no_community_list_expanded_all, |
16848 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16849 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16850 | NO_STR |
16851 | BGP_STR | |
16852 | COMMUNITY_LIST_STR | |
16853 | "Community list number (expanded)\n" | |
16854 | "Add an expanded community-list entry\n" | |
16855 | "Community list name\n" | |
2f8cc0e5 DA |
16856 | "Sequence number of an entry\n" |
16857 | "Sequence number\n" | |
7336e101 SP |
16858 | "Specify community to reject\n" |
16859 | "Specify community to accept\n" | |
16860 | COMMUNITY_VAL_STR) | |
718e3744 | 16861 | { |
d62a17ae | 16862 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16863 | char *seq = NULL; |
174b5cb9 | 16864 | char *str = NULL; |
d62a17ae | 16865 | int direct = 0; |
16866 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16867 | int idx = 0; |
174b5cb9 | 16868 | |
2f8cc0e5 DA |
16869 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16870 | if (idx) | |
16871 | seq = argv[idx]->arg; | |
16872 | ||
16873 | idx = 0; | |
174b5cb9 DA |
16874 | argv_find(argv, argc, "permit", &idx); |
16875 | argv_find(argv, argc, "deny", &idx); | |
16876 | ||
16877 | if (idx) { | |
16878 | direct = argv_find(argv, argc, "permit", &idx) | |
16879 | ? COMMUNITY_PERMIT | |
16880 | : COMMUNITY_DENY; | |
16881 | ||
16882 | idx = 0; | |
16883 | argv_find(argv, argc, "AA:NN", &idx); | |
16884 | str = argv_concat(argv, argc, idx); | |
7336e101 | 16885 | } |
174b5cb9 DA |
16886 | |
16887 | idx = 0; | |
d62a17ae | 16888 | argv_find(argv, argc, "(100-500)", &idx); |
16889 | argv_find(argv, argc, "WORD", &idx); | |
16890 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16891 | |
2f8cc0e5 | 16892 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16893 | direct, style); |
42f914d4 | 16894 | |
d62a17ae | 16895 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16896 | |
d62a17ae | 16897 | if (ret < 0) { |
16898 | community_list_perror(vty, ret); | |
16899 | return CMD_WARNING_CONFIG_FAILED; | |
16900 | } | |
42f914d4 | 16901 | |
d62a17ae | 16902 | return CMD_SUCCESS; |
718e3744 | 16903 | } |
16904 | ||
174b5cb9 DA |
16905 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
16906 | "no bgp community-list <(100-500)|expanded WORD>", | |
16907 | NO_STR IP_STR COMMUNITY_LIST_STR | |
16908 | "Community list number (expanded)\n" | |
16909 | "Add an expanded community-list entry\n" | |
16910 | "Community list name\n") | |
16911 | ||
8d9b8ed9 PM |
16912 | /* Return configuration string of community-list entry. */ |
16913 | static const char *community_list_config_str(struct community_entry *entry) | |
16914 | { | |
16915 | const char *str; | |
16916 | ||
16917 | if (entry->any) | |
16918 | str = ""; | |
16919 | else { | |
16920 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
16921 | str = community_str(entry->u.com, false); | |
16922 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
16923 | str = lcommunity_str(entry->u.lcom, false); | |
16924 | else | |
16925 | str = entry->config; | |
16926 | } | |
16927 | return str; | |
16928 | } | |
16929 | ||
d62a17ae | 16930 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 16931 | { |
d62a17ae | 16932 | struct community_entry *entry; |
718e3744 | 16933 | |
d62a17ae | 16934 | for (entry = list->head; entry; entry = entry->next) { |
16935 | if (entry == list->head) { | |
16936 | if (all_digit(list->name)) | |
16937 | vty_out(vty, "Community %s list %s\n", | |
16938 | entry->style == COMMUNITY_LIST_STANDARD | |
16939 | ? "standard" | |
16940 | : "(expanded) access", | |
16941 | list->name); | |
16942 | else | |
16943 | vty_out(vty, "Named Community %s list %s\n", | |
16944 | entry->style == COMMUNITY_LIST_STANDARD | |
16945 | ? "standard" | |
16946 | : "expanded", | |
16947 | list->name); | |
16948 | } | |
16949 | if (entry->any) | |
16950 | vty_out(vty, " %s\n", | |
16951 | community_direct_str(entry->direct)); | |
16952 | else | |
16953 | vty_out(vty, " %s %s\n", | |
16954 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16955 | community_list_config_str(entry)); |
d62a17ae | 16956 | } |
718e3744 | 16957 | } |
16958 | ||
7336e101 SP |
16959 | DEFUN (show_community_list, |
16960 | show_bgp_community_list_cmd, | |
16961 | "show bgp community-list", | |
718e3744 | 16962 | SHOW_STR |
7336e101 | 16963 | BGP_STR |
718e3744 | 16964 | "List community-list\n") |
16965 | { | |
d62a17ae | 16966 | struct community_list *list; |
16967 | struct community_list_master *cm; | |
718e3744 | 16968 | |
d62a17ae | 16969 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
16970 | if (!cm) | |
16971 | return CMD_SUCCESS; | |
718e3744 | 16972 | |
d62a17ae | 16973 | for (list = cm->num.head; list; list = list->next) |
16974 | community_list_show(vty, list); | |
718e3744 | 16975 | |
d62a17ae | 16976 | for (list = cm->str.head; list; list = list->next) |
16977 | community_list_show(vty, list); | |
718e3744 | 16978 | |
d62a17ae | 16979 | return CMD_SUCCESS; |
718e3744 | 16980 | } |
16981 | ||
7336e101 SP |
16982 | DEFUN (show_community_list_arg, |
16983 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 16984 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
16985 | SHOW_STR |
16986 | BGP_STR | |
718e3744 | 16987 | "List community-list\n" |
16988 | "Community-list number\n" | |
960b69b9 | 16989 | "Community-list name\n" |
16990 | "Detailed information on community-list\n") | |
718e3744 | 16991 | { |
d62a17ae | 16992 | int idx_comm_list = 3; |
16993 | struct community_list *list; | |
718e3744 | 16994 | |
e237b0d2 | 16995 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 16996 | COMMUNITY_LIST_MASTER); |
16997 | if (!list) { | |
16998 | vty_out(vty, "%% Can't find community-list\n"); | |
16999 | return CMD_WARNING; | |
17000 | } | |
718e3744 | 17001 | |
d62a17ae | 17002 | community_list_show(vty, list); |
718e3744 | 17003 | |
d62a17ae | 17004 | return CMD_SUCCESS; |
718e3744 | 17005 | } |
6b0655a2 | 17006 | |
57d187bc JS |
17007 | /* |
17008 | * Large Community code. | |
17009 | */ | |
d62a17ae | 17010 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17011 | struct cmd_token **argv, int style, | |
17012 | int reject_all_digit_name) | |
17013 | { | |
17014 | int ret; | |
17015 | int direct; | |
17016 | char *str; | |
17017 | int idx = 0; | |
17018 | char *cl_name; | |
2f8cc0e5 DA |
17019 | char *seq = NULL; |
17020 | ||
17021 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17022 | if (idx) | |
17023 | seq = argv[idx]->arg; | |
d62a17ae | 17024 | |
2f8cc0e5 | 17025 | idx = 0; |
d62a17ae | 17026 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17027 | : COMMUNITY_DENY; | |
17028 | ||
17029 | /* All digit name check. */ | |
17030 | idx = 0; | |
17031 | argv_find(argv, argc, "WORD", &idx); | |
17032 | argv_find(argv, argc, "(1-99)", &idx); | |
17033 | argv_find(argv, argc, "(100-500)", &idx); | |
17034 | cl_name = argv[idx]->arg; | |
17035 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17036 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17037 | return CMD_WARNING_CONFIG_FAILED; | |
17038 | } | |
17039 | ||
17040 | idx = 0; | |
17041 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17042 | argv_find(argv, argc, "LINE", &idx); | |
17043 | /* Concat community string argument. */ | |
17044 | if (idx) | |
17045 | str = argv_concat(argv, argc, idx); | |
17046 | else | |
17047 | str = NULL; | |
17048 | ||
2f8cc0e5 | 17049 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17050 | |
17051 | /* Free temporary community list string allocated by | |
17052 | argv_concat(). */ | |
0a22ddfb | 17053 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17054 | |
17055 | if (ret < 0) { | |
17056 | community_list_perror(vty, ret); | |
17057 | return CMD_WARNING_CONFIG_FAILED; | |
17058 | } | |
17059 | return CMD_SUCCESS; | |
17060 | } | |
17061 | ||
17062 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17063 | struct cmd_token **argv, int style) | |
17064 | { | |
17065 | int ret; | |
17066 | int direct = 0; | |
17067 | char *str = NULL; | |
17068 | int idx = 0; | |
2f8cc0e5 | 17069 | char *seq = NULL; |
d62a17ae | 17070 | |
2f8cc0e5 DA |
17071 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17072 | if (idx) | |
17073 | seq = argv[idx]->arg; | |
d62a17ae | 17074 | |
2f8cc0e5 | 17075 | idx = 0; |
d62a17ae | 17076 | argv_find(argv, argc, "permit", &idx); |
17077 | argv_find(argv, argc, "deny", &idx); | |
17078 | ||
17079 | if (idx) { | |
17080 | /* Check the list direct. */ | |
17081 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17082 | direct = COMMUNITY_PERMIT; | |
17083 | else | |
17084 | direct = COMMUNITY_DENY; | |
17085 | ||
17086 | idx = 0; | |
17087 | argv_find(argv, argc, "LINE", &idx); | |
17088 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17089 | /* Concat community string argument. */ | |
17090 | str = argv_concat(argv, argc, idx); | |
17091 | } | |
17092 | ||
17093 | idx = 0; | |
17094 | argv_find(argv, argc, "(1-99)", &idx); | |
17095 | argv_find(argv, argc, "(100-500)", &idx); | |
17096 | argv_find(argv, argc, "WORD", &idx); | |
17097 | ||
17098 | /* Unset community list. */ | |
2f8cc0e5 | 17099 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17100 | style); |
17101 | ||
17102 | /* Free temporary community list string allocated by | |
17103 | argv_concat(). */ | |
0a22ddfb | 17104 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17105 | |
17106 | if (ret < 0) { | |
17107 | community_list_perror(vty, ret); | |
17108 | return CMD_WARNING_CONFIG_FAILED; | |
17109 | } | |
17110 | ||
17111 | return CMD_SUCCESS; | |
57d187bc JS |
17112 | } |
17113 | ||
17114 | /* "large-community-list" keyword help string. */ | |
17115 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17116 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17117 | ||
7336e101 SP |
17118 | DEFUN (lcommunity_list_standard, |
17119 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17120 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17121 | BGP_STR |
17122 | LCOMMUNITY_LIST_STR | |
17123 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17124 | "Sequence number of an entry\n" |
17125 | "Sequence number\n" | |
7336e101 SP |
17126 | "Specify large community to reject\n" |
17127 | "Specify large community to accept\n" | |
17128 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17129 | { |
d62a17ae | 17130 | return lcommunity_list_set_vty(vty, argc, argv, |
17131 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17132 | } |
17133 | ||
7336e101 SP |
17134 | DEFUN (lcommunity_list_expanded, |
17135 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17136 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17137 | BGP_STR |
17138 | LCOMMUNITY_LIST_STR | |
17139 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17140 | "Sequence number of an entry\n" |
17141 | "Sequence number\n" | |
7336e101 SP |
17142 | "Specify large community to reject\n" |
17143 | "Specify large community to accept\n" | |
17144 | "An ordered list as a regular-expression\n") | |
57d187bc | 17145 | { |
d62a17ae | 17146 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17147 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17148 | } |
17149 | ||
7336e101 SP |
17150 | DEFUN (lcommunity_list_name_standard, |
17151 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17152 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17153 | BGP_STR |
17154 | LCOMMUNITY_LIST_STR | |
17155 | "Specify standard large-community-list\n" | |
17156 | "Large Community list name\n" | |
2f8cc0e5 DA |
17157 | "Sequence number of an entry\n" |
17158 | "Sequence number\n" | |
7336e101 SP |
17159 | "Specify large community to reject\n" |
17160 | "Specify large community to accept\n" | |
17161 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17162 | { |
d62a17ae | 17163 | return lcommunity_list_set_vty(vty, argc, argv, |
17164 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17165 | } |
17166 | ||
7336e101 SP |
17167 | DEFUN (lcommunity_list_name_expanded, |
17168 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17169 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17170 | BGP_STR |
17171 | LCOMMUNITY_LIST_STR | |
17172 | "Specify expanded large-community-list\n" | |
17173 | "Large Community list name\n" | |
2f8cc0e5 DA |
17174 | "Sequence number of an entry\n" |
17175 | "Sequence number\n" | |
7336e101 SP |
17176 | "Specify large community to reject\n" |
17177 | "Specify large community to accept\n" | |
17178 | "An ordered list as a regular-expression\n") | |
57d187bc | 17179 | { |
d62a17ae | 17180 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17181 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17182 | } |
17183 | ||
4378f57c DA |
17184 | DEFUN (no_lcommunity_list_all, |
17185 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17186 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17187 | NO_STR | |
17188 | BGP_STR | |
17189 | LCOMMUNITY_LIST_STR | |
17190 | "Large Community list number (standard)\n" | |
17191 | "Large Community list number (expanded)\n" | |
17192 | "Large Community list name\n") | |
57d187bc | 17193 | { |
7336e101 SP |
17194 | return lcommunity_list_unset_vty(vty, argc, argv, |
17195 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17196 | } |
17197 | ||
4378f57c DA |
17198 | DEFUN (no_lcommunity_list_name_standard_all, |
17199 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17200 | "no bgp large-community-list standard WORD", | |
17201 | NO_STR | |
17202 | BGP_STR | |
17203 | LCOMMUNITY_LIST_STR | |
17204 | "Specify standard large-community-list\n" | |
17205 | "Large Community list name\n") | |
17206 | { | |
17207 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17208 | LARGE_COMMUNITY_LIST_STANDARD); | |
17209 | } | |
17210 | ||
7336e101 SP |
17211 | DEFUN (no_lcommunity_list_name_expanded_all, |
17212 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17213 | "no bgp large-community-list expanded WORD", | |
17214 | NO_STR | |
17215 | BGP_STR | |
17216 | LCOMMUNITY_LIST_STR | |
17217 | "Specify expanded large-community-list\n" | |
17218 | "Large Community list name\n") | |
57d187bc | 17219 | { |
d62a17ae | 17220 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17221 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17222 | } |
17223 | ||
7336e101 SP |
17224 | DEFUN (no_lcommunity_list_standard, |
17225 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17226 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17227 | NO_STR |
17228 | BGP_STR | |
17229 | LCOMMUNITY_LIST_STR | |
17230 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17231 | "Sequence number of an entry\n" |
17232 | "Sequence number\n" | |
7336e101 SP |
17233 | "Specify large community to reject\n" |
17234 | "Specify large community to accept\n" | |
17235 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17236 | { |
d62a17ae | 17237 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17238 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17239 | } |
17240 | ||
7336e101 SP |
17241 | DEFUN (no_lcommunity_list_expanded, |
17242 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17243 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17244 | NO_STR |
17245 | BGP_STR | |
17246 | LCOMMUNITY_LIST_STR | |
17247 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17248 | "Sequence number of an entry\n" |
17249 | "Sequence number\n" | |
7336e101 SP |
17250 | "Specify large community to reject\n" |
17251 | "Specify large community to accept\n" | |
17252 | "An ordered list as a regular-expression\n") | |
57d187bc | 17253 | { |
d62a17ae | 17254 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17255 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17256 | } |
17257 | ||
7336e101 SP |
17258 | DEFUN (no_lcommunity_list_name_standard, |
17259 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17260 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17261 | NO_STR |
17262 | BGP_STR | |
17263 | LCOMMUNITY_LIST_STR | |
17264 | "Specify standard large-community-list\n" | |
17265 | "Large Community list name\n" | |
2f8cc0e5 DA |
17266 | "Sequence number of an entry\n" |
17267 | "Sequence number\n" | |
7336e101 SP |
17268 | "Specify large community to reject\n" |
17269 | "Specify large community to accept\n" | |
17270 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17271 | { |
d62a17ae | 17272 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17273 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17274 | } |
17275 | ||
7336e101 SP |
17276 | DEFUN (no_lcommunity_list_name_expanded, |
17277 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17278 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17279 | NO_STR |
17280 | BGP_STR | |
17281 | LCOMMUNITY_LIST_STR | |
17282 | "Specify expanded large-community-list\n" | |
17283 | "Large community list name\n" | |
2f8cc0e5 DA |
17284 | "Sequence number of an entry\n" |
17285 | "Sequence number\n" | |
7336e101 SP |
17286 | "Specify large community to reject\n" |
17287 | "Specify large community to accept\n" | |
17288 | "An ordered list as a regular-expression\n") | |
57d187bc | 17289 | { |
d62a17ae | 17290 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17291 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17292 | } |
17293 | ||
d62a17ae | 17294 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17295 | { | |
17296 | struct community_entry *entry; | |
17297 | ||
17298 | for (entry = list->head; entry; entry = entry->next) { | |
17299 | if (entry == list->head) { | |
17300 | if (all_digit(list->name)) | |
17301 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17302 | entry->style == |
17303 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17304 | ? "standard" |
17305 | : "(expanded) access", | |
17306 | list->name); | |
17307 | else | |
17308 | vty_out(vty, | |
17309 | "Named large community %s list %s\n", | |
169b72c8 | 17310 | entry->style == |
17311 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17312 | ? "standard" |
17313 | : "expanded", | |
17314 | list->name); | |
17315 | } | |
17316 | if (entry->any) | |
17317 | vty_out(vty, " %s\n", | |
17318 | community_direct_str(entry->direct)); | |
17319 | else | |
17320 | vty_out(vty, " %s %s\n", | |
17321 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17322 | community_list_config_str(entry)); |
d62a17ae | 17323 | } |
57d187bc JS |
17324 | } |
17325 | ||
7336e101 SP |
17326 | DEFUN (show_lcommunity_list, |
17327 | show_bgp_lcommunity_list_cmd, | |
17328 | "show bgp large-community-list", | |
57d187bc | 17329 | SHOW_STR |
7336e101 | 17330 | BGP_STR |
57d187bc JS |
17331 | "List large-community list\n") |
17332 | { | |
d62a17ae | 17333 | struct community_list *list; |
17334 | struct community_list_master *cm; | |
57d187bc | 17335 | |
d62a17ae | 17336 | cm = community_list_master_lookup(bgp_clist, |
17337 | LARGE_COMMUNITY_LIST_MASTER); | |
17338 | if (!cm) | |
17339 | return CMD_SUCCESS; | |
57d187bc | 17340 | |
d62a17ae | 17341 | for (list = cm->num.head; list; list = list->next) |
17342 | lcommunity_list_show(vty, list); | |
57d187bc | 17343 | |
d62a17ae | 17344 | for (list = cm->str.head; list; list = list->next) |
17345 | lcommunity_list_show(vty, list); | |
57d187bc | 17346 | |
d62a17ae | 17347 | return CMD_SUCCESS; |
57d187bc JS |
17348 | } |
17349 | ||
7336e101 SP |
17350 | DEFUN (show_lcommunity_list_arg, |
17351 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17352 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17353 | SHOW_STR |
17354 | BGP_STR | |
57d187bc | 17355 | "List large-community list\n" |
960b69b9 | 17356 | "Large-community-list number\n" |
17357 | "Large-community-list name\n" | |
17358 | "Detailed information on large-community-list\n") | |
57d187bc | 17359 | { |
d62a17ae | 17360 | struct community_list *list; |
57d187bc | 17361 | |
e237b0d2 | 17362 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17363 | LARGE_COMMUNITY_LIST_MASTER); |
17364 | if (!list) { | |
960b69b9 | 17365 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17366 | return CMD_WARNING; |
17367 | } | |
57d187bc | 17368 | |
d62a17ae | 17369 | lcommunity_list_show(vty, list); |
57d187bc | 17370 | |
d62a17ae | 17371 | return CMD_SUCCESS; |
57d187bc JS |
17372 | } |
17373 | ||
718e3744 | 17374 | /* "extcommunity-list" keyword help string. */ |
17375 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17376 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17377 | ||
7336e101 SP |
17378 | DEFUN (extcommunity_list_standard, |
17379 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17380 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17381 | BGP_STR |
718e3744 | 17382 | EXTCOMMUNITY_LIST_STR |
17383 | "Extended Community list number (standard)\n" | |
718e3744 | 17384 | "Specify standard extcommunity-list\n" |
5bf15956 | 17385 | "Community list name\n" |
2f8cc0e5 DA |
17386 | "Sequence number of an entry\n" |
17387 | "Sequence number\n" | |
718e3744 | 17388 | "Specify community to reject\n" |
17389 | "Specify community to accept\n" | |
17390 | EXTCOMMUNITY_VAL_STR) | |
17391 | { | |
d62a17ae | 17392 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17393 | int direct = 0; | |
17394 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17395 | char *seq = NULL; |
42f914d4 | 17396 | |
d62a17ae | 17397 | int idx = 0; |
7b9a4750 | 17398 | |
d62a17ae | 17399 | argv_find(argv, argc, "(1-99)", &idx); |
17400 | argv_find(argv, argc, "WORD", &idx); | |
17401 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17402 | |
17403 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17404 | if (idx) | |
17405 | seq = argv[idx]->arg; | |
17406 | ||
d62a17ae | 17407 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17408 | : COMMUNITY_DENY; | |
17409 | argv_find(argv, argc, "AA:NN", &idx); | |
17410 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17411 | |
2f8cc0e5 | 17412 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17413 | direct, style); |
42f914d4 | 17414 | |
d62a17ae | 17415 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17416 | |
d62a17ae | 17417 | if (ret < 0) { |
17418 | community_list_perror(vty, ret); | |
17419 | return CMD_WARNING_CONFIG_FAILED; | |
17420 | } | |
42f914d4 | 17421 | |
d62a17ae | 17422 | return CMD_SUCCESS; |
718e3744 | 17423 | } |
17424 | ||
7336e101 SP |
17425 | DEFUN (extcommunity_list_name_expanded, |
17426 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17427 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17428 | BGP_STR |
17429 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17430 | "Extended Community list number (expanded)\n" |
718e3744 | 17431 | "Specify expanded extcommunity-list\n" |
17432 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17433 | "Sequence number of an entry\n" |
17434 | "Sequence number\n" | |
718e3744 | 17435 | "Specify community to reject\n" |
17436 | "Specify community to accept\n" | |
17437 | "An ordered list as a regular-expression\n") | |
17438 | { | |
d62a17ae | 17439 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17440 | int direct = 0; | |
17441 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17442 | char *seq = NULL; |
d62a17ae | 17443 | int idx = 0; |
7336e101 | 17444 | |
d62a17ae | 17445 | argv_find(argv, argc, "(100-500)", &idx); |
17446 | argv_find(argv, argc, "WORD", &idx); | |
17447 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17448 | |
17449 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17450 | if (idx) | |
17451 | seq = argv[idx]->arg; | |
17452 | ||
d62a17ae | 17453 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17454 | : COMMUNITY_DENY; | |
17455 | argv_find(argv, argc, "LINE", &idx); | |
17456 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17457 | |
2f8cc0e5 | 17458 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17459 | direct, style); |
42f914d4 | 17460 | |
d62a17ae | 17461 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17462 | |
d62a17ae | 17463 | if (ret < 0) { |
17464 | community_list_perror(vty, ret); | |
17465 | return CMD_WARNING_CONFIG_FAILED; | |
17466 | } | |
42f914d4 | 17467 | |
d62a17ae | 17468 | return CMD_SUCCESS; |
718e3744 | 17469 | } |
17470 | ||
7336e101 SP |
17471 | DEFUN (no_extcommunity_list_standard_all, |
17472 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17473 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17474 | NO_STR |
17475 | BGP_STR | |
17476 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17477 | "Extended Community list number (standard)\n" |
718e3744 | 17478 | "Specify standard extcommunity-list\n" |
5bf15956 | 17479 | "Community list name\n" |
2f8cc0e5 DA |
17480 | "Sequence number of an entry\n" |
17481 | "Sequence number\n" | |
718e3744 | 17482 | "Specify community to reject\n" |
17483 | "Specify community to accept\n" | |
17484 | EXTCOMMUNITY_VAL_STR) | |
17485 | { | |
d62a17ae | 17486 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17487 | int direct = 0; | |
17488 | char *cl_number_or_name = NULL; | |
d4455c89 | 17489 | char *str = NULL; |
2f8cc0e5 | 17490 | char *seq = NULL; |
d62a17ae | 17491 | int idx = 0; |
d4455c89 | 17492 | |
2f8cc0e5 DA |
17493 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17494 | if (idx) | |
17495 | seq = argv[idx]->arg; | |
17496 | ||
17497 | idx = 0; | |
d4455c89 DA |
17498 | argv_find(argv, argc, "permit", &idx); |
17499 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17500 | if (idx) { |
17501 | direct = argv_find(argv, argc, "permit", &idx) | |
17502 | ? COMMUNITY_PERMIT | |
17503 | : COMMUNITY_DENY; | |
17504 | ||
17505 | idx = 0; | |
17506 | argv_find(argv, argc, "AA:NN", &idx); | |
17507 | str = argv_concat(argv, argc, idx); | |
17508 | } | |
17509 | ||
17510 | idx = 0; | |
d62a17ae | 17511 | argv_find(argv, argc, "(1-99)", &idx); |
17512 | argv_find(argv, argc, "WORD", &idx); | |
17513 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17514 | |
d62a17ae | 17515 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17516 | seq, direct, style); |
42f914d4 | 17517 | |
d62a17ae | 17518 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17519 | |
d62a17ae | 17520 | if (ret < 0) { |
17521 | community_list_perror(vty, ret); | |
17522 | return CMD_WARNING_CONFIG_FAILED; | |
17523 | } | |
42f914d4 | 17524 | |
d62a17ae | 17525 | return CMD_SUCCESS; |
718e3744 | 17526 | } |
17527 | ||
d4455c89 DA |
17528 | ALIAS(no_extcommunity_list_standard_all, |
17529 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17530 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17531 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17532 | "Extended Community list number (standard)\n" | |
17533 | "Specify standard extcommunity-list\n" | |
17534 | "Community list name\n") | |
17535 | ||
7336e101 SP |
17536 | DEFUN (no_extcommunity_list_expanded_all, |
17537 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17538 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17539 | NO_STR |
17540 | BGP_STR | |
17541 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17542 | "Extended Community list number (expanded)\n" |
718e3744 | 17543 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17544 | "Extended Community list name\n" |
2f8cc0e5 DA |
17545 | "Sequence number of an entry\n" |
17546 | "Sequence number\n" | |
718e3744 | 17547 | "Specify community to reject\n" |
17548 | "Specify community to accept\n" | |
17549 | "An ordered list as a regular-expression\n") | |
17550 | { | |
d62a17ae | 17551 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17552 | int direct = 0; | |
17553 | char *cl_number_or_name = NULL; | |
d4455c89 | 17554 | char *str = NULL; |
2f8cc0e5 | 17555 | char *seq = NULL; |
d62a17ae | 17556 | int idx = 0; |
d4455c89 | 17557 | |
2f8cc0e5 DA |
17558 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17559 | if (idx) | |
17560 | seq = argv[idx]->arg; | |
17561 | ||
17562 | idx = 0; | |
d4455c89 DA |
17563 | argv_find(argv, argc, "permit", &idx); |
17564 | argv_find(argv, argc, "deny", &idx); | |
17565 | ||
17566 | if (idx) { | |
17567 | direct = argv_find(argv, argc, "permit", &idx) | |
17568 | ? COMMUNITY_PERMIT | |
17569 | : COMMUNITY_DENY; | |
17570 | ||
17571 | idx = 0; | |
17572 | argv_find(argv, argc, "LINE", &idx); | |
17573 | str = argv_concat(argv, argc, idx); | |
17574 | } | |
17575 | ||
17576 | idx = 0; | |
d62a17ae | 17577 | argv_find(argv, argc, "(100-500)", &idx); |
17578 | argv_find(argv, argc, "WORD", &idx); | |
17579 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17580 | |
d62a17ae | 17581 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17582 | seq, direct, style); |
42f914d4 | 17583 | |
d62a17ae | 17584 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17585 | |
d62a17ae | 17586 | if (ret < 0) { |
17587 | community_list_perror(vty, ret); | |
17588 | return CMD_WARNING_CONFIG_FAILED; | |
17589 | } | |
42f914d4 | 17590 | |
d62a17ae | 17591 | return CMD_SUCCESS; |
718e3744 | 17592 | } |
17593 | ||
d4455c89 DA |
17594 | ALIAS(no_extcommunity_list_expanded_all, |
17595 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17596 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17597 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17598 | "Extended Community list number (expanded)\n" | |
17599 | "Specify expanded extcommunity-list\n" | |
17600 | "Extended Community list name\n") | |
17601 | ||
d62a17ae | 17602 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17603 | { |
d62a17ae | 17604 | struct community_entry *entry; |
718e3744 | 17605 | |
d62a17ae | 17606 | for (entry = list->head; entry; entry = entry->next) { |
17607 | if (entry == list->head) { | |
17608 | if (all_digit(list->name)) | |
17609 | vty_out(vty, "Extended community %s list %s\n", | |
17610 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17611 | ? "standard" | |
17612 | : "(expanded) access", | |
17613 | list->name); | |
17614 | else | |
17615 | vty_out(vty, | |
17616 | "Named extended community %s list %s\n", | |
17617 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17618 | ? "standard" | |
17619 | : "expanded", | |
17620 | list->name); | |
17621 | } | |
17622 | if (entry->any) | |
17623 | vty_out(vty, " %s\n", | |
17624 | community_direct_str(entry->direct)); | |
17625 | else | |
17626 | vty_out(vty, " %s %s\n", | |
17627 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17628 | community_list_config_str(entry)); |
d62a17ae | 17629 | } |
718e3744 | 17630 | } |
17631 | ||
7336e101 SP |
17632 | DEFUN (show_extcommunity_list, |
17633 | show_bgp_extcommunity_list_cmd, | |
17634 | "show bgp extcommunity-list", | |
718e3744 | 17635 | SHOW_STR |
7336e101 | 17636 | BGP_STR |
718e3744 | 17637 | "List extended-community list\n") |
17638 | { | |
d62a17ae | 17639 | struct community_list *list; |
17640 | struct community_list_master *cm; | |
718e3744 | 17641 | |
d62a17ae | 17642 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17643 | if (!cm) | |
17644 | return CMD_SUCCESS; | |
718e3744 | 17645 | |
d62a17ae | 17646 | for (list = cm->num.head; list; list = list->next) |
17647 | extcommunity_list_show(vty, list); | |
718e3744 | 17648 | |
d62a17ae | 17649 | for (list = cm->str.head; list; list = list->next) |
17650 | extcommunity_list_show(vty, list); | |
718e3744 | 17651 | |
d62a17ae | 17652 | return CMD_SUCCESS; |
718e3744 | 17653 | } |
17654 | ||
7336e101 SP |
17655 | DEFUN (show_extcommunity_list_arg, |
17656 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17657 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17658 | SHOW_STR |
17659 | BGP_STR | |
718e3744 | 17660 | "List extended-community list\n" |
17661 | "Extcommunity-list number\n" | |
960b69b9 | 17662 | "Extcommunity-list name\n" |
17663 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17664 | { |
d62a17ae | 17665 | int idx_comm_list = 3; |
17666 | struct community_list *list; | |
718e3744 | 17667 | |
e237b0d2 | 17668 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17669 | EXTCOMMUNITY_LIST_MASTER); |
17670 | if (!list) { | |
17671 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17672 | return CMD_WARNING; | |
17673 | } | |
718e3744 | 17674 | |
d62a17ae | 17675 | extcommunity_list_show(vty, list); |
718e3744 | 17676 | |
d62a17ae | 17677 | return CMD_SUCCESS; |
718e3744 | 17678 | } |
6b0655a2 | 17679 | |
718e3744 | 17680 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17681 | static int community_list_config_write(struct vty *vty) |
17682 | { | |
17683 | struct community_list *list; | |
17684 | struct community_entry *entry; | |
17685 | struct community_list_master *cm; | |
17686 | int write = 0; | |
17687 | ||
17688 | /* Community-list. */ | |
17689 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17690 | ||
17691 | for (list = cm->num.head; list; list = list->next) | |
17692 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17693 | vty_out(vty, |
17694 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
17695 | list->name, entry->seq, | |
d62a17ae | 17696 | community_direct_str(entry->direct), |
17697 | community_list_config_str(entry)); | |
17698 | write++; | |
17699 | } | |
17700 | for (list = cm->str.head; list; list = list->next) | |
17701 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17702 | vty_out(vty, |
17703 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 17704 | entry->style == COMMUNITY_LIST_STANDARD |
17705 | ? "standard" | |
17706 | : "expanded", | |
2f8cc0e5 DA |
17707 | list->name, entry->seq, |
17708 | community_direct_str(entry->direct), | |
d62a17ae | 17709 | community_list_config_str(entry)); |
17710 | write++; | |
17711 | } | |
17712 | ||
17713 | /* Extcommunity-list. */ | |
17714 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17715 | ||
17716 | for (list = cm->num.head; list; list = list->next) | |
17717 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17718 | vty_out(vty, |
17719 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
17720 | list->name, entry->seq, | |
17721 | community_direct_str(entry->direct), | |
d62a17ae | 17722 | community_list_config_str(entry)); |
17723 | write++; | |
17724 | } | |
17725 | for (list = cm->str.head; list; list = list->next) | |
17726 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17727 | vty_out(vty, |
17728 | "bgp extcommunity-list %s %s seq %" PRId64 | |
17729 | " %s %s\n", | |
d62a17ae | 17730 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17731 | ? "standard" | |
17732 | : "expanded", | |
2f8cc0e5 DA |
17733 | list->name, entry->seq, |
17734 | community_direct_str(entry->direct), | |
d62a17ae | 17735 | community_list_config_str(entry)); |
17736 | write++; | |
17737 | } | |
17738 | ||
17739 | ||
17740 | /* lcommunity-list. */ | |
17741 | cm = community_list_master_lookup(bgp_clist, | |
17742 | LARGE_COMMUNITY_LIST_MASTER); | |
17743 | ||
17744 | for (list = cm->num.head; list; list = list->next) | |
17745 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17746 | vty_out(vty, |
17747 | "bgp large-community-list %s seq %" PRId64 | |
17748 | " %s %s\n", | |
17749 | list->name, entry->seq, | |
17750 | community_direct_str(entry->direct), | |
d62a17ae | 17751 | community_list_config_str(entry)); |
17752 | write++; | |
17753 | } | |
17754 | for (list = cm->str.head; list; list = list->next) | |
17755 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17756 | vty_out(vty, |
17757 | "bgp large-community-list %s %s seq %" PRId64 | |
17758 | " %s %s\n", | |
17759 | ||
d62a17ae | 17760 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17761 | ? "standard" | |
17762 | : "expanded", | |
2f8cc0e5 | 17763 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 17764 | community_list_config_str(entry)); |
17765 | write++; | |
17766 | } | |
17767 | ||
17768 | return write; | |
17769 | } | |
17770 | ||
17771 | static struct cmd_node community_list_node = { | |
17772 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 17773 | }; |
17774 | ||
d62a17ae | 17775 | static void community_list_vty(void) |
17776 | { | |
17777 | install_node(&community_list_node, community_list_config_write); | |
17778 | ||
17779 | /* Community-list. */ | |
7336e101 SP |
17780 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
17781 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
17782 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 17783 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 17784 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 17785 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
17786 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
17787 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 17788 | |
17789 | /* Extcommunity-list. */ | |
7336e101 SP |
17790 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
17791 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
17792 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
17793 | install_element(CONFIG_NODE, |
17794 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 17795 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
17796 | install_element(CONFIG_NODE, |
17797 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
17798 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
17799 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 17800 | |
17801 | /* Large Community List */ | |
7336e101 | 17802 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
17803 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
17804 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 17805 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
17806 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
17807 | install_element(CONFIG_NODE, | |
17808 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
17809 | install_element(CONFIG_NODE, |
17810 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
17811 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
17812 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
17813 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
17814 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
17815 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
17816 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 17817 | } |