]>
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 | |
2ba1fe69 | 108 | #define GR_NO_OPER "The Graceful Restart No Operation was executed as cmd same as previous one." |
055679e9 | 109 | #define GR_INVALID "The Graceful Restart command used is not valid at this moment." |
d62a17ae | 110 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
111 | struct prefix *range, int exact); | |
112 | ||
055679e9 | 113 | /* Show BGP peer's information. */ |
114 | enum show_type { | |
115 | show_all, | |
116 | show_peer, | |
117 | show_ipv4_all, | |
118 | show_ipv6_all, | |
119 | show_ipv4_peer, | |
120 | show_ipv6_peer | |
121 | }; | |
122 | ||
2986cac2 | 123 | static struct peer_group *listen_range_exists( |
124 | struct bgp *bgp, | |
125 | struct prefix *range, | |
126 | int exact); | |
127 | ||
128 | static void bgp_show_global_graceful_restart_mode_vty( | |
129 | struct vty *vty, | |
130 | struct bgp *bgp, | |
131 | bool use_json, | |
132 | json_object *json); | |
133 | ||
134 | static int bgp_show_neighbor_graceful_restart_afi_all( | |
135 | struct vty *vty, | |
136 | enum show_type type, | |
137 | const char *ip_str, | |
138 | afi_t afi, | |
139 | bool use_json); | |
140 | ||
d62a17ae | 141 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
142 | { | |
143 | switch (afi) { | |
144 | case AFI_IP: | |
145 | switch (safi) { | |
146 | case SAFI_UNICAST: | |
147 | return BGP_IPV4_NODE; | |
148 | break; | |
149 | case SAFI_MULTICAST: | |
150 | return BGP_IPV4M_NODE; | |
151 | break; | |
152 | case SAFI_LABELED_UNICAST: | |
153 | return BGP_IPV4L_NODE; | |
154 | break; | |
155 | case SAFI_MPLS_VPN: | |
156 | return BGP_VPNV4_NODE; | |
157 | break; | |
7c40bf39 | 158 | case SAFI_FLOWSPEC: |
159 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
160 | default: |
161 | /* not expected */ | |
162 | return BGP_IPV4_NODE; | |
163 | break; | |
d62a17ae | 164 | } |
165 | break; | |
166 | case AFI_IP6: | |
167 | switch (safi) { | |
168 | case SAFI_UNICAST: | |
169 | return BGP_IPV6_NODE; | |
170 | break; | |
171 | case SAFI_MULTICAST: | |
172 | return BGP_IPV6M_NODE; | |
173 | break; | |
174 | case SAFI_LABELED_UNICAST: | |
175 | return BGP_IPV6L_NODE; | |
176 | break; | |
177 | case SAFI_MPLS_VPN: | |
178 | return BGP_VPNV6_NODE; | |
179 | break; | |
7c40bf39 | 180 | case SAFI_FLOWSPEC: |
181 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
182 | default: |
183 | /* not expected */ | |
184 | return BGP_IPV4_NODE; | |
185 | break; | |
d62a17ae | 186 | } |
187 | break; | |
188 | case AFI_L2VPN: | |
189 | return BGP_EVPN_NODE; | |
190 | break; | |
b26f891d | 191 | case AFI_UNSPEC: |
d62a17ae | 192 | case AFI_MAX: |
193 | // We should never be here but to clarify the switch statement.. | |
194 | return BGP_IPV4_NODE; | |
195 | break; | |
196 | } | |
197 | ||
198 | // Impossible to happen | |
199 | return BGP_IPV4_NODE; | |
f51bae9c | 200 | } |
20eb8864 | 201 | |
5cb5f4d0 DD |
202 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
203 | { | |
204 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
205 | return "IPv4 Unicast"; | |
206 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
207 | return "IPv4 Multicast"; | |
208 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
209 | return "IPv4 Labeled Unicast"; | |
210 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
211 | return "IPv4 VPN"; | |
212 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
213 | return "IPv4 Encap"; | |
214 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
215 | return "IPv4 Flowspec"; | |
216 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
217 | return "IPv6 Unicast"; | |
218 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
219 | return "IPv6 Multicast"; | |
220 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
221 | return "IPv6 Labeled Unicast"; | |
222 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
223 | return "IPv6 VPN"; | |
224 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
225 | return "IPv6 Encap"; | |
226 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
227 | return "IPv6 Flowspec"; | |
228 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
229 | return "L2VPN EVPN"; | |
8e5509b0 | 230 | else |
5cb5f4d0 | 231 | return "Unknown"; |
5cb5f4d0 DD |
232 | } |
233 | ||
234 | /* | |
235 | * Please note that we have intentionally camelCased | |
236 | * the return strings here. So if you want | |
237 | * to use this function, please ensure you | |
238 | * are doing this within json output | |
239 | */ | |
240 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
241 | { | |
242 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
243 | return "ipv4Unicast"; | |
244 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
245 | return "ipv4Multicast"; | |
246 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
247 | return "ipv4LabeledUnicast"; | |
248 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
249 | return "ipv4Vpn"; | |
250 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
251 | return "ipv4Encap"; | |
252 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
253 | return "ipv4Flowspec"; | |
254 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
255 | return "ipv6Unicast"; | |
256 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
257 | return "ipv6Multicast"; | |
258 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
259 | return "ipv6LabeledUnicast"; | |
260 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
261 | return "ipv6Vpn"; | |
262 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
263 | return "ipv6Encap"; | |
264 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
265 | return "ipv6Flowspec"; | |
266 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
267 | return "l2VpnEvpn"; | |
8e5509b0 | 268 | else |
5cb5f4d0 | 269 | return "Unknown"; |
5cb5f4d0 DD |
270 | } |
271 | ||
718e3744 | 272 | /* Utility function to get address family from current node. */ |
d62a17ae | 273 | afi_t bgp_node_afi(struct vty *vty) |
274 | { | |
275 | afi_t afi; | |
276 | switch (vty->node) { | |
277 | case BGP_IPV6_NODE: | |
278 | case BGP_IPV6M_NODE: | |
279 | case BGP_IPV6L_NODE: | |
280 | case BGP_VPNV6_NODE: | |
7c40bf39 | 281 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 282 | afi = AFI_IP6; |
283 | break; | |
284 | case BGP_EVPN_NODE: | |
285 | afi = AFI_L2VPN; | |
286 | break; | |
287 | default: | |
288 | afi = AFI_IP; | |
289 | break; | |
290 | } | |
291 | return afi; | |
718e3744 | 292 | } |
293 | ||
294 | /* Utility function to get subsequent address family from current | |
295 | node. */ | |
d62a17ae | 296 | safi_t bgp_node_safi(struct vty *vty) |
297 | { | |
298 | safi_t safi; | |
299 | switch (vty->node) { | |
300 | case BGP_VPNV4_NODE: | |
301 | case BGP_VPNV6_NODE: | |
302 | safi = SAFI_MPLS_VPN; | |
303 | break; | |
304 | case BGP_IPV4M_NODE: | |
305 | case BGP_IPV6M_NODE: | |
306 | safi = SAFI_MULTICAST; | |
307 | break; | |
308 | case BGP_EVPN_NODE: | |
309 | safi = SAFI_EVPN; | |
310 | break; | |
311 | case BGP_IPV4L_NODE: | |
312 | case BGP_IPV6L_NODE: | |
313 | safi = SAFI_LABELED_UNICAST; | |
314 | break; | |
7c40bf39 | 315 | case BGP_FLOWSPECV4_NODE: |
316 | case BGP_FLOWSPECV6_NODE: | |
317 | safi = SAFI_FLOWSPEC; | |
318 | break; | |
d62a17ae | 319 | default: |
320 | safi = SAFI_UNICAST; | |
321 | break; | |
322 | } | |
323 | return safi; | |
718e3744 | 324 | } |
325 | ||
55f91488 QY |
326 | /** |
327 | * Converts an AFI in string form to afi_t | |
328 | * | |
329 | * @param afi string, one of | |
330 | * - "ipv4" | |
331 | * - "ipv6" | |
81cf0de5 | 332 | * - "l2vpn" |
55f91488 QY |
333 | * @return the corresponding afi_t |
334 | */ | |
d62a17ae | 335 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
336 | { | |
337 | afi_t afi = AFI_MAX; /* unknown */ | |
338 | if (strmatch(afi_str, "ipv4")) | |
339 | afi = AFI_IP; | |
340 | else if (strmatch(afi_str, "ipv6")) | |
341 | afi = AFI_IP6; | |
81cf0de5 CS |
342 | else if (strmatch(afi_str, "l2vpn")) |
343 | afi = AFI_L2VPN; | |
d62a17ae | 344 | return afi; |
345 | } | |
346 | ||
347 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
348 | afi_t *afi) | |
349 | { | |
350 | int ret = 0; | |
351 | if (argv_find(argv, argc, "ipv4", index)) { | |
352 | ret = 1; | |
353 | if (afi) | |
354 | *afi = AFI_IP; | |
355 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
356 | ret = 1; | |
357 | if (afi) | |
358 | *afi = AFI_IP6; | |
8688b3e7 DS |
359 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
360 | ret = 1; | |
361 | if (afi) | |
362 | *afi = AFI_L2VPN; | |
d62a17ae | 363 | } |
364 | return ret; | |
46f296b4 LB |
365 | } |
366 | ||
375a2e67 | 367 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 368 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
369 | { | |
370 | safi_t safi = SAFI_MAX; /* unknown */ | |
371 | if (strmatch(safi_str, "multicast")) | |
372 | safi = SAFI_MULTICAST; | |
373 | else if (strmatch(safi_str, "unicast")) | |
374 | safi = SAFI_UNICAST; | |
375 | else if (strmatch(safi_str, "vpn")) | |
376 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
377 | else if (strmatch(safi_str, "evpn")) |
378 | safi = SAFI_EVPN; | |
d62a17ae | 379 | else if (strmatch(safi_str, "labeled-unicast")) |
380 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 381 | else if (strmatch(safi_str, "flowspec")) |
382 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 383 | return safi; |
384 | } | |
385 | ||
386 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
387 | safi_t *safi) | |
388 | { | |
389 | int ret = 0; | |
390 | if (argv_find(argv, argc, "unicast", index)) { | |
391 | ret = 1; | |
392 | if (safi) | |
393 | *safi = SAFI_UNICAST; | |
394 | } else if (argv_find(argv, argc, "multicast", index)) { | |
395 | ret = 1; | |
396 | if (safi) | |
397 | *safi = SAFI_MULTICAST; | |
398 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
399 | ret = 1; | |
400 | if (safi) | |
401 | *safi = SAFI_LABELED_UNICAST; | |
402 | } else if (argv_find(argv, argc, "vpn", index)) { | |
403 | ret = 1; | |
404 | if (safi) | |
405 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
406 | } else if (argv_find(argv, argc, "evpn", index)) { |
407 | ret = 1; | |
408 | if (safi) | |
409 | *safi = SAFI_EVPN; | |
7c40bf39 | 410 | } else if (argv_find(argv, argc, "flowspec", index)) { |
411 | ret = 1; | |
412 | if (safi) | |
413 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 414 | } |
415 | return ret; | |
46f296b4 LB |
416 | } |
417 | ||
5d5393b9 DL |
418 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
419 | enum bgp_instance_type inst_type) | |
420 | { | |
421 | int ret = bgp_get(bgp, as, name, inst_type); | |
422 | ||
423 | if (ret == BGP_CREATED) { | |
424 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
425 | DFLT_BGP_CONNECT_RETRY); | |
426 | ||
427 | if (DFLT_BGP_IMPORT_CHECK) | |
428 | bgp_flag_set(*bgp, BGP_FLAG_IMPORT_CHECK); | |
429 | if (DFLT_BGP_SHOW_HOSTNAME) | |
430 | bgp_flag_set(*bgp, BGP_FLAG_SHOW_HOSTNAME); | |
431 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) | |
432 | bgp_flag_set(*bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
433 | if (DFLT_BGP_DETERMINISTIC_MED) | |
434 | bgp_flag_set(*bgp, BGP_FLAG_DETERMINISTIC_MED); | |
435 | ||
436 | ret = BGP_SUCCESS; | |
437 | } | |
438 | return ret; | |
439 | } | |
440 | ||
7eeee51e | 441 | /* |
f212a857 | 442 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 443 | * |
f212a857 DS |
444 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
445 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
446 | * to appropriate values for the calling function. This is to allow the |
447 | * calling function to make decisions appropriate for the show command | |
448 | * that is being parsed. | |
449 | * | |
450 | * The show commands are generally of the form: | |
d62a17ae | 451 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
452 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
453 | * |
454 | * Since we use argv_find if the show command in particular doesn't have: | |
455 | * [ip] | |
18c57037 | 456 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 457 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
458 | * The command parsing should still be ok. |
459 | * | |
460 | * vty -> The vty for the command so we can output some useful data in | |
461 | * the event of a parse error in the vrf. | |
462 | * argv -> The command tokens | |
463 | * argc -> How many command tokens we have | |
d62a17ae | 464 | * idx -> The current place in the command, generally should be 0 for this |
465 | * function | |
7eeee51e DS |
466 | * afi -> The parsed afi if it was included in the show command, returned here |
467 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 468 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 469 | * use_json -> json is configured or not |
7eeee51e DS |
470 | * |
471 | * The function returns the correct location in the parse tree for the | |
472 | * last token found. | |
0e37c258 DS |
473 | * |
474 | * Returns 0 for failure to parse correctly, else the idx position of where | |
475 | * it found the last token. | |
7eeee51e | 476 | */ |
d62a17ae | 477 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
478 | struct cmd_token **argv, int argc, | |
479 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 480 | struct bgp **bgp, bool use_json) |
d62a17ae | 481 | { |
482 | char *vrf_name = NULL; | |
483 | ||
484 | assert(afi); | |
485 | assert(safi); | |
486 | assert(bgp); | |
487 | ||
488 | if (argv_find(argv, argc, "ip", idx)) | |
489 | *afi = AFI_IP; | |
490 | ||
9a8bdf1c | 491 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 492 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
493 | else if (argv_find(argv, argc, "vrf", idx)) { |
494 | vrf_name = argv[*idx + 1]->arg; | |
495 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
496 | vrf_name = NULL; | |
497 | } | |
498 | if (vrf_name) { | |
d62a17ae | 499 | if (strmatch(vrf_name, "all")) |
500 | *bgp = NULL; | |
501 | else { | |
502 | *bgp = bgp_lookup_by_name(vrf_name); | |
503 | if (!*bgp) { | |
52e5b8c4 SP |
504 | if (use_json) { |
505 | json_object *json = NULL; | |
506 | json = json_object_new_object(); | |
507 | json_object_string_add( | |
508 | json, "warning", | |
509 | "View/Vrf is unknown"); | |
510 | vty_out(vty, "%s\n", | |
511 | json_object_to_json_string_ext(json, | |
512 | JSON_C_TO_STRING_PRETTY)); | |
513 | json_object_free(json); | |
514 | } | |
ca61fd25 DS |
515 | else |
516 | vty_out(vty, "View/Vrf %s is unknown\n", | |
517 | vrf_name); | |
d62a17ae | 518 | *idx = 0; |
519 | return 0; | |
520 | } | |
521 | } | |
522 | } else { | |
523 | *bgp = bgp_get_default(); | |
524 | if (!*bgp) { | |
52e5b8c4 SP |
525 | if (use_json) { |
526 | json_object *json = NULL; | |
527 | json = json_object_new_object(); | |
528 | json_object_string_add( | |
529 | json, "warning", | |
530 | "Default BGP instance not found"); | |
531 | vty_out(vty, "%s\n", | |
532 | json_object_to_json_string_ext(json, | |
533 | JSON_C_TO_STRING_PRETTY)); | |
534 | json_object_free(json); | |
535 | } | |
ca61fd25 DS |
536 | else |
537 | vty_out(vty, | |
538 | "Default BGP instance not found\n"); | |
d62a17ae | 539 | *idx = 0; |
540 | return 0; | |
541 | } | |
542 | } | |
543 | ||
544 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
545 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
546 | ||
547 | *idx += 1; | |
548 | return *idx; | |
549 | } | |
550 | ||
551 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
552 | { | |
553 | struct interface *ifp = NULL; | |
554 | ||
555 | if (su->sa.sa_family == AF_INET) | |
556 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
557 | else if (su->sa.sa_family == AF_INET6) | |
558 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
559 | su->sin6.sin6_scope_id, | |
560 | bgp->vrf_id); | |
561 | ||
562 | if (ifp) | |
563 | return 1; | |
564 | ||
565 | return 0; | |
718e3744 | 566 | } |
567 | ||
568 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
569 | /* This is used only for configuration, so disallow if attempted on |
570 | * a dynamic neighbor. | |
571 | */ | |
d62a17ae | 572 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
573 | { | |
574 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
575 | int ret; | |
576 | union sockunion su; | |
577 | struct peer *peer; | |
578 | ||
579 | if (!bgp) { | |
580 | return NULL; | |
581 | } | |
582 | ||
583 | ret = str2sockunion(ip_str, &su); | |
584 | if (ret < 0) { | |
585 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
586 | if (!peer) { | |
587 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
588 | == NULL) { | |
589 | vty_out(vty, | |
590 | "%% Malformed address or name: %s\n", | |
591 | ip_str); | |
592 | return NULL; | |
593 | } | |
594 | } | |
595 | } else { | |
596 | peer = peer_lookup(bgp, &su); | |
597 | if (!peer) { | |
598 | vty_out(vty, | |
599 | "%% Specify remote-as or peer-group commands first\n"); | |
600 | return NULL; | |
601 | } | |
602 | if (peer_dynamic_neighbor(peer)) { | |
603 | vty_out(vty, | |
604 | "%% Operation not allowed on a dynamic neighbor\n"); | |
605 | return NULL; | |
606 | } | |
607 | } | |
608 | return peer; | |
718e3744 | 609 | } |
610 | ||
611 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
612 | /* This is used only for configuration, so disallow if attempted on |
613 | * a dynamic neighbor. | |
614 | */ | |
d62a17ae | 615 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
616 | { | |
617 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
618 | int ret; | |
619 | union sockunion su; | |
620 | struct peer *peer = NULL; | |
621 | struct peer_group *group = NULL; | |
622 | ||
623 | if (!bgp) { | |
624 | return NULL; | |
625 | } | |
626 | ||
627 | ret = str2sockunion(peer_str, &su); | |
628 | if (ret == 0) { | |
629 | /* IP address, locate peer. */ | |
630 | peer = peer_lookup(bgp, &su); | |
631 | } else { | |
632 | /* Not IP, could match either peer configured on interface or a | |
633 | * group. */ | |
634 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
635 | if (!peer) | |
636 | group = peer_group_lookup(bgp, peer_str); | |
637 | } | |
638 | ||
639 | if (peer) { | |
640 | if (peer_dynamic_neighbor(peer)) { | |
641 | vty_out(vty, | |
642 | "%% Operation not allowed on a dynamic neighbor\n"); | |
643 | return NULL; | |
644 | } | |
645 | ||
646 | return peer; | |
647 | } | |
648 | ||
649 | if (group) | |
650 | return group->conf; | |
651 | ||
652 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
653 | ||
654 | return NULL; | |
655 | } | |
656 | ||
657 | int bgp_vty_return(struct vty *vty, int ret) | |
658 | { | |
659 | const char *str = NULL; | |
660 | ||
661 | switch (ret) { | |
662 | case BGP_ERR_INVALID_VALUE: | |
663 | str = "Invalid value"; | |
664 | break; | |
665 | case BGP_ERR_INVALID_FLAG: | |
666 | str = "Invalid flag"; | |
667 | break; | |
668 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
669 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
670 | break; | |
671 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
672 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
673 | break; | |
674 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
675 | str = "Specify remote-as or peer-group remote AS first"; | |
676 | break; | |
677 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
678 | str = "Cannot change the peer-group. Deconfigure first"; | |
679 | break; | |
680 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
681 | str = "Peer is not a member of this peer-group"; | |
682 | break; | |
683 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
684 | str = "Prefix/distribute list can not co-exist"; | |
685 | break; | |
686 | case BGP_ERR_NOT_INTERNAL_PEER: | |
687 | str = "Invalid command. Not an internal neighbor"; | |
688 | break; | |
689 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
690 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
691 | break; | |
692 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
693 | str = "Local-AS allowed only for EBGP peers"; | |
694 | break; | |
695 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
696 | str = "Cannot have local-as same as BGP AS number"; | |
697 | break; | |
698 | case BGP_ERR_TCPSIG_FAILED: | |
699 | str = "Error while applying TCP-Sig to session(s)"; | |
700 | break; | |
701 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
702 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
703 | break; | |
704 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
705 | str = "ttl-security only allowed for EBGP peers"; | |
706 | break; | |
707 | case BGP_ERR_AS_OVERRIDE: | |
708 | str = "as-override cannot be configured for IBGP peers"; | |
709 | break; | |
710 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
711 | str = "Invalid limit for number of dynamic neighbors"; | |
712 | break; | |
713 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
714 | str = "Dynamic neighbor listen range already exists"; | |
715 | break; | |
716 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
717 | str = "Operation not allowed on a dynamic neighbor"; | |
718 | break; | |
719 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
720 | str = "Operation not allowed on a directly connected neighbor"; | |
721 | break; | |
722 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 723 | str = GR_INVALID; |
724 | break; | |
725 | case BGP_ERR_GR_INVALID_CMD: | |
726 | str = "The Graceful Restart command used is not valid at this moment."; | |
727 | break; | |
728 | case BGP_ERR_GR_OPERATION_FAILED: | |
729 | str = "The Graceful Restart Operation failed due to an err."; | |
730 | break; | |
731 | case BGP_GR_NO_OPERATION: | |
732 | str = GR_NO_OPER; | |
d62a17ae | 733 | break; |
734 | } | |
735 | if (str) { | |
736 | vty_out(vty, "%% %s\n", str); | |
737 | return CMD_WARNING_CONFIG_FAILED; | |
738 | } | |
739 | return CMD_SUCCESS; | |
718e3744 | 740 | } |
741 | ||
7aafcaca | 742 | /* BGP clear sort. */ |
d62a17ae | 743 | enum clear_sort { |
744 | clear_all, | |
745 | clear_peer, | |
746 | clear_group, | |
747 | clear_external, | |
748 | clear_as | |
7aafcaca DS |
749 | }; |
750 | ||
d62a17ae | 751 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
752 | safi_t safi, int error) | |
753 | { | |
754 | switch (error) { | |
755 | case BGP_ERR_AF_UNCONFIGURED: | |
756 | vty_out(vty, | |
757 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 758 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 759 | break; |
760 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
761 | vty_out(vty, | |
762 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
763 | peer->host); | |
764 | break; | |
765 | default: | |
766 | break; | |
767 | } | |
7aafcaca DS |
768 | } |
769 | ||
dc912615 DS |
770 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
771 | struct listnode *nnode, enum bgp_clear_type stype) | |
772 | { | |
773 | int ret = 0; | |
774 | ||
775 | /* if afi/.safi not specified, spin thru all of them */ | |
776 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
777 | afi_t tmp_afi; | |
778 | safi_t tmp_safi; | |
779 | ||
780 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
781 | if (!peer->afc[tmp_afi][tmp_safi]) | |
782 | continue; | |
783 | ||
784 | if (stype == BGP_CLEAR_SOFT_NONE) | |
785 | ret = peer_clear(peer, &nnode); | |
786 | else | |
787 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
788 | stype); | |
789 | } | |
790 | /* if afi specified and safi not, spin thru safis on this afi */ | |
791 | } else if (safi == SAFI_UNSPEC) { | |
792 | safi_t tmp_safi; | |
793 | ||
794 | for (tmp_safi = SAFI_UNICAST; | |
795 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
796 | if (!peer->afc[afi][tmp_safi]) | |
797 | continue; | |
798 | ||
799 | if (stype == BGP_CLEAR_SOFT_NONE) | |
800 | ret = peer_clear(peer, &nnode); | |
801 | else | |
802 | ret = peer_clear_soft(peer, afi, | |
803 | tmp_safi, stype); | |
804 | } | |
805 | /* both afi/safi specified, let the caller know if not defined */ | |
806 | } else { | |
807 | if (!peer->afc[afi][safi]) | |
808 | return 1; | |
809 | ||
810 | if (stype == BGP_CLEAR_SOFT_NONE) | |
811 | ret = peer_clear(peer, &nnode); | |
812 | else | |
813 | ret = peer_clear_soft(peer, afi, safi, stype); | |
814 | } | |
815 | ||
816 | return ret; | |
817 | } | |
818 | ||
7aafcaca | 819 | /* `clear ip bgp' functions. */ |
d62a17ae | 820 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
821 | enum clear_sort sort, enum bgp_clear_type stype, | |
822 | const char *arg) | |
823 | { | |
dc912615 | 824 | int ret = 0; |
3ae8bfa5 | 825 | bool found = false; |
d62a17ae | 826 | struct peer *peer; |
dc95985f | 827 | |
828 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 829 | |
830 | /* Clear all neighbors. */ | |
831 | /* | |
832 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
833 | * nodes on the BGP instance as that may get freed if it is a |
834 | * doppelganger | |
d62a17ae | 835 | */ |
836 | if (sort == clear_all) { | |
837 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 838 | |
839 | bgp_peer_gr_flags_update(peer); | |
840 | ||
841 | if (CHECK_FLAG(peer->flags, | |
842 | PEER_FLAG_GRACEFUL_RESTART)) | |
843 | gr_router_detected = true; | |
844 | ||
dc912615 DS |
845 | ret = bgp_peer_clear(peer, afi, safi, nnode, |
846 | stype); | |
d62a17ae | 847 | |
848 | if (ret < 0) | |
849 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
5cce3f05 | 850 | |
dc95985f | 851 | } |
852 | ||
853 | if (gr_router_detected && | |
854 | bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
855 | bgp_zebra_send_capabilities(bgp, false); | |
856 | } else if (!gr_router_detected && | |
857 | bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
858 | bgp_zebra_send_capabilities(bgp, true); | |
04b6bdc0 | 859 | } |
d62a17ae | 860 | |
861 | /* This is to apply read-only mode on this clear. */ | |
862 | if (stype == BGP_CLEAR_SOFT_NONE) | |
863 | bgp->update_delay_over = 0; | |
864 | ||
865 | return CMD_SUCCESS; | |
7aafcaca DS |
866 | } |
867 | ||
3ae8bfa5 | 868 | /* Clear specified neighbor. */ |
d62a17ae | 869 | if (sort == clear_peer) { |
870 | union sockunion su; | |
d62a17ae | 871 | |
872 | /* Make sockunion for lookup. */ | |
873 | ret = str2sockunion(arg, &su); | |
874 | if (ret < 0) { | |
875 | peer = peer_lookup_by_conf_if(bgp, arg); | |
876 | if (!peer) { | |
877 | peer = peer_lookup_by_hostname(bgp, arg); | |
878 | if (!peer) { | |
879 | vty_out(vty, | |
880 | "Malformed address or name: %s\n", | |
881 | arg); | |
882 | return CMD_WARNING; | |
883 | } | |
884 | } | |
885 | } else { | |
886 | peer = peer_lookup(bgp, &su); | |
887 | if (!peer) { | |
888 | vty_out(vty, | |
889 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
890 | arg); | |
891 | return CMD_WARNING; | |
892 | } | |
893 | } | |
7aafcaca | 894 | |
dc95985f | 895 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
896 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
897 | ||
dc912615 DS |
898 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
899 | ||
900 | /* if afi/safi not defined for this peer, let caller know */ | |
901 | if (ret == 1) | |
3ae8bfa5 | 902 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 903 | |
d62a17ae | 904 | if (ret < 0) |
905 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 906 | |
d62a17ae | 907 | return CMD_SUCCESS; |
7aafcaca | 908 | } |
7aafcaca | 909 | |
3ae8bfa5 | 910 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 911 | if (sort == clear_group) { |
912 | struct peer_group *group; | |
7aafcaca | 913 | |
d62a17ae | 914 | group = peer_group_lookup(bgp, arg); |
915 | if (!group) { | |
916 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
917 | return CMD_WARNING; | |
918 | } | |
919 | ||
920 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
dc912615 | 921 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 922 | |
d62a17ae | 923 | if (ret < 0) |
924 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
925 | else |
926 | found = true; | |
d62a17ae | 927 | } |
3ae8bfa5 PM |
928 | |
929 | if (!found) | |
930 | vty_out(vty, | |
931 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 932 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 933 | |
d62a17ae | 934 | return CMD_SUCCESS; |
7aafcaca | 935 | } |
7aafcaca | 936 | |
3ae8bfa5 | 937 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 938 | if (sort == clear_external) { |
939 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
940 | if (peer->sort == BGP_PEER_IBGP) | |
941 | continue; | |
7aafcaca | 942 | |
dc95985f | 943 | bgp_peer_gr_flags_update(peer); |
944 | ||
945 | if (CHECK_FLAG(peer->flags, | |
946 | PEER_FLAG_GRACEFUL_RESTART)) | |
2ba1fe69 | 947 | gr_router_detected = true; |
dc95985f | 948 | |
dc912615 | 949 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 950 | |
d62a17ae | 951 | if (ret < 0) |
952 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
953 | else |
954 | found = true; | |
d62a17ae | 955 | } |
3ae8bfa5 | 956 | |
dc95985f | 957 | if (gr_router_detected && |
958 | bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
959 | bgp_zebra_send_capabilities(bgp, false); | |
960 | } else if (!gr_router_detected && | |
961 | bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
962 | bgp_zebra_send_capabilities(bgp, true); | |
963 | } | |
964 | ||
3ae8bfa5 PM |
965 | if (!found) |
966 | vty_out(vty, | |
967 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 968 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 969 | |
d62a17ae | 970 | return CMD_SUCCESS; |
971 | } | |
972 | ||
3ae8bfa5 | 973 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 974 | if (sort == clear_as) { |
3ae8bfa5 | 975 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 976 | |
977 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
978 | if (peer->as != as) | |
979 | continue; | |
980 | ||
dc95985f | 981 | bgp_peer_gr_flags_update(peer); |
982 | ||
983 | if (CHECK_FLAG(peer->flags, | |
984 | PEER_FLAG_GRACEFUL_RESTART)) | |
2ba1fe69 | 985 | gr_router_detected = true; |
dc95985f | 986 | |
dc912615 | 987 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
d62a17ae | 988 | |
989 | if (ret < 0) | |
990 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
991 | else |
992 | found = true; | |
d62a17ae | 993 | } |
3ae8bfa5 | 994 | |
dc95985f | 995 | if (gr_router_detected && |
996 | bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
997 | bgp_zebra_send_capabilities(bgp, false); | |
998 | } else if (!gr_router_detected && | |
999 | bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
1000 | bgp_zebra_send_capabilities(bgp, true); | |
1001 | } | |
1002 | ||
3ae8bfa5 | 1003 | if (!found) |
d62a17ae | 1004 | vty_out(vty, |
3ae8bfa5 | 1005 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 1006 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1007 | |
d62a17ae | 1008 | return CMD_SUCCESS; |
1009 | } | |
1010 | ||
1011 | return CMD_SUCCESS; | |
1012 | } | |
1013 | ||
1014 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
1015 | safi_t safi, enum clear_sort sort, | |
1016 | enum bgp_clear_type stype, const char *arg) | |
1017 | { | |
1018 | struct bgp *bgp; | |
1019 | ||
1020 | /* BGP structure lookup. */ | |
1021 | if (name) { | |
1022 | bgp = bgp_lookup_by_name(name); | |
1023 | if (bgp == NULL) { | |
1024 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1025 | return CMD_WARNING; | |
1026 | } | |
1027 | } else { | |
1028 | bgp = bgp_get_default(); | |
1029 | if (bgp == NULL) { | |
1030 | vty_out(vty, "No BGP process is configured\n"); | |
1031 | return CMD_WARNING; | |
1032 | } | |
1033 | } | |
1034 | ||
1035 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
1036 | } |
1037 | ||
1038 | /* clear soft inbound */ | |
d62a17ae | 1039 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1040 | { |
99b3ebd3 NS |
1041 | afi_t afi; |
1042 | safi_t safi; | |
1043 | ||
1044 | FOREACH_AFI_SAFI (afi, safi) | |
1045 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1046 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1047 | } |
1048 | ||
1049 | /* clear soft outbound */ | |
d62a17ae | 1050 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1051 | { |
99b3ebd3 NS |
1052 | afi_t afi; |
1053 | safi_t safi; | |
1054 | ||
1055 | FOREACH_AFI_SAFI (afi, safi) | |
1056 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1057 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1058 | } |
1059 | ||
1060 | ||
f787d7a0 | 1061 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1062 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1063 | #endif |
1064 | ||
8029b216 AK |
1065 | DEFUN_HIDDEN (bgp_local_mac, |
1066 | bgp_local_mac_cmd, | |
093e3f23 | 1067 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1068 | BGP_STR |
1069 | "Local MAC config\n" | |
1070 | "VxLAN Network Identifier\n" | |
1071 | "VNI number\n" | |
1072 | "local mac\n" | |
1073 | "mac address\n" | |
1074 | "mac-mobility sequence\n" | |
1075 | "seq number\n") | |
1076 | { | |
1077 | int rv; | |
1078 | vni_t vni; | |
1079 | struct ethaddr mac; | |
1080 | struct ipaddr ip; | |
1081 | uint32_t seq; | |
1082 | struct bgp *bgp; | |
1083 | ||
1084 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1085 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1086 | vty_out(vty, "%% Malformed MAC address\n"); | |
1087 | return CMD_WARNING; | |
1088 | } | |
1089 | memset(&ip, 0, sizeof(ip)); | |
1090 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1091 | ||
1092 | bgp = bgp_get_default(); | |
1093 | if (!bgp) { | |
1094 | vty_out(vty, "Default BGP instance is not there\n"); | |
1095 | return CMD_WARNING; | |
1096 | } | |
1097 | ||
1098 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1099 | if (rv < 0) { | |
1100 | vty_out(vty, "Internal error\n"); | |
1101 | return CMD_WARNING; | |
1102 | } | |
1103 | ||
1104 | return CMD_SUCCESS; | |
1105 | } | |
1106 | ||
1107 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1108 | no_bgp_local_mac_cmd, | |
093e3f23 | 1109 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1110 | NO_STR |
1111 | BGP_STR | |
1112 | "Local MAC config\n" | |
1113 | "VxLAN Network Identifier\n" | |
1114 | "VNI number\n" | |
1115 | "local mac\n" | |
1116 | "mac address\n") | |
1117 | { | |
1118 | int rv; | |
1119 | vni_t vni; | |
1120 | struct ethaddr mac; | |
1121 | struct ipaddr ip; | |
1122 | struct bgp *bgp; | |
1123 | ||
1124 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1125 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1126 | vty_out(vty, "%% Malformed MAC address\n"); | |
1127 | return CMD_WARNING; | |
1128 | } | |
1129 | memset(&ip, 0, sizeof(ip)); | |
1130 | ||
1131 | bgp = bgp_get_default(); | |
1132 | if (!bgp) { | |
1133 | vty_out(vty, "Default BGP instance is not there\n"); | |
1134 | return CMD_WARNING; | |
1135 | } | |
1136 | ||
ec0ab544 | 1137 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1138 | if (rv < 0) { |
1139 | vty_out(vty, "Internal error\n"); | |
1140 | return CMD_WARNING; | |
1141 | } | |
1142 | ||
1143 | return CMD_SUCCESS; | |
1144 | } | |
1145 | ||
718e3744 | 1146 | DEFUN (no_synchronization, |
1147 | no_synchronization_cmd, | |
1148 | "no synchronization", | |
1149 | NO_STR | |
1150 | "Perform IGP synchronization\n") | |
1151 | { | |
d62a17ae | 1152 | return CMD_SUCCESS; |
718e3744 | 1153 | } |
1154 | ||
1155 | DEFUN (no_auto_summary, | |
1156 | no_auto_summary_cmd, | |
1157 | "no auto-summary", | |
1158 | NO_STR | |
1159 | "Enable automatic network number summarization\n") | |
1160 | { | |
d62a17ae | 1161 | return CMD_SUCCESS; |
718e3744 | 1162 | } |
3d515fd9 | 1163 | |
718e3744 | 1164 | /* "router bgp" commands. */ |
505e5056 | 1165 | DEFUN_NOSH (router_bgp, |
f412b39a | 1166 | router_bgp_cmd, |
2ed9fe4a | 1167 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1168 | ROUTER_STR |
1169 | BGP_STR | |
31500417 DW |
1170 | AS_STR |
1171 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1172 | { |
d62a17ae | 1173 | int idx_asn = 2; |
1174 | int idx_view_vrf = 3; | |
1175 | int idx_vrf = 4; | |
ecec9495 | 1176 | int is_new_bgp = 0; |
d62a17ae | 1177 | int ret; |
1178 | as_t as; | |
1179 | struct bgp *bgp; | |
1180 | const char *name = NULL; | |
1181 | enum bgp_instance_type inst_type; | |
1182 | ||
1183 | // "router bgp" without an ASN | |
1184 | if (argc == 2) { | |
1185 | // Pending: Make VRF option available for ASN less config | |
1186 | bgp = bgp_get_default(); | |
1187 | ||
1188 | if (bgp == NULL) { | |
1189 | vty_out(vty, "%% No BGP process is configured\n"); | |
1190 | return CMD_WARNING_CONFIG_FAILED; | |
1191 | } | |
1192 | ||
1193 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1194 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1195 | return CMD_WARNING_CONFIG_FAILED; |
1196 | } | |
1197 | } | |
1198 | ||
1199 | // "router bgp X" | |
1200 | else { | |
1201 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1202 | ||
1203 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1204 | if (argc > 3) { | |
1205 | name = argv[idx_vrf]->arg; | |
1206 | ||
9a8bdf1c PG |
1207 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1208 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1209 | name = NULL; | |
1210 | else | |
1211 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1212 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1213 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1214 | } | |
1215 | ||
ecec9495 AD |
1216 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1217 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1218 | ||
5d5393b9 | 1219 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1220 | switch (ret) { |
d62a17ae | 1221 | case BGP_ERR_AS_MISMATCH: |
1222 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1223 | return CMD_WARNING_CONFIG_FAILED; | |
1224 | case BGP_ERR_INSTANCE_MISMATCH: | |
1225 | vty_out(vty, | |
1226 | "BGP instance name and AS number mismatch\n"); | |
1227 | vty_out(vty, | |
1228 | "BGP instance is already running; AS is %u\n", | |
1229 | as); | |
1230 | return CMD_WARNING_CONFIG_FAILED; | |
1231 | } | |
1232 | ||
3bd70bf8 PZ |
1233 | /* |
1234 | * If we just instantiated the default instance, complete | |
1235 | * any pending VRF-VPN leaking that was configured via | |
1236 | * earlier "router bgp X vrf FOO" blocks. | |
1237 | */ | |
ecec9495 | 1238 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1239 | vpn_leak_postchange_all(); |
1240 | ||
48381346 CS |
1241 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1242 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1243 | /* Pending: handle when user tries to change a view to vrf n vv. |
1244 | */ | |
1245 | } | |
1246 | ||
0b5131c9 MK |
1247 | /* unset the auto created flag as the user config is now present */ |
1248 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1249 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1250 | ||
1251 | return CMD_SUCCESS; | |
718e3744 | 1252 | } |
1253 | ||
718e3744 | 1254 | /* "no router bgp" commands. */ |
1255 | DEFUN (no_router_bgp, | |
1256 | no_router_bgp_cmd, | |
2ed9fe4a | 1257 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1258 | NO_STR |
1259 | ROUTER_STR | |
1260 | BGP_STR | |
31500417 DW |
1261 | AS_STR |
1262 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1263 | { |
d62a17ae | 1264 | int idx_asn = 3; |
1265 | int idx_vrf = 5; | |
1266 | as_t as; | |
1267 | struct bgp *bgp; | |
1268 | const char *name = NULL; | |
718e3744 | 1269 | |
d62a17ae | 1270 | // "no router bgp" without an ASN |
1271 | if (argc == 3) { | |
1272 | // Pending: Make VRF option available for ASN less config | |
1273 | bgp = bgp_get_default(); | |
718e3744 | 1274 | |
d62a17ae | 1275 | if (bgp == NULL) { |
1276 | vty_out(vty, "%% No BGP process is configured\n"); | |
1277 | return CMD_WARNING_CONFIG_FAILED; | |
1278 | } | |
7fb21a9f | 1279 | |
d62a17ae | 1280 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1281 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1282 | return CMD_WARNING_CONFIG_FAILED; |
1283 | } | |
0b5131c9 MK |
1284 | |
1285 | if (bgp->l3vni) { | |
1286 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1287 | bgp->l3vni); | |
1288 | return CMD_WARNING_CONFIG_FAILED; | |
1289 | } | |
d62a17ae | 1290 | } else { |
1291 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1292 | |
d62a17ae | 1293 | if (argc > 4) |
1294 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1295 | |
d62a17ae | 1296 | /* Lookup bgp structure. */ |
1297 | bgp = bgp_lookup(as, name); | |
1298 | if (!bgp) { | |
1299 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1300 | return CMD_WARNING_CONFIG_FAILED; | |
1301 | } | |
0b5131c9 MK |
1302 | |
1303 | if (bgp->l3vni) { | |
dd5868c2 | 1304 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1305 | bgp->l3vni); |
1306 | return CMD_WARNING_CONFIG_FAILED; | |
1307 | } | |
dd5868c2 DS |
1308 | |
1309 | /* Cannot delete default instance if vrf instances exist */ | |
1310 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1311 | struct listnode *node; | |
1312 | struct bgp *tmp_bgp; | |
1313 | ||
1314 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1315 | if (tmp_bgp->inst_type | |
1316 | == BGP_INSTANCE_TYPE_VRF) { | |
1317 | vty_out(vty, | |
1318 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1319 | return CMD_WARNING_CONFIG_FAILED; | |
1320 | } | |
1321 | } | |
1322 | } | |
d62a17ae | 1323 | } |
718e3744 | 1324 | |
9ecf931b CS |
1325 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1326 | return CMD_WARNING_CONFIG_FAILED; | |
1327 | ||
d62a17ae | 1328 | bgp_delete(bgp); |
718e3744 | 1329 | |
d62a17ae | 1330 | return CMD_SUCCESS; |
718e3744 | 1331 | } |
1332 | ||
6b0655a2 | 1333 | |
718e3744 | 1334 | /* BGP router-id. */ |
1335 | ||
f787d7a0 | 1336 | DEFPY (bgp_router_id, |
718e3744 | 1337 | bgp_router_id_cmd, |
1338 | "bgp router-id A.B.C.D", | |
1339 | BGP_STR | |
1340 | "Override configured router identifier\n" | |
1341 | "Manually configured router identifier\n") | |
1342 | { | |
d62a17ae | 1343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1344 | bgp_router_id_static_set(bgp, router_id); | |
1345 | return CMD_SUCCESS; | |
718e3744 | 1346 | } |
1347 | ||
f787d7a0 | 1348 | DEFPY (no_bgp_router_id, |
718e3744 | 1349 | no_bgp_router_id_cmd, |
31500417 | 1350 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1351 | NO_STR |
1352 | BGP_STR | |
31500417 DW |
1353 | "Override configured router identifier\n" |
1354 | "Manually configured router identifier\n") | |
718e3744 | 1355 | { |
d62a17ae | 1356 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1357 | |
d62a17ae | 1358 | if (router_id_str) { |
1359 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1360 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1361 | return CMD_WARNING_CONFIG_FAILED; | |
1362 | } | |
e018c7cc | 1363 | } |
718e3744 | 1364 | |
d62a17ae | 1365 | router_id.s_addr = 0; |
1366 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1367 | |
d62a17ae | 1368 | return CMD_SUCCESS; |
718e3744 | 1369 | } |
1370 | ||
6b0655a2 | 1371 | |
718e3744 | 1372 | /* BGP Cluster ID. */ |
718e3744 | 1373 | DEFUN (bgp_cluster_id, |
1374 | bgp_cluster_id_cmd, | |
838758ac | 1375 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1376 | BGP_STR |
1377 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1378 | "Route-Reflector Cluster-id in IP address format\n" |
1379 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1380 | { |
d62a17ae | 1381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1382 | int idx_ipv4 = 2; | |
1383 | int ret; | |
1384 | struct in_addr cluster; | |
718e3744 | 1385 | |
d62a17ae | 1386 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1387 | if (!ret) { | |
1388 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1389 | return CMD_WARNING_CONFIG_FAILED; | |
1390 | } | |
718e3744 | 1391 | |
d62a17ae | 1392 | bgp_cluster_id_set(bgp, &cluster); |
1393 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1394 | |
d62a17ae | 1395 | return CMD_SUCCESS; |
718e3744 | 1396 | } |
1397 | ||
718e3744 | 1398 | DEFUN (no_bgp_cluster_id, |
1399 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1400 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1401 | NO_STR |
1402 | BGP_STR | |
838758ac DW |
1403 | "Configure Route-Reflector Cluster-id\n" |
1404 | "Route-Reflector Cluster-id in IP address format\n" | |
1405 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1406 | { |
d62a17ae | 1407 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1408 | bgp_cluster_id_unset(bgp); | |
1409 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1410 | |
d62a17ae | 1411 | return CMD_SUCCESS; |
718e3744 | 1412 | } |
1413 | ||
718e3744 | 1414 | DEFUN (bgp_confederation_identifier, |
1415 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1416 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1417 | "BGP specific commands\n" |
1418 | "AS confederation parameters\n" | |
1419 | "AS number\n" | |
1420 | "Set routing domain confederation AS\n") | |
1421 | { | |
d62a17ae | 1422 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1423 | int idx_number = 3; | |
1424 | as_t as; | |
718e3744 | 1425 | |
d62a17ae | 1426 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1427 | |
d62a17ae | 1428 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1429 | |
d62a17ae | 1430 | return CMD_SUCCESS; |
718e3744 | 1431 | } |
1432 | ||
1433 | DEFUN (no_bgp_confederation_identifier, | |
1434 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1435 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1436 | NO_STR |
1437 | "BGP specific commands\n" | |
1438 | "AS confederation parameters\n" | |
3a2d747c QY |
1439 | "AS number\n" |
1440 | "Set routing domain confederation AS\n") | |
718e3744 | 1441 | { |
d62a17ae | 1442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1443 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1444 | |
d62a17ae | 1445 | return CMD_SUCCESS; |
718e3744 | 1446 | } |
1447 | ||
718e3744 | 1448 | DEFUN (bgp_confederation_peers, |
1449 | bgp_confederation_peers_cmd, | |
12dcf78e | 1450 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1451 | "BGP specific commands\n" |
1452 | "AS confederation parameters\n" | |
1453 | "Peer ASs in BGP confederation\n" | |
1454 | AS_STR) | |
1455 | { | |
d62a17ae | 1456 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1457 | int idx_asn = 3; | |
1458 | as_t as; | |
1459 | int i; | |
718e3744 | 1460 | |
d62a17ae | 1461 | for (i = idx_asn; i < argc; i++) { |
1462 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1463 | |
d62a17ae | 1464 | if (bgp->as == as) { |
1465 | vty_out(vty, | |
1466 | "%% Local member-AS not allowed in confed peer list\n"); | |
1467 | continue; | |
1468 | } | |
718e3744 | 1469 | |
d62a17ae | 1470 | bgp_confederation_peers_add(bgp, as); |
1471 | } | |
1472 | return CMD_SUCCESS; | |
718e3744 | 1473 | } |
1474 | ||
1475 | DEFUN (no_bgp_confederation_peers, | |
1476 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1477 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1478 | NO_STR |
1479 | "BGP specific commands\n" | |
1480 | "AS confederation parameters\n" | |
1481 | "Peer ASs in BGP confederation\n" | |
1482 | AS_STR) | |
1483 | { | |
d62a17ae | 1484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1485 | int idx_asn = 4; | |
1486 | as_t as; | |
1487 | int i; | |
718e3744 | 1488 | |
d62a17ae | 1489 | for (i = idx_asn; i < argc; i++) { |
1490 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1491 | |
d62a17ae | 1492 | bgp_confederation_peers_remove(bgp, as); |
1493 | } | |
1494 | return CMD_SUCCESS; | |
718e3744 | 1495 | } |
6b0655a2 | 1496 | |
5e242b0d DS |
1497 | /** |
1498 | * Central routine for maximum-paths configuration. | |
1499 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1500 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1501 | */ | |
d62a17ae | 1502 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1503 | const char *mpaths, uint16_t options, |
d62a17ae | 1504 | int set) |
1505 | { | |
1506 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1507 | uint16_t maxpaths = 0; |
d62a17ae | 1508 | int ret; |
1509 | afi_t afi; | |
1510 | safi_t safi; | |
1511 | ||
1512 | afi = bgp_node_afi(vty); | |
1513 | safi = bgp_node_safi(vty); | |
1514 | ||
1515 | if (set) { | |
1516 | maxpaths = strtol(mpaths, NULL, 10); | |
1517 | if (maxpaths > multipath_num) { | |
1518 | vty_out(vty, | |
1519 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1520 | maxpaths, multipath_num); | |
1521 | return CMD_WARNING_CONFIG_FAILED; | |
1522 | } | |
1523 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1524 | options); | |
1525 | } else | |
1526 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1527 | ||
1528 | if (ret < 0) { | |
1529 | vty_out(vty, | |
1530 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1531 | (set == 1) ? "" : "un", | |
1532 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1533 | maxpaths, afi, safi); | |
1534 | return CMD_WARNING_CONFIG_FAILED; | |
1535 | } | |
1536 | ||
1537 | bgp_recalculate_all_bestpaths(bgp); | |
1538 | ||
1539 | return CMD_SUCCESS; | |
165b5fff JB |
1540 | } |
1541 | ||
abc920f8 DS |
1542 | DEFUN (bgp_maxmed_admin, |
1543 | bgp_maxmed_admin_cmd, | |
1544 | "bgp max-med administrative ", | |
1545 | BGP_STR | |
1546 | "Advertise routes with max-med\n" | |
1547 | "Administratively applied, for an indefinite period\n") | |
1548 | { | |
d62a17ae | 1549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1550 | |
d62a17ae | 1551 | bgp->v_maxmed_admin = 1; |
1552 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1553 | |
d62a17ae | 1554 | bgp_maxmed_update(bgp); |
abc920f8 | 1555 | |
d62a17ae | 1556 | return CMD_SUCCESS; |
abc920f8 DS |
1557 | } |
1558 | ||
1559 | DEFUN (bgp_maxmed_admin_medv, | |
1560 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1561 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1562 | BGP_STR |
1563 | "Advertise routes with max-med\n" | |
1564 | "Administratively applied, for an indefinite period\n" | |
1565 | "Max MED value to be used\n") | |
1566 | { | |
d62a17ae | 1567 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1568 | int idx_number = 3; | |
abc920f8 | 1569 | |
d62a17ae | 1570 | bgp->v_maxmed_admin = 1; |
1571 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1572 | |
d62a17ae | 1573 | bgp_maxmed_update(bgp); |
abc920f8 | 1574 | |
d62a17ae | 1575 | return CMD_SUCCESS; |
abc920f8 DS |
1576 | } |
1577 | ||
1578 | DEFUN (no_bgp_maxmed_admin, | |
1579 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1580 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1581 | NO_STR |
1582 | BGP_STR | |
1583 | "Advertise routes with max-med\n" | |
838758ac DW |
1584 | "Administratively applied, for an indefinite period\n" |
1585 | "Max MED value to be used\n") | |
abc920f8 | 1586 | { |
d62a17ae | 1587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1588 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1589 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1590 | bgp_maxmed_update(bgp); | |
abc920f8 | 1591 | |
d62a17ae | 1592 | return CMD_SUCCESS; |
abc920f8 DS |
1593 | } |
1594 | ||
abc920f8 DS |
1595 | DEFUN (bgp_maxmed_onstartup, |
1596 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1597 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1598 | BGP_STR |
1599 | "Advertise routes with max-med\n" | |
1600 | "Effective on a startup\n" | |
1601 | "Time (seconds) period for max-med\n" | |
1602 | "Max MED value to be used\n") | |
1603 | { | |
d62a17ae | 1604 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1605 | int idx = 0; | |
4668a151 | 1606 | |
d62a17ae | 1607 | argv_find(argv, argc, "(5-86400)", &idx); |
1608 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1609 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1610 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1611 | else | |
1612 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1613 | |
d62a17ae | 1614 | bgp_maxmed_update(bgp); |
abc920f8 | 1615 | |
d62a17ae | 1616 | return CMD_SUCCESS; |
abc920f8 DS |
1617 | } |
1618 | ||
1619 | DEFUN (no_bgp_maxmed_onstartup, | |
1620 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1621 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1622 | NO_STR |
1623 | BGP_STR | |
1624 | "Advertise routes with max-med\n" | |
838758ac DW |
1625 | "Effective on a startup\n" |
1626 | "Time (seconds) period for max-med\n" | |
1627 | "Max MED value to be used\n") | |
abc920f8 | 1628 | { |
d62a17ae | 1629 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1630 | |
d62a17ae | 1631 | /* Cancel max-med onstartup if its on */ |
1632 | if (bgp->t_maxmed_onstartup) { | |
1633 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1634 | bgp->maxmed_onstartup_over = 1; | |
1635 | } | |
abc920f8 | 1636 | |
d62a17ae | 1637 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1638 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1639 | |
d62a17ae | 1640 | bgp_maxmed_update(bgp); |
abc920f8 | 1641 | |
d62a17ae | 1642 | return CMD_SUCCESS; |
abc920f8 DS |
1643 | } |
1644 | ||
d62a17ae | 1645 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1646 | const char *wait) | |
f188f2c4 | 1647 | { |
d62a17ae | 1648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1649 | uint16_t update_delay; |
1650 | uint16_t establish_wait; | |
f188f2c4 | 1651 | |
d62a17ae | 1652 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1653 | |
d62a17ae | 1654 | if (!wait) /* update-delay <delay> */ |
1655 | { | |
1656 | bgp->v_update_delay = update_delay; | |
1657 | bgp->v_establish_wait = bgp->v_update_delay; | |
1658 | return CMD_SUCCESS; | |
1659 | } | |
f188f2c4 | 1660 | |
d62a17ae | 1661 | /* update-delay <delay> <establish-wait> */ |
1662 | establish_wait = atoi(wait); | |
1663 | if (update_delay < establish_wait) { | |
1664 | vty_out(vty, | |
1665 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1666 | return CMD_WARNING_CONFIG_FAILED; | |
1667 | } | |
f188f2c4 | 1668 | |
d62a17ae | 1669 | bgp->v_update_delay = update_delay; |
1670 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1671 | |
d62a17ae | 1672 | return CMD_SUCCESS; |
f188f2c4 DS |
1673 | } |
1674 | ||
d62a17ae | 1675 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1676 | { |
d62a17ae | 1677 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1678 | |
d62a17ae | 1679 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1680 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1681 | |
d62a17ae | 1682 | return CMD_SUCCESS; |
f188f2c4 DS |
1683 | } |
1684 | ||
2b791107 | 1685 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1686 | { |
d62a17ae | 1687 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1688 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1689 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1690 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1691 | vty_out(vty, "\n"); | |
1692 | } | |
f188f2c4 DS |
1693 | } |
1694 | ||
1695 | ||
1696 | /* Update-delay configuration */ | |
1697 | DEFUN (bgp_update_delay, | |
1698 | bgp_update_delay_cmd, | |
6147e2c6 | 1699 | "update-delay (0-3600)", |
f188f2c4 DS |
1700 | "Force initial delay for best-path and updates\n" |
1701 | "Seconds\n") | |
1702 | { | |
d62a17ae | 1703 | int idx_number = 1; |
1704 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1705 | } |
1706 | ||
1707 | DEFUN (bgp_update_delay_establish_wait, | |
1708 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1709 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1710 | "Force initial delay for best-path and updates\n" |
1711 | "Seconds\n" | |
f188f2c4 DS |
1712 | "Seconds\n") |
1713 | { | |
d62a17ae | 1714 | int idx_number = 1; |
1715 | int idx_number_2 = 2; | |
1716 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1717 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1718 | } |
1719 | ||
1720 | /* Update-delay deconfiguration */ | |
1721 | DEFUN (no_bgp_update_delay, | |
1722 | no_bgp_update_delay_cmd, | |
838758ac DW |
1723 | "no update-delay [(0-3600) [(1-3600)]]", |
1724 | NO_STR | |
f188f2c4 | 1725 | "Force initial delay for best-path and updates\n" |
838758ac | 1726 | "Seconds\n" |
7111c1a0 | 1727 | "Seconds\n") |
f188f2c4 | 1728 | { |
d62a17ae | 1729 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1730 | } |
1731 | ||
5e242b0d | 1732 | |
8fa7732f QY |
1733 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1734 | bool set) | |
cb1faec9 | 1735 | { |
d62a17ae | 1736 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1737 | |
8fa7732f QY |
1738 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1739 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1740 | |
1741 | return CMD_SUCCESS; | |
1742 | } | |
1743 | ||
8fa7732f QY |
1744 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1745 | bool set) | |
555e09d4 QY |
1746 | { |
1747 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1748 | ||
8fa7732f QY |
1749 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1750 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1751 | |
d62a17ae | 1752 | return CMD_SUCCESS; |
cb1faec9 DS |
1753 | } |
1754 | ||
2b791107 | 1755 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1756 | { |
555e09d4 QY |
1757 | uint32_t quanta = |
1758 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1759 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1760 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1761 | } |
1762 | ||
555e09d4 QY |
1763 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1764 | { | |
1765 | uint32_t quanta = | |
1766 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1767 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1768 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1769 | } |
cb1faec9 | 1770 | |
8fa7732f QY |
1771 | /* Packet quanta configuration |
1772 | * | |
1773 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1774 | * thread. When changing these limits be careful to prevent stack overflow. | |
1775 | * | |
1776 | * Furthermore, the maximums used here should correspond to | |
1777 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1778 | */ | |
1779 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1780 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1781 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1782 | NO_STR |
8fa7732f | 1783 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1784 | "Number of packets\n") |
1785 | { | |
8fa7732f | 1786 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1787 | } |
1788 | ||
8fa7732f | 1789 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1790 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1791 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1792 | NO_STR |
1793 | "How many packets to read from peer socket per I/O cycle\n" | |
1794 | "Number of packets\n") | |
1795 | { | |
8fa7732f | 1796 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1797 | } |
1798 | ||
2b791107 | 1799 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1800 | { |
37a333fe | 1801 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1802 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1803 | } |
1804 | ||
1805 | ||
1806 | DEFUN (bgp_coalesce_time, | |
1807 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1808 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1809 | "Subgroup coalesce timer\n" |
1810 | "Subgroup coalesce timer value (in ms)\n") | |
1811 | { | |
d62a17ae | 1812 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1813 | |
d62a17ae | 1814 | int idx = 0; |
1815 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1816 | bgp->heuristic_coalesce = false; |
d62a17ae | 1817 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1818 | return CMD_SUCCESS; | |
3f9c7369 DS |
1819 | } |
1820 | ||
1821 | DEFUN (no_bgp_coalesce_time, | |
1822 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1823 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1824 | NO_STR |
3f9c7369 DS |
1825 | "Subgroup coalesce timer\n" |
1826 | "Subgroup coalesce timer value (in ms)\n") | |
1827 | { | |
d62a17ae | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1829 | |
37a333fe | 1830 | bgp->heuristic_coalesce = true; |
d62a17ae | 1831 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1832 | return CMD_SUCCESS; | |
3f9c7369 DS |
1833 | } |
1834 | ||
5e242b0d DS |
1835 | /* Maximum-paths configuration */ |
1836 | DEFUN (bgp_maxpaths, | |
1837 | bgp_maxpaths_cmd, | |
6319fd63 | 1838 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1839 | "Forward packets over multiple paths\n" |
1840 | "Number of paths\n") | |
1841 | { | |
d62a17ae | 1842 | int idx_number = 1; |
1843 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1844 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1845 | } |
1846 | ||
d62a17ae | 1847 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1848 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1849 | "Forward packets over multiple paths\n" | |
1850 | "Number of paths\n") | |
596c17ba | 1851 | |
165b5fff JB |
1852 | DEFUN (bgp_maxpaths_ibgp, |
1853 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1854 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1855 | "Forward packets over multiple paths\n" |
1856 | "iBGP-multipath\n" | |
1857 | "Number of paths\n") | |
1858 | { | |
d62a17ae | 1859 | int idx_number = 2; |
1860 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1861 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1862 | } |
165b5fff | 1863 | |
d62a17ae | 1864 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1865 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1866 | "Forward packets over multiple paths\n" | |
1867 | "iBGP-multipath\n" | |
1868 | "Number of paths\n") | |
596c17ba | 1869 | |
5e242b0d DS |
1870 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1871 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1872 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1873 | "Forward packets over multiple paths\n" |
1874 | "iBGP-multipath\n" | |
1875 | "Number of paths\n" | |
1876 | "Match the cluster length\n") | |
1877 | { | |
d62a17ae | 1878 | int idx_number = 2; |
1879 | return bgp_maxpaths_config_vty( | |
1880 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1881 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1882 | } |
1883 | ||
d62a17ae | 1884 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1885 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1886 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1887 | "Forward packets over multiple paths\n" | |
1888 | "iBGP-multipath\n" | |
1889 | "Number of paths\n" | |
1890 | "Match the cluster length\n") | |
596c17ba | 1891 | |
165b5fff JB |
1892 | DEFUN (no_bgp_maxpaths, |
1893 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1894 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1895 | NO_STR |
1896 | "Forward packets over multiple paths\n" | |
1897 | "Number of paths\n") | |
1898 | { | |
d62a17ae | 1899 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1900 | } |
1901 | ||
d62a17ae | 1902 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1903 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1904 | "Forward packets over multiple paths\n" |
1905 | "Number of paths\n") | |
596c17ba | 1906 | |
165b5fff JB |
1907 | DEFUN (no_bgp_maxpaths_ibgp, |
1908 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1909 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1910 | NO_STR |
1911 | "Forward packets over multiple paths\n" | |
1912 | "iBGP-multipath\n" | |
838758ac DW |
1913 | "Number of paths\n" |
1914 | "Match the cluster length\n") | |
165b5fff | 1915 | { |
d62a17ae | 1916 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1917 | } |
1918 | ||
d62a17ae | 1919 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1920 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1921 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1922 | NO_STR | |
1923 | "Forward packets over multiple paths\n" | |
1924 | "iBGP-multipath\n" | |
1925 | "Number of paths\n" | |
1926 | "Match the cluster length\n") | |
596c17ba | 1927 | |
dd65f45e DL |
1928 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1929 | afi_t afi, safi_t safi) | |
165b5fff | 1930 | { |
d62a17ae | 1931 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1932 | vty_out(vty, " maximum-paths %d\n", |
1933 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1934 | } | |
165b5fff | 1935 | |
d62a17ae | 1936 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1937 | vty_out(vty, " maximum-paths ibgp %d", |
1938 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1939 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1940 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1941 | vty_out(vty, " equal-cluster-length"); | |
1942 | vty_out(vty, "\n"); | |
1943 | } | |
165b5fff | 1944 | } |
6b0655a2 | 1945 | |
718e3744 | 1946 | /* BGP timers. */ |
1947 | ||
1948 | DEFUN (bgp_timers, | |
1949 | bgp_timers_cmd, | |
6147e2c6 | 1950 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1951 | "Adjust routing timers\n" |
1952 | "BGP timers\n" | |
1953 | "Keepalive interval\n" | |
1954 | "Holdtime\n") | |
1955 | { | |
d62a17ae | 1956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1957 | int idx_number = 2; | |
1958 | int idx_number_2 = 3; | |
1959 | unsigned long keepalive = 0; | |
1960 | unsigned long holdtime = 0; | |
718e3744 | 1961 | |
d62a17ae | 1962 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1963 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1964 | |
d62a17ae | 1965 | /* Holdtime value check. */ |
1966 | if (holdtime < 3 && holdtime != 0) { | |
1967 | vty_out(vty, | |
1968 | "%% hold time value must be either 0 or greater than 3\n"); | |
1969 | return CMD_WARNING_CONFIG_FAILED; | |
1970 | } | |
718e3744 | 1971 | |
5d5393b9 | 1972 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1973 | |
d62a17ae | 1974 | return CMD_SUCCESS; |
718e3744 | 1975 | } |
1976 | ||
1977 | DEFUN (no_bgp_timers, | |
1978 | no_bgp_timers_cmd, | |
838758ac | 1979 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1980 | NO_STR |
1981 | "Adjust routing timers\n" | |
838758ac DW |
1982 | "BGP timers\n" |
1983 | "Keepalive interval\n" | |
1984 | "Holdtime\n") | |
718e3744 | 1985 | { |
d62a17ae | 1986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1987 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1988 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1989 | |
d62a17ae | 1990 | return CMD_SUCCESS; |
718e3744 | 1991 | } |
1992 | ||
6b0655a2 | 1993 | |
718e3744 | 1994 | DEFUN (bgp_client_to_client_reflection, |
1995 | bgp_client_to_client_reflection_cmd, | |
1996 | "bgp client-to-client reflection", | |
1997 | "BGP specific commands\n" | |
1998 | "Configure client to client route reflection\n" | |
1999 | "reflection of routes allowed\n") | |
2000 | { | |
d62a17ae | 2001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2002 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2003 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2004 | |
d62a17ae | 2005 | return CMD_SUCCESS; |
718e3744 | 2006 | } |
2007 | ||
2008 | DEFUN (no_bgp_client_to_client_reflection, | |
2009 | no_bgp_client_to_client_reflection_cmd, | |
2010 | "no bgp client-to-client reflection", | |
2011 | NO_STR | |
2012 | "BGP specific commands\n" | |
2013 | "Configure client to client route reflection\n" | |
2014 | "reflection of routes allowed\n") | |
2015 | { | |
d62a17ae | 2016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2017 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2018 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2019 | |
d62a17ae | 2020 | return CMD_SUCCESS; |
718e3744 | 2021 | } |
2022 | ||
2023 | /* "bgp always-compare-med" configuration. */ | |
2024 | DEFUN (bgp_always_compare_med, | |
2025 | bgp_always_compare_med_cmd, | |
2026 | "bgp always-compare-med", | |
2027 | "BGP specific commands\n" | |
2028 | "Allow comparing MED from different neighbors\n") | |
2029 | { | |
d62a17ae | 2030 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2031 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2032 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2033 | |
d62a17ae | 2034 | return CMD_SUCCESS; |
718e3744 | 2035 | } |
2036 | ||
2037 | DEFUN (no_bgp_always_compare_med, | |
2038 | no_bgp_always_compare_med_cmd, | |
2039 | "no bgp always-compare-med", | |
2040 | NO_STR | |
2041 | "BGP specific commands\n" | |
2042 | "Allow comparing MED from different neighbors\n") | |
2043 | { | |
d62a17ae | 2044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2045 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2046 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2047 | |
d62a17ae | 2048 | return CMD_SUCCESS; |
718e3744 | 2049 | } |
6b0655a2 | 2050 | |
9dac9fc8 DA |
2051 | |
2052 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2053 | "bgp ebgp-requires-policy", | |
2054 | "BGP specific commands\n" | |
2055 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2056 | { | |
2057 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2058 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
2059 | return CMD_SUCCESS; | |
2060 | } | |
2061 | ||
2062 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2063 | "no bgp ebgp-requires-policy", | |
2064 | NO_STR | |
2065 | "BGP specific commands\n" | |
2066 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2067 | { | |
2068 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2069 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
2070 | return CMD_SUCCESS; | |
2071 | } | |
2072 | ||
fb29348a DA |
2073 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2074 | "bgp reject-as-sets", | |
2075 | "BGP specific commands\n" | |
2076 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2077 | { | |
2078 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2079 | struct listnode *node, *nnode; | |
2080 | struct peer *peer; | |
2081 | ||
2082 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_ENABLED; | |
2083 | ||
2084 | /* Reset existing BGP sessions to reject routes | |
2085 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2086 | */ | |
2087 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2088 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2089 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2090 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2091 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2092 | } | |
2093 | } | |
2094 | ||
2095 | return CMD_SUCCESS; | |
2096 | } | |
2097 | ||
2098 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2099 | "no bgp reject-as-sets", | |
2100 | NO_STR | |
2101 | "BGP specific commands\n" | |
2102 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2103 | { | |
2104 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2105 | struct listnode *node, *nnode; | |
2106 | struct peer *peer; | |
2107 | ||
2108 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_DISABLED; | |
2109 | ||
2110 | /* Reset existing BGP sessions to reject routes | |
2111 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2112 | */ | |
2113 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2114 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2115 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2116 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2117 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2118 | } | |
2119 | } | |
2120 | ||
2121 | return CMD_SUCCESS; | |
2122 | } | |
9dac9fc8 | 2123 | |
718e3744 | 2124 | /* "bgp deterministic-med" configuration. */ |
2125 | DEFUN (bgp_deterministic_med, | |
2126 | bgp_deterministic_med_cmd, | |
2127 | "bgp deterministic-med", | |
2128 | "BGP specific commands\n" | |
2129 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2130 | { | |
d62a17ae | 2131 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2132 | |
d62a17ae | 2133 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
2134 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2135 | bgp_recalculate_all_bestpaths(bgp); | |
2136 | } | |
7aafcaca | 2137 | |
d62a17ae | 2138 | return CMD_SUCCESS; |
718e3744 | 2139 | } |
2140 | ||
2141 | DEFUN (no_bgp_deterministic_med, | |
2142 | no_bgp_deterministic_med_cmd, | |
2143 | "no bgp deterministic-med", | |
2144 | NO_STR | |
2145 | "BGP specific commands\n" | |
2146 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2147 | { | |
d62a17ae | 2148 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2149 | int bestpath_per_as_used; | |
2150 | afi_t afi; | |
2151 | safi_t safi; | |
2152 | struct peer *peer; | |
2153 | struct listnode *node, *nnode; | |
2154 | ||
2155 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
2156 | bestpath_per_as_used = 0; | |
2157 | ||
2158 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2159 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2160 | if (bgp_addpath_dmed_required( |
2161 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2162 | bestpath_per_as_used = 1; |
2163 | break; | |
2164 | } | |
d62a17ae | 2165 | |
2166 | if (bestpath_per_as_used) | |
2167 | break; | |
2168 | } | |
2169 | ||
2170 | if (bestpath_per_as_used) { | |
2171 | vty_out(vty, | |
2172 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2173 | return CMD_WARNING_CONFIG_FAILED; | |
2174 | } else { | |
2175 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2176 | bgp_recalculate_all_bestpaths(bgp); | |
2177 | } | |
2178 | } | |
2179 | ||
2180 | return CMD_SUCCESS; | |
718e3744 | 2181 | } |
538621f2 | 2182 | |
055679e9 | 2183 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2184 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2185 | bgp_graceful_restart_cmd, |
2186 | "bgp graceful-restart", | |
2187 | "BGP specific commands\n" | |
2188 | GR_CMD | |
055679e9 | 2189 | ) |
538621f2 | 2190 | { |
055679e9 | 2191 | int ret = BGP_GR_FAILURE; |
2192 | ||
2193 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2194 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2195 | |
d62a17ae | 2196 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2197 | |
2198 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2199 | ||
dc95985f | 2200 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2201 | bgp->peer, ret); | |
5cce3f05 | 2202 | |
055679e9 | 2203 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2204 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2205 | vty_out(vty, |
2206 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2207 | return bgp_vty_return(vty, ret); |
538621f2 | 2208 | } |
2209 | ||
2210 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2211 | no_bgp_graceful_restart_cmd, |
2212 | "no bgp graceful-restart", | |
2213 | NO_STR | |
2214 | "BGP specific commands\n" | |
2215 | NO_GR_CMD | |
055679e9 | 2216 | ) |
538621f2 | 2217 | { |
d62a17ae | 2218 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2219 | |
2220 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2221 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2222 | |
2223 | int ret = BGP_GR_FAILURE; | |
2224 | ||
2225 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2226 | ||
dc95985f | 2227 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2228 | bgp->peer, ret); | |
5cce3f05 | 2229 | |
055679e9 | 2230 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2231 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2232 | vty_out(vty, |
2233 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2234 | |
2235 | return bgp_vty_return(vty, ret); | |
538621f2 | 2236 | } |
2237 | ||
93406d87 | 2238 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2239 | bgp_graceful_restart_stalepath_time_cmd, |
2240 | "bgp graceful-restart stalepath-time (1-4095)", | |
2241 | "BGP specific commands\n" | |
2242 | "Graceful restart capability parameters\n" | |
2243 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2244 | "Delay value (seconds)\n") | |
93406d87 | 2245 | { |
d62a17ae | 2246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2247 | int idx_number = 3; | |
d7c0a89a | 2248 | uint32_t stalepath; |
93406d87 | 2249 | |
d62a17ae | 2250 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2251 | bgp->stalepath_time = stalepath; | |
2252 | return CMD_SUCCESS; | |
93406d87 | 2253 | } |
2254 | ||
eb6f1b41 | 2255 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2256 | bgp_graceful_restart_restart_time_cmd, |
2257 | "bgp graceful-restart restart-time (1-4095)", | |
2258 | "BGP specific commands\n" | |
2259 | "Graceful restart capability parameters\n" | |
2260 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2261 | "Delay value (seconds)\n") | |
eb6f1b41 | 2262 | { |
d62a17ae | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2264 | int idx_number = 3; | |
d7c0a89a | 2265 | uint32_t restart; |
eb6f1b41 | 2266 | |
d62a17ae | 2267 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2268 | bgp->restart_time = restart; | |
2269 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2270 | } |
2271 | ||
cfd47646 | 2272 | DEFUN (bgp_graceful_restart_select_defer_time, |
2273 | bgp_graceful_restart_select_defer_time_cmd, | |
2274 | "bgp graceful-restart select-defer-time (0-3600)", | |
2275 | "BGP specific commands\n" | |
2276 | "Graceful restart capability parameters\n" | |
2277 | "Set the time to defer the BGP route selection after restart\n" | |
2278 | "Delay value (seconds, 0 - disable)\n") | |
2279 | { | |
2280 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2281 | int idx_number = 3; | |
2282 | uint32_t defer_time; | |
2283 | ||
2284 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2285 | bgp->select_defer_time = defer_time; | |
2286 | if (defer_time == 0) | |
2287 | bgp_flag_set(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2288 | else | |
2289 | bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2290 | ||
2291 | return CMD_SUCCESS; | |
2292 | } | |
2293 | ||
93406d87 | 2294 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2295 | no_bgp_graceful_restart_stalepath_time_cmd, |
2296 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2297 | NO_STR | |
2298 | "BGP specific commands\n" | |
2299 | "Graceful restart capability parameters\n" | |
2300 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2301 | "Delay value (seconds)\n") | |
93406d87 | 2302 | { |
d62a17ae | 2303 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2304 | |
d62a17ae | 2305 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2306 | return CMD_SUCCESS; | |
93406d87 | 2307 | } |
2308 | ||
eb6f1b41 | 2309 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2310 | no_bgp_graceful_restart_restart_time_cmd, |
2311 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2312 | NO_STR | |
2313 | "BGP specific commands\n" | |
2314 | "Graceful restart capability parameters\n" | |
2315 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2316 | "Delay value (seconds)\n") | |
eb6f1b41 | 2317 | { |
d62a17ae | 2318 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2319 | |
d62a17ae | 2320 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2321 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2322 | } |
2323 | ||
cfd47646 | 2324 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2325 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2326 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2327 | NO_STR | |
2328 | "BGP specific commands\n" | |
2329 | "Graceful restart capability parameters\n" | |
2330 | "Set the time to defer the BGP route selection after restart\n" | |
2331 | "Delay value (seconds)\n") | |
2332 | { | |
2333 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2334 | ||
2335 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
2336 | bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2337 | ||
2338 | return CMD_SUCCESS; | |
2339 | } | |
2340 | ||
43fc21b3 | 2341 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2342 | bgp_graceful_restart_preserve_fw_cmd, |
2343 | "bgp graceful-restart preserve-fw-state", | |
2344 | "BGP specific commands\n" | |
2345 | "Graceful restart capability parameters\n" | |
2346 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2347 | { |
d62a17ae | 2348 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2349 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2350 | return CMD_SUCCESS; | |
43fc21b3 JC |
2351 | } |
2352 | ||
2353 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2354 | no_bgp_graceful_restart_preserve_fw_cmd, |
2355 | "no bgp graceful-restart preserve-fw-state", | |
2356 | NO_STR | |
2357 | "BGP specific commands\n" | |
2358 | "Graceful restart capability parameters\n" | |
2359 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2360 | { |
d62a17ae | 2361 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2362 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2363 | return CMD_SUCCESS; | |
43fc21b3 JC |
2364 | } |
2365 | ||
055679e9 | 2366 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2367 | bgp_graceful_restart_disable_cmd, |
2368 | "bgp graceful-restart-disable", | |
2369 | "BGP specific commands\n" | |
2370 | GR_DISABLE) | |
055679e9 | 2371 | { |
2372 | int ret = BGP_GR_FAILURE; | |
2373 | ||
2374 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2375 | zlog_debug( | |
2ba1fe69 | 2376 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2377 | |
055679e9 | 2378 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2379 | ||
2380 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2381 | ||
dc95985f | 2382 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2383 | bgp->peer, ret); | |
5cce3f05 | 2384 | |
055679e9 | 2385 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2386 | zlog_debug( | |
2ba1fe69 | 2387 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2388 | vty_out(vty, |
2389 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2390 | ||
055679e9 | 2391 | return bgp_vty_return(vty, ret); |
2392 | } | |
2393 | ||
2394 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2395 | no_bgp_graceful_restart_disable_cmd, |
2396 | "no bgp graceful-restart-disable", | |
2397 | NO_STR | |
2398 | "BGP specific commands\n" | |
2399 | NO_GR_DISABLE | |
055679e9 | 2400 | ) |
2401 | { | |
2402 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2403 | ||
2404 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2405 | zlog_debug( | |
2ba1fe69 | 2406 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2407 | |
2408 | int ret = BGP_GR_FAILURE; | |
2409 | ||
2410 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2411 | ||
dc95985f | 2412 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2413 | bgp->peer, ret); | |
5cce3f05 | 2414 | |
055679e9 | 2415 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2416 | zlog_debug( | |
2ba1fe69 | 2417 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2418 | vty_out(vty, |
2419 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2420 | |
2421 | return bgp_vty_return(vty, ret); | |
2422 | } | |
2423 | ||
2424 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2425 | bgp_neighbor_graceful_restart_set_cmd, |
2426 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2427 | NEIGHBOR_STR | |
2428 | NEIGHBOR_ADDR_STR2 | |
2429 | GR_NEIGHBOR_CMD | |
055679e9 | 2430 | ) |
2431 | { | |
2432 | int idx_peer = 1; | |
2433 | struct peer *peer; | |
2434 | int ret = BGP_GR_FAILURE; | |
2435 | ||
dc95985f | 2436 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2437 | ||
055679e9 | 2438 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2439 | zlog_debug( | |
2ba1fe69 | 2440 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2441 | |
055679e9 | 2442 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2443 | if (!peer) | |
2444 | return CMD_WARNING_CONFIG_FAILED; | |
2445 | ||
2446 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2447 | ||
dc95985f | 2448 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2449 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2450 | |
2451 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2452 | zlog_debug( | |
2ba1fe69 | 2453 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2454 | vty_out(vty, |
2455 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2456 | |
2457 | return bgp_vty_return(vty, ret); | |
2458 | } | |
2459 | ||
2460 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2461 | no_bgp_neighbor_graceful_restart_set_cmd, |
2462 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2463 | NO_STR | |
2464 | NEIGHBOR_STR | |
2465 | NEIGHBOR_ADDR_STR2 | |
2466 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2467 | ) |
2468 | { | |
2469 | int idx_peer = 2; | |
2470 | int ret = BGP_GR_FAILURE; | |
2471 | struct peer *peer; | |
2472 | ||
dc95985f | 2473 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2474 | ||
055679e9 | 2475 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2476 | if (!peer) | |
2477 | return CMD_WARNING_CONFIG_FAILED; | |
2478 | ||
2479 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2480 | zlog_debug( | |
2ba1fe69 | 2481 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2482 | |
2483 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2484 | ||
dc95985f | 2485 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2486 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2487 | |
2488 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2489 | zlog_debug( | |
2ba1fe69 | 2490 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2491 | vty_out(vty, |
2492 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2493 | |
2494 | return bgp_vty_return(vty, ret); | |
2495 | } | |
2496 | ||
2497 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2498 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2499 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2500 | NEIGHBOR_STR | |
2501 | NEIGHBOR_ADDR_STR2 | |
2502 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2503 | ) |
2504 | { | |
2505 | int idx_peer = 1; | |
2506 | struct peer *peer; | |
2507 | int ret = BGP_GR_FAILURE; | |
2508 | ||
dc95985f | 2509 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2510 | ||
055679e9 | 2511 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2512 | zlog_debug( | |
2ba1fe69 | 2513 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2514 | |
055679e9 | 2515 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2516 | ||
055679e9 | 2517 | if (!peer) |
2518 | return CMD_WARNING_CONFIG_FAILED; | |
2519 | ||
2520 | ||
2521 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2522 | |
dc95985f | 2523 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2524 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2525 | |
055679e9 | 2526 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2527 | zlog_debug( | |
2ba1fe69 | 2528 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2529 | vty_out(vty, |
2530 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2531 | |
2532 | return bgp_vty_return(vty, ret); | |
2533 | } | |
2534 | ||
2535 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2536 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2537 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2538 | NO_STR | |
2539 | NEIGHBOR_STR | |
2540 | NEIGHBOR_ADDR_STR2 | |
2541 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2542 | ) |
2543 | { | |
2544 | int idx_peer = 2; | |
2545 | int ret = BGP_GR_FAILURE; | |
2546 | struct peer *peer; | |
2547 | ||
dc95985f | 2548 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2549 | ||
055679e9 | 2550 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2551 | if (!peer) | |
2552 | return CMD_WARNING_CONFIG_FAILED; | |
2553 | ||
2554 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2555 | zlog_debug( | |
2ba1fe69 | 2556 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2557 | |
2558 | ret = bgp_neighbor_graceful_restart(peer, | |
2559 | NO_PEER_HELPER_CMD); | |
2560 | ||
dc95985f | 2561 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2562 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2563 | |
2564 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2565 | zlog_debug( | |
2ba1fe69 | 2566 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2567 | vty_out(vty, |
2568 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2569 | |
2570 | return bgp_vty_return(vty, ret); | |
2571 | } | |
2572 | ||
2573 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2574 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2575 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2576 | NEIGHBOR_STR | |
2577 | NEIGHBOR_ADDR_STR2 | |
2578 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2579 | ) |
2580 | { | |
2581 | int idx_peer = 1; | |
2582 | struct peer *peer; | |
2583 | int ret = BGP_GR_FAILURE; | |
2584 | ||
dc95985f | 2585 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2586 | ||
055679e9 | 2587 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2588 | zlog_debug( | |
2ba1fe69 | 2589 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2590 | |
2591 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2592 | if (!peer) | |
2593 | return CMD_WARNING_CONFIG_FAILED; | |
2594 | ||
055679e9 | 2595 | ret = bgp_neighbor_graceful_restart(peer, |
2ba1fe69 | 2596 | PEER_DISABLE_CMD); |
055679e9 | 2597 | |
2598 | if (peer->bgp->t_startup) | |
2599 | bgp_peer_gr_flags_update(peer); | |
2600 | ||
dc95985f | 2601 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2602 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2603 | ||
055679e9 | 2604 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2605 | zlog_debug( | |
2ba1fe69 | 2606 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2607 | vty_out(vty, |
2608 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2609 | |
2610 | return bgp_vty_return(vty, ret); | |
2611 | } | |
2612 | ||
2613 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2614 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2615 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2616 | NO_STR | |
2617 | NEIGHBOR_STR | |
2618 | NEIGHBOR_ADDR_STR2 | |
2619 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2620 | ) |
2621 | { | |
2622 | int idx_peer = 2; | |
2623 | int ret = BGP_GR_FAILURE; | |
2624 | struct peer *peer; | |
2625 | ||
dc95985f | 2626 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2627 | ||
055679e9 | 2628 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2629 | if (!peer) | |
2630 | return CMD_WARNING_CONFIG_FAILED; | |
2631 | ||
2632 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2633 | zlog_debug( | |
2ba1fe69 | 2634 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2635 | |
2636 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2637 | ||
dc95985f | 2638 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2639 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2640 | |
2641 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2642 | zlog_debug( | |
2ba1fe69 | 2643 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2644 | vty_out(vty, |
2645 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2646 | |
2647 | return bgp_vty_return(vty, ret); | |
2648 | } | |
2649 | ||
d6e3c15b | 2650 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2651 | bgp_graceful_restart_disable_eor_cmd, | |
2652 | "bgp graceful-restart disable-eor", | |
2653 | "BGP specific commands\n" | |
2654 | "Graceful restart configuration parameters\n" | |
2655 | "Disable EOR Check\n") | |
2656 | { | |
2657 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2658 | bgp_flag_set(bgp, BGP_FLAG_GR_DISABLE_EOR); | |
dc95985f | 2659 | |
d6e3c15b | 2660 | return CMD_SUCCESS; |
2661 | } | |
2662 | ||
2663 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2664 | no_bgp_graceful_restart_disable_eor_cmd, | |
2665 | "no bgp graceful-restart disable-eor", | |
2666 | NO_STR | |
2667 | "BGP specific commands\n" | |
2668 | "Graceful restart configuration parameters\n" | |
2669 | "Disable EOR Check\n") | |
2670 | { | |
2671 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2672 | bgp_flag_unset(bgp, BGP_FLAG_GR_DISABLE_EOR); | |
dc95985f | 2673 | |
2674 | return CMD_SUCCESS; | |
2675 | } | |
2676 | ||
2677 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2678 | bgp_graceful_restart_rib_stale_time_cmd, | |
2679 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2680 | "BGP specific commands\n" | |
2681 | "Graceful restart configuration parameters\n" | |
2682 | "Specify the stale route removal timer in rib\n" | |
2683 | "Delay value (seconds)\n") | |
2684 | { | |
2685 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2686 | int idx_number = 3; | |
2687 | uint32_t stale_time; | |
2688 | ||
2689 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2690 | bgp->rib_stale_time = stale_time; | |
2691 | /* Send the stale timer update message to RIB */ | |
2692 | if (bgp_zebra_stale_timer_update(bgp)) | |
2693 | return CMD_WARNING; | |
2694 | ||
2695 | return CMD_SUCCESS; | |
2696 | } | |
2697 | ||
2698 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2699 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2700 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2701 | NO_STR | |
2702 | "BGP specific commands\n" | |
2703 | "Graceful restart configuration parameters\n" | |
2704 | "Specify the stale route removal timer in rib\n" | |
2705 | "Delay value (seconds)\n") | |
2706 | { | |
2707 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2708 | ||
2709 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2710 | /* Send the stale timer update message to RIB */ | |
2711 | if (bgp_zebra_stale_timer_update(bgp)) | |
2712 | return CMD_WARNING; | |
2713 | ||
d6e3c15b | 2714 | return CMD_SUCCESS; |
2715 | } | |
2716 | ||
7f323236 DW |
2717 | /* "bgp graceful-shutdown" configuration */ |
2718 | DEFUN (bgp_graceful_shutdown, | |
2719 | bgp_graceful_shutdown_cmd, | |
2720 | "bgp graceful-shutdown", | |
2721 | BGP_STR | |
2722 | "Graceful shutdown parameters\n") | |
2723 | { | |
2724 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2725 | ||
2726 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2727 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2728 | bgp_static_redo_import_check(bgp); | |
2729 | bgp_redistribute_redo(bgp); | |
2730 | bgp_clear_star_soft_out(vty, bgp->name); | |
2731 | bgp_clear_star_soft_in(vty, bgp->name); | |
2732 | } | |
2733 | ||
2734 | return CMD_SUCCESS; | |
2735 | } | |
2736 | ||
2737 | DEFUN (no_bgp_graceful_shutdown, | |
2738 | no_bgp_graceful_shutdown_cmd, | |
2739 | "no bgp graceful-shutdown", | |
2740 | NO_STR | |
2741 | BGP_STR | |
2742 | "Graceful shutdown parameters\n") | |
2743 | { | |
2744 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2745 | ||
2746 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2747 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2748 | bgp_static_redo_import_check(bgp); | |
2749 | bgp_redistribute_redo(bgp); | |
2750 | bgp_clear_star_soft_out(vty, bgp->name); | |
2751 | bgp_clear_star_soft_in(vty, bgp->name); | |
2752 | } | |
2753 | ||
2754 | return CMD_SUCCESS; | |
2755 | } | |
2756 | ||
718e3744 | 2757 | /* "bgp fast-external-failover" configuration. */ |
2758 | DEFUN (bgp_fast_external_failover, | |
2759 | bgp_fast_external_failover_cmd, | |
2760 | "bgp fast-external-failover", | |
2761 | BGP_STR | |
2762 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2763 | { | |
d62a17ae | 2764 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2765 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2766 | return CMD_SUCCESS; | |
718e3744 | 2767 | } |
2768 | ||
2769 | DEFUN (no_bgp_fast_external_failover, | |
2770 | no_bgp_fast_external_failover_cmd, | |
2771 | "no bgp fast-external-failover", | |
2772 | NO_STR | |
2773 | BGP_STR | |
2774 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2775 | { | |
d62a17ae | 2776 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2777 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2778 | return CMD_SUCCESS; | |
718e3744 | 2779 | } |
6b0655a2 | 2780 | |
718e3744 | 2781 | /* "bgp bestpath compare-routerid" configuration. */ |
2782 | DEFUN (bgp_bestpath_compare_router_id, | |
2783 | bgp_bestpath_compare_router_id_cmd, | |
2784 | "bgp bestpath compare-routerid", | |
2785 | "BGP specific commands\n" | |
2786 | "Change the default bestpath selection\n" | |
2787 | "Compare router-id for identical EBGP paths\n") | |
2788 | { | |
d62a17ae | 2789 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2790 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2791 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2792 | |
d62a17ae | 2793 | return CMD_SUCCESS; |
718e3744 | 2794 | } |
2795 | ||
2796 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2797 | no_bgp_bestpath_compare_router_id_cmd, | |
2798 | "no bgp bestpath compare-routerid", | |
2799 | NO_STR | |
2800 | "BGP specific commands\n" | |
2801 | "Change the default bestpath selection\n" | |
2802 | "Compare router-id for identical EBGP paths\n") | |
2803 | { | |
d62a17ae | 2804 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2805 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2806 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2807 | |
d62a17ae | 2808 | return CMD_SUCCESS; |
718e3744 | 2809 | } |
6b0655a2 | 2810 | |
718e3744 | 2811 | /* "bgp bestpath as-path ignore" configuration. */ |
2812 | DEFUN (bgp_bestpath_aspath_ignore, | |
2813 | bgp_bestpath_aspath_ignore_cmd, | |
2814 | "bgp bestpath as-path ignore", | |
2815 | "BGP specific commands\n" | |
2816 | "Change the default bestpath selection\n" | |
2817 | "AS-path attribute\n" | |
2818 | "Ignore as-path length in selecting a route\n") | |
2819 | { | |
d62a17ae | 2820 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2821 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2822 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2823 | |
d62a17ae | 2824 | return CMD_SUCCESS; |
718e3744 | 2825 | } |
2826 | ||
2827 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2828 | no_bgp_bestpath_aspath_ignore_cmd, | |
2829 | "no bgp bestpath as-path ignore", | |
2830 | NO_STR | |
2831 | "BGP specific commands\n" | |
2832 | "Change the default bestpath selection\n" | |
2833 | "AS-path attribute\n" | |
2834 | "Ignore as-path length in selecting a route\n") | |
2835 | { | |
d62a17ae | 2836 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2837 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2838 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2839 | |
d62a17ae | 2840 | return CMD_SUCCESS; |
718e3744 | 2841 | } |
6b0655a2 | 2842 | |
6811845b | 2843 | /* "bgp bestpath as-path confed" configuration. */ |
2844 | DEFUN (bgp_bestpath_aspath_confed, | |
2845 | bgp_bestpath_aspath_confed_cmd, | |
2846 | "bgp bestpath as-path confed", | |
2847 | "BGP specific commands\n" | |
2848 | "Change the default bestpath selection\n" | |
2849 | "AS-path attribute\n" | |
2850 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2851 | { | |
d62a17ae | 2852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2853 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2854 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2855 | |
d62a17ae | 2856 | return CMD_SUCCESS; |
6811845b | 2857 | } |
2858 | ||
2859 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2860 | no_bgp_bestpath_aspath_confed_cmd, | |
2861 | "no bgp bestpath as-path confed", | |
2862 | NO_STR | |
2863 | "BGP specific commands\n" | |
2864 | "Change the default bestpath selection\n" | |
2865 | "AS-path attribute\n" | |
2866 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2867 | { | |
d62a17ae | 2868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2869 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2870 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2871 | |
d62a17ae | 2872 | return CMD_SUCCESS; |
6811845b | 2873 | } |
6b0655a2 | 2874 | |
2fdd455c PM |
2875 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2876 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2877 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2878 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2879 | "BGP specific commands\n" |
2880 | "Change the default bestpath selection\n" | |
2881 | "AS-path attribute\n" | |
2882 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2883 | "Generate an AS_SET\n" |
16fc1eec DS |
2884 | "Do not generate an AS_SET\n") |
2885 | { | |
d62a17ae | 2886 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2887 | int idx = 0; | |
2888 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2889 | |
d62a17ae | 2890 | /* no-as-set is now the default behavior so we can silently |
2891 | * ignore it */ | |
2892 | if (argv_find(argv, argc, "as-set", &idx)) | |
2893 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2894 | else | |
2895 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2896 | |
d62a17ae | 2897 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2898 | |
d62a17ae | 2899 | return CMD_SUCCESS; |
16fc1eec DS |
2900 | } |
2901 | ||
219178b6 DW |
2902 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2903 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2904 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2905 | NO_STR |
2906 | "BGP specific commands\n" | |
2907 | "Change the default bestpath selection\n" | |
2908 | "AS-path attribute\n" | |
2909 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2910 | "Generate an AS_SET\n" |
16fc1eec DS |
2911 | "Do not generate an AS_SET\n") |
2912 | { | |
d62a17ae | 2913 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2914 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2915 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2916 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2917 | |
d62a17ae | 2918 | return CMD_SUCCESS; |
2fdd455c | 2919 | } |
6b0655a2 | 2920 | |
848973c7 | 2921 | /* "bgp log-neighbor-changes" configuration. */ |
2922 | DEFUN (bgp_log_neighbor_changes, | |
2923 | bgp_log_neighbor_changes_cmd, | |
2924 | "bgp log-neighbor-changes", | |
2925 | "BGP specific commands\n" | |
2926 | "Log neighbor up/down and reset reason\n") | |
2927 | { | |
d62a17ae | 2928 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2929 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2930 | return CMD_SUCCESS; | |
848973c7 | 2931 | } |
2932 | ||
2933 | DEFUN (no_bgp_log_neighbor_changes, | |
2934 | no_bgp_log_neighbor_changes_cmd, | |
2935 | "no bgp log-neighbor-changes", | |
2936 | NO_STR | |
2937 | "BGP specific commands\n" | |
2938 | "Log neighbor up/down and reset reason\n") | |
2939 | { | |
d62a17ae | 2940 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2941 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2942 | return CMD_SUCCESS; | |
848973c7 | 2943 | } |
6b0655a2 | 2944 | |
718e3744 | 2945 | /* "bgp bestpath med" configuration. */ |
2946 | DEFUN (bgp_bestpath_med, | |
2947 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2948 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2949 | "BGP specific commands\n" |
2950 | "Change the default bestpath selection\n" | |
2951 | "MED attribute\n" | |
2952 | "Compare MED among confederation paths\n" | |
838758ac DW |
2953 | "Treat missing MED as the least preferred one\n" |
2954 | "Treat missing MED as the least preferred one\n" | |
2955 | "Compare MED among confederation paths\n") | |
718e3744 | 2956 | { |
d62a17ae | 2957 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2958 | |
d62a17ae | 2959 | int idx = 0; |
2960 | if (argv_find(argv, argc, "confed", &idx)) | |
2961 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2962 | idx = 0; | |
2963 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2964 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2965 | |
d62a17ae | 2966 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2967 | |
d62a17ae | 2968 | return CMD_SUCCESS; |
718e3744 | 2969 | } |
2970 | ||
718e3744 | 2971 | DEFUN (no_bgp_bestpath_med, |
2972 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2973 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2974 | NO_STR |
2975 | "BGP specific commands\n" | |
2976 | "Change the default bestpath selection\n" | |
2977 | "MED attribute\n" | |
2978 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2979 | "Treat missing MED as the least preferred one\n" |
2980 | "Treat missing MED as the least preferred one\n" | |
2981 | "Compare MED among confederation paths\n") | |
718e3744 | 2982 | { |
d62a17ae | 2983 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2984 | |
d62a17ae | 2985 | int idx = 0; |
2986 | if (argv_find(argv, argc, "confed", &idx)) | |
2987 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2988 | idx = 0; | |
2989 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2990 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2991 | |
d62a17ae | 2992 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2993 | |
d62a17ae | 2994 | return CMD_SUCCESS; |
718e3744 | 2995 | } |
2996 | ||
718e3744 | 2997 | /* "no bgp default ipv4-unicast". */ |
2998 | DEFUN (no_bgp_default_ipv4_unicast, | |
2999 | no_bgp_default_ipv4_unicast_cmd, | |
3000 | "no bgp default ipv4-unicast", | |
3001 | NO_STR | |
3002 | "BGP specific commands\n" | |
3003 | "Configure BGP defaults\n" | |
3004 | "Activate ipv4-unicast for a peer by default\n") | |
3005 | { | |
d62a17ae | 3006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3007 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
3008 | return CMD_SUCCESS; | |
718e3744 | 3009 | } |
3010 | ||
3011 | DEFUN (bgp_default_ipv4_unicast, | |
3012 | bgp_default_ipv4_unicast_cmd, | |
3013 | "bgp default ipv4-unicast", | |
3014 | "BGP specific commands\n" | |
3015 | "Configure BGP defaults\n" | |
3016 | "Activate ipv4-unicast for a peer by default\n") | |
3017 | { | |
d62a17ae | 3018 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3019 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
3020 | return CMD_SUCCESS; | |
718e3744 | 3021 | } |
6b0655a2 | 3022 | |
04b6bdc0 DW |
3023 | /* Display hostname in certain command outputs */ |
3024 | DEFUN (bgp_default_show_hostname, | |
3025 | bgp_default_show_hostname_cmd, | |
3026 | "bgp default show-hostname", | |
3027 | "BGP specific commands\n" | |
3028 | "Configure BGP defaults\n" | |
0437e105 | 3029 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3030 | { |
d62a17ae | 3031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3032 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
3033 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3034 | } |
3035 | ||
3036 | DEFUN (no_bgp_default_show_hostname, | |
3037 | no_bgp_default_show_hostname_cmd, | |
3038 | "no bgp default show-hostname", | |
3039 | NO_STR | |
3040 | "BGP specific commands\n" | |
3041 | "Configure BGP defaults\n" | |
0437e105 | 3042 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3043 | { |
d62a17ae | 3044 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3045 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
3046 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3047 | } |
3048 | ||
8233ef81 | 3049 | /* "bgp network import-check" configuration. */ |
718e3744 | 3050 | DEFUN (bgp_network_import_check, |
3051 | bgp_network_import_check_cmd, | |
5623e905 | 3052 | "bgp network import-check", |
718e3744 | 3053 | "BGP specific commands\n" |
3054 | "BGP network command\n" | |
5623e905 | 3055 | "Check BGP network route exists in IGP\n") |
718e3744 | 3056 | { |
d62a17ae | 3057 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3058 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
3059 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
3060 | bgp_static_redo_import_check(bgp); | |
3061 | } | |
078430f6 | 3062 | |
d62a17ae | 3063 | return CMD_SUCCESS; |
718e3744 | 3064 | } |
3065 | ||
d62a17ae | 3066 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3067 | "bgp network import-check exact", | |
3068 | "BGP specific commands\n" | |
3069 | "BGP network command\n" | |
3070 | "Check BGP network route exists in IGP\n" | |
3071 | "Match route precisely\n") | |
8233ef81 | 3072 | |
718e3744 | 3073 | DEFUN (no_bgp_network_import_check, |
3074 | no_bgp_network_import_check_cmd, | |
5623e905 | 3075 | "no bgp network import-check", |
718e3744 | 3076 | NO_STR |
3077 | "BGP specific commands\n" | |
3078 | "BGP network command\n" | |
3079 | "Check BGP network route exists in IGP\n") | |
3080 | { | |
d62a17ae | 3081 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3082 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
3083 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
3084 | bgp_static_redo_import_check(bgp); | |
3085 | } | |
5623e905 | 3086 | |
d62a17ae | 3087 | return CMD_SUCCESS; |
718e3744 | 3088 | } |
6b0655a2 | 3089 | |
718e3744 | 3090 | DEFUN (bgp_default_local_preference, |
3091 | bgp_default_local_preference_cmd, | |
6147e2c6 | 3092 | "bgp default local-preference (0-4294967295)", |
718e3744 | 3093 | "BGP specific commands\n" |
3094 | "Configure BGP defaults\n" | |
3095 | "local preference (higher=more preferred)\n" | |
3096 | "Configure default local preference value\n") | |
3097 | { | |
d62a17ae | 3098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3099 | int idx_number = 3; | |
d7c0a89a | 3100 | uint32_t local_pref; |
718e3744 | 3101 | |
d62a17ae | 3102 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3103 | |
d62a17ae | 3104 | bgp_default_local_preference_set(bgp, local_pref); |
3105 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3106 | |
d62a17ae | 3107 | return CMD_SUCCESS; |
718e3744 | 3108 | } |
3109 | ||
3110 | DEFUN (no_bgp_default_local_preference, | |
3111 | no_bgp_default_local_preference_cmd, | |
838758ac | 3112 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 3113 | NO_STR |
3114 | "BGP specific commands\n" | |
3115 | "Configure BGP defaults\n" | |
838758ac DW |
3116 | "local preference (higher=more preferred)\n" |
3117 | "Configure default local preference value\n") | |
718e3744 | 3118 | { |
d62a17ae | 3119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3120 | bgp_default_local_preference_unset(bgp); | |
3121 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3122 | |
d62a17ae | 3123 | return CMD_SUCCESS; |
718e3744 | 3124 | } |
3125 | ||
6b0655a2 | 3126 | |
3f9c7369 DS |
3127 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3128 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3129 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3130 | "BGP specific commands\n" |
3131 | "Configure BGP defaults\n" | |
3132 | "subgroup-pkt-queue-max\n" | |
3133 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3134 | { |
d62a17ae | 3135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3136 | int idx_number = 3; | |
d7c0a89a | 3137 | uint32_t max_size; |
8bd9d948 | 3138 | |
d62a17ae | 3139 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3140 | |
d62a17ae | 3141 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3142 | |
d62a17ae | 3143 | return CMD_SUCCESS; |
3f9c7369 DS |
3144 | } |
3145 | ||
3146 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3147 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3148 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3149 | NO_STR |
3150 | "BGP specific commands\n" | |
3151 | "Configure BGP defaults\n" | |
838758ac DW |
3152 | "subgroup-pkt-queue-max\n" |
3153 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3154 | { |
d62a17ae | 3155 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3156 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3157 | return CMD_SUCCESS; | |
8bd9d948 DS |
3158 | } |
3159 | ||
813d4307 | 3160 | |
8bd9d948 DS |
3161 | DEFUN (bgp_rr_allow_outbound_policy, |
3162 | bgp_rr_allow_outbound_policy_cmd, | |
3163 | "bgp route-reflector allow-outbound-policy", | |
3164 | "BGP specific commands\n" | |
3165 | "Allow modifications made by out route-map\n" | |
3166 | "on ibgp neighbors\n") | |
3167 | { | |
d62a17ae | 3168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3169 | |
d62a17ae | 3170 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3171 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3172 | update_group_announce_rrclients(bgp); | |
3173 | bgp_clear_star_soft_out(vty, bgp->name); | |
3174 | } | |
8bd9d948 | 3175 | |
d62a17ae | 3176 | return CMD_SUCCESS; |
8bd9d948 DS |
3177 | } |
3178 | ||
3179 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3180 | no_bgp_rr_allow_outbound_policy_cmd, | |
3181 | "no bgp route-reflector allow-outbound-policy", | |
3182 | NO_STR | |
3183 | "BGP specific commands\n" | |
3184 | "Allow modifications made by out route-map\n" | |
3185 | "on ibgp neighbors\n") | |
3186 | { | |
d62a17ae | 3187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3188 | |
d62a17ae | 3189 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3190 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3191 | update_group_announce_rrclients(bgp); | |
3192 | bgp_clear_star_soft_out(vty, bgp->name); | |
3193 | } | |
8bd9d948 | 3194 | |
d62a17ae | 3195 | return CMD_SUCCESS; |
8bd9d948 DS |
3196 | } |
3197 | ||
f14e6fdb DS |
3198 | DEFUN (bgp_listen_limit, |
3199 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3200 | "bgp listen limit (1-5000)", |
f14e6fdb | 3201 | "BGP specific commands\n" |
1601a46f | 3202 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3203 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3204 | "Configure Dynamic Neighbors listen limit value\n") |
3205 | { | |
d62a17ae | 3206 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3207 | int idx_number = 3; | |
3208 | int listen_limit; | |
f14e6fdb | 3209 | |
d62a17ae | 3210 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3211 | |
d62a17ae | 3212 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3213 | |
d62a17ae | 3214 | return CMD_SUCCESS; |
f14e6fdb DS |
3215 | } |
3216 | ||
3217 | DEFUN (no_bgp_listen_limit, | |
3218 | no_bgp_listen_limit_cmd, | |
838758ac | 3219 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3220 | NO_STR |
f14e6fdb | 3221 | "BGP specific commands\n" |
1601a46f | 3222 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3223 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3224 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3225 | { |
d62a17ae | 3226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3227 | bgp_listen_limit_unset(bgp); | |
3228 | return CMD_SUCCESS; | |
f14e6fdb DS |
3229 | } |
3230 | ||
3231 | ||
20eb8864 | 3232 | /* |
3233 | * Check if this listen range is already configured. Check for exact | |
3234 | * match or overlap based on input. | |
3235 | */ | |
d62a17ae | 3236 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3237 | struct prefix *range, int exact) | |
3238 | { | |
3239 | struct listnode *node, *nnode; | |
3240 | struct listnode *node1, *nnode1; | |
3241 | struct peer_group *group; | |
3242 | struct prefix *lr; | |
3243 | afi_t afi; | |
3244 | int match; | |
3245 | ||
3246 | afi = family2afi(range->family); | |
3247 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3248 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3249 | lr)) { | |
3250 | if (exact) | |
3251 | match = prefix_same(range, lr); | |
3252 | else | |
3253 | match = (prefix_match(range, lr) | |
3254 | || prefix_match(lr, range)); | |
3255 | if (match) | |
3256 | return group; | |
3257 | } | |
3258 | } | |
3259 | ||
3260 | return NULL; | |
20eb8864 | 3261 | } |
3262 | ||
f14e6fdb DS |
3263 | DEFUN (bgp_listen_range, |
3264 | bgp_listen_range_cmd, | |
d7b9898c | 3265 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3266 | "BGP specific commands\n" |
d7fa34c1 QY |
3267 | "Configure BGP dynamic neighbors listen range\n" |
3268 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3269 | NEIGHBOR_ADDR_STR |
3270 | "Member of the peer-group\n" | |
3271 | "Peer-group name\n") | |
f14e6fdb | 3272 | { |
d62a17ae | 3273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3274 | struct prefix range; | |
3275 | struct peer_group *group, *existing_group; | |
3276 | afi_t afi; | |
3277 | int ret; | |
3278 | int idx = 0; | |
3279 | ||
3280 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3281 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3282 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3283 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3284 | char *peergroup = argv[idx]->arg; |
3285 | ||
3286 | /* Convert IP prefix string to struct prefix. */ | |
3287 | ret = str2prefix(prefix, &range); | |
3288 | if (!ret) { | |
3289 | vty_out(vty, "%% Malformed listen range\n"); | |
3290 | return CMD_WARNING_CONFIG_FAILED; | |
3291 | } | |
3292 | ||
3293 | afi = family2afi(range.family); | |
3294 | ||
3295 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3296 | vty_out(vty, | |
3297 | "%% Malformed listen range (link-local address)\n"); | |
3298 | return CMD_WARNING_CONFIG_FAILED; | |
3299 | } | |
3300 | ||
3301 | apply_mask(&range); | |
3302 | ||
3303 | /* Check if same listen range is already configured. */ | |
3304 | existing_group = listen_range_exists(bgp, &range, 1); | |
3305 | if (existing_group) { | |
3306 | if (strcmp(existing_group->name, peergroup) == 0) | |
3307 | return CMD_SUCCESS; | |
3308 | else { | |
3309 | vty_out(vty, | |
3310 | "%% Same listen range is attached to peer-group %s\n", | |
3311 | existing_group->name); | |
3312 | return CMD_WARNING_CONFIG_FAILED; | |
3313 | } | |
3314 | } | |
3315 | ||
3316 | /* Check if an overlapping listen range exists. */ | |
3317 | if (listen_range_exists(bgp, &range, 0)) { | |
3318 | vty_out(vty, | |
3319 | "%% Listen range overlaps with existing listen range\n"); | |
3320 | return CMD_WARNING_CONFIG_FAILED; | |
3321 | } | |
3322 | ||
3323 | group = peer_group_lookup(bgp, peergroup); | |
3324 | if (!group) { | |
3325 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3326 | return CMD_WARNING_CONFIG_FAILED; | |
3327 | } | |
3328 | ||
3329 | ret = peer_group_listen_range_add(group, &range); | |
3330 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3331 | } |
3332 | ||
3333 | DEFUN (no_bgp_listen_range, | |
3334 | no_bgp_listen_range_cmd, | |
d7b9898c | 3335 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3336 | NO_STR |
f14e6fdb | 3337 | "BGP specific commands\n" |
d7fa34c1 QY |
3338 | "Unconfigure BGP dynamic neighbors listen range\n" |
3339 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3340 | NEIGHBOR_ADDR_STR | |
3341 | "Member of the peer-group\n" | |
3342 | "Peer-group name\n") | |
f14e6fdb | 3343 | { |
d62a17ae | 3344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3345 | struct prefix range; | |
3346 | struct peer_group *group; | |
3347 | afi_t afi; | |
3348 | int ret; | |
3349 | int idx = 0; | |
3350 | ||
3351 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3352 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3353 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3354 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3355 | char *peergroup = argv[idx]->arg; |
3356 | ||
3357 | /* Convert IP prefix string to struct prefix. */ | |
3358 | ret = str2prefix(prefix, &range); | |
3359 | if (!ret) { | |
3360 | vty_out(vty, "%% Malformed listen range\n"); | |
3361 | return CMD_WARNING_CONFIG_FAILED; | |
3362 | } | |
3363 | ||
3364 | afi = family2afi(range.family); | |
3365 | ||
3366 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3367 | vty_out(vty, | |
3368 | "%% Malformed listen range (link-local address)\n"); | |
3369 | return CMD_WARNING_CONFIG_FAILED; | |
3370 | } | |
3371 | ||
3372 | apply_mask(&range); | |
3373 | ||
3374 | group = peer_group_lookup(bgp, peergroup); | |
3375 | if (!group) { | |
3376 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3377 | return CMD_WARNING_CONFIG_FAILED; | |
3378 | } | |
3379 | ||
3380 | ret = peer_group_listen_range_del(group, &range); | |
3381 | return bgp_vty_return(vty, ret); | |
3382 | } | |
3383 | ||
2b791107 | 3384 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3385 | { |
3386 | struct peer_group *group; | |
3387 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3388 | struct prefix *range; | |
3389 | afi_t afi; | |
3390 | char buf[PREFIX2STR_BUFFER]; | |
3391 | ||
3392 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3393 | vty_out(vty, " bgp listen limit %d\n", | |
3394 | bgp->dynamic_neighbors_limit); | |
3395 | ||
3396 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3397 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3398 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3399 | nrnode, range)) { | |
3400 | prefix2str(range, buf, sizeof(buf)); | |
3401 | vty_out(vty, | |
3402 | " bgp listen range %s peer-group %s\n", | |
3403 | buf, group->name); | |
3404 | } | |
3405 | } | |
3406 | } | |
f14e6fdb DS |
3407 | } |
3408 | ||
3409 | ||
907f92c8 DS |
3410 | DEFUN (bgp_disable_connected_route_check, |
3411 | bgp_disable_connected_route_check_cmd, | |
3412 | "bgp disable-ebgp-connected-route-check", | |
3413 | "BGP specific commands\n" | |
3414 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3415 | { | |
d62a17ae | 3416 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3417 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
3418 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3419 | |
d62a17ae | 3420 | return CMD_SUCCESS; |
907f92c8 DS |
3421 | } |
3422 | ||
3423 | DEFUN (no_bgp_disable_connected_route_check, | |
3424 | no_bgp_disable_connected_route_check_cmd, | |
3425 | "no bgp disable-ebgp-connected-route-check", | |
3426 | NO_STR | |
3427 | "BGP specific commands\n" | |
3428 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3429 | { | |
d62a17ae | 3430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3431 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
3432 | bgp_clear_star_soft_in(vty, bgp->name); | |
3433 | ||
3434 | return CMD_SUCCESS; | |
3435 | } | |
3436 | ||
3437 | ||
3438 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3439 | const char *as_str, afi_t afi, safi_t safi) | |
3440 | { | |
3441 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3442 | int ret; | |
3443 | as_t as; | |
3444 | int as_type = AS_SPECIFIED; | |
3445 | union sockunion su; | |
3446 | ||
3447 | if (as_str[0] == 'i') { | |
3448 | as = 0; | |
3449 | as_type = AS_INTERNAL; | |
3450 | } else if (as_str[0] == 'e') { | |
3451 | as = 0; | |
3452 | as_type = AS_EXTERNAL; | |
3453 | } else { | |
3454 | /* Get AS number. */ | |
3455 | as = strtoul(as_str, NULL, 10); | |
3456 | } | |
3457 | ||
390485fd | 3458 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3459 | ret = str2sockunion(peer_str, &su); |
3460 | if (ret < 0) { | |
390485fd DS |
3461 | struct peer *peer; |
3462 | ||
3463 | /* Check if existing interface peer */ | |
3464 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3465 | ||
d62a17ae | 3466 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3467 | safi); | |
390485fd DS |
3468 | |
3469 | /* if not interface peer, check peer-group settings */ | |
3470 | if (ret < 0 && !peer) { | |
d62a17ae | 3471 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3472 | if (ret < 0) { | |
3473 | vty_out(vty, | |
390485fd | 3474 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3475 | return CMD_WARNING_CONFIG_FAILED; |
3476 | } | |
3477 | return CMD_SUCCESS; | |
3478 | } | |
3479 | } else { | |
3480 | if (peer_address_self_check(bgp, &su)) { | |
3481 | vty_out(vty, | |
3482 | "%% Can not configure the local system as neighbor\n"); | |
3483 | return CMD_WARNING_CONFIG_FAILED; | |
3484 | } | |
3485 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3486 | } | |
3487 | ||
3488 | /* This peer belongs to peer group. */ | |
3489 | switch (ret) { | |
3490 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3491 | vty_out(vty, | |
faa16034 | 3492 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3493 | return CMD_WARNING_CONFIG_FAILED; |
3494 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3495 | vty_out(vty, | |
faa16034 | 3496 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3497 | return CMD_WARNING_CONFIG_FAILED; |
3498 | } | |
3499 | return bgp_vty_return(vty, ret); | |
718e3744 | 3500 | } |
3501 | ||
f26845f9 QY |
3502 | DEFUN (bgp_default_shutdown, |
3503 | bgp_default_shutdown_cmd, | |
3504 | "[no] bgp default shutdown", | |
3505 | NO_STR | |
3506 | BGP_STR | |
3507 | "Configure BGP defaults\n" | |
b012cbe2 | 3508 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3509 | { |
3510 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3511 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3512 | return CMD_SUCCESS; | |
3513 | } | |
3514 | ||
718e3744 | 3515 | DEFUN (neighbor_remote_as, |
3516 | neighbor_remote_as_cmd, | |
3a2d747c | 3517 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3518 | NEIGHBOR_STR |
3519 | NEIGHBOR_ADDR_STR2 | |
3520 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3521 | AS_STR |
3a2d747c QY |
3522 | "Internal BGP peer\n" |
3523 | "External BGP peer\n") | |
718e3744 | 3524 | { |
d62a17ae | 3525 | int idx_peer = 1; |
3526 | int idx_remote_as = 3; | |
3527 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3528 | argv[idx_remote_as]->arg, AFI_IP, | |
3529 | SAFI_UNICAST); | |
3530 | } | |
3531 | ||
3532 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3533 | afi_t afi, safi_t safi, int v6only, | |
3534 | const char *peer_group_name, | |
3535 | const char *as_str) | |
3536 | { | |
3537 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3538 | as_t as = 0; | |
3539 | int as_type = AS_UNSPECIFIED; | |
3540 | struct peer *peer; | |
3541 | struct peer_group *group; | |
3542 | int ret = 0; | |
3543 | union sockunion su; | |
3544 | ||
3545 | group = peer_group_lookup(bgp, conf_if); | |
3546 | ||
3547 | if (group) { | |
3548 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3549 | return CMD_WARNING_CONFIG_FAILED; | |
3550 | } | |
3551 | ||
3552 | if (as_str) { | |
3553 | if (as_str[0] == 'i') { | |
3554 | as_type = AS_INTERNAL; | |
3555 | } else if (as_str[0] == 'e') { | |
3556 | as_type = AS_EXTERNAL; | |
3557 | } else { | |
3558 | /* Get AS number. */ | |
3559 | as = strtoul(as_str, NULL, 10); | |
3560 | as_type = AS_SPECIFIED; | |
3561 | } | |
3562 | } | |
3563 | ||
3564 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3565 | if (peer) { | |
3566 | if (as_str) | |
cc4d4ce8 | 3567 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3568 | afi, safi); |
3569 | } else { | |
3570 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
3571 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
3572 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3573 | as_type, 0, 0, NULL); | |
3574 | else | |
3575 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3576 | as_type, afi, safi, NULL); | |
3577 | ||
3578 | if (!peer) { | |
3579 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3580 | return CMD_WARNING_CONFIG_FAILED; | |
3581 | } | |
3582 | ||
3583 | if (v6only) | |
527de3dc | 3584 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3585 | |
3586 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3587 | * this | |
3588 | * any unnumbered peer in order to not worry about run-time | |
3589 | * transitions | |
3590 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3591 | * address | |
3592 | * gets deleted later etc.) | |
3593 | */ | |
3594 | if (peer->ifp) | |
3595 | bgp_zebra_initiate_radv(bgp, peer); | |
3596 | } | |
3597 | ||
3598 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3599 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3600 | if (v6only) | |
527de3dc | 3601 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3602 | else |
527de3dc | 3603 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3604 | |
3605 | /* v6only flag changed. Reset bgp seesion */ | |
3606 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3607 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3608 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3609 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3610 | } else | |
3611 | bgp_session_reset(peer); | |
3612 | } | |
3613 | ||
9fb964de PM |
3614 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3615 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3616 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3617 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3618 | } |
d62a17ae | 3619 | |
3620 | if (peer_group_name) { | |
3621 | group = peer_group_lookup(bgp, peer_group_name); | |
3622 | if (!group) { | |
3623 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3624 | return CMD_WARNING_CONFIG_FAILED; | |
3625 | } | |
3626 | ||
3627 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3628 | } | |
3629 | ||
3630 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3631 | } |
3632 | ||
4c48cf63 DW |
3633 | DEFUN (neighbor_interface_config, |
3634 | neighbor_interface_config_cmd, | |
d7b9898c | 3635 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3636 | NEIGHBOR_STR |
3637 | "Interface name or neighbor tag\n" | |
31500417 DW |
3638 | "Enable BGP on interface\n" |
3639 | "Member of the peer-group\n" | |
16cedbb0 | 3640 | "Peer-group name\n") |
4c48cf63 | 3641 | { |
d62a17ae | 3642 | int idx_word = 1; |
3643 | int idx_peer_group_word = 4; | |
31500417 | 3644 | |
d62a17ae | 3645 | if (argc > idx_peer_group_word) |
3646 | return peer_conf_interface_get( | |
3647 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3648 | argv[idx_peer_group_word]->arg, NULL); | |
3649 | else | |
3650 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3651 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3652 | } |
3653 | ||
4c48cf63 DW |
3654 | DEFUN (neighbor_interface_config_v6only, |
3655 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3656 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3657 | NEIGHBOR_STR |
3658 | "Interface name or neighbor tag\n" | |
3659 | "Enable BGP on interface\n" | |
31500417 DW |
3660 | "Enable BGP with v6 link-local only\n" |
3661 | "Member of the peer-group\n" | |
16cedbb0 | 3662 | "Peer-group name\n") |
4c48cf63 | 3663 | { |
d62a17ae | 3664 | int idx_word = 1; |
3665 | int idx_peer_group_word = 5; | |
31500417 | 3666 | |
d62a17ae | 3667 | if (argc > idx_peer_group_word) |
3668 | return peer_conf_interface_get( | |
3669 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3670 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3671 | |
d62a17ae | 3672 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3673 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3674 | } |
3675 | ||
a80beece | 3676 | |
b3a39dc5 DD |
3677 | DEFUN (neighbor_interface_config_remote_as, |
3678 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3679 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3680 | NEIGHBOR_STR |
3681 | "Interface name or neighbor tag\n" | |
3682 | "Enable BGP on interface\n" | |
3a2d747c | 3683 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3684 | AS_STR |
3a2d747c QY |
3685 | "Internal BGP peer\n" |
3686 | "External BGP peer\n") | |
b3a39dc5 | 3687 | { |
d62a17ae | 3688 | int idx_word = 1; |
3689 | int idx_remote_as = 4; | |
3690 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3691 | SAFI_UNICAST, 0, NULL, | |
3692 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3693 | } |
3694 | ||
3695 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3696 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3697 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3698 | NEIGHBOR_STR |
3699 | "Interface name or neighbor tag\n" | |
3a2d747c | 3700 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3701 | "Enable BGP on interface\n" |
3a2d747c | 3702 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3703 | AS_STR |
3a2d747c QY |
3704 | "Internal BGP peer\n" |
3705 | "External BGP peer\n") | |
b3a39dc5 | 3706 | { |
d62a17ae | 3707 | int idx_word = 1; |
3708 | int idx_remote_as = 5; | |
3709 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3710 | SAFI_UNICAST, 1, NULL, | |
3711 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3712 | } |
3713 | ||
718e3744 | 3714 | DEFUN (neighbor_peer_group, |
3715 | neighbor_peer_group_cmd, | |
3716 | "neighbor WORD peer-group", | |
3717 | NEIGHBOR_STR | |
a80beece | 3718 | "Interface name or neighbor tag\n" |
718e3744 | 3719 | "Configure peer-group\n") |
3720 | { | |
d62a17ae | 3721 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3722 | int idx_word = 1; | |
3723 | struct peer *peer; | |
3724 | struct peer_group *group; | |
718e3744 | 3725 | |
d62a17ae | 3726 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3727 | if (peer) { | |
3728 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3729 | return CMD_WARNING_CONFIG_FAILED; | |
3730 | } | |
718e3744 | 3731 | |
d62a17ae | 3732 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3733 | if (!group) { | |
3734 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3735 | return CMD_WARNING_CONFIG_FAILED; | |
3736 | } | |
718e3744 | 3737 | |
d62a17ae | 3738 | return CMD_SUCCESS; |
718e3744 | 3739 | } |
3740 | ||
3741 | DEFUN (no_neighbor, | |
3742 | no_neighbor_cmd, | |
dab8cd00 | 3743 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3744 | NO_STR |
3745 | NEIGHBOR_STR | |
3a2d747c QY |
3746 | NEIGHBOR_ADDR_STR2 |
3747 | "Specify a BGP neighbor\n" | |
3748 | AS_STR | |
3749 | "Internal BGP peer\n" | |
3750 | "External BGP peer\n") | |
718e3744 | 3751 | { |
d62a17ae | 3752 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3753 | int idx_peer = 2; | |
3754 | int ret; | |
3755 | union sockunion su; | |
3756 | struct peer_group *group; | |
3757 | struct peer *peer; | |
3758 | struct peer *other; | |
3759 | ||
3760 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3761 | if (ret < 0) { | |
3762 | /* look up for neighbor by interface name config. */ | |
3763 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3764 | if (peer) { | |
3765 | /* Request zebra to terminate IPv6 RAs on this | |
3766 | * interface. */ | |
3767 | if (peer->ifp) | |
3768 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3769 | peer_notify_unconfig(peer); |
d62a17ae | 3770 | peer_delete(peer); |
3771 | return CMD_SUCCESS; | |
3772 | } | |
f14e6fdb | 3773 | |
d62a17ae | 3774 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3775 | if (group) { |
3776 | peer_group_notify_unconfig(group); | |
d62a17ae | 3777 | peer_group_delete(group); |
4e2786df | 3778 | } else { |
d62a17ae | 3779 | vty_out(vty, "%% Create the peer-group first\n"); |
3780 | return CMD_WARNING_CONFIG_FAILED; | |
3781 | } | |
3782 | } else { | |
3783 | peer = peer_lookup(bgp, &su); | |
3784 | if (peer) { | |
3785 | if (peer_dynamic_neighbor(peer)) { | |
3786 | vty_out(vty, | |
3787 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3788 | return CMD_WARNING_CONFIG_FAILED; | |
3789 | } | |
3790 | ||
3791 | other = peer->doppelganger; | |
4e2786df | 3792 | peer_notify_unconfig(peer); |
d62a17ae | 3793 | peer_delete(peer); |
4e2786df DA |
3794 | if (other && other->status != Deleted) { |
3795 | peer_notify_unconfig(other); | |
d62a17ae | 3796 | peer_delete(other); |
4e2786df | 3797 | } |
d62a17ae | 3798 | } |
1ff9a340 | 3799 | } |
718e3744 | 3800 | |
d62a17ae | 3801 | return CMD_SUCCESS; |
718e3744 | 3802 | } |
3803 | ||
a80beece DS |
3804 | DEFUN (no_neighbor_interface_config, |
3805 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3806 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3807 | NO_STR |
3808 | NEIGHBOR_STR | |
3809 | "Interface name\n" | |
31500417 DW |
3810 | "Configure BGP on interface\n" |
3811 | "Enable BGP with v6 link-local only\n" | |
3812 | "Member of the peer-group\n" | |
16cedbb0 | 3813 | "Peer-group name\n" |
3a2d747c QY |
3814 | "Specify a BGP neighbor\n" |
3815 | AS_STR | |
3816 | "Internal BGP peer\n" | |
3817 | "External BGP peer\n") | |
a80beece | 3818 | { |
d62a17ae | 3819 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3820 | int idx_word = 2; | |
3821 | struct peer *peer; | |
3822 | ||
3823 | /* look up for neighbor by interface name config. */ | |
3824 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3825 | if (peer) { | |
3826 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3827 | if (peer->ifp) | |
3828 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3829 | peer_notify_unconfig(peer); |
d62a17ae | 3830 | peer_delete(peer); |
3831 | } else { | |
3832 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3833 | return CMD_WARNING_CONFIG_FAILED; | |
3834 | } | |
3835 | return CMD_SUCCESS; | |
a80beece DS |
3836 | } |
3837 | ||
718e3744 | 3838 | DEFUN (no_neighbor_peer_group, |
3839 | no_neighbor_peer_group_cmd, | |
3840 | "no neighbor WORD peer-group", | |
3841 | NO_STR | |
3842 | NEIGHBOR_STR | |
3843 | "Neighbor tag\n" | |
3844 | "Configure peer-group\n") | |
3845 | { | |
d62a17ae | 3846 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3847 | int idx_word = 2; | |
3848 | struct peer_group *group; | |
718e3744 | 3849 | |
d62a17ae | 3850 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3851 | if (group) { |
3852 | peer_group_notify_unconfig(group); | |
d62a17ae | 3853 | peer_group_delete(group); |
4e2786df | 3854 | } else { |
d62a17ae | 3855 | vty_out(vty, "%% Create the peer-group first\n"); |
3856 | return CMD_WARNING_CONFIG_FAILED; | |
3857 | } | |
3858 | return CMD_SUCCESS; | |
718e3744 | 3859 | } |
3860 | ||
a80beece DS |
3861 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3862 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3863 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3864 | NO_STR |
3865 | NEIGHBOR_STR | |
a80beece | 3866 | "Interface name or neighbor tag\n" |
718e3744 | 3867 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3868 | AS_STR |
3869 | "Internal BGP peer\n" | |
3870 | "External BGP peer\n") | |
718e3744 | 3871 | { |
d62a17ae | 3872 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3873 | int idx_word = 2; | |
3874 | struct peer_group *group; | |
3875 | struct peer *peer; | |
3876 | ||
3877 | /* look up for neighbor by interface name config. */ | |
3878 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3879 | if (peer) { | |
390485fd | 3880 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3881 | return CMD_SUCCESS; |
3882 | } | |
3883 | ||
3884 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3885 | if (group) | |
3886 | peer_group_remote_as_delete(group); | |
3887 | else { | |
3888 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3889 | return CMD_WARNING_CONFIG_FAILED; | |
3890 | } | |
3891 | return CMD_SUCCESS; | |
718e3744 | 3892 | } |
6b0655a2 | 3893 | |
718e3744 | 3894 | DEFUN (neighbor_local_as, |
3895 | neighbor_local_as_cmd, | |
9ccf14f7 | 3896 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3897 | NEIGHBOR_STR |
3898 | NEIGHBOR_ADDR_STR2 | |
3899 | "Specify a local-as number\n" | |
3900 | "AS number used as local AS\n") | |
3901 | { | |
d62a17ae | 3902 | int idx_peer = 1; |
3903 | int idx_number = 3; | |
3904 | struct peer *peer; | |
3905 | int ret; | |
3906 | as_t as; | |
718e3744 | 3907 | |
d62a17ae | 3908 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3909 | if (!peer) | |
3910 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3911 | |
d62a17ae | 3912 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3913 | ret = peer_local_as_set(peer, as, 0, 0); | |
3914 | return bgp_vty_return(vty, ret); | |
718e3744 | 3915 | } |
3916 | ||
3917 | DEFUN (neighbor_local_as_no_prepend, | |
3918 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3919 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3920 | NEIGHBOR_STR |
3921 | NEIGHBOR_ADDR_STR2 | |
3922 | "Specify a local-as number\n" | |
3923 | "AS number used as local AS\n" | |
3924 | "Do not prepend local-as to updates from ebgp peers\n") | |
3925 | { | |
d62a17ae | 3926 | int idx_peer = 1; |
3927 | int idx_number = 3; | |
3928 | struct peer *peer; | |
3929 | int ret; | |
3930 | as_t as; | |
718e3744 | 3931 | |
d62a17ae | 3932 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3933 | if (!peer) | |
3934 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3935 | |
d62a17ae | 3936 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3937 | ret = peer_local_as_set(peer, as, 1, 0); | |
3938 | return bgp_vty_return(vty, ret); | |
718e3744 | 3939 | } |
3940 | ||
9d3f9705 AC |
3941 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3942 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3943 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3944 | NEIGHBOR_STR |
3945 | NEIGHBOR_ADDR_STR2 | |
3946 | "Specify a local-as number\n" | |
3947 | "AS number used as local AS\n" | |
3948 | "Do not prepend local-as to updates from ebgp peers\n" | |
3949 | "Do not prepend local-as to updates from ibgp peers\n") | |
3950 | { | |
d62a17ae | 3951 | int idx_peer = 1; |
3952 | int idx_number = 3; | |
3953 | struct peer *peer; | |
3954 | int ret; | |
3955 | as_t as; | |
9d3f9705 | 3956 | |
d62a17ae | 3957 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3958 | if (!peer) | |
3959 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3960 | |
d62a17ae | 3961 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3962 | ret = peer_local_as_set(peer, as, 1, 1); | |
3963 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3964 | } |
3965 | ||
718e3744 | 3966 | DEFUN (no_neighbor_local_as, |
3967 | no_neighbor_local_as_cmd, | |
a636c635 | 3968 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3969 | NO_STR |
3970 | NEIGHBOR_STR | |
3971 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3972 | "Specify a local-as number\n" |
3973 | "AS number used as local AS\n" | |
3974 | "Do not prepend local-as to updates from ebgp peers\n" | |
3975 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3976 | { |
d62a17ae | 3977 | int idx_peer = 2; |
3978 | struct peer *peer; | |
3979 | int ret; | |
718e3744 | 3980 | |
d62a17ae | 3981 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3982 | if (!peer) | |
3983 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3984 | |
d62a17ae | 3985 | ret = peer_local_as_unset(peer); |
3986 | return bgp_vty_return(vty, ret); | |
718e3744 | 3987 | } |
3988 | ||
718e3744 | 3989 | |
3f9c7369 DS |
3990 | DEFUN (neighbor_solo, |
3991 | neighbor_solo_cmd, | |
9ccf14f7 | 3992 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3993 | NEIGHBOR_STR |
3994 | NEIGHBOR_ADDR_STR2 | |
3995 | "Solo peer - part of its own update group\n") | |
3996 | { | |
d62a17ae | 3997 | int idx_peer = 1; |
3998 | struct peer *peer; | |
3999 | int ret; | |
3f9c7369 | 4000 | |
d62a17ae | 4001 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4002 | if (!peer) | |
4003 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4004 | |
d62a17ae | 4005 | ret = update_group_adjust_soloness(peer, 1); |
4006 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4007 | } |
4008 | ||
4009 | DEFUN (no_neighbor_solo, | |
4010 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4011 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4012 | NO_STR |
4013 | NEIGHBOR_STR | |
4014 | NEIGHBOR_ADDR_STR2 | |
4015 | "Solo peer - part of its own update group\n") | |
4016 | { | |
d62a17ae | 4017 | int idx_peer = 2; |
4018 | struct peer *peer; | |
4019 | int ret; | |
3f9c7369 | 4020 | |
d62a17ae | 4021 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4022 | if (!peer) | |
4023 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4024 | |
d62a17ae | 4025 | ret = update_group_adjust_soloness(peer, 0); |
4026 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4027 | } |
4028 | ||
0df7c91f PJ |
4029 | DEFUN (neighbor_password, |
4030 | neighbor_password_cmd, | |
9ccf14f7 | 4031 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4032 | NEIGHBOR_STR |
4033 | NEIGHBOR_ADDR_STR2 | |
4034 | "Set a password\n" | |
4035 | "The password\n") | |
4036 | { | |
d62a17ae | 4037 | int idx_peer = 1; |
4038 | int idx_line = 3; | |
4039 | struct peer *peer; | |
4040 | int ret; | |
0df7c91f | 4041 | |
d62a17ae | 4042 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4043 | if (!peer) | |
4044 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4045 | |
d62a17ae | 4046 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4047 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4048 | } |
4049 | ||
4050 | DEFUN (no_neighbor_password, | |
4051 | no_neighbor_password_cmd, | |
a636c635 | 4052 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4053 | NO_STR |
4054 | NEIGHBOR_STR | |
4055 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4056 | "Set a password\n" |
4057 | "The password\n") | |
0df7c91f | 4058 | { |
d62a17ae | 4059 | int idx_peer = 2; |
4060 | struct peer *peer; | |
4061 | int ret; | |
0df7c91f | 4062 | |
d62a17ae | 4063 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4064 | if (!peer) | |
4065 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4066 | |
d62a17ae | 4067 | ret = peer_password_unset(peer); |
4068 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4069 | } |
6b0655a2 | 4070 | |
718e3744 | 4071 | DEFUN (neighbor_activate, |
4072 | neighbor_activate_cmd, | |
9ccf14f7 | 4073 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4074 | NEIGHBOR_STR |
4075 | NEIGHBOR_ADDR_STR2 | |
4076 | "Enable the Address Family for this Neighbor\n") | |
4077 | { | |
d62a17ae | 4078 | int idx_peer = 1; |
4079 | int ret; | |
4080 | struct peer *peer; | |
718e3744 | 4081 | |
d62a17ae | 4082 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4083 | if (!peer) | |
4084 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4085 | |
d62a17ae | 4086 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4087 | return bgp_vty_return(vty, ret); | |
718e3744 | 4088 | } |
4089 | ||
d62a17ae | 4090 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4091 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4092 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4093 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4094 | |
718e3744 | 4095 | DEFUN (no_neighbor_activate, |
4096 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4097 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4098 | NO_STR |
4099 | NEIGHBOR_STR | |
4100 | NEIGHBOR_ADDR_STR2 | |
4101 | "Enable the Address Family for this Neighbor\n") | |
4102 | { | |
d62a17ae | 4103 | int idx_peer = 2; |
4104 | int ret; | |
4105 | struct peer *peer; | |
718e3744 | 4106 | |
d62a17ae | 4107 | /* Lookup peer. */ |
4108 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4109 | if (!peer) | |
4110 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4111 | |
d62a17ae | 4112 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4113 | return bgp_vty_return(vty, ret); | |
718e3744 | 4114 | } |
6b0655a2 | 4115 | |
d62a17ae | 4116 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4118 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4119 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4120 | |
718e3744 | 4121 | DEFUN (neighbor_set_peer_group, |
4122 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4123 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4124 | NEIGHBOR_STR |
a80beece | 4125 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4126 | "Member of the peer-group\n" |
16cedbb0 | 4127 | "Peer-group name\n") |
718e3744 | 4128 | { |
d62a17ae | 4129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4130 | int idx_peer = 1; | |
4131 | int idx_word = 3; | |
4132 | int ret; | |
4133 | as_t as; | |
4134 | union sockunion su; | |
4135 | struct peer *peer; | |
4136 | struct peer_group *group; | |
4137 | ||
d62a17ae | 4138 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4139 | if (ret < 0) { | |
4140 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4141 | if (!peer) { | |
4142 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4143 | argv[idx_peer]->arg); | |
4144 | return CMD_WARNING_CONFIG_FAILED; | |
4145 | } | |
4146 | } else { | |
4147 | if (peer_address_self_check(bgp, &su)) { | |
4148 | vty_out(vty, | |
4149 | "%% Can not configure the local system as neighbor\n"); | |
4150 | return CMD_WARNING_CONFIG_FAILED; | |
4151 | } | |
4152 | ||
4153 | /* Disallow for dynamic neighbor. */ | |
4154 | peer = peer_lookup(bgp, &su); | |
4155 | if (peer && peer_dynamic_neighbor(peer)) { | |
4156 | vty_out(vty, | |
4157 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4158 | return CMD_WARNING_CONFIG_FAILED; | |
4159 | } | |
4160 | } | |
4161 | ||
4162 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4163 | if (!group) { | |
4164 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4165 | return CMD_WARNING_CONFIG_FAILED; | |
4166 | } | |
4167 | ||
4168 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4169 | ||
4170 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4171 | vty_out(vty, | |
4172 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4173 | as); | |
4174 | return CMD_WARNING_CONFIG_FAILED; | |
4175 | } | |
4176 | ||
4177 | return bgp_vty_return(vty, ret); | |
4178 | } | |
4179 | ||
4180 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4181 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4182 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4183 | "Member of the peer-group\n" | |
4184 | "Peer-group name\n") | |
596c17ba | 4185 | |
718e3744 | 4186 | DEFUN (no_neighbor_set_peer_group, |
4187 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4188 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4189 | NO_STR |
4190 | NEIGHBOR_STR | |
a80beece | 4191 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4192 | "Member of the peer-group\n" |
16cedbb0 | 4193 | "Peer-group name\n") |
718e3744 | 4194 | { |
d62a17ae | 4195 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4196 | int idx_peer = 2; | |
4197 | int idx_word = 4; | |
4198 | int ret; | |
4199 | struct peer *peer; | |
4200 | struct peer_group *group; | |
4201 | ||
4202 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4203 | if (!peer) | |
4204 | return CMD_WARNING_CONFIG_FAILED; | |
4205 | ||
4206 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4207 | if (!group) { | |
4208 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4209 | return CMD_WARNING_CONFIG_FAILED; | |
4210 | } | |
718e3744 | 4211 | |
4e2786df | 4212 | peer_notify_unconfig(peer); |
827ed707 | 4213 | ret = peer_delete(peer); |
718e3744 | 4214 | |
d62a17ae | 4215 | return bgp_vty_return(vty, ret); |
718e3744 | 4216 | } |
6b0655a2 | 4217 | |
d62a17ae | 4218 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4219 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4220 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4221 | "Member of the peer-group\n" | |
4222 | "Peer-group name\n") | |
596c17ba | 4223 | |
d62a17ae | 4224 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4225 | uint32_t flag, int set) |
718e3744 | 4226 | { |
d62a17ae | 4227 | int ret; |
4228 | struct peer *peer; | |
718e3744 | 4229 | |
d62a17ae | 4230 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4231 | if (!peer) | |
4232 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4233 | |
7ebe625c QY |
4234 | /* |
4235 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4236 | * we should not accept disable-connected-check. | |
4237 | */ | |
4238 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4239 | vty_out(vty, | |
4240 | "%s is directly connected peer, cannot accept disable-" | |
4241 | "connected-check\n", | |
4242 | ip_str); | |
4243 | return CMD_WARNING_CONFIG_FAILED; | |
4244 | } | |
4245 | ||
d62a17ae | 4246 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4247 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4248 | |
d62a17ae | 4249 | if (set) |
4250 | ret = peer_flag_set(peer, flag); | |
4251 | else | |
4252 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4253 | |
d62a17ae | 4254 | return bgp_vty_return(vty, ret); |
718e3744 | 4255 | } |
4256 | ||
47cbc09b | 4257 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4258 | { |
d62a17ae | 4259 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4260 | } |
4261 | ||
d62a17ae | 4262 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4263 | uint32_t flag) |
718e3744 | 4264 | { |
d62a17ae | 4265 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4266 | } |
4267 | ||
4268 | /* neighbor passive. */ | |
4269 | DEFUN (neighbor_passive, | |
4270 | neighbor_passive_cmd, | |
9ccf14f7 | 4271 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4272 | NEIGHBOR_STR |
4273 | NEIGHBOR_ADDR_STR2 | |
4274 | "Don't send open messages to this neighbor\n") | |
4275 | { | |
d62a17ae | 4276 | int idx_peer = 1; |
4277 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4278 | } |
4279 | ||
4280 | DEFUN (no_neighbor_passive, | |
4281 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4282 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4283 | NO_STR |
4284 | NEIGHBOR_STR | |
4285 | NEIGHBOR_ADDR_STR2 | |
4286 | "Don't send open messages to this neighbor\n") | |
4287 | { | |
d62a17ae | 4288 | int idx_peer = 2; |
4289 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4290 | } |
6b0655a2 | 4291 | |
718e3744 | 4292 | /* neighbor shutdown. */ |
73d70fa6 DL |
4293 | DEFUN (neighbor_shutdown_msg, |
4294 | neighbor_shutdown_msg_cmd, | |
4295 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4296 | NEIGHBOR_STR |
4297 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
4298 | "Administratively shut down this neighbor\n" |
4299 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4300 | "Shutdown message\n") | |
718e3744 | 4301 | { |
d62a17ae | 4302 | int idx_peer = 1; |
73d70fa6 | 4303 | |
d62a17ae | 4304 | if (argc >= 5) { |
4305 | struct peer *peer = | |
4306 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4307 | char *message; | |
73d70fa6 | 4308 | |
d62a17ae | 4309 | if (!peer) |
4310 | return CMD_WARNING_CONFIG_FAILED; | |
4311 | message = argv_concat(argv, argc, 4); | |
4312 | peer_tx_shutdown_message_set(peer, message); | |
4313 | XFREE(MTYPE_TMP, message); | |
4314 | } | |
73d70fa6 | 4315 | |
d62a17ae | 4316 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4317 | } |
4318 | ||
d62a17ae | 4319 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4320 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4321 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4322 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4323 | |
4324 | DEFUN (no_neighbor_shutdown_msg, | |
4325 | no_neighbor_shutdown_msg_cmd, | |
4326 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4327 | NO_STR | |
4328 | NEIGHBOR_STR | |
4329 | NEIGHBOR_ADDR_STR2 | |
4330 | "Administratively shut down this neighbor\n" | |
4331 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4332 | "Shutdown message\n") | |
718e3744 | 4333 | { |
d62a17ae | 4334 | int idx_peer = 2; |
73d70fa6 | 4335 | |
d62a17ae | 4336 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4337 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4338 | } |
6b0655a2 | 4339 | |
d62a17ae | 4340 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4341 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4342 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4343 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4344 | |
718e3744 | 4345 | /* neighbor capability dynamic. */ |
4346 | DEFUN (neighbor_capability_dynamic, | |
4347 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4348 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4349 | NEIGHBOR_STR |
4350 | NEIGHBOR_ADDR_STR2 | |
4351 | "Advertise capability to the peer\n" | |
4352 | "Advertise dynamic capability to this neighbor\n") | |
4353 | { | |
d62a17ae | 4354 | int idx_peer = 1; |
4355 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4356 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4357 | } |
4358 | ||
4359 | DEFUN (no_neighbor_capability_dynamic, | |
4360 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4362 | NO_STR |
4363 | NEIGHBOR_STR | |
4364 | NEIGHBOR_ADDR_STR2 | |
4365 | "Advertise capability to the peer\n" | |
4366 | "Advertise dynamic capability to this neighbor\n") | |
4367 | { | |
d62a17ae | 4368 | int idx_peer = 2; |
4369 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4370 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4371 | } |
6b0655a2 | 4372 | |
718e3744 | 4373 | /* neighbor dont-capability-negotiate */ |
4374 | DEFUN (neighbor_dont_capability_negotiate, | |
4375 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4376 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4377 | NEIGHBOR_STR |
4378 | NEIGHBOR_ADDR_STR2 | |
4379 | "Do not perform capability negotiation\n") | |
4380 | { | |
d62a17ae | 4381 | int idx_peer = 1; |
4382 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4383 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4384 | } |
4385 | ||
4386 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4387 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4389 | NO_STR |
4390 | NEIGHBOR_STR | |
4391 | NEIGHBOR_ADDR_STR2 | |
4392 | "Do not perform capability negotiation\n") | |
4393 | { | |
d62a17ae | 4394 | int idx_peer = 2; |
4395 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4396 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4397 | } |
6b0655a2 | 4398 | |
8a92a8a0 DS |
4399 | /* neighbor capability extended next hop encoding */ |
4400 | DEFUN (neighbor_capability_enhe, | |
4401 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4402 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4403 | NEIGHBOR_STR |
4404 | NEIGHBOR_ADDR_STR2 | |
4405 | "Advertise capability to the peer\n" | |
4406 | "Advertise extended next-hop capability to the peer\n") | |
4407 | { | |
d62a17ae | 4408 | int idx_peer = 1; |
4409 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4410 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4411 | } |
4412 | ||
4413 | DEFUN (no_neighbor_capability_enhe, | |
4414 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4416 | NO_STR |
4417 | NEIGHBOR_STR | |
4418 | NEIGHBOR_ADDR_STR2 | |
4419 | "Advertise capability to the peer\n" | |
4420 | "Advertise extended next-hop capability to the peer\n") | |
4421 | { | |
d62a17ae | 4422 | int idx_peer = 2; |
4423 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4424 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4425 | } |
4426 | ||
d62a17ae | 4427 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4428 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4429 | int set) |
718e3744 | 4430 | { |
d62a17ae | 4431 | int ret; |
4432 | struct peer *peer; | |
718e3744 | 4433 | |
d62a17ae | 4434 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4435 | if (!peer) | |
4436 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4437 | |
d62a17ae | 4438 | if (set) |
4439 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4440 | else | |
4441 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4442 | |
d62a17ae | 4443 | return bgp_vty_return(vty, ret); |
718e3744 | 4444 | } |
4445 | ||
d62a17ae | 4446 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4447 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4448 | { |
d62a17ae | 4449 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4450 | } |
4451 | ||
d62a17ae | 4452 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4453 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4454 | { |
d62a17ae | 4455 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4456 | } |
6b0655a2 | 4457 | |
718e3744 | 4458 | /* neighbor capability orf prefix-list. */ |
4459 | DEFUN (neighbor_capability_orf_prefix, | |
4460 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4461 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4462 | NEIGHBOR_STR |
4463 | NEIGHBOR_ADDR_STR2 | |
4464 | "Advertise capability to the peer\n" | |
4465 | "Advertise ORF capability to the peer\n" | |
4466 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4467 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4468 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4469 | "Capability to SEND the ORF to this neighbor\n") | |
4470 | { | |
d62a17ae | 4471 | int idx_peer = 1; |
4472 | int idx_send_recv = 5; | |
d7c0a89a | 4473 | uint16_t flag = 0; |
d62a17ae | 4474 | |
4475 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4476 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4477 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4478 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4479 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4480 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4481 | else { | |
4482 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4483 | return CMD_WARNING_CONFIG_FAILED; | |
4484 | } | |
4485 | ||
4486 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4487 | bgp_node_safi(vty), flag); | |
4488 | } | |
4489 | ||
4490 | ALIAS_HIDDEN( | |
4491 | neighbor_capability_orf_prefix, | |
4492 | neighbor_capability_orf_prefix_hidden_cmd, | |
4493 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4494 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4495 | "Advertise capability to the peer\n" | |
4496 | "Advertise ORF capability to the peer\n" | |
4497 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4498 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4499 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4500 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4501 | |
718e3744 | 4502 | DEFUN (no_neighbor_capability_orf_prefix, |
4503 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4504 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4505 | NO_STR |
4506 | NEIGHBOR_STR | |
4507 | NEIGHBOR_ADDR_STR2 | |
4508 | "Advertise capability to the peer\n" | |
4509 | "Advertise ORF capability to the peer\n" | |
4510 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4511 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4512 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4513 | "Capability to SEND the ORF to this neighbor\n") | |
4514 | { | |
d62a17ae | 4515 | int idx_peer = 2; |
4516 | int idx_send_recv = 6; | |
d7c0a89a | 4517 | uint16_t flag = 0; |
d62a17ae | 4518 | |
4519 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4520 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4521 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4522 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4523 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4524 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4525 | else { | |
4526 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4527 | return CMD_WARNING_CONFIG_FAILED; | |
4528 | } | |
4529 | ||
4530 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4531 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4532 | flag); | |
4533 | } | |
4534 | ||
4535 | ALIAS_HIDDEN( | |
4536 | no_neighbor_capability_orf_prefix, | |
4537 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4538 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4539 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4540 | "Advertise capability to the peer\n" | |
4541 | "Advertise ORF capability to the peer\n" | |
4542 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4543 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4544 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4545 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4546 | |
718e3744 | 4547 | /* neighbor next-hop-self. */ |
4548 | DEFUN (neighbor_nexthop_self, | |
4549 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4550 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4551 | NEIGHBOR_STR |
4552 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4553 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4554 | { |
d62a17ae | 4555 | int idx_peer = 1; |
4556 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4557 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4558 | } |
9e7a53c1 | 4559 | |
d62a17ae | 4560 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4561 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4562 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4563 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4564 | |
a538debe DS |
4565 | /* neighbor next-hop-self. */ |
4566 | DEFUN (neighbor_nexthop_self_force, | |
4567 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4568 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4569 | NEIGHBOR_STR |
4570 | NEIGHBOR_ADDR_STR2 | |
4571 | "Disable the next hop calculation for this neighbor\n" | |
4572 | "Set the next hop to self for reflected routes\n") | |
4573 | { | |
d62a17ae | 4574 | int idx_peer = 1; |
4575 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4576 | bgp_node_safi(vty), | |
4577 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4578 | } |
4579 | ||
d62a17ae | 4580 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4581 | neighbor_nexthop_self_force_hidden_cmd, | |
4582 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4583 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4584 | "Disable the next hop calculation for this neighbor\n" | |
4585 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4586 | |
1bc4e531 DA |
4587 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4588 | neighbor_nexthop_self_all_hidden_cmd, | |
4589 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4590 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4591 | "Disable the next hop calculation for this neighbor\n" | |
4592 | "Set the next hop to self for reflected routes\n") | |
4593 | ||
718e3744 | 4594 | DEFUN (no_neighbor_nexthop_self, |
4595 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4596 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4597 | NO_STR |
4598 | NEIGHBOR_STR | |
4599 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4600 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4601 | { |
d62a17ae | 4602 | int idx_peer = 2; |
4603 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4604 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4605 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4606 | } |
6b0655a2 | 4607 | |
d62a17ae | 4608 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4610 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4611 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4612 | |
88b8ed8d | 4613 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4614 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4615 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4616 | NO_STR |
4617 | NEIGHBOR_STR | |
4618 | NEIGHBOR_ADDR_STR2 | |
4619 | "Disable the next hop calculation for this neighbor\n" | |
4620 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4621 | { |
d62a17ae | 4622 | int idx_peer = 2; |
4623 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4624 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4625 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4626 | } |
a538debe | 4627 | |
d62a17ae | 4628 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4629 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4630 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4631 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4632 | "Disable the next hop calculation for this neighbor\n" | |
4633 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4634 | |
1bc4e531 DA |
4635 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4636 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4637 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4638 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4639 | "Disable the next hop calculation for this neighbor\n" | |
4640 | "Set the next hop to self for reflected routes\n") | |
4641 | ||
c7122e14 DS |
4642 | /* neighbor as-override */ |
4643 | DEFUN (neighbor_as_override, | |
4644 | neighbor_as_override_cmd, | |
9ccf14f7 | 4645 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4646 | NEIGHBOR_STR |
4647 | NEIGHBOR_ADDR_STR2 | |
4648 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4649 | { | |
d62a17ae | 4650 | int idx_peer = 1; |
4651 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4652 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4653 | } |
4654 | ||
d62a17ae | 4655 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4656 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4657 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4658 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4659 | |
c7122e14 DS |
4660 | DEFUN (no_neighbor_as_override, |
4661 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4662 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4663 | NO_STR |
4664 | NEIGHBOR_STR | |
4665 | NEIGHBOR_ADDR_STR2 | |
4666 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4667 | { | |
d62a17ae | 4668 | int idx_peer = 2; |
4669 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4670 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4671 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4672 | } |
4673 | ||
d62a17ae | 4674 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4675 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4676 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4677 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4678 | |
718e3744 | 4679 | /* neighbor remove-private-AS. */ |
4680 | DEFUN (neighbor_remove_private_as, | |
4681 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4682 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4683 | NEIGHBOR_STR |
4684 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4685 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4686 | { |
d62a17ae | 4687 | int idx_peer = 1; |
4688 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4689 | bgp_node_safi(vty), | |
4690 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4691 | } |
4692 | ||
d62a17ae | 4693 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4694 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4695 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4696 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4697 | |
5000f21c DS |
4698 | DEFUN (neighbor_remove_private_as_all, |
4699 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4700 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4701 | NEIGHBOR_STR |
4702 | NEIGHBOR_ADDR_STR2 | |
4703 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4704 | "Apply to all AS numbers\n") |
5000f21c | 4705 | { |
d62a17ae | 4706 | int idx_peer = 1; |
4707 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4708 | bgp_node_safi(vty), | |
4709 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4710 | } |
4711 | ||
d62a17ae | 4712 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4713 | neighbor_remove_private_as_all_hidden_cmd, | |
4714 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4715 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4716 | "Remove private ASNs in outbound updates\n" | |
4717 | "Apply to all AS numbers") | |
596c17ba | 4718 | |
5000f21c DS |
4719 | DEFUN (neighbor_remove_private_as_replace_as, |
4720 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4721 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4722 | NEIGHBOR_STR |
4723 | NEIGHBOR_ADDR_STR2 | |
4724 | "Remove private ASNs in outbound updates\n" | |
4725 | "Replace private ASNs with our ASN in outbound updates\n") | |
4726 | { | |
d62a17ae | 4727 | int idx_peer = 1; |
4728 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4729 | bgp_node_safi(vty), | |
4730 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4731 | } |
4732 | ||
d62a17ae | 4733 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4734 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4735 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4736 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4737 | "Remove private ASNs in outbound updates\n" | |
4738 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4739 | |
5000f21c DS |
4740 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4741 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4742 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4743 | NEIGHBOR_STR |
4744 | NEIGHBOR_ADDR_STR2 | |
4745 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4746 | "Apply to all AS numbers\n" |
5000f21c DS |
4747 | "Replace private ASNs with our ASN in outbound updates\n") |
4748 | { | |
d62a17ae | 4749 | int idx_peer = 1; |
4750 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4751 | bgp_node_safi(vty), | |
4752 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4753 | } |
4754 | ||
d62a17ae | 4755 | ALIAS_HIDDEN( |
4756 | neighbor_remove_private_as_all_replace_as, | |
4757 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4758 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4759 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4760 | "Remove private ASNs in outbound updates\n" | |
4761 | "Apply to all AS numbers\n" | |
4762 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4763 | |
718e3744 | 4764 | DEFUN (no_neighbor_remove_private_as, |
4765 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4766 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4767 | NO_STR |
4768 | NEIGHBOR_STR | |
4769 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4770 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4771 | { |
d62a17ae | 4772 | int idx_peer = 2; |
4773 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4774 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4775 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4776 | } |
6b0655a2 | 4777 | |
d62a17ae | 4778 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4779 | no_neighbor_remove_private_as_hidden_cmd, | |
4780 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4781 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4782 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4783 | |
88b8ed8d | 4784 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4785 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4786 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4787 | NO_STR |
4788 | NEIGHBOR_STR | |
4789 | NEIGHBOR_ADDR_STR2 | |
4790 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4791 | "Apply to all AS numbers\n") |
88b8ed8d | 4792 | { |
d62a17ae | 4793 | int idx_peer = 2; |
4794 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4795 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4796 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4797 | } |
5000f21c | 4798 | |
d62a17ae | 4799 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4800 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4801 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4802 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4803 | "Remove private ASNs in outbound updates\n" | |
4804 | "Apply to all AS numbers\n") | |
596c17ba | 4805 | |
88b8ed8d | 4806 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4807 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4808 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4809 | NO_STR |
4810 | NEIGHBOR_STR | |
4811 | NEIGHBOR_ADDR_STR2 | |
4812 | "Remove private ASNs in outbound updates\n" | |
4813 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4814 | { |
d62a17ae | 4815 | int idx_peer = 2; |
4816 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4817 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4818 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4819 | } |
5000f21c | 4820 | |
d62a17ae | 4821 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4822 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4823 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4824 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4825 | "Remove private ASNs in outbound updates\n" | |
4826 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4827 | |
88b8ed8d | 4828 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4829 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4830 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4831 | NO_STR |
4832 | NEIGHBOR_STR | |
4833 | NEIGHBOR_ADDR_STR2 | |
4834 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4835 | "Apply to all AS numbers\n" |
5000f21c | 4836 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4837 | { |
d62a17ae | 4838 | int idx_peer = 2; |
4839 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4840 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4841 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4842 | } |
5000f21c | 4843 | |
d62a17ae | 4844 | ALIAS_HIDDEN( |
4845 | no_neighbor_remove_private_as_all_replace_as, | |
4846 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4847 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4848 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4849 | "Remove private ASNs in outbound updates\n" | |
4850 | "Apply to all AS numbers\n" | |
4851 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4852 | |
5000f21c | 4853 | |
718e3744 | 4854 | /* neighbor send-community. */ |
4855 | DEFUN (neighbor_send_community, | |
4856 | neighbor_send_community_cmd, | |
9ccf14f7 | 4857 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4858 | NEIGHBOR_STR |
4859 | NEIGHBOR_ADDR_STR2 | |
4860 | "Send Community attribute to this neighbor\n") | |
4861 | { | |
d62a17ae | 4862 | int idx_peer = 1; |
27c05d4d | 4863 | |
d62a17ae | 4864 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4865 | bgp_node_safi(vty), | |
4866 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4867 | } |
4868 | ||
d62a17ae | 4869 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4870 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4871 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4872 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4873 | |
718e3744 | 4874 | DEFUN (no_neighbor_send_community, |
4875 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4877 | NO_STR |
4878 | NEIGHBOR_STR | |
4879 | NEIGHBOR_ADDR_STR2 | |
4880 | "Send Community attribute to this neighbor\n") | |
4881 | { | |
d62a17ae | 4882 | int idx_peer = 2; |
27c05d4d | 4883 | |
d62a17ae | 4884 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4885 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4886 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4887 | } |
6b0655a2 | 4888 | |
d62a17ae | 4889 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4891 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4892 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4893 | |
718e3744 | 4894 | /* neighbor send-community extended. */ |
4895 | DEFUN (neighbor_send_community_type, | |
4896 | neighbor_send_community_type_cmd, | |
57d187bc | 4897 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4898 | NEIGHBOR_STR |
4899 | NEIGHBOR_ADDR_STR2 | |
4900 | "Send Community attribute to this neighbor\n" | |
4901 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4902 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4903 | "Send Extended Community attributes\n" |
57d187bc JS |
4904 | "Send Standard Community attributes\n" |
4905 | "Send Large Community attributes\n") | |
718e3744 | 4906 | { |
27c05d4d | 4907 | int idx_peer = 1; |
d7c0a89a | 4908 | uint32_t flag = 0; |
27c05d4d | 4909 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4910 | |
27c05d4d | 4911 | if (strmatch(type, "standard")) { |
d62a17ae | 4912 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4913 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4914 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4915 | } else if (strmatch(type, "large")) { |
d62a17ae | 4916 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4917 | } else if (strmatch(type, "both")) { |
d62a17ae | 4918 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4919 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4920 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4921 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4922 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4923 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4924 | } | |
4925 | ||
27c05d4d | 4926 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4927 | bgp_node_safi(vty), flag); |
4928 | } | |
4929 | ||
4930 | ALIAS_HIDDEN( | |
4931 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4932 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4933 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4934 | "Send Community attribute to this neighbor\n" | |
4935 | "Send Standard and Extended Community attributes\n" | |
4936 | "Send Standard, Large and Extended Community attributes\n" | |
4937 | "Send Extended Community attributes\n" | |
4938 | "Send Standard Community attributes\n" | |
4939 | "Send Large Community attributes\n") | |
596c17ba | 4940 | |
718e3744 | 4941 | DEFUN (no_neighbor_send_community_type, |
4942 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4943 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4944 | NO_STR |
4945 | NEIGHBOR_STR | |
4946 | NEIGHBOR_ADDR_STR2 | |
4947 | "Send Community attribute to this neighbor\n" | |
4948 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4949 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4950 | "Send Extended Community attributes\n" |
57d187bc JS |
4951 | "Send Standard Community attributes\n" |
4952 | "Send Large Community attributes\n") | |
718e3744 | 4953 | { |
d62a17ae | 4954 | int idx_peer = 2; |
27c05d4d | 4955 | uint32_t flag = 0; |
d62a17ae | 4956 | const char *type = argv[argc - 1]->text; |
4957 | ||
27c05d4d PM |
4958 | if (strmatch(type, "standard")) { |
4959 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4960 | } else if (strmatch(type, "extended")) { | |
4961 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4962 | } else if (strmatch(type, "large")) { | |
4963 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4964 | } else if (strmatch(type, "both")) { | |
4965 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4966 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4967 | } else { /* if (strmatch(type, "all")) */ | |
4968 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4969 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4970 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4971 | } | |
4972 | ||
4973 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4974 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4975 | flag); | |
d62a17ae | 4976 | } |
4977 | ||
4978 | ALIAS_HIDDEN( | |
4979 | no_neighbor_send_community_type, | |
4980 | no_neighbor_send_community_type_hidden_cmd, | |
4981 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4982 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4983 | "Send Community attribute to this neighbor\n" | |
4984 | "Send Standard and Extended Community attributes\n" | |
4985 | "Send Standard, Large and Extended Community attributes\n" | |
4986 | "Send Extended Community attributes\n" | |
4987 | "Send Standard Community attributes\n" | |
4988 | "Send Large Community attributes\n") | |
596c17ba | 4989 | |
718e3744 | 4990 | /* neighbor soft-reconfig. */ |
4991 | DEFUN (neighbor_soft_reconfiguration, | |
4992 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4993 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4994 | NEIGHBOR_STR |
4995 | NEIGHBOR_ADDR_STR2 | |
4996 | "Per neighbor soft reconfiguration\n" | |
4997 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4998 | { | |
d62a17ae | 4999 | int idx_peer = 1; |
5000 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5001 | bgp_node_safi(vty), | |
5002 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5003 | } |
5004 | ||
d62a17ae | 5005 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5006 | neighbor_soft_reconfiguration_hidden_cmd, | |
5007 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5008 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5009 | "Per neighbor soft reconfiguration\n" | |
5010 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5011 | |
718e3744 | 5012 | DEFUN (no_neighbor_soft_reconfiguration, |
5013 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5014 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5015 | NO_STR |
5016 | NEIGHBOR_STR | |
5017 | NEIGHBOR_ADDR_STR2 | |
5018 | "Per neighbor soft reconfiguration\n" | |
5019 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5020 | { | |
d62a17ae | 5021 | int idx_peer = 2; |
5022 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5023 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5024 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5025 | } |
6b0655a2 | 5026 | |
d62a17ae | 5027 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5028 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5029 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5030 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5031 | "Per neighbor soft reconfiguration\n" | |
5032 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5033 | |
718e3744 | 5034 | DEFUN (neighbor_route_reflector_client, |
5035 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5036 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5037 | NEIGHBOR_STR |
5038 | NEIGHBOR_ADDR_STR2 | |
5039 | "Configure a neighbor as Route Reflector client\n") | |
5040 | { | |
d62a17ae | 5041 | int idx_peer = 1; |
5042 | struct peer *peer; | |
718e3744 | 5043 | |
5044 | ||
d62a17ae | 5045 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5046 | if (!peer) | |
5047 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5048 | |
d62a17ae | 5049 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5050 | bgp_node_safi(vty), | |
5051 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5052 | } |
5053 | ||
d62a17ae | 5054 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5055 | neighbor_route_reflector_client_hidden_cmd, | |
5056 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5057 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5058 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5059 | |
718e3744 | 5060 | DEFUN (no_neighbor_route_reflector_client, |
5061 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5062 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5063 | NO_STR |
5064 | NEIGHBOR_STR | |
5065 | NEIGHBOR_ADDR_STR2 | |
5066 | "Configure a neighbor as Route Reflector client\n") | |
5067 | { | |
d62a17ae | 5068 | int idx_peer = 2; |
5069 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5070 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5071 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5072 | } |
6b0655a2 | 5073 | |
d62a17ae | 5074 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5075 | no_neighbor_route_reflector_client_hidden_cmd, | |
5076 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5077 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5078 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5079 | |
718e3744 | 5080 | /* neighbor route-server-client. */ |
5081 | DEFUN (neighbor_route_server_client, | |
5082 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5083 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5084 | NEIGHBOR_STR |
5085 | NEIGHBOR_ADDR_STR2 | |
5086 | "Configure a neighbor as Route Server client\n") | |
5087 | { | |
d62a17ae | 5088 | int idx_peer = 1; |
5089 | struct peer *peer; | |
2a3d5731 | 5090 | |
d62a17ae | 5091 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5092 | if (!peer) | |
5093 | return CMD_WARNING_CONFIG_FAILED; | |
5094 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5095 | bgp_node_safi(vty), | |
5096 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5097 | } |
5098 | ||
d62a17ae | 5099 | ALIAS_HIDDEN(neighbor_route_server_client, |
5100 | neighbor_route_server_client_hidden_cmd, | |
5101 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5102 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5103 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5104 | |
718e3744 | 5105 | DEFUN (no_neighbor_route_server_client, |
5106 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5107 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5108 | NO_STR |
5109 | NEIGHBOR_STR | |
5110 | NEIGHBOR_ADDR_STR2 | |
5111 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5112 | { |
d62a17ae | 5113 | int idx_peer = 2; |
5114 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5115 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5116 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5117 | } |
6b0655a2 | 5118 | |
d62a17ae | 5119 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5120 | no_neighbor_route_server_client_hidden_cmd, | |
5121 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5122 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5123 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5124 | |
fee0f4c6 | 5125 | DEFUN (neighbor_nexthop_local_unchanged, |
5126 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5127 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5128 | NEIGHBOR_STR |
5129 | NEIGHBOR_ADDR_STR2 | |
5130 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5131 | "Leave link-local nexthop unchanged for this peer\n") | |
5132 | { | |
d62a17ae | 5133 | int idx_peer = 1; |
5134 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5135 | bgp_node_safi(vty), | |
5136 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5137 | } |
6b0655a2 | 5138 | |
fee0f4c6 | 5139 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5140 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5141 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5142 | NO_STR |
5143 | NEIGHBOR_STR | |
5144 | NEIGHBOR_ADDR_STR2 | |
5145 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5146 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5147 | { |
d62a17ae | 5148 | int idx_peer = 2; |
5149 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5150 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5151 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5152 | } |
6b0655a2 | 5153 | |
718e3744 | 5154 | DEFUN (neighbor_attr_unchanged, |
5155 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5156 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5157 | NEIGHBOR_STR |
5158 | NEIGHBOR_ADDR_STR2 | |
5159 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5160 | "As-path attribute\n" | |
5161 | "Nexthop attribute\n" | |
a8206004 | 5162 | "Med attribute\n") |
718e3744 | 5163 | { |
d62a17ae | 5164 | int idx = 0; |
8eeb0335 DW |
5165 | char *peer_str = argv[1]->arg; |
5166 | struct peer *peer; | |
d7c0a89a | 5167 | uint16_t flags = 0; |
8eeb0335 DW |
5168 | afi_t afi = bgp_node_afi(vty); |
5169 | safi_t safi = bgp_node_safi(vty); | |
5170 | ||
5171 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5172 | if (!peer) | |
5173 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5174 | |
5175 | if (argv_find(argv, argc, "as-path", &idx)) | |
5176 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5177 | idx = 0; | |
5178 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5179 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5180 | idx = 0; | |
5181 | if (argv_find(argv, argc, "med", &idx)) | |
5182 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5183 | ||
8eeb0335 DW |
5184 | /* no flags means all of them! */ |
5185 | if (!flags) { | |
d62a17ae | 5186 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
5187 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5188 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5189 | } else { |
a4d82a8a PZ |
5190 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
5191 | && peer_af_flag_check(peer, afi, safi, | |
5192 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
5193 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5194 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5195 | } | |
5196 | ||
a4d82a8a PZ |
5197 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
5198 | && peer_af_flag_check(peer, afi, safi, | |
5199 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
5200 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5201 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5202 | } | |
5203 | ||
a4d82a8a PZ |
5204 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
5205 | && peer_af_flag_check(peer, afi, safi, | |
5206 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
5207 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5208 | PEER_FLAG_MED_UNCHANGED); | |
5209 | } | |
d62a17ae | 5210 | } |
5211 | ||
8eeb0335 | 5212 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 5213 | } |
5214 | ||
5215 | ALIAS_HIDDEN( | |
5216 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5217 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5218 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5219 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5220 | "As-path attribute\n" | |
5221 | "Nexthop attribute\n" | |
5222 | "Med attribute\n") | |
596c17ba | 5223 | |
718e3744 | 5224 | DEFUN (no_neighbor_attr_unchanged, |
5225 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5226 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5227 | NO_STR |
718e3744 | 5228 | NEIGHBOR_STR |
5229 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5230 | "BGP attribute is propagated unchanged to this neighbor\n" |
5231 | "As-path attribute\n" | |
40e718b5 | 5232 | "Nexthop attribute\n" |
a8206004 | 5233 | "Med attribute\n") |
718e3744 | 5234 | { |
d62a17ae | 5235 | int idx = 0; |
5236 | char *peer = argv[2]->arg; | |
d7c0a89a | 5237 | uint16_t flags = 0; |
d62a17ae | 5238 | |
5239 | if (argv_find(argv, argc, "as-path", &idx)) | |
5240 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5241 | idx = 0; | |
5242 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5243 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5244 | idx = 0; | |
5245 | if (argv_find(argv, argc, "med", &idx)) | |
5246 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5247 | ||
5248 | if (!flags) // no flags means all of them! | |
5249 | { | |
5250 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5251 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5252 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5253 | } | |
5254 | ||
5255 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
5256 | bgp_node_safi(vty), flags); | |
5257 | } | |
5258 | ||
5259 | ALIAS_HIDDEN( | |
5260 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5261 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5262 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5263 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5264 | "As-path attribute\n" | |
5265 | "Nexthop attribute\n" | |
5266 | "Med attribute\n") | |
718e3744 | 5267 | |
718e3744 | 5268 | /* EBGP multihop configuration. */ |
d62a17ae | 5269 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5270 | const char *ttl_str) | |
718e3744 | 5271 | { |
d62a17ae | 5272 | struct peer *peer; |
5273 | unsigned int ttl; | |
718e3744 | 5274 | |
d62a17ae | 5275 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5276 | if (!peer) | |
5277 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5278 | |
d62a17ae | 5279 | if (peer->conf_if) |
5280 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5281 | |
d62a17ae | 5282 | if (!ttl_str) |
5283 | ttl = MAXTTL; | |
5284 | else | |
5285 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5286 | |
d62a17ae | 5287 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5288 | } |
5289 | ||
d62a17ae | 5290 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5291 | { |
d62a17ae | 5292 | struct peer *peer; |
718e3744 | 5293 | |
d62a17ae | 5294 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5295 | if (!peer) | |
5296 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5297 | |
d62a17ae | 5298 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5299 | } |
5300 | ||
5301 | /* neighbor ebgp-multihop. */ | |
5302 | DEFUN (neighbor_ebgp_multihop, | |
5303 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5304 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5305 | NEIGHBOR_STR |
5306 | NEIGHBOR_ADDR_STR2 | |
5307 | "Allow EBGP neighbors not on directly connected networks\n") | |
5308 | { | |
d62a17ae | 5309 | int idx_peer = 1; |
5310 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5311 | } |
5312 | ||
5313 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5314 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5315 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5316 | NEIGHBOR_STR |
5317 | NEIGHBOR_ADDR_STR2 | |
5318 | "Allow EBGP neighbors not on directly connected networks\n" | |
5319 | "maximum hop count\n") | |
5320 | { | |
d62a17ae | 5321 | int idx_peer = 1; |
5322 | int idx_number = 3; | |
5323 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5324 | argv[idx_number]->arg); | |
718e3744 | 5325 | } |
5326 | ||
5327 | DEFUN (no_neighbor_ebgp_multihop, | |
5328 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5329 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5330 | NO_STR |
5331 | NEIGHBOR_STR | |
5332 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5333 | "Allow EBGP neighbors not on directly connected networks\n" |
5334 | "maximum hop count\n") | |
718e3744 | 5335 | { |
d62a17ae | 5336 | int idx_peer = 2; |
5337 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5338 | } |
5339 | ||
6b0655a2 | 5340 | |
6ffd2079 | 5341 | /* disable-connected-check */ |
5342 | DEFUN (neighbor_disable_connected_check, | |
5343 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5344 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5345 | NEIGHBOR_STR |
7ebe625c | 5346 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5347 | "one-hop away EBGP peer using loopback address\n" |
5348 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5349 | { |
d62a17ae | 5350 | int idx_peer = 1; |
5351 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5352 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5353 | } |
5354 | ||
5355 | DEFUN (no_neighbor_disable_connected_check, | |
5356 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5357 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5358 | NO_STR |
5359 | NEIGHBOR_STR | |
7ebe625c | 5360 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5361 | "one-hop away EBGP peer using loopback address\n" |
5362 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5363 | { |
d62a17ae | 5364 | int idx_peer = 2; |
5365 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5366 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5367 | } |
5368 | ||
47cbc09b PM |
5369 | |
5370 | /* enforce-first-as */ | |
5371 | DEFUN (neighbor_enforce_first_as, | |
5372 | neighbor_enforce_first_as_cmd, | |
5373 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5374 | NEIGHBOR_STR | |
5375 | NEIGHBOR_ADDR_STR2 | |
5376 | "Enforce the first AS for EBGP routes\n") | |
5377 | { | |
5378 | int idx_peer = 1; | |
5379 | ||
5380 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5381 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5382 | } | |
5383 | ||
5384 | DEFUN (no_neighbor_enforce_first_as, | |
5385 | no_neighbor_enforce_first_as_cmd, | |
5386 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5387 | NO_STR | |
5388 | NEIGHBOR_STR | |
5389 | NEIGHBOR_ADDR_STR2 | |
5390 | "Enforce the first AS for EBGP routes\n") | |
5391 | { | |
5392 | int idx_peer = 2; | |
5393 | ||
5394 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5395 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5396 | } | |
5397 | ||
5398 | ||
718e3744 | 5399 | DEFUN (neighbor_description, |
5400 | neighbor_description_cmd, | |
e961923c | 5401 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5402 | NEIGHBOR_STR |
5403 | NEIGHBOR_ADDR_STR2 | |
5404 | "Neighbor specific description\n" | |
5405 | "Up to 80 characters describing this neighbor\n") | |
5406 | { | |
d62a17ae | 5407 | int idx_peer = 1; |
5408 | int idx_line = 3; | |
5409 | struct peer *peer; | |
5410 | char *str; | |
718e3744 | 5411 | |
d62a17ae | 5412 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5413 | if (!peer) | |
5414 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5415 | |
d62a17ae | 5416 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5417 | |
d62a17ae | 5418 | peer_description_set(peer, str); |
718e3744 | 5419 | |
d62a17ae | 5420 | XFREE(MTYPE_TMP, str); |
718e3744 | 5421 | |
d62a17ae | 5422 | return CMD_SUCCESS; |
718e3744 | 5423 | } |
5424 | ||
5425 | DEFUN (no_neighbor_description, | |
5426 | no_neighbor_description_cmd, | |
a14810f4 | 5427 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5428 | NO_STR |
5429 | NEIGHBOR_STR | |
5430 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5431 | "Neighbor specific description\n") |
718e3744 | 5432 | { |
d62a17ae | 5433 | int idx_peer = 2; |
5434 | struct peer *peer; | |
718e3744 | 5435 | |
d62a17ae | 5436 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5437 | if (!peer) | |
5438 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5439 | |
d62a17ae | 5440 | peer_description_unset(peer); |
718e3744 | 5441 | |
d62a17ae | 5442 | return CMD_SUCCESS; |
718e3744 | 5443 | } |
5444 | ||
a14810f4 PM |
5445 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5446 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5447 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5448 | "Neighbor specific description\n" | |
5449 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5450 | |
718e3744 | 5451 | /* Neighbor update-source. */ |
d62a17ae | 5452 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5453 | const char *source_str) | |
5454 | { | |
5455 | struct peer *peer; | |
5456 | struct prefix p; | |
a14810f4 | 5457 | union sockunion su; |
d62a17ae | 5458 | |
5459 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5460 | if (!peer) | |
5461 | return CMD_WARNING_CONFIG_FAILED; | |
5462 | ||
5463 | if (peer->conf_if) | |
5464 | return CMD_WARNING; | |
5465 | ||
5466 | if (source_str) { | |
a14810f4 | 5467 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5468 | peer_update_source_addr_set(peer, &su); |
5469 | else { | |
5470 | if (str2prefix(source_str, &p)) { | |
5471 | vty_out(vty, | |
5472 | "%% Invalid update-source, remove prefix length \n"); | |
5473 | return CMD_WARNING_CONFIG_FAILED; | |
5474 | } else | |
5475 | peer_update_source_if_set(peer, source_str); | |
5476 | } | |
5477 | } else | |
5478 | peer_update_source_unset(peer); | |
5479 | ||
5480 | return CMD_SUCCESS; | |
5481 | } | |
5482 | ||
5483 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5484 | "IPv4 address\n" \ | |
5485 | "IPv6 address\n" \ | |
5486 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5487 | |
718e3744 | 5488 | DEFUN (neighbor_update_source, |
5489 | neighbor_update_source_cmd, | |
9ccf14f7 | 5490 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5491 | NEIGHBOR_STR |
5492 | NEIGHBOR_ADDR_STR2 | |
5493 | "Source of routing updates\n" | |
369688c0 | 5494 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5495 | { |
d62a17ae | 5496 | int idx_peer = 1; |
5497 | int idx_peer_2 = 3; | |
5498 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5499 | argv[idx_peer_2]->arg); | |
718e3744 | 5500 | } |
5501 | ||
5502 | DEFUN (no_neighbor_update_source, | |
5503 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5504 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5505 | NO_STR |
5506 | NEIGHBOR_STR | |
5507 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5508 | "Source of routing updates\n" |
5509 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5510 | { |
d62a17ae | 5511 | int idx_peer = 2; |
5512 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5513 | } |
6b0655a2 | 5514 | |
d62a17ae | 5515 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5516 | afi_t afi, safi_t safi, | |
5517 | const char *rmap, int set) | |
718e3744 | 5518 | { |
d62a17ae | 5519 | int ret; |
5520 | struct peer *peer; | |
80912664 | 5521 | struct route_map *route_map = NULL; |
718e3744 | 5522 | |
d62a17ae | 5523 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5524 | if (!peer) | |
5525 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5526 | |
1de27621 | 5527 | if (set) { |
80912664 DS |
5528 | if (rmap) |
5529 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5530 | ret = peer_default_originate_set(peer, afi, safi, |
5531 | rmap, route_map); | |
5532 | } else | |
d62a17ae | 5533 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5534 | |
d62a17ae | 5535 | return bgp_vty_return(vty, ret); |
718e3744 | 5536 | } |
5537 | ||
5538 | /* neighbor default-originate. */ | |
5539 | DEFUN (neighbor_default_originate, | |
5540 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5541 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5542 | NEIGHBOR_STR |
5543 | NEIGHBOR_ADDR_STR2 | |
5544 | "Originate default route to this neighbor\n") | |
5545 | { | |
d62a17ae | 5546 | int idx_peer = 1; |
5547 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5548 | bgp_node_afi(vty), | |
5549 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5550 | } |
5551 | ||
d62a17ae | 5552 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5553 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5554 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5555 | "Originate default route to this neighbor\n") | |
596c17ba | 5556 | |
718e3744 | 5557 | DEFUN (neighbor_default_originate_rmap, |
5558 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5559 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5560 | NEIGHBOR_STR |
5561 | NEIGHBOR_ADDR_STR2 | |
5562 | "Originate default route to this neighbor\n" | |
5563 | "Route-map to specify criteria to originate default\n" | |
5564 | "route-map name\n") | |
5565 | { | |
d62a17ae | 5566 | int idx_peer = 1; |
5567 | int idx_word = 4; | |
5568 | return peer_default_originate_set_vty( | |
5569 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5570 | argv[idx_word]->arg, 1); | |
718e3744 | 5571 | } |
5572 | ||
d62a17ae | 5573 | ALIAS_HIDDEN( |
5574 | neighbor_default_originate_rmap, | |
5575 | neighbor_default_originate_rmap_hidden_cmd, | |
5576 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5577 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5578 | "Originate default route to this neighbor\n" | |
5579 | "Route-map to specify criteria to originate default\n" | |
5580 | "route-map name\n") | |
596c17ba | 5581 | |
718e3744 | 5582 | DEFUN (no_neighbor_default_originate, |
5583 | no_neighbor_default_originate_cmd, | |
a636c635 | 5584 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5585 | NO_STR |
5586 | NEIGHBOR_STR | |
5587 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5588 | "Originate default route to this neighbor\n" |
5589 | "Route-map to specify criteria to originate default\n" | |
5590 | "route-map name\n") | |
718e3744 | 5591 | { |
d62a17ae | 5592 | int idx_peer = 2; |
5593 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5594 | bgp_node_afi(vty), | |
5595 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5596 | } |
5597 | ||
d62a17ae | 5598 | ALIAS_HIDDEN( |
5599 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5600 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5601 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5602 | "Originate default route to this neighbor\n" | |
5603 | "Route-map to specify criteria to originate default\n" | |
5604 | "route-map name\n") | |
596c17ba | 5605 | |
6b0655a2 | 5606 | |
718e3744 | 5607 | /* Set neighbor's BGP port. */ |
d62a17ae | 5608 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5609 | const char *port_str) | |
5610 | { | |
5611 | struct peer *peer; | |
d7c0a89a | 5612 | uint16_t port; |
d62a17ae | 5613 | struct servent *sp; |
5614 | ||
5615 | peer = peer_lookup_vty(vty, ip_str); | |
5616 | if (!peer) | |
5617 | return CMD_WARNING_CONFIG_FAILED; | |
5618 | ||
5619 | if (!port_str) { | |
5620 | sp = getservbyname("bgp", "tcp"); | |
5621 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5622 | } else { | |
5623 | port = strtoul(port_str, NULL, 10); | |
5624 | } | |
718e3744 | 5625 | |
d62a17ae | 5626 | peer_port_set(peer, port); |
718e3744 | 5627 | |
d62a17ae | 5628 | return CMD_SUCCESS; |
718e3744 | 5629 | } |
5630 | ||
f418446b | 5631 | /* Set specified peer's BGP port. */ |
718e3744 | 5632 | DEFUN (neighbor_port, |
5633 | neighbor_port_cmd, | |
9ccf14f7 | 5634 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5635 | NEIGHBOR_STR |
5636 | NEIGHBOR_ADDR_STR | |
5637 | "Neighbor's BGP port\n" | |
5638 | "TCP port number\n") | |
5639 | { | |
d62a17ae | 5640 | int idx_ip = 1; |
5641 | int idx_number = 3; | |
5642 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5643 | argv[idx_number]->arg); | |
718e3744 | 5644 | } |
5645 | ||
5646 | DEFUN (no_neighbor_port, | |
5647 | no_neighbor_port_cmd, | |
9ccf14f7 | 5648 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5649 | NO_STR |
5650 | NEIGHBOR_STR | |
5651 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5652 | "Neighbor's BGP port\n" |
5653 | "TCP port number\n") | |
718e3744 | 5654 | { |
d62a17ae | 5655 | int idx_ip = 2; |
5656 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5657 | } |
5658 | ||
6b0655a2 | 5659 | |
718e3744 | 5660 | /* neighbor weight. */ |
d62a17ae | 5661 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5662 | safi_t safi, const char *weight_str) | |
718e3744 | 5663 | { |
d62a17ae | 5664 | int ret; |
5665 | struct peer *peer; | |
5666 | unsigned long weight; | |
718e3744 | 5667 | |
d62a17ae | 5668 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5669 | if (!peer) | |
5670 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5671 | |
d62a17ae | 5672 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5673 | |
d62a17ae | 5674 | ret = peer_weight_set(peer, afi, safi, weight); |
5675 | return bgp_vty_return(vty, ret); | |
718e3744 | 5676 | } |
5677 | ||
d62a17ae | 5678 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5679 | safi_t safi) | |
718e3744 | 5680 | { |
d62a17ae | 5681 | int ret; |
5682 | struct peer *peer; | |
718e3744 | 5683 | |
d62a17ae | 5684 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5685 | if (!peer) | |
5686 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5687 | |
d62a17ae | 5688 | ret = peer_weight_unset(peer, afi, safi); |
5689 | return bgp_vty_return(vty, ret); | |
718e3744 | 5690 | } |
5691 | ||
5692 | DEFUN (neighbor_weight, | |
5693 | neighbor_weight_cmd, | |
9ccf14f7 | 5694 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5695 | NEIGHBOR_STR |
5696 | NEIGHBOR_ADDR_STR2 | |
5697 | "Set default weight for routes from this neighbor\n" | |
5698 | "default weight\n") | |
5699 | { | |
d62a17ae | 5700 | int idx_peer = 1; |
5701 | int idx_number = 3; | |
5702 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5703 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5704 | } |
5705 | ||
d62a17ae | 5706 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5707 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5708 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5709 | "Set default weight for routes from this neighbor\n" | |
5710 | "default weight\n") | |
596c17ba | 5711 | |
718e3744 | 5712 | DEFUN (no_neighbor_weight, |
5713 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5714 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5715 | NO_STR |
5716 | NEIGHBOR_STR | |
5717 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5718 | "Set default weight for routes from this neighbor\n" |
5719 | "default weight\n") | |
718e3744 | 5720 | { |
d62a17ae | 5721 | int idx_peer = 2; |
5722 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5723 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5724 | } |
5725 | ||
d62a17ae | 5726 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5727 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5728 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5729 | "Set default weight for routes from this neighbor\n" | |
5730 | "default weight\n") | |
596c17ba | 5731 | |
6b0655a2 | 5732 | |
718e3744 | 5733 | /* Override capability negotiation. */ |
5734 | DEFUN (neighbor_override_capability, | |
5735 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5736 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5737 | NEIGHBOR_STR |
5738 | NEIGHBOR_ADDR_STR2 | |
5739 | "Override capability negotiation result\n") | |
5740 | { | |
d62a17ae | 5741 | int idx_peer = 1; |
5742 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5743 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5744 | } |
5745 | ||
5746 | DEFUN (no_neighbor_override_capability, | |
5747 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5748 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5749 | NO_STR |
5750 | NEIGHBOR_STR | |
5751 | NEIGHBOR_ADDR_STR2 | |
5752 | "Override capability negotiation result\n") | |
5753 | { | |
d62a17ae | 5754 | int idx_peer = 2; |
5755 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5756 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5757 | } |
6b0655a2 | 5758 | |
718e3744 | 5759 | DEFUN (neighbor_strict_capability, |
5760 | neighbor_strict_capability_cmd, | |
9fb964de | 5761 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5762 | NEIGHBOR_STR |
9fb964de | 5763 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5764 | "Strict capability negotiation match\n") |
5765 | { | |
9fb964de PM |
5766 | int idx_peer = 1; |
5767 | ||
5768 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5769 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5770 | } |
5771 | ||
5772 | DEFUN (no_neighbor_strict_capability, | |
5773 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5774 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5775 | NO_STR |
5776 | NEIGHBOR_STR | |
9fb964de | 5777 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5778 | "Strict capability negotiation match\n") |
5779 | { | |
9fb964de PM |
5780 | int idx_peer = 2; |
5781 | ||
5782 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5783 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5784 | } |
6b0655a2 | 5785 | |
d62a17ae | 5786 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5787 | const char *keep_str, const char *hold_str) | |
718e3744 | 5788 | { |
d62a17ae | 5789 | int ret; |
5790 | struct peer *peer; | |
d7c0a89a QY |
5791 | uint32_t keepalive; |
5792 | uint32_t holdtime; | |
718e3744 | 5793 | |
d62a17ae | 5794 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5795 | if (!peer) | |
5796 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5797 | |
d62a17ae | 5798 | keepalive = strtoul(keep_str, NULL, 10); |
5799 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5800 | |
d62a17ae | 5801 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5802 | |
d62a17ae | 5803 | return bgp_vty_return(vty, ret); |
718e3744 | 5804 | } |
6b0655a2 | 5805 | |
d62a17ae | 5806 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5807 | { |
d62a17ae | 5808 | int ret; |
5809 | struct peer *peer; | |
718e3744 | 5810 | |
d62a17ae | 5811 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5812 | if (!peer) | |
5813 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5814 | |
d62a17ae | 5815 | ret = peer_timers_unset(peer); |
718e3744 | 5816 | |
d62a17ae | 5817 | return bgp_vty_return(vty, ret); |
718e3744 | 5818 | } |
5819 | ||
5820 | DEFUN (neighbor_timers, | |
5821 | neighbor_timers_cmd, | |
9ccf14f7 | 5822 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5823 | NEIGHBOR_STR |
5824 | NEIGHBOR_ADDR_STR2 | |
5825 | "BGP per neighbor timers\n" | |
5826 | "Keepalive interval\n" | |
5827 | "Holdtime\n") | |
5828 | { | |
d62a17ae | 5829 | int idx_peer = 1; |
5830 | int idx_number = 3; | |
5831 | int idx_number_2 = 4; | |
5832 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5833 | argv[idx_number]->arg, | |
5834 | argv[idx_number_2]->arg); | |
718e3744 | 5835 | } |
5836 | ||
5837 | DEFUN (no_neighbor_timers, | |
5838 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5839 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5840 | NO_STR |
5841 | NEIGHBOR_STR | |
5842 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5843 | "BGP per neighbor timers\n" |
5844 | "Keepalive interval\n" | |
5845 | "Holdtime\n") | |
718e3744 | 5846 | { |
d62a17ae | 5847 | int idx_peer = 2; |
5848 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5849 | } |
6b0655a2 | 5850 | |
813d4307 | 5851 | |
d62a17ae | 5852 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5853 | const char *time_str) | |
718e3744 | 5854 | { |
d62a17ae | 5855 | int ret; |
5856 | struct peer *peer; | |
d7c0a89a | 5857 | uint32_t connect; |
718e3744 | 5858 | |
d62a17ae | 5859 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5860 | if (!peer) | |
5861 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5862 | |
d62a17ae | 5863 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5864 | |
d62a17ae | 5865 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5866 | |
d62a17ae | 5867 | return bgp_vty_return(vty, ret); |
718e3744 | 5868 | } |
5869 | ||
d62a17ae | 5870 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5871 | { |
d62a17ae | 5872 | int ret; |
5873 | struct peer *peer; | |
718e3744 | 5874 | |
d62a17ae | 5875 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5876 | if (!peer) | |
5877 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5878 | |
d62a17ae | 5879 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5880 | |
d62a17ae | 5881 | return bgp_vty_return(vty, ret); |
718e3744 | 5882 | } |
5883 | ||
5884 | DEFUN (neighbor_timers_connect, | |
5885 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5886 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5887 | NEIGHBOR_STR |
966f821c | 5888 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5889 | "BGP per neighbor timers\n" |
5890 | "BGP connect timer\n" | |
5891 | "Connect timer\n") | |
5892 | { | |
d62a17ae | 5893 | int idx_peer = 1; |
5894 | int idx_number = 4; | |
5895 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5896 | argv[idx_number]->arg); | |
718e3744 | 5897 | } |
5898 | ||
5899 | DEFUN (no_neighbor_timers_connect, | |
5900 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5901 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5902 | NO_STR |
5903 | NEIGHBOR_STR | |
966f821c | 5904 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5905 | "BGP per neighbor timers\n" |
8334fd5a DW |
5906 | "BGP connect timer\n" |
5907 | "Connect timer\n") | |
718e3744 | 5908 | { |
d62a17ae | 5909 | int idx_peer = 2; |
5910 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5911 | } |
5912 | ||
6b0655a2 | 5913 | |
d62a17ae | 5914 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5915 | const char *time_str, int set) | |
718e3744 | 5916 | { |
d62a17ae | 5917 | int ret; |
5918 | struct peer *peer; | |
d7c0a89a | 5919 | uint32_t routeadv = 0; |
718e3744 | 5920 | |
d62a17ae | 5921 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5922 | if (!peer) | |
5923 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5924 | |
d62a17ae | 5925 | if (time_str) |
5926 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5927 | |
d62a17ae | 5928 | if (set) |
5929 | ret = peer_advertise_interval_set(peer, routeadv); | |
5930 | else | |
5931 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5932 | |
d62a17ae | 5933 | return bgp_vty_return(vty, ret); |
718e3744 | 5934 | } |
5935 | ||
5936 | DEFUN (neighbor_advertise_interval, | |
5937 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5938 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5939 | NEIGHBOR_STR |
966f821c | 5940 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5941 | "Minimum interval between sending BGP routing updates\n" |
5942 | "time in seconds\n") | |
5943 | { | |
d62a17ae | 5944 | int idx_peer = 1; |
5945 | int idx_number = 3; | |
5946 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5947 | argv[idx_number]->arg, 1); | |
718e3744 | 5948 | } |
5949 | ||
5950 | DEFUN (no_neighbor_advertise_interval, | |
5951 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5953 | NO_STR |
5954 | NEIGHBOR_STR | |
966f821c | 5955 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5956 | "Minimum interval between sending BGP routing updates\n" |
5957 | "time in seconds\n") | |
718e3744 | 5958 | { |
d62a17ae | 5959 | int idx_peer = 2; |
5960 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5961 | } |
5962 | ||
6b0655a2 | 5963 | |
518f0eb1 DS |
5964 | /* Time to wait before processing route-map updates */ |
5965 | DEFUN (bgp_set_route_map_delay_timer, | |
5966 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5967 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5968 | SET_STR |
5969 | "BGP route-map delay timer\n" | |
5970 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5971 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5972 | { |
d62a17ae | 5973 | int idx_number = 3; |
d7c0a89a | 5974 | uint32_t rmap_delay_timer; |
d62a17ae | 5975 | |
5976 | if (argv[idx_number]->arg) { | |
5977 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5978 | bm->rmap_update_timer = rmap_delay_timer; | |
5979 | ||
5980 | /* if the dynamic update handling is being disabled, and a timer | |
5981 | * is | |
5982 | * running, stop the timer and act as if the timer has already | |
5983 | * fired. | |
5984 | */ | |
5985 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5986 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5987 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5988 | NULL, 0); | |
5989 | } | |
5990 | return CMD_SUCCESS; | |
5991 | } else { | |
5992 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5993 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5994 | } |
518f0eb1 DS |
5995 | } |
5996 | ||
5997 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5998 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5999 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6000 | NO_STR |
3a2d747c | 6001 | BGP_STR |
518f0eb1 | 6002 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6003 | "Reset to default time to wait for processing route-map changes\n" |
6004 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6005 | { |
518f0eb1 | 6006 | |
d62a17ae | 6007 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6008 | |
d62a17ae | 6009 | return CMD_SUCCESS; |
518f0eb1 DS |
6010 | } |
6011 | ||
f414725f | 6012 | |
718e3744 | 6013 | /* neighbor interface */ |
d62a17ae | 6014 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6015 | const char *str) | |
718e3744 | 6016 | { |
d62a17ae | 6017 | struct peer *peer; |
718e3744 | 6018 | |
d62a17ae | 6019 | peer = peer_lookup_vty(vty, ip_str); |
6020 | if (!peer || peer->conf_if) { | |
6021 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6022 | return CMD_WARNING_CONFIG_FAILED; | |
6023 | } | |
718e3744 | 6024 | |
d62a17ae | 6025 | if (str) |
6026 | peer_interface_set(peer, str); | |
6027 | else | |
6028 | peer_interface_unset(peer); | |
718e3744 | 6029 | |
d62a17ae | 6030 | return CMD_SUCCESS; |
718e3744 | 6031 | } |
6032 | ||
6033 | DEFUN (neighbor_interface, | |
6034 | neighbor_interface_cmd, | |
9ccf14f7 | 6035 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6036 | NEIGHBOR_STR |
6037 | NEIGHBOR_ADDR_STR | |
6038 | "Interface\n" | |
6039 | "Interface name\n") | |
6040 | { | |
d62a17ae | 6041 | int idx_ip = 1; |
6042 | int idx_word = 3; | |
6043 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6044 | } |
6045 | ||
6046 | DEFUN (no_neighbor_interface, | |
6047 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6048 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6049 | NO_STR |
6050 | NEIGHBOR_STR | |
16cedbb0 | 6051 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6052 | "Interface\n" |
6053 | "Interface name\n") | |
6054 | { | |
d62a17ae | 6055 | int idx_peer = 2; |
6056 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6057 | } |
6b0655a2 | 6058 | |
718e3744 | 6059 | DEFUN (neighbor_distribute_list, |
6060 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6061 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6062 | NEIGHBOR_STR |
6063 | NEIGHBOR_ADDR_STR2 | |
6064 | "Filter updates to/from this neighbor\n" | |
6065 | "IP access-list number\n" | |
6066 | "IP access-list number (expanded range)\n" | |
6067 | "IP Access-list name\n" | |
6068 | "Filter incoming updates\n" | |
6069 | "Filter outgoing updates\n") | |
6070 | { | |
d62a17ae | 6071 | int idx_peer = 1; |
6072 | int idx_acl = 3; | |
6073 | int direct, ret; | |
6074 | struct peer *peer; | |
a8206004 | 6075 | |
d62a17ae | 6076 | const char *pstr = argv[idx_peer]->arg; |
6077 | const char *acl = argv[idx_acl]->arg; | |
6078 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6079 | |
d62a17ae | 6080 | peer = peer_and_group_lookup_vty(vty, pstr); |
6081 | if (!peer) | |
6082 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6083 | |
d62a17ae | 6084 | /* Check filter direction. */ |
6085 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6086 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6087 | direct, acl); | |
a8206004 | 6088 | |
d62a17ae | 6089 | return bgp_vty_return(vty, ret); |
718e3744 | 6090 | } |
6091 | ||
d62a17ae | 6092 | ALIAS_HIDDEN( |
6093 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6094 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6095 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6096 | "Filter updates to/from this neighbor\n" | |
6097 | "IP access-list number\n" | |
6098 | "IP access-list number (expanded range)\n" | |
6099 | "IP Access-list name\n" | |
6100 | "Filter incoming updates\n" | |
6101 | "Filter outgoing updates\n") | |
596c17ba | 6102 | |
718e3744 | 6103 | DEFUN (no_neighbor_distribute_list, |
6104 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6105 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6106 | NO_STR |
6107 | NEIGHBOR_STR | |
6108 | NEIGHBOR_ADDR_STR2 | |
6109 | "Filter updates to/from this neighbor\n" | |
6110 | "IP access-list number\n" | |
6111 | "IP access-list number (expanded range)\n" | |
6112 | "IP Access-list name\n" | |
6113 | "Filter incoming updates\n" | |
6114 | "Filter outgoing updates\n") | |
6115 | { | |
d62a17ae | 6116 | int idx_peer = 2; |
6117 | int direct, ret; | |
6118 | struct peer *peer; | |
a8206004 | 6119 | |
d62a17ae | 6120 | const char *pstr = argv[idx_peer]->arg; |
6121 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6122 | |
d62a17ae | 6123 | peer = peer_and_group_lookup_vty(vty, pstr); |
6124 | if (!peer) | |
6125 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6126 | |
d62a17ae | 6127 | /* Check filter direction. */ |
6128 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6129 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6130 | direct); | |
a8206004 | 6131 | |
d62a17ae | 6132 | return bgp_vty_return(vty, ret); |
718e3744 | 6133 | } |
6b0655a2 | 6134 | |
d62a17ae | 6135 | ALIAS_HIDDEN( |
6136 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6137 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6138 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6139 | "Filter updates to/from this neighbor\n" | |
6140 | "IP access-list number\n" | |
6141 | "IP access-list number (expanded range)\n" | |
6142 | "IP Access-list name\n" | |
6143 | "Filter incoming updates\n" | |
6144 | "Filter outgoing updates\n") | |
596c17ba | 6145 | |
718e3744 | 6146 | /* Set prefix list to the peer. */ |
d62a17ae | 6147 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6148 | afi_t afi, safi_t safi, | |
6149 | const char *name_str, | |
6150 | const char *direct_str) | |
718e3744 | 6151 | { |
d62a17ae | 6152 | int ret; |
d62a17ae | 6153 | int direct = FILTER_IN; |
cf9ac8bf | 6154 | struct peer *peer; |
718e3744 | 6155 | |
d62a17ae | 6156 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6157 | if (!peer) | |
6158 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6159 | |
d62a17ae | 6160 | /* Check filter direction. */ |
6161 | if (strncmp(direct_str, "i", 1) == 0) | |
6162 | direct = FILTER_IN; | |
6163 | else if (strncmp(direct_str, "o", 1) == 0) | |
6164 | direct = FILTER_OUT; | |
718e3744 | 6165 | |
d62a17ae | 6166 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6167 | |
d62a17ae | 6168 | return bgp_vty_return(vty, ret); |
718e3744 | 6169 | } |
6170 | ||
d62a17ae | 6171 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6172 | afi_t afi, safi_t safi, | |
6173 | const char *direct_str) | |
718e3744 | 6174 | { |
d62a17ae | 6175 | int ret; |
6176 | struct peer *peer; | |
6177 | int direct = FILTER_IN; | |
718e3744 | 6178 | |
d62a17ae | 6179 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6180 | if (!peer) | |
6181 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6182 | |
d62a17ae | 6183 | /* Check filter direction. */ |
6184 | if (strncmp(direct_str, "i", 1) == 0) | |
6185 | direct = FILTER_IN; | |
6186 | else if (strncmp(direct_str, "o", 1) == 0) | |
6187 | direct = FILTER_OUT; | |
718e3744 | 6188 | |
d62a17ae | 6189 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6190 | |
d62a17ae | 6191 | return bgp_vty_return(vty, ret); |
718e3744 | 6192 | } |
6193 | ||
6194 | DEFUN (neighbor_prefix_list, | |
6195 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6196 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6197 | NEIGHBOR_STR |
6198 | NEIGHBOR_ADDR_STR2 | |
6199 | "Filter updates to/from this neighbor\n" | |
6200 | "Name of a prefix list\n" | |
6201 | "Filter incoming updates\n" | |
6202 | "Filter outgoing updates\n") | |
6203 | { | |
d62a17ae | 6204 | int idx_peer = 1; |
6205 | int idx_word = 3; | |
6206 | int idx_in_out = 4; | |
6207 | return peer_prefix_list_set_vty( | |
6208 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6209 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6210 | } |
6211 | ||
d62a17ae | 6212 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6213 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6214 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6215 | "Filter updates to/from this neighbor\n" | |
6216 | "Name of a prefix list\n" | |
6217 | "Filter incoming updates\n" | |
6218 | "Filter outgoing updates\n") | |
596c17ba | 6219 | |
718e3744 | 6220 | DEFUN (no_neighbor_prefix_list, |
6221 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6222 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6223 | NO_STR |
6224 | NEIGHBOR_STR | |
6225 | NEIGHBOR_ADDR_STR2 | |
6226 | "Filter updates to/from this neighbor\n" | |
6227 | "Name of a prefix list\n" | |
6228 | "Filter incoming updates\n" | |
6229 | "Filter outgoing updates\n") | |
6230 | { | |
d62a17ae | 6231 | int idx_peer = 2; |
6232 | int idx_in_out = 5; | |
6233 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6234 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6235 | argv[idx_in_out]->arg); | |
718e3744 | 6236 | } |
6b0655a2 | 6237 | |
d62a17ae | 6238 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6239 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6240 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6241 | "Filter updates to/from this neighbor\n" | |
6242 | "Name of a prefix list\n" | |
6243 | "Filter incoming updates\n" | |
6244 | "Filter outgoing updates\n") | |
596c17ba | 6245 | |
d62a17ae | 6246 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6247 | safi_t safi, const char *name_str, | |
6248 | const char *direct_str) | |
718e3744 | 6249 | { |
d62a17ae | 6250 | int ret; |
6251 | struct peer *peer; | |
6252 | int direct = FILTER_IN; | |
718e3744 | 6253 | |
d62a17ae | 6254 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6255 | if (!peer) | |
6256 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6257 | |
d62a17ae | 6258 | /* Check filter direction. */ |
6259 | if (strncmp(direct_str, "i", 1) == 0) | |
6260 | direct = FILTER_IN; | |
6261 | else if (strncmp(direct_str, "o", 1) == 0) | |
6262 | direct = FILTER_OUT; | |
718e3744 | 6263 | |
d62a17ae | 6264 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6265 | |
d62a17ae | 6266 | return bgp_vty_return(vty, ret); |
718e3744 | 6267 | } |
6268 | ||
d62a17ae | 6269 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6270 | safi_t safi, const char *direct_str) | |
718e3744 | 6271 | { |
d62a17ae | 6272 | int ret; |
6273 | struct peer *peer; | |
6274 | int direct = FILTER_IN; | |
718e3744 | 6275 | |
d62a17ae | 6276 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6277 | if (!peer) | |
6278 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6279 | |
d62a17ae | 6280 | /* Check filter direction. */ |
6281 | if (strncmp(direct_str, "i", 1) == 0) | |
6282 | direct = FILTER_IN; | |
6283 | else if (strncmp(direct_str, "o", 1) == 0) | |
6284 | direct = FILTER_OUT; | |
718e3744 | 6285 | |
d62a17ae | 6286 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6287 | |
d62a17ae | 6288 | return bgp_vty_return(vty, ret); |
718e3744 | 6289 | } |
6290 | ||
6291 | DEFUN (neighbor_filter_list, | |
6292 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6293 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6294 | NEIGHBOR_STR |
6295 | NEIGHBOR_ADDR_STR2 | |
6296 | "Establish BGP filters\n" | |
6297 | "AS path access-list name\n" | |
6298 | "Filter incoming routes\n" | |
6299 | "Filter outgoing routes\n") | |
6300 | { | |
d62a17ae | 6301 | int idx_peer = 1; |
6302 | int idx_word = 3; | |
6303 | int idx_in_out = 4; | |
6304 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6305 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6306 | argv[idx_in_out]->arg); | |
718e3744 | 6307 | } |
6308 | ||
d62a17ae | 6309 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6310 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6311 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6312 | "Establish BGP filters\n" | |
6313 | "AS path access-list name\n" | |
6314 | "Filter incoming routes\n" | |
6315 | "Filter outgoing routes\n") | |
596c17ba | 6316 | |
718e3744 | 6317 | DEFUN (no_neighbor_filter_list, |
6318 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6319 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6320 | NO_STR |
6321 | NEIGHBOR_STR | |
6322 | NEIGHBOR_ADDR_STR2 | |
6323 | "Establish BGP filters\n" | |
6324 | "AS path access-list name\n" | |
6325 | "Filter incoming routes\n" | |
6326 | "Filter outgoing routes\n") | |
6327 | { | |
d62a17ae | 6328 | int idx_peer = 2; |
6329 | int idx_in_out = 5; | |
6330 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6331 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6332 | argv[idx_in_out]->arg); | |
718e3744 | 6333 | } |
6b0655a2 | 6334 | |
d62a17ae | 6335 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6337 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6338 | "Establish BGP filters\n" | |
6339 | "AS path access-list name\n" | |
6340 | "Filter incoming routes\n" | |
6341 | "Filter outgoing routes\n") | |
596c17ba | 6342 | |
718e3744 | 6343 | /* Set route-map to the peer. */ |
d62a17ae | 6344 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6345 | afi_t afi, safi_t safi, const char *name_str, | |
6346 | const char *direct_str) | |
718e3744 | 6347 | { |
d62a17ae | 6348 | int ret; |
6349 | struct peer *peer; | |
6350 | int direct = RMAP_IN; | |
1de27621 | 6351 | struct route_map *route_map; |
718e3744 | 6352 | |
d62a17ae | 6353 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6354 | if (!peer) | |
6355 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6356 | |
d62a17ae | 6357 | /* Check filter direction. */ |
6358 | if (strncmp(direct_str, "in", 2) == 0) | |
6359 | direct = RMAP_IN; | |
6360 | else if (strncmp(direct_str, "o", 1) == 0) | |
6361 | direct = RMAP_OUT; | |
718e3744 | 6362 | |
1de27621 DA |
6363 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6364 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6365 | |
d62a17ae | 6366 | return bgp_vty_return(vty, ret); |
718e3744 | 6367 | } |
6368 | ||
d62a17ae | 6369 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6370 | afi_t afi, safi_t safi, | |
6371 | const char *direct_str) | |
718e3744 | 6372 | { |
d62a17ae | 6373 | int ret; |
6374 | struct peer *peer; | |
6375 | int direct = RMAP_IN; | |
718e3744 | 6376 | |
d62a17ae | 6377 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6378 | if (!peer) | |
6379 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6380 | |
d62a17ae | 6381 | /* Check filter direction. */ |
6382 | if (strncmp(direct_str, "in", 2) == 0) | |
6383 | direct = RMAP_IN; | |
6384 | else if (strncmp(direct_str, "o", 1) == 0) | |
6385 | direct = RMAP_OUT; | |
718e3744 | 6386 | |
d62a17ae | 6387 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6388 | |
d62a17ae | 6389 | return bgp_vty_return(vty, ret); |
718e3744 | 6390 | } |
6391 | ||
6392 | DEFUN (neighbor_route_map, | |
6393 | neighbor_route_map_cmd, | |
9ccf14f7 | 6394 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6395 | NEIGHBOR_STR |
6396 | NEIGHBOR_ADDR_STR2 | |
6397 | "Apply route map to neighbor\n" | |
6398 | "Name of route map\n" | |
6399 | "Apply map to incoming routes\n" | |
2a3d5731 | 6400 | "Apply map to outbound routes\n") |
718e3744 | 6401 | { |
d62a17ae | 6402 | int idx_peer = 1; |
6403 | int idx_word = 3; | |
6404 | int idx_in_out = 4; | |
6405 | return peer_route_map_set_vty( | |
6406 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6407 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6408 | } |
6409 | ||
d62a17ae | 6410 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6411 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6412 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6413 | "Apply route map to neighbor\n" | |
6414 | "Name of route map\n" | |
6415 | "Apply map to incoming routes\n" | |
6416 | "Apply map to outbound routes\n") | |
596c17ba | 6417 | |
718e3744 | 6418 | DEFUN (no_neighbor_route_map, |
6419 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6421 | NO_STR |
6422 | NEIGHBOR_STR | |
6423 | NEIGHBOR_ADDR_STR2 | |
6424 | "Apply route map to neighbor\n" | |
6425 | "Name of route map\n" | |
6426 | "Apply map to incoming routes\n" | |
2a3d5731 | 6427 | "Apply map to outbound routes\n") |
718e3744 | 6428 | { |
d62a17ae | 6429 | int idx_peer = 2; |
6430 | int idx_in_out = 5; | |
6431 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6432 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6433 | argv[idx_in_out]->arg); | |
718e3744 | 6434 | } |
6b0655a2 | 6435 | |
d62a17ae | 6436 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6437 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6438 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6439 | "Apply route map to neighbor\n" | |
6440 | "Name of route map\n" | |
6441 | "Apply map to incoming routes\n" | |
6442 | "Apply map to outbound routes\n") | |
596c17ba | 6443 | |
718e3744 | 6444 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6445 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6446 | afi_t afi, safi_t safi, | |
6447 | const char *name_str) | |
718e3744 | 6448 | { |
d62a17ae | 6449 | int ret; |
6450 | struct peer *peer; | |
1de27621 | 6451 | struct route_map *route_map; |
718e3744 | 6452 | |
d62a17ae | 6453 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6454 | if (!peer) | |
6455 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6456 | |
1de27621 DA |
6457 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6458 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6459 | |
d62a17ae | 6460 | return bgp_vty_return(vty, ret); |
718e3744 | 6461 | } |
6462 | ||
6463 | /* Unset route-map from the peer. */ | |
d62a17ae | 6464 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6465 | afi_t afi, safi_t safi) | |
718e3744 | 6466 | { |
d62a17ae | 6467 | int ret; |
6468 | struct peer *peer; | |
718e3744 | 6469 | |
d62a17ae | 6470 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6471 | if (!peer) | |
6472 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6473 | |
d62a17ae | 6474 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6475 | |
d62a17ae | 6476 | return bgp_vty_return(vty, ret); |
718e3744 | 6477 | } |
6478 | ||
6479 | DEFUN (neighbor_unsuppress_map, | |
6480 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6481 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6482 | NEIGHBOR_STR |
6483 | NEIGHBOR_ADDR_STR2 | |
6484 | "Route-map to selectively unsuppress suppressed routes\n" | |
6485 | "Name of route map\n") | |
6486 | { | |
d62a17ae | 6487 | int idx_peer = 1; |
6488 | int idx_word = 3; | |
6489 | return peer_unsuppress_map_set_vty( | |
6490 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6491 | argv[idx_word]->arg); | |
718e3744 | 6492 | } |
6493 | ||
d62a17ae | 6494 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6495 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6496 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6497 | "Route-map to selectively unsuppress suppressed routes\n" | |
6498 | "Name of route map\n") | |
596c17ba | 6499 | |
718e3744 | 6500 | DEFUN (no_neighbor_unsuppress_map, |
6501 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6502 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6503 | NO_STR |
6504 | NEIGHBOR_STR | |
6505 | NEIGHBOR_ADDR_STR2 | |
6506 | "Route-map to selectively unsuppress suppressed routes\n" | |
6507 | "Name of route map\n") | |
6508 | { | |
d62a17ae | 6509 | int idx_peer = 2; |
6510 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6511 | bgp_node_afi(vty), | |
6512 | bgp_node_safi(vty)); | |
718e3744 | 6513 | } |
6b0655a2 | 6514 | |
d62a17ae | 6515 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6516 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6517 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6518 | "Route-map to selectively unsuppress suppressed routes\n" | |
6519 | "Name of route map\n") | |
596c17ba | 6520 | |
d62a17ae | 6521 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6522 | afi_t afi, safi_t safi, | |
6523 | const char *num_str, | |
6524 | const char *threshold_str, int warning, | |
6525 | const char *restart_str) | |
718e3744 | 6526 | { |
d62a17ae | 6527 | int ret; |
6528 | struct peer *peer; | |
d7c0a89a QY |
6529 | uint32_t max; |
6530 | uint8_t threshold; | |
6531 | uint16_t restart; | |
718e3744 | 6532 | |
d62a17ae | 6533 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6534 | if (!peer) | |
6535 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6536 | |
d62a17ae | 6537 | max = strtoul(num_str, NULL, 10); |
6538 | if (threshold_str) | |
6539 | threshold = atoi(threshold_str); | |
6540 | else | |
6541 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6542 | |
d62a17ae | 6543 | if (restart_str) |
6544 | restart = atoi(restart_str); | |
6545 | else | |
6546 | restart = 0; | |
0a486e5f | 6547 | |
d62a17ae | 6548 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6549 | restart); | |
718e3744 | 6550 | |
d62a17ae | 6551 | return bgp_vty_return(vty, ret); |
718e3744 | 6552 | } |
6553 | ||
d62a17ae | 6554 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6555 | afi_t afi, safi_t safi) | |
718e3744 | 6556 | { |
d62a17ae | 6557 | int ret; |
6558 | struct peer *peer; | |
718e3744 | 6559 | |
d62a17ae | 6560 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6561 | if (!peer) | |
6562 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6563 | |
d62a17ae | 6564 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6565 | |
d62a17ae | 6566 | return bgp_vty_return(vty, ret); |
718e3744 | 6567 | } |
6568 | ||
fde246e8 DA |
6569 | /* Maximum number of prefix to be sent to the neighbor. */ |
6570 | DEFUN(neighbor_maximum_prefix_out, | |
6571 | neighbor_maximum_prefix_out_cmd, | |
6572 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6573 | NEIGHBOR_STR | |
6574 | NEIGHBOR_ADDR_STR2 | |
6575 | "Maximum number of prefixes to be sent to this peer\n" | |
6576 | "Maximum no. of prefix limit\n") | |
6577 | { | |
6578 | int idx_peer = 1; | |
6579 | int idx_number = 3; | |
6580 | struct peer *peer; | |
6581 | uint32_t max; | |
6582 | afi_t afi = bgp_node_afi(vty); | |
6583 | safi_t safi = bgp_node_safi(vty); | |
6584 | ||
6585 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6586 | if (!peer) | |
6587 | return CMD_WARNING_CONFIG_FAILED; | |
6588 | ||
6589 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6590 | ||
6591 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6592 | peer->pmax_out[afi][safi] = max; | |
6593 | ||
6594 | return CMD_SUCCESS; | |
6595 | } | |
6596 | ||
6597 | DEFUN(no_neighbor_maximum_prefix_out, | |
6598 | no_neighbor_maximum_prefix_out_cmd, | |
6599 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6600 | NO_STR | |
6601 | NEIGHBOR_STR | |
6602 | NEIGHBOR_ADDR_STR2 | |
6603 | "Maximum number of prefixes to be sent to this peer\n") | |
6604 | { | |
6605 | int idx_peer = 2; | |
6606 | struct peer *peer; | |
6607 | afi_t afi = bgp_node_afi(vty); | |
6608 | safi_t safi = bgp_node_safi(vty); | |
6609 | ||
6610 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6611 | if (!peer) | |
6612 | return CMD_WARNING_CONFIG_FAILED; | |
6613 | ||
6614 | peer->pmax_out[afi][safi] = 0; | |
6615 | ||
6616 | return CMD_SUCCESS; | |
6617 | } | |
6618 | ||
718e3744 | 6619 | /* Maximum number of prefix configuration. prefix count is different |
6620 | for each peer configuration. So this configuration can be set for | |
6621 | each peer configuration. */ | |
6622 | DEFUN (neighbor_maximum_prefix, | |
6623 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6624 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6625 | NEIGHBOR_STR |
6626 | NEIGHBOR_ADDR_STR2 | |
6627 | "Maximum number of prefix accept from this peer\n" | |
6628 | "maximum no. of prefix limit\n") | |
6629 | { | |
d62a17ae | 6630 | int idx_peer = 1; |
6631 | int idx_number = 3; | |
6632 | return peer_maximum_prefix_set_vty( | |
6633 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6634 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6635 | } |
6636 | ||
d62a17ae | 6637 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6638 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6639 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6640 | "Maximum number of prefix accept from this peer\n" | |
6641 | "maximum no. of prefix limit\n") | |
596c17ba | 6642 | |
e0701b79 | 6643 | DEFUN (neighbor_maximum_prefix_threshold, |
6644 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6645 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6646 | NEIGHBOR_STR |
6647 | NEIGHBOR_ADDR_STR2 | |
6648 | "Maximum number of prefix accept from this peer\n" | |
6649 | "maximum no. of prefix limit\n" | |
6650 | "Threshold value (%) at which to generate a warning msg\n") | |
6651 | { | |
d62a17ae | 6652 | int idx_peer = 1; |
6653 | int idx_number = 3; | |
6654 | int idx_number_2 = 4; | |
6655 | return peer_maximum_prefix_set_vty( | |
6656 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6657 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6658 | } |
e0701b79 | 6659 | |
d62a17ae | 6660 | ALIAS_HIDDEN( |
6661 | neighbor_maximum_prefix_threshold, | |
6662 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6663 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6664 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6665 | "Maximum number of prefix accept from this peer\n" | |
6666 | "maximum no. of prefix limit\n" | |
6667 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6668 | |
718e3744 | 6669 | DEFUN (neighbor_maximum_prefix_warning, |
6670 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6671 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6672 | NEIGHBOR_STR |
6673 | NEIGHBOR_ADDR_STR2 | |
6674 | "Maximum number of prefix accept from this peer\n" | |
6675 | "maximum no. of prefix limit\n" | |
6676 | "Only give warning message when limit is exceeded\n") | |
6677 | { | |
d62a17ae | 6678 | int idx_peer = 1; |
6679 | int idx_number = 3; | |
6680 | return peer_maximum_prefix_set_vty( | |
6681 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6682 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6683 | } |
6684 | ||
d62a17ae | 6685 | ALIAS_HIDDEN( |
6686 | neighbor_maximum_prefix_warning, | |
6687 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6688 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6689 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6690 | "Maximum number of prefix accept from this peer\n" | |
6691 | "maximum no. of prefix limit\n" | |
6692 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6693 | |
e0701b79 | 6694 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6695 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6696 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6697 | NEIGHBOR_STR |
6698 | NEIGHBOR_ADDR_STR2 | |
6699 | "Maximum number of prefix accept from this peer\n" | |
6700 | "maximum no. of prefix limit\n" | |
6701 | "Threshold value (%) at which to generate a warning msg\n" | |
6702 | "Only give warning message when limit is exceeded\n") | |
6703 | { | |
d62a17ae | 6704 | int idx_peer = 1; |
6705 | int idx_number = 3; | |
6706 | int idx_number_2 = 4; | |
6707 | return peer_maximum_prefix_set_vty( | |
6708 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6709 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6710 | } |
6711 | ||
d62a17ae | 6712 | ALIAS_HIDDEN( |
6713 | neighbor_maximum_prefix_threshold_warning, | |
6714 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6715 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6716 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6717 | "Maximum number of prefix accept from this peer\n" | |
6718 | "maximum no. of prefix limit\n" | |
6719 | "Threshold value (%) at which to generate a warning msg\n" | |
6720 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6721 | |
0a486e5f | 6722 | DEFUN (neighbor_maximum_prefix_restart, |
6723 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6724 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6725 | NEIGHBOR_STR |
6726 | NEIGHBOR_ADDR_STR2 | |
6727 | "Maximum number of prefix accept from this peer\n" | |
6728 | "maximum no. of prefix limit\n" | |
6729 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6730 | "Restart interval in minutes\n") |
0a486e5f | 6731 | { |
d62a17ae | 6732 | int idx_peer = 1; |
6733 | int idx_number = 3; | |
6734 | int idx_number_2 = 5; | |
6735 | return peer_maximum_prefix_set_vty( | |
6736 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6737 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6738 | } |
6739 | ||
d62a17ae | 6740 | ALIAS_HIDDEN( |
6741 | neighbor_maximum_prefix_restart, | |
6742 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6743 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6744 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6745 | "Maximum number of prefix accept from this peer\n" | |
6746 | "maximum no. of prefix limit\n" | |
6747 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6748 | "Restart interval in minutes\n") |
596c17ba | 6749 | |
0a486e5f | 6750 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6751 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6752 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6753 | NEIGHBOR_STR |
6754 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6755 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6756 | "maximum no. of prefix limit\n" |
6757 | "Threshold value (%) at which to generate a warning msg\n" | |
6758 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6759 | "Restart interval in minutes\n") |
0a486e5f | 6760 | { |
d62a17ae | 6761 | int idx_peer = 1; |
6762 | int idx_number = 3; | |
6763 | int idx_number_2 = 4; | |
6764 | int idx_number_3 = 6; | |
6765 | return peer_maximum_prefix_set_vty( | |
6766 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6767 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6768 | argv[idx_number_3]->arg); | |
6769 | } | |
6770 | ||
6771 | ALIAS_HIDDEN( | |
6772 | neighbor_maximum_prefix_threshold_restart, | |
6773 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6774 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6775 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6776 | "Maximum number of prefixes to accept from this peer\n" | |
6777 | "maximum no. of prefix limit\n" | |
6778 | "Threshold value (%) at which to generate a warning msg\n" | |
6779 | "Restart bgp connection after limit is exceeded\n" | |
6780 | "Restart interval in minutes\n") | |
596c17ba | 6781 | |
718e3744 | 6782 | DEFUN (no_neighbor_maximum_prefix, |
6783 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6784 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6785 | NO_STR |
6786 | NEIGHBOR_STR | |
6787 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6788 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6789 | "maximum no. of prefix limit\n" |
6790 | "Threshold value (%) at which to generate a warning msg\n" | |
6791 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6792 | "Restart interval in minutes\n" |
31500417 | 6793 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6794 | { |
d62a17ae | 6795 | int idx_peer = 2; |
6796 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6797 | bgp_node_afi(vty), | |
6798 | bgp_node_safi(vty)); | |
718e3744 | 6799 | } |
e52702f2 | 6800 | |
d62a17ae | 6801 | ALIAS_HIDDEN( |
6802 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6803 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6804 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6805 | "Maximum number of prefixes to accept from this peer\n" | |
6806 | "maximum no. of prefix limit\n" | |
6807 | "Threshold value (%) at which to generate a warning msg\n" | |
6808 | "Restart bgp connection after limit is exceeded\n" | |
6809 | "Restart interval in minutes\n" | |
6810 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6811 | |
718e3744 | 6812 | |
718e3744 | 6813 | /* "neighbor allowas-in" */ |
6814 | DEFUN (neighbor_allowas_in, | |
6815 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6816 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6817 | NEIGHBOR_STR |
6818 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6819 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6820 | "Number of occurrences of AS number\n" |
fd8503f5 | 6821 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6822 | { |
d62a17ae | 6823 | int idx_peer = 1; |
6824 | int idx_number_origin = 3; | |
6825 | int ret; | |
6826 | int origin = 0; | |
6827 | struct peer *peer; | |
6828 | int allow_num = 0; | |
6829 | ||
6830 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6831 | if (!peer) | |
6832 | return CMD_WARNING_CONFIG_FAILED; | |
6833 | ||
6834 | if (argc <= idx_number_origin) | |
6835 | allow_num = 3; | |
6836 | else { | |
6837 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6838 | origin = 1; | |
6839 | else | |
6840 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6841 | } | |
6842 | ||
6843 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6844 | allow_num, origin); | |
6845 | ||
6846 | return bgp_vty_return(vty, ret); | |
6847 | } | |
6848 | ||
6849 | ALIAS_HIDDEN( | |
6850 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6851 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6852 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6853 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6854 | "Number of occurrences of AS number\n" |
d62a17ae | 6855 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6856 | |
718e3744 | 6857 | DEFUN (no_neighbor_allowas_in, |
6858 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6860 | NO_STR |
6861 | NEIGHBOR_STR | |
6862 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6863 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6864 | "Number of occurrences of AS number\n" |
fd8503f5 | 6865 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6866 | { |
d62a17ae | 6867 | int idx_peer = 2; |
6868 | int ret; | |
6869 | struct peer *peer; | |
718e3744 | 6870 | |
d62a17ae | 6871 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6872 | if (!peer) | |
6873 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6874 | |
d62a17ae | 6875 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6876 | bgp_node_safi(vty)); | |
718e3744 | 6877 | |
d62a17ae | 6878 | return bgp_vty_return(vty, ret); |
718e3744 | 6879 | } |
6b0655a2 | 6880 | |
d62a17ae | 6881 | ALIAS_HIDDEN( |
6882 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6883 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6884 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6885 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6886 | "Number of occurrences of AS number\n" |
d62a17ae | 6887 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6888 | |
fa411a21 NH |
6889 | DEFUN (neighbor_ttl_security, |
6890 | neighbor_ttl_security_cmd, | |
7ebe625c | 6891 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6892 | NEIGHBOR_STR |
7ebe625c | 6893 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6894 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6895 | "Specify the maximum number of hops to the BGP peer\n" |
6896 | "Number of hops to BGP peer\n") | |
fa411a21 | 6897 | { |
d62a17ae | 6898 | int idx_peer = 1; |
6899 | int idx_number = 4; | |
6900 | struct peer *peer; | |
6901 | int gtsm_hops; | |
6902 | ||
6903 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6904 | if (!peer) | |
6905 | return CMD_WARNING_CONFIG_FAILED; | |
6906 | ||
6907 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6908 | ||
7ebe625c QY |
6909 | /* |
6910 | * If 'neighbor swpX', then this is for directly connected peers, | |
6911 | * we should not accept a ttl-security hops value greater than 1. | |
6912 | */ | |
6913 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6914 | vty_out(vty, | |
6915 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6916 | argv[idx_peer]->arg); | |
6917 | return CMD_WARNING_CONFIG_FAILED; | |
6918 | } | |
6919 | ||
d62a17ae | 6920 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6921 | } |
6922 | ||
6923 | DEFUN (no_neighbor_ttl_security, | |
6924 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6926 | NO_STR |
6927 | NEIGHBOR_STR | |
7ebe625c | 6928 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6929 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6930 | "Specify the maximum number of hops to the BGP peer\n" |
6931 | "Number of hops to BGP peer\n") | |
fa411a21 | 6932 | { |
d62a17ae | 6933 | int idx_peer = 2; |
6934 | struct peer *peer; | |
fa411a21 | 6935 | |
d62a17ae | 6936 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6937 | if (!peer) | |
6938 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6939 | |
d62a17ae | 6940 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6941 | } |
6b0655a2 | 6942 | |
adbac85e DW |
6943 | DEFUN (neighbor_addpath_tx_all_paths, |
6944 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6945 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6946 | NEIGHBOR_STR |
6947 | NEIGHBOR_ADDR_STR2 | |
6948 | "Use addpath to advertise all paths to a neighbor\n") | |
6949 | { | |
d62a17ae | 6950 | int idx_peer = 1; |
6951 | struct peer *peer; | |
adbac85e | 6952 | |
d62a17ae | 6953 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6954 | if (!peer) | |
6955 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6956 | |
dcc68b5e MS |
6957 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6958 | BGP_ADDPATH_ALL); | |
6959 | return CMD_SUCCESS; | |
adbac85e DW |
6960 | } |
6961 | ||
d62a17ae | 6962 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6963 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6964 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6965 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6966 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6967 | |
adbac85e DW |
6968 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6969 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6970 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6971 | NO_STR |
6972 | NEIGHBOR_STR | |
6973 | NEIGHBOR_ADDR_STR2 | |
6974 | "Use addpath to advertise all paths to a neighbor\n") | |
6975 | { | |
d62a17ae | 6976 | int idx_peer = 2; |
dcc68b5e MS |
6977 | struct peer *peer; |
6978 | ||
6979 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6980 | if (!peer) | |
6981 | return CMD_WARNING_CONFIG_FAILED; | |
6982 | ||
6983 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6984 | != BGP_ADDPATH_ALL) { | |
6985 | vty_out(vty, | |
6986 | "%% Peer not currently configured to transmit all paths."); | |
6987 | return CMD_WARNING_CONFIG_FAILED; | |
6988 | } | |
6989 | ||
6990 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6991 | BGP_ADDPATH_NONE); | |
6992 | ||
6993 | return CMD_SUCCESS; | |
adbac85e DW |
6994 | } |
6995 | ||
d62a17ae | 6996 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6997 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6998 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6999 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7000 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7001 | |
06370dac DW |
7002 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7003 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7004 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7005 | NEIGHBOR_STR |
7006 | NEIGHBOR_ADDR_STR2 | |
7007 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7008 | { | |
d62a17ae | 7009 | int idx_peer = 1; |
7010 | struct peer *peer; | |
06370dac | 7011 | |
d62a17ae | 7012 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7013 | if (!peer) | |
7014 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7015 | |
dcc68b5e MS |
7016 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7017 | BGP_ADDPATH_BEST_PER_AS); | |
7018 | ||
7019 | return CMD_SUCCESS; | |
06370dac DW |
7020 | } |
7021 | ||
d62a17ae | 7022 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7023 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7024 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7025 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7026 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7027 | |
06370dac DW |
7028 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7029 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7031 | NO_STR |
7032 | NEIGHBOR_STR | |
7033 | NEIGHBOR_ADDR_STR2 | |
7034 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7035 | { | |
d62a17ae | 7036 | int idx_peer = 2; |
dcc68b5e MS |
7037 | struct peer *peer; |
7038 | ||
7039 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7040 | if (!peer) | |
7041 | return CMD_WARNING_CONFIG_FAILED; | |
7042 | ||
7043 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7044 | != BGP_ADDPATH_BEST_PER_AS) { | |
7045 | vty_out(vty, | |
7046 | "%% Peer not currently configured to transmit all best path per as."); | |
7047 | return CMD_WARNING_CONFIG_FAILED; | |
7048 | } | |
7049 | ||
7050 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7051 | BGP_ADDPATH_NONE); | |
7052 | ||
7053 | return CMD_SUCCESS; | |
06370dac DW |
7054 | } |
7055 | ||
d62a17ae | 7056 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7057 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7058 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7059 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7060 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7061 | |
2b31007c RZ |
7062 | DEFPY( |
7063 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7064 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7065 | NEIGHBOR_STR | |
7066 | NEIGHBOR_ADDR_STR2 | |
7067 | "Detect AS loops before sending to neighbor\n") | |
7068 | { | |
7069 | struct peer *peer; | |
7070 | ||
7071 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7072 | if (!peer) | |
7073 | return CMD_WARNING_CONFIG_FAILED; | |
7074 | ||
7075 | peer->as_path_loop_detection = true; | |
7076 | ||
7077 | return CMD_SUCCESS; | |
7078 | } | |
7079 | ||
7080 | DEFPY( | |
7081 | no_neighbor_aspath_loop_detection, | |
7082 | no_neighbor_aspath_loop_detection_cmd, | |
7083 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7084 | NO_STR | |
7085 | NEIGHBOR_STR | |
7086 | NEIGHBOR_ADDR_STR2 | |
7087 | "Detect AS loops before sending to neighbor\n") | |
7088 | { | |
7089 | struct peer *peer; | |
7090 | ||
7091 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7092 | if (!peer) | |
7093 | return CMD_WARNING_CONFIG_FAILED; | |
7094 | ||
7095 | peer->as_path_loop_detection = false; | |
7096 | ||
7097 | return CMD_SUCCESS; | |
7098 | } | |
7099 | ||
b9c7bc5a PZ |
7100 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7101 | struct ecommunity **list) | |
ddb5b488 | 7102 | { |
b9c7bc5a PZ |
7103 | struct ecommunity *ecom = NULL; |
7104 | struct ecommunity *ecomadd; | |
ddb5b488 | 7105 | |
b9c7bc5a | 7106 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7107 | |
b9c7bc5a PZ |
7108 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7109 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7110 | if (!ecomadd) { | |
7111 | vty_out(vty, "Malformed community-list value\n"); | |
7112 | if (ecom) | |
7113 | ecommunity_free(&ecom); | |
7114 | return CMD_WARNING_CONFIG_FAILED; | |
7115 | } | |
ddb5b488 | 7116 | |
b9c7bc5a PZ |
7117 | if (ecom) { |
7118 | ecommunity_merge(ecom, ecomadd); | |
7119 | ecommunity_free(&ecomadd); | |
7120 | } else { | |
7121 | ecom = ecomadd; | |
7122 | } | |
7123 | } | |
7124 | ||
7125 | if (*list) { | |
7126 | ecommunity_free(&*list); | |
ddb5b488 | 7127 | } |
b9c7bc5a PZ |
7128 | *list = ecom; |
7129 | ||
7130 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7131 | } |
7132 | ||
0ca70ba5 DS |
7133 | /* |
7134 | * v2vimport is true if we are handling a `import vrf ...` command | |
7135 | */ | |
7136 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7137 | { |
0ca70ba5 DS |
7138 | afi_t afi; |
7139 | ||
ddb5b488 | 7140 | switch (vty->node) { |
b9c7bc5a | 7141 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7142 | afi = AFI_IP; |
7143 | break; | |
b9c7bc5a | 7144 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7145 | afi = AFI_IP6; |
7146 | break; | |
ddb5b488 PZ |
7147 | default: |
7148 | vty_out(vty, | |
b9c7bc5a | 7149 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7150 | return AFI_MAX; |
ddb5b488 | 7151 | } |
69b07479 | 7152 | |
0ca70ba5 DS |
7153 | if (!v2vimport) { |
7154 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7155 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7156 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7157 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7158 | vty_out(vty, | |
7159 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7160 | return AFI_MAX; | |
7161 | } | |
7162 | } else { | |
7163 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7164 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7165 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7166 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7167 | vty_out(vty, | |
7168 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7169 | return AFI_MAX; | |
7170 | } | |
7171 | } | |
7172 | return afi; | |
ddb5b488 PZ |
7173 | } |
7174 | ||
b9c7bc5a PZ |
7175 | DEFPY (af_rd_vpn_export, |
7176 | af_rd_vpn_export_cmd, | |
7177 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7178 | NO_STR | |
ddb5b488 | 7179 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7180 | "Between current address-family and vpn\n" |
7181 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7182 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7183 | { | |
7184 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7185 | struct prefix_rd prd; | |
7186 | int ret; | |
ddb5b488 | 7187 | afi_t afi; |
b9c7bc5a PZ |
7188 | int idx = 0; |
7189 | int yes = 1; | |
ddb5b488 | 7190 | |
b9c7bc5a | 7191 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7192 | yes = 0; |
b9c7bc5a PZ |
7193 | |
7194 | if (yes) { | |
7195 | ret = str2prefix_rd(rd_str, &prd); | |
7196 | if (!ret) { | |
7197 | vty_out(vty, "%% Malformed rd\n"); | |
7198 | return CMD_WARNING_CONFIG_FAILED; | |
7199 | } | |
ddb5b488 PZ |
7200 | } |
7201 | ||
0ca70ba5 | 7202 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7203 | if (afi == AFI_MAX) |
7204 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7205 | |
69b07479 DS |
7206 | /* |
7207 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7208 | */ | |
7209 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7210 | bgp_get_default(), bgp); | |
ddb5b488 | 7211 | |
69b07479 DS |
7212 | if (yes) { |
7213 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7214 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7215 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7216 | } else { | |
7217 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7218 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7219 | } |
7220 | ||
69b07479 DS |
7221 | /* post-change: re-export vpn routes */ |
7222 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7223 | bgp_get_default(), bgp); | |
7224 | ||
ddb5b488 PZ |
7225 | return CMD_SUCCESS; |
7226 | } | |
7227 | ||
b9c7bc5a PZ |
7228 | ALIAS (af_rd_vpn_export, |
7229 | af_no_rd_vpn_export_cmd, | |
7230 | "no rd vpn export", | |
ddb5b488 | 7231 | NO_STR |
b9c7bc5a PZ |
7232 | "Specify route distinguisher\n" |
7233 | "Between current address-family and vpn\n" | |
7234 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7235 | |
b9c7bc5a PZ |
7236 | DEFPY (af_label_vpn_export, |
7237 | af_label_vpn_export_cmd, | |
e70e9f8e | 7238 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7239 | NO_STR |
ddb5b488 | 7240 | "label value for VRF\n" |
b9c7bc5a PZ |
7241 | "Between current address-family and vpn\n" |
7242 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7243 | "Label Value <0-1048575>\n" |
7244 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7245 | { |
7246 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7247 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7248 | afi_t afi; |
b9c7bc5a PZ |
7249 | int idx = 0; |
7250 | int yes = 1; | |
7251 | ||
7252 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7253 | yes = 0; |
ddb5b488 | 7254 | |
21a16cc2 PZ |
7255 | /* If "no ...", squash trailing parameter */ |
7256 | if (!yes) | |
7257 | label_auto = NULL; | |
7258 | ||
e70e9f8e PZ |
7259 | if (yes) { |
7260 | if (!label_auto) | |
7261 | label = label_val; /* parser should force unsigned */ | |
7262 | } | |
ddb5b488 | 7263 | |
0ca70ba5 | 7264 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7265 | if (afi == AFI_MAX) |
7266 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7267 | |
e70e9f8e | 7268 | |
69b07479 DS |
7269 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7270 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7271 | /* no change */ | |
7272 | return CMD_SUCCESS; | |
e70e9f8e | 7273 | |
69b07479 DS |
7274 | /* |
7275 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7276 | */ | |
7277 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7278 | bgp_get_default(), bgp); | |
7279 | ||
7280 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7281 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7282 | ||
7283 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7284 | ||
7285 | /* | |
7286 | * label has previously been automatically | |
7287 | * assigned by labelpool: release it | |
7288 | * | |
7289 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7290 | * means the automatic assignment is in flight | |
7291 | * and therefore the labelpool callback must | |
7292 | * detect that the auto label is not needed. | |
7293 | */ | |
7294 | ||
7295 | bgp_lp_release(LP_TYPE_VRF, | |
7296 | &bgp->vpn_policy[afi], | |
7297 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7298 | } |
69b07479 DS |
7299 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7300 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7301 | } | |
ddb5b488 | 7302 | |
69b07479 DS |
7303 | bgp->vpn_policy[afi].tovpn_label = label; |
7304 | if (label_auto) { | |
7305 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7306 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7307 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7308 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7309 | } |
7310 | ||
69b07479 DS |
7311 | /* post-change: re-export vpn routes */ |
7312 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7313 | bgp_get_default(), bgp); | |
7314 | ||
ddb5b488 PZ |
7315 | return CMD_SUCCESS; |
7316 | } | |
7317 | ||
b9c7bc5a PZ |
7318 | ALIAS (af_label_vpn_export, |
7319 | af_no_label_vpn_export_cmd, | |
7320 | "no label vpn export", | |
7321 | NO_STR | |
7322 | "label value for VRF\n" | |
7323 | "Between current address-family and vpn\n" | |
7324 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7325 | |
b9c7bc5a PZ |
7326 | DEFPY (af_nexthop_vpn_export, |
7327 | af_nexthop_vpn_export_cmd, | |
7328 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
7329 | NO_STR | |
ddb5b488 | 7330 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7331 | "Between current address-family and vpn\n" |
7332 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7333 | "IPv4 prefix\n" |
7334 | "IPv6 prefix\n") | |
7335 | { | |
7336 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7337 | afi_t afi; |
ddb5b488 | 7338 | struct prefix p; |
b9c7bc5a PZ |
7339 | int idx = 0; |
7340 | int yes = 1; | |
ddb5b488 | 7341 | |
b9c7bc5a | 7342 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7343 | yes = 0; |
b9c7bc5a PZ |
7344 | |
7345 | if (yes) { | |
7346 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
7347 | return CMD_WARNING_CONFIG_FAILED; | |
7348 | } | |
ddb5b488 | 7349 | |
0ca70ba5 | 7350 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7351 | if (afi == AFI_MAX) |
7352 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7353 | |
69b07479 DS |
7354 | /* |
7355 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7356 | */ | |
7357 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7358 | bgp_get_default(), bgp); | |
ddb5b488 | 7359 | |
69b07479 DS |
7360 | if (yes) { |
7361 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
7362 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7363 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7364 | } else { | |
7365 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7366 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7367 | } |
7368 | ||
69b07479 DS |
7369 | /* post-change: re-export vpn routes */ |
7370 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7371 | bgp_get_default(), bgp); | |
7372 | ||
ddb5b488 PZ |
7373 | return CMD_SUCCESS; |
7374 | } | |
7375 | ||
b9c7bc5a PZ |
7376 | ALIAS (af_nexthop_vpn_export, |
7377 | af_no_nexthop_vpn_export_cmd, | |
7378 | "no nexthop vpn export", | |
ddb5b488 | 7379 | NO_STR |
b9c7bc5a PZ |
7380 | "Specify next hop to use for VRF advertised prefixes\n" |
7381 | "Between current address-family and vpn\n" | |
7382 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7383 | |
b9c7bc5a | 7384 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7385 | { |
b9c7bc5a PZ |
7386 | if (!strcmp(dstr, "import")) { |
7387 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7388 | } else if (!strcmp(dstr, "export")) { | |
7389 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7390 | } else if (!strcmp(dstr, "both")) { | |
7391 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7392 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7393 | } else { | |
7394 | vty_out(vty, "%% direction parse error\n"); | |
7395 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7396 | } |
ddb5b488 PZ |
7397 | return CMD_SUCCESS; |
7398 | } | |
7399 | ||
b9c7bc5a PZ |
7400 | DEFPY (af_rt_vpn_imexport, |
7401 | af_rt_vpn_imexport_cmd, | |
7402 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7403 | NO_STR | |
7404 | "Specify route target list\n" | |
ddb5b488 | 7405 | "Specify route target list\n" |
b9c7bc5a PZ |
7406 | "Between current address-family and vpn\n" |
7407 | "For routes leaked from vpn to current address-family: match any\n" | |
7408 | "For routes leaked from current address-family to vpn: set\n" | |
7409 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7410 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7411 | { | |
7412 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7413 | int ret; | |
7414 | struct ecommunity *ecom = NULL; | |
7415 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7416 | vpn_policy_direction_t dir; |
7417 | afi_t afi; | |
7418 | int idx = 0; | |
b9c7bc5a | 7419 | int yes = 1; |
ddb5b488 | 7420 | |
b9c7bc5a | 7421 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7422 | yes = 0; |
b9c7bc5a | 7423 | |
0ca70ba5 | 7424 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7425 | if (afi == AFI_MAX) |
7426 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7427 | |
b9c7bc5a | 7428 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7429 | if (ret != CMD_SUCCESS) |
7430 | return ret; | |
7431 | ||
b9c7bc5a PZ |
7432 | if (yes) { |
7433 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7434 | vty_out(vty, "%% Missing RTLIST\n"); | |
7435 | return CMD_WARNING_CONFIG_FAILED; | |
7436 | } | |
7437 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7438 | if (ret != CMD_SUCCESS) { | |
7439 | return ret; | |
7440 | } | |
ddb5b488 PZ |
7441 | } |
7442 | ||
69b07479 DS |
7443 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7444 | if (!dodir[dir]) | |
ddb5b488 | 7445 | continue; |
ddb5b488 | 7446 | |
69b07479 | 7447 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7448 | |
69b07479 DS |
7449 | if (yes) { |
7450 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7451 | ecommunity_free( | |
7452 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7453 | bgp->vpn_policy[afi].rtlist[dir] = | |
7454 | ecommunity_dup(ecom); | |
7455 | } else { | |
7456 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7457 | ecommunity_free( | |
7458 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7459 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7460 | } |
69b07479 DS |
7461 | |
7462 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7463 | } |
69b07479 | 7464 | |
d555f3e9 PZ |
7465 | if (ecom) |
7466 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7467 | |
7468 | return CMD_SUCCESS; | |
7469 | } | |
7470 | ||
b9c7bc5a PZ |
7471 | ALIAS (af_rt_vpn_imexport, |
7472 | af_no_rt_vpn_imexport_cmd, | |
7473 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7474 | NO_STR |
7475 | "Specify route target list\n" | |
b9c7bc5a PZ |
7476 | "Specify route target list\n" |
7477 | "Between current address-family and vpn\n" | |
7478 | "For routes leaked from vpn to current address-family\n" | |
7479 | "For routes leaked from current address-family to vpn\n" | |
7480 | "both import and export\n") | |
7481 | ||
7482 | DEFPY (af_route_map_vpn_imexport, | |
7483 | af_route_map_vpn_imexport_cmd, | |
7484 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7485 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7486 | NO_STR | |
ddb5b488 | 7487 | "Specify route map\n" |
b9c7bc5a PZ |
7488 | "Between current address-family and vpn\n" |
7489 | "For routes leaked from vpn to current address-family\n" | |
7490 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7491 | "name of route-map\n") |
7492 | { | |
7493 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7494 | int ret; | |
7495 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7496 | vpn_policy_direction_t dir; |
7497 | afi_t afi; | |
ddb5b488 | 7498 | int idx = 0; |
b9c7bc5a | 7499 | int yes = 1; |
ddb5b488 | 7500 | |
b9c7bc5a | 7501 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7502 | yes = 0; |
b9c7bc5a | 7503 | |
0ca70ba5 | 7504 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7505 | if (afi == AFI_MAX) |
7506 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7507 | |
b9c7bc5a | 7508 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7509 | if (ret != CMD_SUCCESS) |
7510 | return ret; | |
7511 | ||
69b07479 DS |
7512 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7513 | if (!dodir[dir]) | |
ddb5b488 | 7514 | continue; |
ddb5b488 | 7515 | |
69b07479 | 7516 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7517 | |
69b07479 DS |
7518 | if (yes) { |
7519 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7520 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7521 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7522 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7523 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7524 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7525 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7526 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7527 | return CMD_SUCCESS; | |
7528 | } else { | |
7529 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7530 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7531 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7532 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7533 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7534 | } |
69b07479 DS |
7535 | |
7536 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7537 | } |
7538 | ||
7539 | return CMD_SUCCESS; | |
7540 | } | |
7541 | ||
b9c7bc5a PZ |
7542 | ALIAS (af_route_map_vpn_imexport, |
7543 | af_no_route_map_vpn_imexport_cmd, | |
7544 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7545 | NO_STR |
7546 | "Specify route map\n" | |
b9c7bc5a PZ |
7547 | "Between current address-family and vpn\n" |
7548 | "For routes leaked from vpn to current address-family\n" | |
7549 | "For routes leaked from current address-family to vpn\n") | |
7550 | ||
bb4f6190 DS |
7551 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
7552 | "[no] import vrf route-map RMAP$rmap_str", | |
7553 | NO_STR | |
7554 | "Import routes from another VRF\n" | |
7555 | "Vrf routes being filtered\n" | |
7556 | "Specify route map\n" | |
7557 | "name of route-map\n") | |
7558 | { | |
7559 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7560 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7561 | afi_t afi; | |
7562 | int idx = 0; | |
7563 | int yes = 1; | |
7564 | struct bgp *bgp_default; | |
7565 | ||
7566 | if (argv_find(argv, argc, "no", &idx)) | |
7567 | yes = 0; | |
7568 | ||
0ca70ba5 | 7569 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7570 | if (afi == AFI_MAX) |
7571 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7572 | |
7573 | bgp_default = bgp_get_default(); | |
7574 | if (!bgp_default) { | |
7575 | int32_t ret; | |
7576 | as_t as = bgp->as; | |
7577 | ||
7578 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7579 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7580 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7581 | |
7582 | if (ret) { | |
7583 | vty_out(vty, | |
7584 | "VRF default is not configured as a bgp instance\n"); | |
7585 | return CMD_WARNING; | |
7586 | } | |
7587 | } | |
7588 | ||
69b07479 | 7589 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7590 | |
69b07479 DS |
7591 | if (yes) { |
7592 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7593 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7594 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7595 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7596 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7597 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7598 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7599 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7600 | return CMD_SUCCESS; | |
7601 | } else { | |
7602 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7603 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7604 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7605 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7606 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
7607 | } |
7608 | ||
69b07479 DS |
7609 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7610 | ||
bb4f6190 DS |
7611 | return CMD_SUCCESS; |
7612 | } | |
7613 | ||
7614 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
7615 | "no import vrf route-map", | |
7616 | NO_STR | |
7617 | "Import routes from another VRF\n" | |
7618 | "Vrf routes being filtered\n" | |
7619 | "Specify route map\n") | |
7620 | ||
4d1b335c DA |
7621 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7622 | "[no] import vrf VIEWVRFNAME$import_name", | |
7623 | NO_STR | |
7624 | "Import routes from another VRF\n" | |
7625 | "VRF to import from\n" | |
7626 | "The name of the VRF\n") | |
12a844a5 DS |
7627 | { |
7628 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7629 | struct listnode *node; | |
79ef8664 DS |
7630 | struct bgp *vrf_bgp, *bgp_default; |
7631 | int32_t ret = 0; | |
7632 | as_t as = bgp->as; | |
12a844a5 DS |
7633 | bool remove = false; |
7634 | int32_t idx = 0; | |
7635 | char *vname; | |
a8dadcf6 | 7636 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7637 | safi_t safi; |
7638 | afi_t afi; | |
7639 | ||
867f0cca | 7640 | if (import_name == NULL) { |
7641 | vty_out(vty, "%% Missing import name\n"); | |
7642 | return CMD_WARNING; | |
7643 | } | |
7644 | ||
12a844a5 DS |
7645 | if (argv_find(argv, argc, "no", &idx)) |
7646 | remove = true; | |
7647 | ||
0ca70ba5 DS |
7648 | afi = vpn_policy_getafi(vty, bgp, true); |
7649 | if (afi == AFI_MAX) | |
7650 | return CMD_WARNING_CONFIG_FAILED; | |
7651 | ||
12a844a5 DS |
7652 | safi = bgp_node_safi(vty); |
7653 | ||
25679caa | 7654 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7655 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7656 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7657 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7658 | remove ? "unimport" : "import", import_name); | |
7659 | return CMD_WARNING; | |
7660 | } | |
7661 | ||
79ef8664 DS |
7662 | bgp_default = bgp_get_default(); |
7663 | if (!bgp_default) { | |
7664 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7665 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7666 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7667 | |
7668 | if (ret) { | |
7669 | vty_out(vty, | |
7670 | "VRF default is not configured as a bgp instance\n"); | |
7671 | return CMD_WARNING; | |
7672 | } | |
7673 | } | |
7674 | ||
12a844a5 DS |
7675 | vrf_bgp = bgp_lookup_by_name(import_name); |
7676 | if (!vrf_bgp) { | |
5742e42b | 7677 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7678 | vrf_bgp = bgp_default; |
7679 | else | |
0fb8d6e6 | 7680 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7681 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7682 | |
6e2c7fe6 | 7683 | if (ret) { |
020a3f60 DS |
7684 | vty_out(vty, |
7685 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7686 | import_name); |
7687 | return CMD_WARNING; | |
7688 | } | |
12a844a5 DS |
7689 | } |
7690 | ||
12a844a5 | 7691 | if (remove) { |
44338987 | 7692 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7693 | } else { |
44338987 | 7694 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7695 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7696 | vname)) { | |
7697 | if (strcmp(vname, import_name) == 0) | |
7698 | return CMD_WARNING; | |
7699 | } | |
7700 | ||
44338987 | 7701 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7702 | } |
7703 | ||
7704 | return CMD_SUCCESS; | |
7705 | } | |
7706 | ||
b9c7bc5a PZ |
7707 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7708 | DEFPY (bgp_imexport_vpn, | |
7709 | bgp_imexport_vpn_cmd, | |
7710 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7711 | NO_STR |
7712 | "Import routes to this address-family\n" | |
7713 | "Export routes from this address-family\n" | |
7714 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7715 | { |
7716 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7717 | int previous_state; |
ddb5b488 | 7718 | afi_t afi; |
b9c7bc5a | 7719 | safi_t safi; |
ddb5b488 | 7720 | int idx = 0; |
b9c7bc5a PZ |
7721 | int yes = 1; |
7722 | int flag; | |
7723 | vpn_policy_direction_t dir; | |
ddb5b488 | 7724 | |
b9c7bc5a | 7725 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7726 | yes = 0; |
ddb5b488 | 7727 | |
b9c7bc5a PZ |
7728 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7729 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7730 | |
b9c7bc5a PZ |
7731 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7732 | return CMD_WARNING_CONFIG_FAILED; | |
7733 | } | |
ddb5b488 | 7734 | |
b9c7bc5a PZ |
7735 | afi = bgp_node_afi(vty); |
7736 | safi = bgp_node_safi(vty); | |
7737 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7738 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7739 | return CMD_WARNING_CONFIG_FAILED; | |
7740 | } | |
ddb5b488 | 7741 | |
b9c7bc5a PZ |
7742 | if (!strcmp(direction_str, "import")) { |
7743 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7744 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7745 | } else if (!strcmp(direction_str, "export")) { | |
7746 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7747 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7748 | } else { | |
7749 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7750 | return CMD_WARNING_CONFIG_FAILED; | |
7751 | } | |
7752 | ||
7753 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7754 | |
b9c7bc5a PZ |
7755 | if (yes) { |
7756 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7757 | if (!previous_state) { | |
7758 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7759 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7760 | } | |
b9c7bc5a PZ |
7761 | } else { |
7762 | if (previous_state) { | |
7763 | /* trigger un-export current vrf */ | |
7764 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7765 | } | |
7766 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7767 | } |
7768 | ||
7769 | return CMD_SUCCESS; | |
7770 | } | |
7771 | ||
301ad80a PG |
7772 | DEFPY (af_routetarget_import, |
7773 | af_routetarget_import_cmd, | |
7774 | "[no] <rt|route-target> redirect import RTLIST...", | |
7775 | NO_STR | |
7776 | "Specify route target list\n" | |
7777 | "Specify route target list\n" | |
7778 | "Flow-spec redirect type route target\n" | |
7779 | "Import routes to this address-family\n" | |
7780 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7781 | { | |
7782 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7783 | int ret; | |
7784 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7785 | afi_t afi; |
7786 | int idx = 0; | |
7787 | int yes = 1; | |
7788 | ||
7789 | if (argv_find(argv, argc, "no", &idx)) | |
7790 | yes = 0; | |
7791 | ||
0ca70ba5 | 7792 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7793 | if (afi == AFI_MAX) |
7794 | return CMD_WARNING_CONFIG_FAILED; | |
7795 | ||
301ad80a PG |
7796 | if (yes) { |
7797 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7798 | vty_out(vty, "%% Missing RTLIST\n"); | |
7799 | return CMD_WARNING_CONFIG_FAILED; | |
7800 | } | |
7801 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7802 | if (ret != CMD_SUCCESS) | |
7803 | return ret; | |
7804 | } | |
69b07479 DS |
7805 | |
7806 | if (yes) { | |
7807 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7808 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7809 | .import_redirect_rtlist); |
69b07479 DS |
7810 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7811 | ecommunity_dup(ecom); | |
7812 | } else { | |
7813 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7814 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7815 | .import_redirect_rtlist); |
69b07479 | 7816 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7817 | } |
69b07479 | 7818 | |
301ad80a PG |
7819 | if (ecom) |
7820 | ecommunity_free(&ecom); | |
7821 | ||
7822 | return CMD_SUCCESS; | |
7823 | } | |
7824 | ||
505e5056 | 7825 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7826 | address_family_ipv4_safi_cmd, |
7827 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7828 | "Enter Address Family command mode\n" | |
7829 | "Address Family\n" | |
7830 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7831 | { |
f51bae9c | 7832 | |
d62a17ae | 7833 | if (argc == 3) { |
2131d5cf | 7834 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7835 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7836 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7837 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7838 | && safi != SAFI_EVPN) { |
31947174 MK |
7839 | vty_out(vty, |
7840 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7841 | return CMD_WARNING_CONFIG_FAILED; |
7842 | } | |
d62a17ae | 7843 | vty->node = bgp_node_type(AFI_IP, safi); |
7844 | } else | |
7845 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7846 | |
d62a17ae | 7847 | return CMD_SUCCESS; |
718e3744 | 7848 | } |
7849 | ||
505e5056 | 7850 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7851 | address_family_ipv6_safi_cmd, |
7852 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7853 | "Enter Address Family command mode\n" | |
7854 | "Address Family\n" | |
7855 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7856 | { |
d62a17ae | 7857 | if (argc == 3) { |
2131d5cf | 7858 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7859 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7860 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7861 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7862 | && safi != SAFI_EVPN) { |
31947174 MK |
7863 | vty_out(vty, |
7864 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7865 | return CMD_WARNING_CONFIG_FAILED; |
7866 | } | |
d62a17ae | 7867 | vty->node = bgp_node_type(AFI_IP6, safi); |
7868 | } else | |
7869 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7870 | |
d62a17ae | 7871 | return CMD_SUCCESS; |
25ffbdc1 | 7872 | } |
718e3744 | 7873 | |
d6902373 | 7874 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7875 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7876 | address_family_vpnv4_cmd, |
8334fd5a | 7877 | "address-family vpnv4 [unicast]", |
718e3744 | 7878 | "Enter Address Family command mode\n" |
8c3deaae | 7879 | "Address Family\n" |
3a2d747c | 7880 | "Address Family modifier\n") |
718e3744 | 7881 | { |
d62a17ae | 7882 | vty->node = BGP_VPNV4_NODE; |
7883 | return CMD_SUCCESS; | |
718e3744 | 7884 | } |
7885 | ||
505e5056 | 7886 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7887 | address_family_vpnv6_cmd, |
8334fd5a | 7888 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7889 | "Enter Address Family command mode\n" |
8c3deaae | 7890 | "Address Family\n" |
3a2d747c | 7891 | "Address Family modifier\n") |
8ecd3266 | 7892 | { |
d62a17ae | 7893 | vty->node = BGP_VPNV6_NODE; |
7894 | return CMD_SUCCESS; | |
8ecd3266 | 7895 | } |
64e4a6c5 | 7896 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7897 | |
505e5056 | 7898 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7899 | address_family_evpn_cmd, |
7111c1a0 | 7900 | "address-family l2vpn evpn", |
4e0b7b6d | 7901 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7902 | "Address Family\n" |
7903 | "Address Family modifier\n") | |
4e0b7b6d | 7904 | { |
2131d5cf | 7905 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7906 | vty->node = BGP_EVPN_NODE; |
7907 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7908 | } |
7909 | ||
505e5056 | 7910 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7911 | exit_address_family_cmd, |
7912 | "exit-address-family", | |
7913 | "Exit from Address Family configuration mode\n") | |
7914 | { | |
d62a17ae | 7915 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7916 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7917 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7918 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7919 | || vty->node == BGP_EVPN_NODE |
7920 | || vty->node == BGP_FLOWSPECV4_NODE | |
7921 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7922 | vty->node = BGP_NODE; |
7923 | return CMD_SUCCESS; | |
718e3744 | 7924 | } |
6b0655a2 | 7925 | |
8ad7271d | 7926 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7927 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7928 | const char *ip_str, afi_t afi, safi_t safi, | |
7929 | struct prefix_rd *prd) | |
7930 | { | |
7931 | int ret; | |
7932 | struct prefix match; | |
7933 | struct bgp_node *rn; | |
7934 | struct bgp_node *rm; | |
7935 | struct bgp *bgp; | |
7936 | struct bgp_table *table; | |
7937 | struct bgp_table *rib; | |
7938 | ||
7939 | /* BGP structure lookup. */ | |
7940 | if (view_name) { | |
7941 | bgp = bgp_lookup_by_name(view_name); | |
7942 | if (bgp == NULL) { | |
7943 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7944 | view_name); | |
7945 | return CMD_WARNING; | |
7946 | } | |
7947 | } else { | |
7948 | bgp = bgp_get_default(); | |
7949 | if (bgp == NULL) { | |
7950 | vty_out(vty, "%% No BGP process is configured\n"); | |
7951 | return CMD_WARNING; | |
7952 | } | |
7953 | } | |
7954 | ||
7955 | /* Check IP address argument. */ | |
7956 | ret = str2prefix(ip_str, &match); | |
7957 | if (!ret) { | |
7958 | vty_out(vty, "%% address is malformed\n"); | |
7959 | return CMD_WARNING; | |
7960 | } | |
7961 | ||
7962 | match.family = afi2family(afi); | |
7963 | rib = bgp->rib[afi][safi]; | |
7964 | ||
7965 | if (safi == SAFI_MPLS_VPN) { | |
7966 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7967 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7968 | continue; | |
7969 | ||
67009e22 DS |
7970 | table = bgp_node_get_bgp_table_info(rn); |
7971 | if (table != NULL) { | |
7972 | ||
d62a17ae | 7973 | if ((rm = bgp_node_match(table, &match)) |
7974 | != NULL) { | |
7975 | if (rm->p.prefixlen | |
7976 | == match.prefixlen) { | |
343cdb61 | 7977 | SET_FLAG(rm->flags, |
d62a17ae | 7978 | BGP_NODE_USER_CLEAR); |
7979 | bgp_process(bgp, rm, afi, safi); | |
7980 | } | |
7981 | bgp_unlock_node(rm); | |
7982 | } | |
7983 | } | |
7984 | } | |
7985 | } else { | |
7986 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7987 | if (rn->p.prefixlen == match.prefixlen) { | |
7988 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7989 | bgp_process(bgp, rn, afi, safi); | |
7990 | } | |
7991 | bgp_unlock_node(rn); | |
7992 | } | |
7993 | } | |
7994 | ||
7995 | return CMD_SUCCESS; | |
8ad7271d DS |
7996 | } |
7997 | ||
b09b5ae0 | 7998 | /* one clear bgp command to rule them all */ |
718e3744 | 7999 | DEFUN (clear_ip_bgp_all, |
8000 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8001 | "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 | 8002 | CLEAR_STR |
8003 | IP_STR | |
8004 | BGP_STR | |
838758ac | 8005 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8006 | BGP_AFI_HELP_STR |
fd5e7b70 | 8007 | "Address Family\n" |
510afcd6 | 8008 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8009 | "Address Family modifier\n" |
b09b5ae0 | 8010 | "Clear all peers\n" |
453c92f6 | 8011 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8012 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8013 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8014 | "Clear peers with the AS number\n" |
8015 | "Clear all external peers\n" | |
718e3744 | 8016 | "Clear all members of peer-group\n" |
b09b5ae0 | 8017 | "BGP peer-group name\n" |
b09b5ae0 DW |
8018 | BGP_SOFT_STR |
8019 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8020 | BGP_SOFT_OUT_STR |
8021 | BGP_SOFT_IN_STR | |
8022 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8023 | BGP_SOFT_OUT_STR) |
718e3744 | 8024 | { |
d62a17ae | 8025 | char *vrf = NULL; |
8026 | ||
dc912615 DS |
8027 | afi_t afi = AFI_UNSPEC; |
8028 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8029 | enum clear_sort clr_sort = clear_peer; |
8030 | enum bgp_clear_type clr_type; | |
8031 | char *clr_arg = NULL; | |
8032 | ||
8033 | int idx = 0; | |
8034 | ||
8035 | /* clear [ip] bgp */ | |
8036 | if (argv_find(argv, argc, "ip", &idx)) | |
8037 | afi = AFI_IP; | |
8038 | ||
9a8bdf1c PG |
8039 | /* [<vrf> VIEWVRFNAME] */ |
8040 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8041 | vrf = argv[idx + 1]->arg; | |
8042 | idx += 2; | |
8043 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8044 | vrf = NULL; | |
8045 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8046 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8047 | vrf = argv[idx + 1]->arg; |
8048 | idx += 2; | |
8049 | } | |
d62a17ae | 8050 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8051 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8052 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8053 | ||
d7b9898c | 8054 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8055 | if (argv_find(argv, argc, "*", &idx)) { |
8056 | clr_sort = clear_all; | |
8057 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8058 | clr_sort = clear_peer; | |
8059 | clr_arg = argv[idx]->arg; | |
8060 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8061 | clr_sort = clear_peer; | |
8062 | clr_arg = argv[idx]->arg; | |
8063 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8064 | clr_sort = clear_group; | |
8065 | idx++; | |
8066 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8067 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8068 | clr_sort = clear_peer; |
8069 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8070 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8071 | clr_sort = clear_peer; | |
8072 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8073 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8074 | clr_sort = clear_as; | |
8075 | clr_arg = argv[idx]->arg; | |
8076 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8077 | clr_sort = clear_external; | |
8078 | } | |
8079 | ||
8080 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8081 | if (argv_find(argv, argc, "soft", &idx)) { | |
8082 | if (argv_find(argv, argc, "in", &idx) | |
8083 | || argv_find(argv, argc, "out", &idx)) | |
8084 | clr_type = strmatch(argv[idx]->text, "in") | |
8085 | ? BGP_CLEAR_SOFT_IN | |
8086 | : BGP_CLEAR_SOFT_OUT; | |
8087 | else | |
8088 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8089 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8090 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8091 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8092 | : BGP_CLEAR_SOFT_IN; | |
8093 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8094 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8095 | } else | |
8096 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8097 | ||
8098 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8099 | } |
01080f7c | 8100 | |
8ad7271d DS |
8101 | DEFUN (clear_ip_bgp_prefix, |
8102 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8103 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8104 | CLEAR_STR |
8105 | IP_STR | |
8106 | BGP_STR | |
838758ac | 8107 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8108 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8109 | "IPv4 prefix\n") |
8ad7271d | 8110 | { |
d62a17ae | 8111 | char *vrf = NULL; |
8112 | char *prefix = NULL; | |
8ad7271d | 8113 | |
d62a17ae | 8114 | int idx = 0; |
01080f7c | 8115 | |
d62a17ae | 8116 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8117 | if (argv_find(argv, argc, "vrf", &idx)) { |
8118 | vrf = argv[idx + 1]->arg; | |
8119 | idx += 2; | |
8120 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8121 | vrf = NULL; | |
8122 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8123 | /* [<view> VIEWVRFNAME] */ | |
8124 | vrf = argv[idx + 1]->arg; | |
8125 | idx += 2; | |
8126 | } | |
0c7b1b01 | 8127 | |
d62a17ae | 8128 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8129 | |
d62a17ae | 8130 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8131 | } |
8ad7271d | 8132 | |
b09b5ae0 DW |
8133 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8134 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8135 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8136 | CLEAR_STR |
3a2d747c | 8137 | IP_STR |
718e3744 | 8138 | BGP_STR |
8c3deaae | 8139 | "Address Family\n" |
46f296b4 | 8140 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8141 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8142 | "IPv6 prefix\n") |
718e3744 | 8143 | { |
9b475e76 PG |
8144 | int idx_safi = 0; |
8145 | int idx_ipv6_prefix = 0; | |
8146 | safi_t safi = SAFI_UNICAST; | |
8147 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8148 | argv[idx_ipv6_prefix]->arg : NULL; | |
8149 | ||
8150 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8151 | return bgp_clear_prefix( |
9b475e76 PG |
8152 | vty, NULL, prefix, AFI_IP6, |
8153 | safi, NULL); | |
838758ac | 8154 | } |
01080f7c | 8155 | |
b09b5ae0 DW |
8156 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8157 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8158 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8159 | CLEAR_STR |
3a2d747c | 8160 | IP_STR |
718e3744 | 8161 | BGP_STR |
838758ac | 8162 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8163 | "Address Family\n" |
46f296b4 | 8164 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8165 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8166 | "IPv6 prefix\n") |
718e3744 | 8167 | { |
9b475e76 | 8168 | int idx_safi = 0; |
9a8bdf1c | 8169 | int idx_vrfview = 0; |
9b475e76 PG |
8170 | int idx_ipv6_prefix = 0; |
8171 | safi_t safi = SAFI_UNICAST; | |
8172 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8173 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8174 | char *vrfview = NULL; |
9b475e76 | 8175 | |
9a8bdf1c PG |
8176 | /* [<view|vrf> VIEWVRFNAME] */ |
8177 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8178 | vrfview = argv[idx_vrfview + 1]->arg; | |
8179 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8180 | vrfview = NULL; | |
8181 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8182 | /* [<view> VIEWVRFNAME] */ | |
8183 | vrfview = argv[idx_vrfview + 1]->arg; | |
8184 | } | |
9b475e76 PG |
8185 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8186 | ||
d62a17ae | 8187 | return bgp_clear_prefix( |
9b475e76 PG |
8188 | vty, vrfview, prefix, |
8189 | AFI_IP6, safi, NULL); | |
718e3744 | 8190 | } |
8191 | ||
b09b5ae0 DW |
8192 | DEFUN (show_bgp_views, |
8193 | show_bgp_views_cmd, | |
d6e3c605 | 8194 | "show [ip] bgp views", |
b09b5ae0 | 8195 | SHOW_STR |
d6e3c605 | 8196 | IP_STR |
01080f7c | 8197 | BGP_STR |
b09b5ae0 | 8198 | "Show the defined BGP views\n") |
01080f7c | 8199 | { |
d62a17ae | 8200 | struct list *inst = bm->bgp; |
8201 | struct listnode *node; | |
8202 | struct bgp *bgp; | |
01080f7c | 8203 | |
d62a17ae | 8204 | vty_out(vty, "Defined BGP views:\n"); |
8205 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8206 | /* Skip VRFs. */ | |
8207 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8208 | continue; | |
8209 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8210 | bgp->as); | |
8211 | } | |
e52702f2 | 8212 | |
d62a17ae | 8213 | return CMD_SUCCESS; |
e0081f70 ML |
8214 | } |
8215 | ||
8386ac43 | 8216 | DEFUN (show_bgp_vrfs, |
8217 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8218 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8219 | SHOW_STR |
d6e3c605 | 8220 | IP_STR |
8386ac43 | 8221 | BGP_STR |
8222 | "Show BGP VRFs\n" | |
9973d184 | 8223 | JSON_STR) |
8386ac43 | 8224 | { |
fe1dc5a3 | 8225 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8226 | struct list *inst = bm->bgp; |
8227 | struct listnode *node; | |
8228 | struct bgp *bgp; | |
9f049418 | 8229 | bool uj = use_json(argc, argv); |
d62a17ae | 8230 | json_object *json = NULL; |
8231 | json_object *json_vrfs = NULL; | |
8232 | int count = 0; | |
d62a17ae | 8233 | |
d62a17ae | 8234 | if (uj) { |
8235 | json = json_object_new_object(); | |
8236 | json_vrfs = json_object_new_object(); | |
8237 | } | |
8238 | ||
8239 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8240 | const char *name, *type; | |
8241 | struct peer *peer; | |
7fe96307 | 8242 | struct listnode *node2, *nnode2; |
d62a17ae | 8243 | int peers_cfg, peers_estb; |
8244 | json_object *json_vrf = NULL; | |
d62a17ae | 8245 | |
8246 | /* Skip Views. */ | |
8247 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8248 | continue; | |
8249 | ||
8250 | count++; | |
efb4077a | 8251 | if (!uj && count == 1) { |
fe1dc5a3 | 8252 | vty_out(vty, |
efb4077a | 8253 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8254 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8255 | "#PeersEstb", "Name"); |
8256 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8257 | "L3-VNI", "RouterMAC", "Interface"); | |
8258 | } | |
d62a17ae | 8259 | |
8260 | peers_cfg = peers_estb = 0; | |
8261 | if (uj) | |
8262 | json_vrf = json_object_new_object(); | |
8263 | ||
8264 | ||
7fe96307 | 8265 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8266 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8267 | continue; | |
8268 | peers_cfg++; | |
8269 | if (peer->status == Established) | |
8270 | peers_estb++; | |
8271 | } | |
8272 | ||
8273 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8274 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8275 | type = "DFLT"; |
8276 | } else { | |
8277 | name = bgp->name; | |
8278 | type = "VRF"; | |
8279 | } | |
8280 | ||
a8bf7d9c | 8281 | |
d62a17ae | 8282 | if (uj) { |
a4d82a8a PZ |
8283 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8284 | ? -1 | |
8285 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8286 | json_object_string_add(json_vrf, "type", type); |
8287 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8288 | json_object_string_add(json_vrf, "routerId", | |
8289 | inet_ntoa(bgp->router_id)); | |
8290 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8291 | peers_cfg); | |
8292 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8293 | peers_estb); | |
8294 | ||
fe1dc5a3 | 8295 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8296 | json_object_string_add( |
8297 | json_vrf, "rmac", | |
8298 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8299 | json_object_string_add(json_vrf, "interface", |
8300 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8301 | bgp->vrf_id)); | |
d62a17ae | 8302 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8303 | } else { |
fe1dc5a3 | 8304 | vty_out(vty, |
efb4077a | 8305 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8306 | type, |
8307 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8308 | : (int)bgp->vrf_id, | |
8309 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8310 | peers_estb, name); |
8311 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8312 | bgp->l3vni, | |
8313 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8314 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8315 | bgp->vrf_id)); | |
8316 | } | |
d62a17ae | 8317 | } |
8318 | ||
8319 | if (uj) { | |
8320 | json_object_object_add(json, "vrfs", json_vrfs); | |
8321 | ||
8322 | json_object_int_add(json, "totalVrfs", count); | |
8323 | ||
996c9314 LB |
8324 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8325 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8326 | json_object_free(json); |
8327 | } else { | |
8328 | if (count) | |
8329 | vty_out(vty, | |
8330 | "\nTotal number of VRFs (including default): %d\n", | |
8331 | count); | |
8332 | } | |
8333 | ||
8334 | return CMD_SUCCESS; | |
8386ac43 | 8335 | } |
8336 | ||
48ecf8f5 DS |
8337 | DEFUN (show_bgp_mac_hash, |
8338 | show_bgp_mac_hash_cmd, | |
8339 | "show bgp mac hash", | |
8340 | SHOW_STR | |
8341 | BGP_STR | |
8342 | "Mac Address\n" | |
8343 | "Mac Address database\n") | |
8344 | { | |
8345 | bgp_mac_dump_table(vty); | |
8346 | ||
8347 | return CMD_SUCCESS; | |
8348 | } | |
acf71666 | 8349 | |
e3b78da8 | 8350 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8351 | { |
0291c246 | 8352 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8353 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8354 | |
60466a63 | 8355 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8356 | tip->refcnt); |
8357 | } | |
8358 | ||
8359 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8360 | { | |
8361 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8362 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8363 | |
8364 | vty_out(vty, "Tunnel-ip database:\n"); | |
8365 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8366 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8367 | vty); |
8368 | } | |
8369 | ||
15c81ca4 DS |
8370 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8371 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8372 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8373 | "martian next-hops\n" |
8374 | "martian next-hop database\n") | |
acf71666 | 8375 | { |
0291c246 | 8376 | struct bgp *bgp = NULL; |
15c81ca4 | 8377 | int idx = 0; |
9a8bdf1c PG |
8378 | char *name = NULL; |
8379 | ||
8380 | /* [<vrf> VIEWVRFNAME] */ | |
8381 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8382 | name = argv[idx + 1]->arg; | |
8383 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8384 | name = NULL; | |
8385 | } else if (argv_find(argv, argc, "view", &idx)) | |
8386 | /* [<view> VIEWVRFNAME] */ | |
8387 | name = argv[idx + 1]->arg; | |
8388 | if (name) | |
8389 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8390 | else |
8391 | bgp = bgp_get_default(); | |
acf71666 | 8392 | |
acf71666 MK |
8393 | if (!bgp) { |
8394 | vty_out(vty, "%% No BGP process is configured\n"); | |
8395 | return CMD_WARNING; | |
8396 | } | |
8397 | bgp_show_martian_nexthops(vty, bgp); | |
8398 | ||
8399 | return CMD_SUCCESS; | |
8400 | } | |
8401 | ||
f412b39a | 8402 | DEFUN (show_bgp_memory, |
4bf6a362 | 8403 | show_bgp_memory_cmd, |
7fa12b13 | 8404 | "show [ip] bgp memory", |
4bf6a362 | 8405 | SHOW_STR |
3a2d747c | 8406 | IP_STR |
4bf6a362 PJ |
8407 | BGP_STR |
8408 | "Global BGP memory statistics\n") | |
8409 | { | |
d62a17ae | 8410 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8411 | unsigned long count; | |
8412 | ||
8413 | /* RIB related usage stats */ | |
8414 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8415 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8416 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8417 | count * sizeof(struct bgp_node))); | |
8418 | ||
8419 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8420 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8421 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8422 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8423 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8424 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8425 | count, | |
4b7e6066 DS |
8426 | mtype_memstr( |
8427 | memstrbuf, sizeof(memstrbuf), | |
8428 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8429 | |
8430 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8431 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8432 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8433 | count * sizeof(struct bgp_static))); | |
8434 | ||
8435 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8436 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8437 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8438 | count * sizeof(struct bpacket))); | |
8439 | ||
8440 | /* Adj-In/Out */ | |
8441 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8442 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8443 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8444 | count * sizeof(struct bgp_adj_in))); | |
8445 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8446 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8447 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8448 | count * sizeof(struct bgp_adj_out))); | |
8449 | ||
8450 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8451 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8452 | count, | |
8453 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8454 | count * sizeof(struct bgp_nexthop_cache))); | |
8455 | ||
8456 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8457 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8458 | count, | |
8459 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8460 | count * sizeof(struct bgp_damp_info))); | |
8461 | ||
8462 | /* Attributes */ | |
8463 | count = attr_count(); | |
8464 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8465 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8466 | count * sizeof(struct attr))); | |
8467 | ||
8468 | if ((count = attr_unknown_count())) | |
8469 | vty_out(vty, "%ld unknown attributes\n", count); | |
8470 | ||
8471 | /* AS_PATH attributes */ | |
8472 | count = aspath_count(); | |
8473 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8474 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8475 | count * sizeof(struct aspath))); | |
8476 | ||
8477 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8478 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8479 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8480 | count * sizeof(struct assegment))); | |
8481 | ||
8482 | /* Other attributes */ | |
8483 | if ((count = community_count())) | |
8484 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8485 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8486 | count * sizeof(struct community))); | |
d62a17ae | 8487 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8488 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8489 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8490 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8491 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8492 | vty_out(vty, | |
8493 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8494 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8495 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8496 | |
8497 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8498 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8499 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8500 | count * sizeof(struct cluster_list))); | |
8501 | ||
8502 | /* Peer related usage */ | |
8503 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8504 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8505 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8506 | count * sizeof(struct peer))); | |
8507 | ||
8508 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8509 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8510 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8511 | count * sizeof(struct peer_group))); | |
8512 | ||
8513 | /* Other */ | |
d62a17ae | 8514 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8515 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8516 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8517 | count * sizeof(regex_t))); | |
d62a17ae | 8518 | return CMD_SUCCESS; |
4bf6a362 | 8519 | } |
fee0f4c6 | 8520 | |
57a9c8a8 DS |
8521 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8522 | { | |
8523 | json_object *bestpath = json_object_new_object(); | |
8524 | ||
8525 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
8526 | json_object_string_add(bestpath, "asPath", "ignore"); | |
8527 | ||
8528 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
8529 | json_object_string_add(bestpath, "asPath", "confed"); | |
8530 | ||
8531 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
8532 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
8533 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
8534 | "as-set"); |
8535 | else | |
a4d82a8a | 8536 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8537 | "true"); |
8538 | } else | |
a4d82a8a | 8539 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
8540 | |
8541 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
8542 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
8543 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
8544 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8545 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8546 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
8547 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
8548 | json_object_string_add(bestpath, "med", | |
8549 | "missing-as-worst"); | |
8550 | else | |
8551 | json_object_string_add(bestpath, "med", "true"); | |
8552 | } | |
8553 | ||
8554 | json_object_object_add(json, "bestPath", bestpath); | |
8555 | } | |
8556 | ||
3577f1c5 DD |
8557 | /* Print the error code/subcode for why the peer is down */ |
8558 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8559 | json_object *json_peer, bool use_json) | |
8560 | { | |
8561 | const char *code_str; | |
8562 | const char *subcode_str; | |
8563 | ||
8564 | if (use_json) { | |
8565 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8566 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8567 | char errorcodesubcode_hexstr[5]; | |
8568 | char errorcodesubcode_str[256]; | |
8569 | ||
8570 | code_str = bgp_notify_code_str(peer->notify.code); | |
8571 | subcode_str = bgp_notify_subcode_str( | |
8572 | peer->notify.code, | |
8573 | peer->notify.subcode); | |
8574 | ||
8575 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
8576 | peer->notify.code, peer->notify.subcode); | |
8577 | json_object_string_add(json_peer, | |
8578 | "lastErrorCodeSubcode", | |
8579 | errorcodesubcode_hexstr); | |
8580 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8581 | code_str, subcode_str); | |
8582 | json_object_string_add(json_peer, | |
8583 | "lastNotificationReason", | |
8584 | errorcodesubcode_str); | |
8585 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8586 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8587 | && (peer->notify.subcode | |
8588 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8589 | || peer->notify.subcode | |
8590 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8591 | && peer->notify.length) { | |
8592 | char msgbuf[1024]; | |
8593 | const char *msg_str; | |
8594 | ||
8595 | msg_str = bgp_notify_admin_message( | |
8596 | msgbuf, sizeof(msgbuf), | |
8597 | (uint8_t *)peer->notify.data, | |
8598 | peer->notify.length); | |
8599 | if (msg_str) | |
8600 | json_object_string_add( | |
8601 | json_peer, | |
8602 | "lastShutdownDescription", | |
8603 | msg_str); | |
8604 | } | |
8605 | ||
c258527b | 8606 | } |
3577f1c5 DD |
8607 | json_object_string_add(json_peer, "lastResetDueTo", |
8608 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8609 | json_object_int_add(json_peer, "lastResetCode", |
8610 | peer->last_reset); | |
3577f1c5 DD |
8611 | } else { |
8612 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8613 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8614 | code_str = bgp_notify_code_str(peer->notify.code); | |
8615 | subcode_str = | |
8616 | bgp_notify_subcode_str(peer->notify.code, | |
8617 | peer->notify.subcode); | |
8618 | vty_out(vty, " Notification %s (%s%s)\n", | |
8619 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8620 | ? "sent" | |
8621 | : "received", | |
8622 | code_str, subcode_str); | |
8623 | } else { | |
8624 | vty_out(vty, " %s\n", | |
8625 | peer_down_str[(int)peer->last_reset]); | |
8626 | } | |
8627 | } | |
8628 | } | |
8629 | ||
8630 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8631 | safi_t safi) | |
8632 | { | |
8633 | return ((peer->status != Established) || | |
8634 | !peer->afc_recv[afi][safi]); | |
8635 | } | |
8636 | ||
8637 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8638 | struct peer *peer, json_object *json_peer, | |
8639 | int max_neighbor_width, bool use_json) | |
8640 | { | |
8641 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8642 | int len; | |
8643 | ||
8644 | if (use_json) { | |
8645 | if (peer_dynamic_neighbor(peer)) | |
8646 | json_object_boolean_true_add(json_peer, | |
8647 | "dynamicPeer"); | |
8648 | if (peer->hostname) | |
8649 | json_object_string_add(json_peer, "hostname", | |
8650 | peer->hostname); | |
8651 | ||
8652 | if (peer->domainname) | |
8653 | json_object_string_add(json_peer, "domainname", | |
8654 | peer->domainname); | |
8655 | json_object_int_add(json_peer, "connectionsEstablished", | |
8656 | peer->established); | |
8657 | json_object_int_add(json_peer, "connectionsDropped", | |
8658 | peer->dropped); | |
8659 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8660 | use_json, json_peer); | |
8661 | if (peer->status == Established) | |
8662 | json_object_string_add(json_peer, "lastResetDueTo", | |
8663 | "AFI/SAFI Not Negotiated"); | |
8664 | else | |
8665 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8666 | } else { | |
8667 | dn_flag[1] = '\0'; | |
8668 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8669 | if (peer->hostname | |
8670 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8671 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8672 | peer->hostname, peer->host); | |
8673 | else | |
8674 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8675 | ||
8676 | /* pad the neighbor column with spaces */ | |
8677 | if (len < max_neighbor_width) | |
8678 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8679 | " "); | |
8680 | vty_out(vty, "%7d %7d %8s", peer->established, | |
8681 | peer->dropped, | |
8682 | peer_uptime(peer->uptime, timebuf, | |
8683 | BGP_UPTIME_LEN, 0, NULL)); | |
8684 | if (peer->status == Established) | |
8685 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8686 | else | |
8687 | bgp_show_peer_reset(vty, peer, NULL, | |
8688 | false); | |
8689 | } | |
8690 | } | |
c258527b | 8691 | |
3577f1c5 | 8692 | |
718e3744 | 8693 | /* Show BGP peer's summary information. */ |
d62a17ae | 8694 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8695 | bool show_failed, bool use_json) |
d62a17ae | 8696 | { |
8697 | struct peer *peer; | |
8698 | struct listnode *node, *nnode; | |
8699 | unsigned int count = 0, dn_count = 0; | |
8700 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8701 | char neighbor_buf[VTY_BUFSIZ]; | |
8702 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8703 | int len, failed_count = 0; |
d62a17ae | 8704 | int max_neighbor_width = 0; |
8705 | int pfx_rcd_safi; | |
3c13337d | 8706 | json_object *json = NULL; |
d62a17ae | 8707 | json_object *json_peer = NULL; |
8708 | json_object *json_peers = NULL; | |
50e05855 | 8709 | struct peer_af *paf; |
d62a17ae | 8710 | |
8711 | /* labeled-unicast routes are installed in the unicast table so in order | |
8712 | * to | |
8713 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8714 | */ | |
3577f1c5 | 8715 | |
d62a17ae | 8716 | if (safi == SAFI_LABELED_UNICAST) |
8717 | pfx_rcd_safi = SAFI_UNICAST; | |
8718 | else | |
8719 | pfx_rcd_safi = safi; | |
8720 | ||
8721 | if (use_json) { | |
3c13337d | 8722 | json = json_object_new_object(); |
d62a17ae | 8723 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8724 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8725 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8726 | continue; | |
8727 | ||
8728 | if (peer->afc[afi][safi]) { | |
8729 | /* See if we have at least a single failed peer */ | |
8730 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8731 | failed_count++; | |
8732 | count++; | |
8733 | } | |
8734 | if (peer_dynamic_neighbor(peer)) | |
8735 | dn_count++; | |
8736 | } | |
c258527b | 8737 | |
d62a17ae | 8738 | } else { |
8739 | /* Loop over all neighbors that will be displayed to determine | |
8740 | * how many | |
8741 | * characters are needed for the Neighbor column | |
8742 | */ | |
8743 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8744 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8745 | continue; | |
8746 | ||
8747 | if (peer->afc[afi][safi]) { | |
8748 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8749 | if (peer_dynamic_neighbor(peer)) | |
8750 | dn_flag[0] = '*'; | |
8751 | ||
8752 | if (peer->hostname | |
8753 | && bgp_flag_check(bgp, | |
8754 | BGP_FLAG_SHOW_HOSTNAME)) | |
8755 | sprintf(neighbor_buf, "%s%s(%s) ", | |
8756 | dn_flag, peer->hostname, | |
8757 | peer->host); | |
8758 | else | |
8759 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8760 | peer->host); | |
8761 | ||
8762 | len = strlen(neighbor_buf); | |
8763 | ||
8764 | if (len > max_neighbor_width) | |
8765 | max_neighbor_width = len; | |
c258527b | 8766 | |
3577f1c5 DD |
8767 | /* See if we have at least a single failed peer */ |
8768 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8769 | failed_count++; | |
8770 | count++; | |
d62a17ae | 8771 | } |
8772 | } | |
f933309e | 8773 | |
d62a17ae | 8774 | /* Originally we displayed the Neighbor column as 16 |
8775 | * characters wide so make that the default | |
8776 | */ | |
8777 | if (max_neighbor_width < neighbor_col_default_width) | |
8778 | max_neighbor_width = neighbor_col_default_width; | |
8779 | } | |
f933309e | 8780 | |
3577f1c5 DD |
8781 | if (show_failed && !failed_count) { |
8782 | if (use_json) { | |
8783 | json_object_int_add(json, "failedPeersCount", 0); | |
8784 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8785 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8786 | |
8787 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8788 | json, JSON_C_TO_STRING_PRETTY)); | |
8789 | json_object_free(json); | |
8790 | } else { | |
8791 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8792 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8793 | } | |
8794 | return CMD_SUCCESS; | |
8795 | } | |
c258527b | 8796 | |
3577f1c5 | 8797 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8798 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8799 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8800 | continue; | |
8801 | ||
ea47320b DL |
8802 | if (!peer->afc[afi][safi]) |
8803 | continue; | |
d62a17ae | 8804 | |
ea47320b DL |
8805 | if (!count) { |
8806 | unsigned long ents; | |
8807 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8808 | int64_t vrf_id_ui; |
d62a17ae | 8809 | |
a4d82a8a PZ |
8810 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8811 | ? -1 | |
8812 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8813 | |
8814 | /* Usage summary and header */ | |
8815 | if (use_json) { | |
8816 | json_object_string_add( | |
8817 | json, "routerId", | |
8818 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8819 | json_object_int_add(json, "as", bgp->as); |
8820 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8821 | json_object_string_add( |
8822 | json, "vrfName", | |
8823 | (bgp->inst_type | |
8824 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8825 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8826 | : bgp->name); |
8827 | } else { | |
8828 | vty_out(vty, | |
8829 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8830 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8831 | bgp->vrf_id == VRF_UNKNOWN |
8832 | ? -1 | |
8833 | : (int)bgp->vrf_id); | |
ea47320b DL |
8834 | vty_out(vty, "\n"); |
8835 | } | |
d62a17ae | 8836 | |
ea47320b | 8837 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8838 | if (use_json) { |
ea47320b | 8839 | json_object_int_add( |
60466a63 | 8840 | json, "updateDelayLimit", |
ea47320b | 8841 | bgp->v_update_delay); |
d62a17ae | 8842 | |
ea47320b DL |
8843 | if (bgp->v_update_delay |
8844 | != bgp->v_establish_wait) | |
d62a17ae | 8845 | json_object_int_add( |
8846 | json, | |
ea47320b DL |
8847 | "updateDelayEstablishWait", |
8848 | bgp->v_establish_wait); | |
d62a17ae | 8849 | |
60466a63 | 8850 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8851 | json_object_string_add( |
8852 | json, | |
8853 | "updateDelayFirstNeighbor", | |
8854 | bgp->update_delay_begin_time); | |
8855 | json_object_boolean_true_add( | |
8856 | json, | |
8857 | "updateDelayInProgress"); | |
8858 | } else { | |
8859 | if (bgp->update_delay_over) { | |
d62a17ae | 8860 | json_object_string_add( |
8861 | json, | |
8862 | "updateDelayFirstNeighbor", | |
8863 | bgp->update_delay_begin_time); | |
ea47320b | 8864 | json_object_string_add( |
d62a17ae | 8865 | json, |
ea47320b DL |
8866 | "updateDelayBestpathResumed", |
8867 | bgp->update_delay_end_time); | |
8868 | json_object_string_add( | |
d62a17ae | 8869 | json, |
ea47320b DL |
8870 | "updateDelayZebraUpdateResume", |
8871 | bgp->update_delay_zebra_resume_time); | |
8872 | json_object_string_add( | |
8873 | json, | |
8874 | "updateDelayPeerUpdateResume", | |
8875 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8876 | } |
ea47320b DL |
8877 | } |
8878 | } else { | |
8879 | vty_out(vty, | |
8880 | "Read-only mode update-delay limit: %d seconds\n", | |
8881 | bgp->v_update_delay); | |
8882 | if (bgp->v_update_delay | |
8883 | != bgp->v_establish_wait) | |
d62a17ae | 8884 | vty_out(vty, |
ea47320b DL |
8885 | " Establish wait: %d seconds\n", |
8886 | bgp->v_establish_wait); | |
d62a17ae | 8887 | |
60466a63 | 8888 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8889 | vty_out(vty, |
8890 | " First neighbor established: %s\n", | |
8891 | bgp->update_delay_begin_time); | |
8892 | vty_out(vty, | |
8893 | " Delay in progress\n"); | |
8894 | } else { | |
8895 | if (bgp->update_delay_over) { | |
d62a17ae | 8896 | vty_out(vty, |
8897 | " First neighbor established: %s\n", | |
8898 | bgp->update_delay_begin_time); | |
8899 | vty_out(vty, | |
ea47320b DL |
8900 | " Best-paths resumed: %s\n", |
8901 | bgp->update_delay_end_time); | |
8902 | vty_out(vty, | |
8903 | " zebra update resumed: %s\n", | |
8904 | bgp->update_delay_zebra_resume_time); | |
8905 | vty_out(vty, | |
8906 | " peers update resumed: %s\n", | |
8907 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8908 | } |
8909 | } | |
8910 | } | |
ea47320b | 8911 | } |
d62a17ae | 8912 | |
ea47320b DL |
8913 | if (use_json) { |
8914 | if (bgp_maxmed_onstartup_configured(bgp) | |
8915 | && bgp->maxmed_active) | |
8916 | json_object_boolean_true_add( | |
60466a63 | 8917 | json, "maxMedOnStartup"); |
ea47320b DL |
8918 | if (bgp->v_maxmed_admin) |
8919 | json_object_boolean_true_add( | |
60466a63 | 8920 | json, "maxMedAdministrative"); |
d62a17ae | 8921 | |
ea47320b DL |
8922 | json_object_int_add( |
8923 | json, "tableVersion", | |
60466a63 | 8924 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8925 | |
60466a63 QY |
8926 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8927 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8928 | json_object_int_add( |
8929 | json, "ribMemory", | |
8930 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8931 | |
210ec2a0 | 8932 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8933 | json_object_int_add(json, "peerCount", ents); |
8934 | json_object_int_add(json, "peerMemory", | |
8935 | ents * sizeof(struct peer)); | |
d62a17ae | 8936 | |
ea47320b DL |
8937 | if ((ents = listcount(bgp->group))) { |
8938 | json_object_int_add( | |
60466a63 | 8939 | json, "peerGroupCount", ents); |
ea47320b DL |
8940 | json_object_int_add( |
8941 | json, "peerGroupMemory", | |
996c9314 LB |
8942 | ents * sizeof(struct |
8943 | peer_group)); | |
ea47320b | 8944 | } |
d62a17ae | 8945 | |
ea47320b DL |
8946 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8947 | BGP_CONFIG_DAMPENING)) | |
8948 | json_object_boolean_true_add( | |
60466a63 | 8949 | json, "dampeningEnabled"); |
ea47320b DL |
8950 | } else { |
8951 | if (bgp_maxmed_onstartup_configured(bgp) | |
8952 | && bgp->maxmed_active) | |
d62a17ae | 8953 | vty_out(vty, |
ea47320b DL |
8954 | "Max-med on-startup active\n"); |
8955 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8956 | vty_out(vty, |
ea47320b | 8957 | "Max-med administrative active\n"); |
d62a17ae | 8958 | |
60466a63 QY |
8959 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8960 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8961 | |
60466a63 | 8962 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8963 | vty_out(vty, |
8964 | "RIB entries %ld, using %s of memory\n", | |
8965 | ents, | |
996c9314 LB |
8966 | mtype_memstr(memstrbuf, |
8967 | sizeof(memstrbuf), | |
8968 | ents * sizeof(struct | |
8969 | bgp_node))); | |
ea47320b DL |
8970 | |
8971 | /* Peer related usage */ | |
210ec2a0 | 8972 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8973 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8974 | ents, |
8975 | mtype_memstr( | |
60466a63 QY |
8976 | memstrbuf, sizeof(memstrbuf), |
8977 | ents * sizeof(struct peer))); | |
ea47320b DL |
8978 | |
8979 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8980 | vty_out(vty, |
ea47320b | 8981 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8982 | ents, |
8983 | mtype_memstr( | |
8984 | memstrbuf, | |
8985 | sizeof(memstrbuf), | |
996c9314 LB |
8986 | ents * sizeof(struct |
8987 | peer_group))); | |
d62a17ae | 8988 | |
ea47320b DL |
8989 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8990 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8991 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8992 | vty_out(vty, "\n"); |
d62a17ae | 8993 | |
ea47320b DL |
8994 | /* Subtract 8 here because 'Neighbor' is |
8995 | * 8 characters */ | |
8996 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8997 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8998 | " "); | |
3577f1c5 DD |
8999 | if (show_failed) |
9000 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9001 | else | |
9002 | vty_out(vty, | |
ea47320b | 9003 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 9004 | } |
ea47320b | 9005 | } |
d62a17ae | 9006 | |
ea47320b | 9007 | count++; |
3577f1c5 DD |
9008 | /* Works for both failed & successful cases */ |
9009 | if (peer_dynamic_neighbor(peer)) | |
9010 | dn_count++; | |
d62a17ae | 9011 | |
ea47320b | 9012 | if (use_json) { |
3577f1c5 DD |
9013 | json_peer = NULL; |
9014 | ||
9015 | if (show_failed && | |
9016 | bgp_has_peer_failed(peer, afi, safi)) { | |
9017 | json_peer = json_object_new_object(); | |
9018 | bgp_show_failed_summary(vty, bgp, peer, | |
9019 | json_peer, 0, use_json); | |
9020 | } else if (!show_failed) { | |
9021 | json_peer = json_object_new_object(); | |
9022 | if (peer_dynamic_neighbor(peer)) { | |
9023 | json_object_boolean_true_add(json_peer, | |
9024 | "dynamicPeer"); | |
9025 | } | |
d62a17ae | 9026 | |
3577f1c5 DD |
9027 | if (peer->hostname) |
9028 | json_object_string_add(json_peer, "hostname", | |
9029 | peer->hostname); | |
9030 | ||
9031 | if (peer->domainname) | |
9032 | json_object_string_add(json_peer, "domainname", | |
9033 | peer->domainname); | |
9034 | ||
9035 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9036 | json_object_int_add(json_peer, "version", 4); | |
9037 | json_object_int_add(json_peer, "msgRcvd", | |
9038 | PEER_TOTAL_RX(peer)); | |
9039 | json_object_int_add(json_peer, "msgSent", | |
9040 | PEER_TOTAL_TX(peer)); | |
9041 | ||
9042 | json_object_int_add(json_peer, "tableVersion", | |
9043 | peer->version[afi][safi]); | |
9044 | json_object_int_add(json_peer, "outq", | |
9045 | peer->obuf->count); | |
9046 | json_object_int_add(json_peer, "inq", 0); | |
9047 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9048 | use_json, json_peer); | |
9049 | ||
9050 | /* | |
9051 | * Adding "pfxRcd" field to match with the corresponding | |
9052 | * CLI. "prefixReceivedCount" will be deprecated in | |
9053 | * future. | |
9054 | */ | |
9055 | json_object_int_add(json_peer, "prefixReceivedCount", | |
9056 | peer->pcount[afi][pfx_rcd_safi]); | |
9057 | json_object_int_add(json_peer, "pfxRcd", | |
9058 | peer->pcount[afi][pfx_rcd_safi]); | |
9059 | ||
9060 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
9061 | if (paf && PAF_SUBGRP(paf)) | |
9062 | json_object_int_add(json_peer, | |
9063 | "pfxSnt", | |
9064 | (PAF_SUBGRP(paf))->scount); | |
9065 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9066 | json_object_string_add(json_peer, "state", | |
9067 | "Idle (Admin)"); | |
9068 | else if (peer->afc_recv[afi][safi]) | |
9069 | json_object_string_add( | |
9070 | json_peer, "state", | |
9071 | lookup_msg(bgp_status_msg, peer->status, | |
9072 | NULL)); | |
9073 | else if (CHECK_FLAG(peer->sflags, | |
9074 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9075 | json_object_string_add(json_peer, "state", | |
9076 | "Idle (PfxCt)"); | |
9077 | else | |
9078 | json_object_string_add( | |
9079 | json_peer, "state", | |
9080 | lookup_msg(bgp_status_msg, peer->status, | |
9081 | NULL)); | |
200116db DD |
9082 | json_object_int_add(json_peer, "connectionsEstablished", |
9083 | peer->established); | |
9084 | json_object_int_add(json_peer, "connectionsDropped", | |
9085 | peer->dropped); | |
b4e9dcba | 9086 | } |
3577f1c5 DD |
9087 | /* Avoid creating empty peer dicts in JSON */ |
9088 | if (json_peer == NULL) | |
9089 | continue; | |
ea47320b DL |
9090 | |
9091 | if (peer->conf_if) | |
60466a63 | 9092 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9093 | "interface"); |
9094 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9095 | json_object_string_add(json_peer, "idType", |
9096 | "ipv4"); | |
ea47320b | 9097 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9098 | json_object_string_add(json_peer, "idType", |
9099 | "ipv6"); | |
ea47320b DL |
9100 | json_object_object_add(json_peers, peer->host, |
9101 | json_peer); | |
9102 | } else { | |
3577f1c5 DD |
9103 | if (show_failed && |
9104 | bgp_has_peer_failed(peer, afi, safi)) { | |
9105 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9106 | max_neighbor_width, | |
9107 | use_json); | |
9108 | } else if (!show_failed) { | |
9109 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9110 | if (peer_dynamic_neighbor(peer)) { | |
9111 | dn_flag[0] = '*'; | |
9112 | } | |
d62a17ae | 9113 | |
3577f1c5 DD |
9114 | if (peer->hostname |
9115 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
9116 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
9117 | peer->hostname, peer->host); | |
d62a17ae | 9118 | else |
3577f1c5 DD |
9119 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9120 | ||
9121 | /* pad the neighbor column with spaces */ | |
9122 | if (len < max_neighbor_width) | |
9123 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9124 | " "); | |
9125 | ||
9126 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", | |
9127 | peer->as, PEER_TOTAL_RX(peer), | |
9128 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
9129 | 0, peer->obuf->count, | |
9130 | peer_uptime(peer->uptime, timebuf, | |
9131 | BGP_UPTIME_LEN, 0, NULL)); | |
9132 | ||
9133 | if (peer->status == Established) | |
9134 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
9135 | vty_out(vty, " %12" PRIu32, |
9136 | peer->pcount | |
9137 | [afi] | |
9138 | [pfx_rcd_safi]); | |
3577f1c5 DD |
9139 | else |
9140 | vty_out(vty, " NoNeg"); | |
9141 | else { | |
9142 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9143 | vty_out(vty, " Idle (Admin)"); | |
9144 | else if (CHECK_FLAG( | |
9145 | peer->sflags, | |
9146 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9147 | vty_out(vty, " Idle (PfxCt)"); | |
9148 | else | |
9149 | vty_out(vty, " %12s", | |
9150 | lookup_msg(bgp_status_msg, | |
9151 | peer->status, NULL)); | |
9152 | } | |
9153 | vty_out(vty, "\n"); | |
d62a17ae | 9154 | } |
3577f1c5 | 9155 | |
d62a17ae | 9156 | } |
9157 | } | |
f933309e | 9158 | |
d62a17ae | 9159 | if (use_json) { |
9160 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9161 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9162 | json_object_int_add(json, "totalPeers", count); |
9163 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9164 | ||
3577f1c5 DD |
9165 | if (!show_failed) |
9166 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9167 | |
996c9314 LB |
9168 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9169 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9170 | json_object_free(json); |
9171 | } else { | |
9172 | if (count) | |
9173 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9174 | else { | |
d6ceaca3 | 9175 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9176 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9177 | } |
b05a1c8b | 9178 | |
d6ceaca3 | 9179 | if (dn_count) { |
d62a17ae | 9180 | vty_out(vty, "* - dynamic neighbor\n"); |
9181 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9182 | dn_count, bgp->dynamic_neighbors_limit); | |
9183 | } | |
9184 | } | |
1ff9a340 | 9185 | |
d62a17ae | 9186 | return CMD_SUCCESS; |
718e3744 | 9187 | } |
9188 | ||
d62a17ae | 9189 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9190 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9191 | { |
9192 | int is_first = 1; | |
9193 | int afi_wildcard = (afi == AFI_MAX); | |
9194 | int safi_wildcard = (safi == SAFI_MAX); | |
9195 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9196 | bool nbr_output = false; |
d62a17ae | 9197 | |
9198 | if (use_json && is_wildcard) | |
9199 | vty_out(vty, "{\n"); | |
9200 | if (afi_wildcard) | |
9201 | afi = 1; /* AFI_IP */ | |
9202 | while (afi < AFI_MAX) { | |
9203 | if (safi_wildcard) | |
9204 | safi = 1; /* SAFI_UNICAST */ | |
9205 | while (safi < SAFI_MAX) { | |
318cac96 | 9206 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9207 | nbr_output = true; |
f86897b9 | 9208 | |
d62a17ae | 9209 | if (is_wildcard) { |
9210 | /* | |
9211 | * So limit output to those afi/safi | |
9212 | * pairs that | |
9213 | * actualy have something interesting in | |
9214 | * them | |
9215 | */ | |
9216 | if (use_json) { | |
d62a17ae | 9217 | if (!is_first) |
9218 | vty_out(vty, ",\n"); | |
9219 | else | |
9220 | is_first = 0; | |
9221 | ||
9222 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9223 | get_afi_safi_str(afi, |
9224 | safi, | |
9225 | true)); | |
d62a17ae | 9226 | } else { |
9227 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9228 | get_afi_safi_str(afi, |
9229 | safi, | |
9230 | false)); | |
d62a17ae | 9231 | } |
9232 | } | |
3577f1c5 DD |
9233 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9234 | use_json); | |
d62a17ae | 9235 | } |
9236 | safi++; | |
d62a17ae | 9237 | if (!safi_wildcard) |
9238 | safi = SAFI_MAX; | |
9239 | } | |
9240 | afi++; | |
ee851c8c | 9241 | if (!afi_wildcard) |
d62a17ae | 9242 | afi = AFI_MAX; |
9243 | } | |
9244 | ||
9245 | if (use_json && is_wildcard) | |
9246 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9247 | else if (!nbr_output) { |
9248 | if (use_json) | |
9249 | vty_out(vty, "{}\n"); | |
9250 | else | |
9251 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9252 | } | |
d62a17ae | 9253 | } |
9254 | ||
9255 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9256 | safi_t safi, bool show_failed, |
9257 | bool use_json) | |
d62a17ae | 9258 | { |
9259 | struct listnode *node, *nnode; | |
9260 | struct bgp *bgp; | |
d62a17ae | 9261 | int is_first = 1; |
9f049418 | 9262 | bool nbr_output = false; |
d62a17ae | 9263 | |
9264 | if (use_json) | |
9265 | vty_out(vty, "{\n"); | |
9266 | ||
9267 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9268 | nbr_output = true; |
d62a17ae | 9269 | if (use_json) { |
d62a17ae | 9270 | if (!is_first) |
9271 | vty_out(vty, ",\n"); | |
9272 | else | |
9273 | is_first = 0; | |
9274 | ||
9275 | vty_out(vty, "\"%s\":", | |
9276 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9277 | ? VRF_DEFAULT_NAME |
d62a17ae | 9278 | : bgp->name); |
9279 | } else { | |
9280 | vty_out(vty, "\nInstance %s:\n", | |
9281 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9282 | ? VRF_DEFAULT_NAME |
d62a17ae | 9283 | : bgp->name); |
9284 | } | |
3577f1c5 DD |
9285 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9286 | use_json); | |
d62a17ae | 9287 | } |
9288 | ||
9289 | if (use_json) | |
9290 | vty_out(vty, "}\n"); | |
9f049418 DS |
9291 | else if (!nbr_output) |
9292 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9293 | } |
9294 | ||
9295 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9296 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9297 | { |
9298 | struct bgp *bgp; | |
9299 | ||
9300 | if (name) { | |
9301 | if (strmatch(name, "all")) { | |
9302 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9303 | show_failed, |
d62a17ae | 9304 | use_json); |
9305 | return CMD_SUCCESS; | |
9306 | } else { | |
9307 | bgp = bgp_lookup_by_name(name); | |
9308 | ||
9309 | if (!bgp) { | |
9310 | if (use_json) | |
9311 | vty_out(vty, "{}\n"); | |
9312 | else | |
9313 | vty_out(vty, | |
ca61fd25 | 9314 | "%% BGP instance not found\n"); |
d62a17ae | 9315 | return CMD_WARNING; |
9316 | } | |
9317 | ||
f86897b9 | 9318 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9319 | show_failed, use_json); |
d62a17ae | 9320 | return CMD_SUCCESS; |
9321 | } | |
9322 | } | |
9323 | ||
9324 | bgp = bgp_get_default(); | |
9325 | ||
9326 | if (bgp) | |
3577f1c5 DD |
9327 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9328 | use_json); | |
9f049418 | 9329 | else { |
ca61fd25 DS |
9330 | if (use_json) |
9331 | vty_out(vty, "{}\n"); | |
9332 | else | |
9333 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9334 | return CMD_WARNING; |
9335 | } | |
d62a17ae | 9336 | |
9337 | return CMD_SUCCESS; | |
4fb25c53 DW |
9338 | } |
9339 | ||
716b2d8a | 9340 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9341 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9342 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9343 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9344 | SHOW_STR |
9345 | IP_STR | |
9346 | BGP_STR | |
8386ac43 | 9347 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9348 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9349 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9350 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9351 | "Show only sessions not in Established state\n" |
9973d184 | 9352 | JSON_STR) |
718e3744 | 9353 | { |
d62a17ae | 9354 | char *vrf = NULL; |
9355 | afi_t afi = AFI_MAX; | |
9356 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9357 | bool show_failed = false; |
d62a17ae | 9358 | |
9359 | int idx = 0; | |
9360 | ||
9361 | /* show [ip] bgp */ | |
9362 | if (argv_find(argv, argc, "ip", &idx)) | |
9363 | afi = AFI_IP; | |
9a8bdf1c PG |
9364 | /* [<vrf> VIEWVRFNAME] */ |
9365 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9366 | vrf = argv[idx + 1]->arg; | |
9367 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9368 | vrf = NULL; | |
9369 | } else if (argv_find(argv, argc, "view", &idx)) | |
9370 | /* [<view> VIEWVRFNAME] */ | |
9371 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9372 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9373 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9374 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9375 | } | |
9376 | ||
3577f1c5 DD |
9377 | if (argv_find(argv, argc, "failed", &idx)) |
9378 | show_failed = true; | |
9379 | ||
9f049418 | 9380 | bool uj = use_json(argc, argv); |
d62a17ae | 9381 | |
3577f1c5 | 9382 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9383 | } |
9384 | ||
5cb5f4d0 | 9385 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9386 | { |
5cb5f4d0 DD |
9387 | if (for_json) |
9388 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9389 | else |
5cb5f4d0 | 9390 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9391 | } |
9392 | ||
d62a17ae | 9393 | |
9394 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9395 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9396 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9397 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9398 | bool use_json, json_object *json_pref) |
d62a17ae | 9399 | { |
9400 | /* Send-Mode */ | |
9401 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9402 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9403 | if (use_json) { | |
9404 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9405 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9406 | json_object_string_add(json_pref, "sendMode", | |
9407 | "advertisedAndReceived"); | |
9408 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9409 | json_object_string_add(json_pref, "sendMode", | |
9410 | "advertised"); | |
9411 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9412 | json_object_string_add(json_pref, "sendMode", | |
9413 | "received"); | |
9414 | } else { | |
9415 | vty_out(vty, " Send-mode: "); | |
9416 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9417 | vty_out(vty, "advertised"); | |
9418 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9419 | vty_out(vty, "%sreceived", | |
9420 | CHECK_FLAG(p->af_cap[afi][safi], | |
9421 | adv_smcap) | |
9422 | ? ", " | |
9423 | : ""); | |
9424 | vty_out(vty, "\n"); | |
9425 | } | |
9426 | } | |
9427 | ||
9428 | /* Receive-Mode */ | |
9429 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9430 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9431 | if (use_json) { | |
9432 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9433 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9434 | json_object_string_add(json_pref, "recvMode", | |
9435 | "advertisedAndReceived"); | |
9436 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9437 | json_object_string_add(json_pref, "recvMode", | |
9438 | "advertised"); | |
9439 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9440 | json_object_string_add(json_pref, "recvMode", | |
9441 | "received"); | |
9442 | } else { | |
9443 | vty_out(vty, " Receive-mode: "); | |
9444 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9445 | vty_out(vty, "advertised"); | |
9446 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9447 | vty_out(vty, "%sreceived", | |
9448 | CHECK_FLAG(p->af_cap[afi][safi], | |
9449 | adv_rmcap) | |
9450 | ? ", " | |
9451 | : ""); | |
9452 | vty_out(vty, "\n"); | |
9453 | } | |
9454 | } | |
9455 | } | |
9456 | ||
2986cac2 | 9457 | static void bgp_show_neighnor_graceful_restart_rbit( |
9458 | struct vty *vty, | |
9459 | struct peer *p, | |
9460 | bool use_json, | |
9461 | json_object *json) | |
9462 | { | |
9463 | bool rbit_status = 0; | |
9464 | ||
9465 | if (!use_json) | |
9466 | vty_out(vty, "\n R bit : "); | |
9467 | ||
9468 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
9469 | (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) && | |
9470 | (p->status == Established)) { | |
9471 | ||
9472 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
9473 | rbit_status = 1; | |
9474 | else | |
9475 | rbit_status = 0; | |
9476 | } | |
9477 | ||
9478 | if (rbit_status) { | |
9479 | if (use_json) | |
9480 | json_object_boolean_true_add( | |
9481 | json, "rBit"); | |
9482 | else | |
9483 | vty_out(vty, "True\n"); | |
9484 | } else { | |
9485 | if (use_json) | |
9486 | json_object_boolean_false_add( | |
9487 | json, "rBit"); | |
9488 | else | |
9489 | vty_out(vty, "False\n"); | |
9490 | } | |
9491 | } | |
9492 | ||
9493 | static void bgp_show_neighbor_graceful_restart_remote_mode( | |
9494 | struct vty *vty, | |
9495 | struct peer *peer, | |
9496 | bool use_json, | |
9497 | json_object *json) | |
9498 | { | |
2bb5d39b | 9499 | const char *mode = "NotApplicable"; |
2986cac2 | 9500 | |
9501 | if (!use_json) | |
9502 | vty_out(vty, "\n Remote GR Mode : "); | |
9503 | ||
9504 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) && | |
2986cac2 | 9505 | (peer->status == Established)) { |
9506 | ||
9507 | if ((peer->nsf_af_count == 0) && | |
9508 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
9509 | ||
2986cac2 | 9510 | mode = "Disable"; |
9511 | ||
2bb5d39b | 9512 | } else if (peer->nsf_af_count == 0 && |
9513 | CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9514 | |
2986cac2 | 9515 | mode = "Helper"; |
9516 | ||
2bb5d39b | 9517 | } else if (peer->nsf_af_count != 0 && |
9518 | CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9519 | |
2986cac2 | 9520 | mode = "Restart"; |
9521 | ||
9522 | } | |
9523 | } | |
9524 | ||
9525 | if (use_json) { | |
9526 | json_object_string_add(json, | |
9527 | "remoteGrMode", mode); | |
9528 | } else | |
9529 | vty_out(vty, mode, "\n"); | |
9530 | } | |
9531 | ||
9532 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, | |
9533 | struct peer *p, | |
9534 | bool use_json, | |
9535 | json_object *json) | |
9536 | { | |
9537 | const char *mode = "Invalid"; | |
9538 | ||
9539 | if (!use_json) | |
9540 | vty_out(vty, " Local GR Mode : "); | |
9541 | ||
9542 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9543 | mode = "Helper"; | |
9544 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9545 | mode = "Restart"; | |
9546 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9547 | mode = "Disable"; | |
2ba1fe69 | 9548 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9549 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9550 | mode = "Helper*"; | |
9551 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9552 | mode = "Restart*"; | |
9553 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9554 | mode = "Disable*"; | |
9555 | else | |
9556 | mode = "Invalid*"; | |
2ba1fe69 | 9557 | } |
2986cac2 | 9558 | |
9559 | if (use_json) { | |
9560 | json_object_string_add(json, | |
9561 | "localGrMode", mode); | |
9562 | } else { | |
9563 | vty_out(vty, mode, "\n"); | |
9564 | } | |
9565 | } | |
9566 | ||
9567 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( | |
9568 | struct vty *vty, struct peer *peer, | |
9569 | bool use_json, json_object *json) | |
9570 | { | |
2ba1fe69 | 9571 | afi_t afi; |
9572 | safi_t safi; | |
2986cac2 | 9573 | json_object *json_afi_safi = NULL; |
9574 | json_object *json_timer = NULL; | |
9575 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9576 | bool eor_flag = false; |
2986cac2 | 9577 | |
9578 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9579 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
3a75afa4 | 9580 | if (peer->afc[afi][safi] |
2986cac2 | 9581 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
3a75afa4 | 9582 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV) |
9583 | ) { | |
2986cac2 | 9584 | if (use_json) { |
9585 | json_afi_safi = | |
9586 | json_object_new_object(); | |
9587 | json_endofrib_status = | |
9588 | json_object_new_object(); | |
9589 | json_timer = | |
9590 | json_object_new_object(); | |
9591 | } | |
9592 | ||
9e3b51a7 | 9593 | if (peer->eor_stime[afi][safi] >= |
9594 | peer->pkt_stime[afi][safi]) | |
9595 | eor_flag = true; | |
9596 | else | |
9597 | eor_flag = false; | |
9598 | ||
2986cac2 | 9599 | if (!use_json) { |
9600 | vty_out(vty, " %s :\n", | |
9601 | get_afi_safi_str(afi, safi, false)); | |
9602 | ||
9603 | vty_out(vty, | |
9604 | " F bit : "); | |
9605 | } else | |
9606 | get_afi_safi_str(afi, safi, true); | |
9607 | ||
9608 | if (peer->nsf[afi][safi] | |
9609 | && CHECK_FLAG( | |
9610 | peer->af_cap[afi][safi], | |
9611 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
9612 | ||
9613 | if (use_json) { | |
9614 | json_object_boolean_true_add( | |
9615 | json_afi_safi, "fBit"); | |
9616 | } else { | |
9617 | vty_out(vty, | |
9618 | "True\n"); | |
9619 | } | |
9620 | ||
9621 | } else { | |
9622 | ||
9623 | if (use_json) { | |
9624 | json_object_boolean_false_add( | |
9625 | json_afi_safi, "fBit"); | |
9626 | } else { | |
9627 | vty_out(vty, | |
9628 | "False\n"); | |
9629 | } | |
9630 | ||
9631 | } | |
9632 | ||
9633 | if (!use_json) | |
9634 | vty_out(vty, | |
9635 | " End-of-RIB Received : "); | |
9636 | ||
9637 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9638 | PEER_STATUS_EOR_RECEIVED)) { | |
9639 | ||
9640 | if (use_json) { | |
9641 | json_object_boolean_true_add( | |
9642 | json_endofrib_status, | |
9643 | "endOfRibRecv"); | |
9644 | } else { | |
9645 | vty_out(vty, "Yes\n"); | |
9646 | } | |
9647 | ||
9648 | } else { | |
9649 | if (use_json) { | |
9650 | json_object_boolean_false_add( | |
9651 | json_endofrib_status, | |
9652 | "endOfRibRecv"); | |
9653 | } else { | |
9654 | vty_out(vty, "No\n"); | |
9655 | } | |
9656 | } | |
9657 | ||
9658 | if (!use_json) | |
9659 | vty_out(vty, | |
9660 | " End-of-RIB Send : "); | |
9661 | ||
9662 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9663 | PEER_STATUS_EOR_SEND)) { | |
2986cac2 | 9664 | if (use_json) { |
9665 | json_object_boolean_true_add( | |
9666 | json_endofrib_status, | |
9667 | "endOfRibSend"); | |
9e3b51a7 | 9668 | |
9669 | PRINT_EOR_JSON(eor_flag); | |
2986cac2 | 9670 | } else { |
9671 | vty_out(vty, "Yes\n"); | |
9e3b51a7 | 9672 | vty_out(vty, |
9673 | " EoRSentAfterUpdate : "); | |
2986cac2 | 9674 | |
9e3b51a7 | 9675 | PRINT_EOR(eor_flag); |
9676 | } | |
2986cac2 | 9677 | } else { |
9678 | if (use_json) { | |
9679 | json_object_boolean_false_add( | |
9680 | json_endofrib_status, | |
9681 | "endOfRibSend"); | |
9e3b51a7 | 9682 | json_object_boolean_false_add( |
9683 | json_endofrib_status, | |
9684 | "endOfRibSentAfterUpdate"); | |
2986cac2 | 9685 | } else { |
9686 | vty_out(vty, "No\n"); | |
9e3b51a7 | 9687 | vty_out(vty, |
9688 | " EoRSentAfterUpdate : "); | |
9689 | vty_out(vty, "No\n"); | |
2986cac2 | 9690 | } |
9691 | } | |
9692 | ||
9693 | if (use_json) { | |
9694 | ||
9695 | json_object_int_add(json_timer, | |
9696 | "stalePathTimer", | |
9697 | peer->bgp->stalepath_time); | |
9698 | ||
9699 | if (peer->t_gr_stale != NULL) { | |
9700 | ||
9701 | json_object_int_add( | |
9702 | json_timer, | |
9703 | "stalePathTimerRemaining", | |
9704 | thread_timer_remain_second( | |
9705 | peer->t_gr_stale)); | |
9706 | } | |
9707 | ||
3a75afa4 | 9708 | /* Display Configured Selection |
9709 | * Deferral only when when | |
9710 | * Gr mode is enabled. | |
9711 | */ | |
9712 | if (CHECK_FLAG(peer->flags, | |
9713 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9714 | ||
9715 | json_object_int_add( | |
9716 | json_timer, | |
2986cac2 | 9717 | "selectionDeferralTimer", |
9718 | peer->bgp->stalepath_time); | |
3a75afa4 | 9719 | } |
2986cac2 | 9720 | |
dc95985f | 9721 | if (peer->bgp->gr_info[afi][safi] |
2986cac2 | 9722 | .t_select_deferral != NULL) { |
9723 | ||
9724 | json_object_int_add( | |
9725 | json_timer, | |
9726 | "selectionDeferralTimerRemaining", | |
9727 | thread_timer_remain_second( | |
9728 | peer->bgp | |
9729 | ->gr_info[afi][safi] | |
9730 | .t_select_deferral)); | |
9731 | } | |
9732 | ||
9733 | } else { | |
9734 | ||
9735 | vty_out(vty, " Timers:\n"); | |
9736 | ||
9737 | vty_out(vty, "%*s", 6, ""); | |
9738 | vty_out(vty, | |
3a75afa4 | 9739 | "Configured Stale Path Time(sec)%*s: %u\n", |
9740 | 8, "", | |
2986cac2 | 9741 | peer->bgp->stalepath_time); |
9742 | ||
9743 | if (peer->t_gr_stale != NULL) { | |
9744 | vty_out(vty, "%*s", 6, ""); | |
9745 | vty_out(vty, | |
9746 | "Stale Path Remaining(sec)%*s: %ld\n", | |
9747 | 14, "", | |
9748 | thread_timer_remain_second( | |
9749 | peer->t_gr_stale)); | |
9750 | } | |
3a75afa4 | 9751 | /* Display Configured Selection |
9752 | * Deferral only when when | |
9753 | * Gr mode is enabled. | |
9754 | */ | |
9755 | if (CHECK_FLAG(peer->flags, | |
9756 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9757 | vty_out(vty, "%*s", 6, ""); | |
9758 | vty_out(vty, | |
9759 | "Configured Selection Deferral Time(sec): %u\n", | |
9760 | peer->bgp->select_defer_time); | |
9761 | } | |
2986cac2 | 9762 | |
9763 | if (peer->bgp | |
9764 | ->gr_info[afi][safi] | |
9765 | .t_select_deferral != NULL) { | |
9766 | ||
9767 | vty_out(vty, "%*s", 6, ""); | |
9768 | vty_out(vty, | |
9769 | "Selection Deferral Time Remaining(sec) : %ld\n", | |
9770 | thread_timer_remain_second( | |
9771 | peer->bgp | |
9772 | ->gr_info[afi][safi] | |
9773 | .t_select_deferral)); | |
9774 | } | |
9775 | ||
9776 | } | |
9777 | if (use_json) { | |
9778 | json_object_object_add(json_afi_safi, | |
9779 | "endOfRibStatus", | |
9780 | json_endofrib_status); | |
9781 | json_object_object_add(json_afi_safi, | |
9782 | "timers", | |
9783 | json_timer); | |
9784 | json_object_object_add(json, | |
9785 | get_afi_safi_str(afi, safi, true), | |
9786 | json_afi_safi); | |
9787 | } | |
9788 | } | |
9789 | } | |
9790 | } | |
9791 | } | |
9792 | ||
9793 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, | |
9794 | struct peer *p, | |
9795 | bool use_json, | |
9796 | json_object *json) | |
9797 | { | |
9798 | if (use_json) { | |
9799 | json_object *json_timer = NULL; | |
9800 | ||
9801 | json_timer = json_object_new_object(); | |
9802 | ||
9803 | json_object_int_add(json_timer, | |
9804 | "configuredRestartTimer", | |
9805 | p->bgp->restart_time); | |
9806 | ||
9807 | json_object_int_add(json_timer, | |
2ba1fe69 | 9808 | "receivedRestartTimer", |
2986cac2 | 9809 | p->v_gr_restart); |
9810 | ||
9811 | if (p->t_gr_restart != NULL) { | |
9812 | json_object_int_add(json_timer, | |
9813 | "restartTimerRemaining", | |
9814 | thread_timer_remain_second( | |
9815 | p->t_gr_restart) | |
9816 | ); | |
9817 | } | |
9818 | ||
9819 | json_object_object_add(json, "timers", json_timer); | |
9820 | } else { | |
9821 | ||
9822 | vty_out(vty, " Timers :\n"); | |
9823 | vty_out(vty, | |
9824 | " Configured Restart Time(sec) : %u\n", | |
9825 | p->bgp->restart_time); | |
9826 | ||
9827 | vty_out(vty, | |
9828 | " Received Restart Time(sec) : %u\n", | |
9829 | p->v_gr_restart); | |
9830 | if (p->t_gr_restart != NULL) { | |
9831 | vty_out(vty, | |
9832 | " Restart Time Remaining(sec) : %ld\n", | |
9833 | thread_timer_remain_second( | |
9834 | p->t_gr_restart)); | |
9835 | } | |
9836 | } | |
9837 | } | |
9838 | ||
9839 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
9840 | bool use_json, | |
9841 | json_object *json) | |
9842 | { | |
9843 | char buf[SU_ADDRSTRLEN] = {0}; | |
9844 | char dn_flag[2] = {0}; | |
9845 | char neighborAddr[INET6_ADDRSTRLEN] = {0}; | |
9846 | ||
2986cac2 | 9847 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
9848 | dn_flag[0] = '*'; | |
9849 | ||
9850 | if (p->conf_if) { | |
9851 | if (use_json) | |
9852 | json_object_string_add(json, "neighborAddr", | |
9853 | BGP_PEER_SU_UNSPEC(p) | |
9854 | ? "none" | |
9855 | : sockunion2str(&p->su, buf, | |
9856 | SU_ADDRSTRLEN)); | |
9857 | else | |
9858 | vty_out(vty, "BGP neighbor on %s: %s\n", | |
9859 | p->conf_if, | |
9860 | BGP_PEER_SU_UNSPEC(p) | |
9861 | ? "none" | |
9862 | : sockunion2str(&p->su, buf, | |
9863 | SU_ADDRSTRLEN)); | |
9864 | } else { | |
9865 | sprintf(neighborAddr, "%s%s", dn_flag, p->host); | |
9866 | ||
9867 | if (use_json) | |
9868 | json_object_string_add( | |
9869 | json, "neighborAddr", | |
9870 | neighborAddr); | |
9871 | else | |
9872 | vty_out(vty, "BGP neighbor is %s\n", | |
9873 | neighborAddr); | |
9874 | } | |
9875 | ||
9876 | /* more gr info in new format */ | |
9877 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9878 | } | |
9879 | ||
d62a17ae | 9880 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9881 | safi_t safi, bool use_json, |
d62a17ae | 9882 | json_object *json_neigh) |
9883 | { | |
0291c246 MK |
9884 | struct bgp_filter *filter; |
9885 | struct peer_af *paf; | |
9886 | char orf_pfx_name[BUFSIZ]; | |
9887 | int orf_pfx_count; | |
9888 | json_object *json_af = NULL; | |
9889 | json_object *json_prefA = NULL; | |
9890 | json_object *json_prefB = NULL; | |
9891 | json_object *json_addr = NULL; | |
d62a17ae | 9892 | |
9893 | if (use_json) { | |
9894 | json_addr = json_object_new_object(); | |
9895 | json_af = json_object_new_object(); | |
9896 | filter = &p->filter[afi][safi]; | |
9897 | ||
9898 | if (peer_group_active(p)) | |
9899 | json_object_string_add(json_addr, "peerGroupMember", | |
9900 | p->group->name); | |
9901 | ||
9902 | paf = peer_af_find(p, afi, safi); | |
9903 | if (paf && PAF_SUBGRP(paf)) { | |
9904 | json_object_int_add(json_addr, "updateGroupId", | |
9905 | PAF_UPDGRP(paf)->id); | |
9906 | json_object_int_add(json_addr, "subGroupId", | |
9907 | PAF_SUBGRP(paf)->id); | |
9908 | json_object_int_add(json_addr, "packetQueueLength", | |
9909 | bpacket_queue_virtual_length(paf)); | |
9910 | } | |
9911 | ||
9912 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9913 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9914 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9915 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9916 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9917 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9918 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9919 | json_object_int_add(json_af, "orfType", | |
9920 | ORF_TYPE_PREFIX); | |
9921 | json_prefA = json_object_new_object(); | |
9922 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
9923 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
9924 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9925 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9926 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
9927 | use_json, json_prefA); | |
9928 | json_object_object_add(json_af, "orfPrefixList", | |
9929 | json_prefA); | |
9930 | } | |
9931 | ||
9932 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9933 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9934 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9935 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9936 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9937 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9938 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9939 | json_object_int_add(json_af, "orfOldType", | |
9940 | ORF_TYPE_PREFIX_OLD); | |
9941 | json_prefB = json_object_new_object(); | |
9942 | bgp_show_peer_afi_orf_cap( | |
9943 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9944 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9945 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9946 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9947 | json_prefB); | |
9948 | json_object_object_add(json_af, "orfOldPrefixList", | |
9949 | json_prefB); | |
9950 | } | |
9951 | ||
9952 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9953 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9954 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9955 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9956 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9957 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9958 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9959 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9960 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9961 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9962 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9963 | json_object_object_add(json_addr, "afDependentCap", | |
9964 | json_af); | |
9965 | else | |
9966 | json_object_free(json_af); | |
9967 | ||
9968 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9969 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9970 | NULL, afi, orf_pfx_name, use_json); | |
9971 | ||
9972 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9973 | PEER_STATUS_ORF_PREFIX_SEND) | |
9974 | || orf_pfx_count) { | |
9975 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9976 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9977 | json_object_boolean_true_add(json_neigh, | |
9978 | "orfSent"); | |
9979 | if (orf_pfx_count) | |
9980 | json_object_int_add(json_addr, "orfRecvCounter", | |
9981 | orf_pfx_count); | |
9982 | } | |
9983 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9984 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9985 | json_object_string_add( | |
9986 | json_addr, "orfFirstUpdate", | |
9987 | "deferredUntilORFOrRouteRefreshRecvd"); | |
9988 | ||
9989 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9990 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9991 | json_object_boolean_true_add(json_addr, | |
9992 | "routeReflectorClient"); | |
9993 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9994 | PEER_FLAG_RSERVER_CLIENT)) | |
9995 | json_object_boolean_true_add(json_addr, | |
9996 | "routeServerClient"); | |
9997 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9998 | json_object_boolean_true_add(json_addr, | |
9999 | "inboundSoftConfigPermit"); | |
10000 | ||
10001 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10002 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10003 | json_object_boolean_true_add( | |
10004 | json_addr, | |
10005 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10006 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10007 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10008 | json_object_boolean_true_add( | |
10009 | json_addr, | |
10010 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10011 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10012 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10013 | json_object_boolean_true_add( | |
10014 | json_addr, | |
10015 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10016 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10017 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10018 | json_object_boolean_true_add( | |
10019 | json_addr, | |
10020 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10021 | ||
dcc68b5e MS |
10022 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10023 | json_object_boolean_true_add( | |
10024 | json_addr, | |
10025 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10026 | ->type_json_name); | |
d62a17ae | 10027 | |
10028 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10029 | json_object_string_add(json_addr, | |
10030 | "overrideASNsInOutboundUpdates", | |
10031 | "ifAspathEqualRemoteAs"); | |
10032 | ||
10033 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10034 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10035 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10036 | json_object_boolean_true_add(json_addr, | |
10037 | "routerAlwaysNextHop"); | |
10038 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10039 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10040 | json_object_boolean_true_add( | |
10041 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10042 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10043 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10044 | json_object_boolean_true_add( | |
10045 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10046 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10047 | json_object_boolean_true_add( | |
10048 | json_addr, "unchangedMedPropogatedToNbr"); | |
10049 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10050 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10051 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10052 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10053 | PEER_FLAG_SEND_COMMUNITY) | |
10054 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10055 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10056 | json_object_string_add(json_addr, | |
10057 | "commAttriSentToNbr", | |
10058 | "extendedAndStandard"); | |
10059 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10060 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10061 | json_object_string_add(json_addr, | |
10062 | "commAttriSentToNbr", | |
10063 | "extended"); | |
10064 | else | |
10065 | json_object_string_add(json_addr, | |
10066 | "commAttriSentToNbr", | |
10067 | "standard"); | |
10068 | } | |
10069 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10070 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10071 | if (p->default_rmap[afi][safi].name) | |
10072 | json_object_string_add( | |
10073 | json_addr, "defaultRouteMap", | |
10074 | p->default_rmap[afi][safi].name); | |
10075 | ||
10076 | if (paf && PAF_SUBGRP(paf) | |
10077 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10078 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10079 | json_object_boolean_true_add(json_addr, | |
10080 | "defaultSent"); | |
10081 | else | |
10082 | json_object_boolean_true_add(json_addr, | |
10083 | "defaultNotSent"); | |
10084 | } | |
10085 | ||
dff8f48d | 10086 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10087 | if (is_evpn_enabled()) |
60466a63 QY |
10088 | json_object_boolean_true_add( |
10089 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10090 | } |
10091 | ||
d62a17ae | 10092 | if (filter->plist[FILTER_IN].name |
10093 | || filter->dlist[FILTER_IN].name | |
10094 | || filter->aslist[FILTER_IN].name | |
10095 | || filter->map[RMAP_IN].name) | |
10096 | json_object_boolean_true_add(json_addr, | |
10097 | "inboundPathPolicyConfig"); | |
10098 | if (filter->plist[FILTER_OUT].name | |
10099 | || filter->dlist[FILTER_OUT].name | |
10100 | || filter->aslist[FILTER_OUT].name | |
10101 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10102 | json_object_boolean_true_add( | |
10103 | json_addr, "outboundPathPolicyConfig"); | |
10104 | ||
10105 | /* prefix-list */ | |
10106 | if (filter->plist[FILTER_IN].name) | |
10107 | json_object_string_add(json_addr, | |
10108 | "incomingUpdatePrefixFilterList", | |
10109 | filter->plist[FILTER_IN].name); | |
10110 | if (filter->plist[FILTER_OUT].name) | |
10111 | json_object_string_add(json_addr, | |
10112 | "outgoingUpdatePrefixFilterList", | |
10113 | filter->plist[FILTER_OUT].name); | |
10114 | ||
10115 | /* distribute-list */ | |
10116 | if (filter->dlist[FILTER_IN].name) | |
10117 | json_object_string_add( | |
10118 | json_addr, "incomingUpdateNetworkFilterList", | |
10119 | filter->dlist[FILTER_IN].name); | |
10120 | if (filter->dlist[FILTER_OUT].name) | |
10121 | json_object_string_add( | |
10122 | json_addr, "outgoingUpdateNetworkFilterList", | |
10123 | filter->dlist[FILTER_OUT].name); | |
10124 | ||
10125 | /* filter-list. */ | |
10126 | if (filter->aslist[FILTER_IN].name) | |
10127 | json_object_string_add(json_addr, | |
10128 | "incomingUpdateAsPathFilterList", | |
10129 | filter->aslist[FILTER_IN].name); | |
10130 | if (filter->aslist[FILTER_OUT].name) | |
10131 | json_object_string_add(json_addr, | |
10132 | "outgoingUpdateAsPathFilterList", | |
10133 | filter->aslist[FILTER_OUT].name); | |
10134 | ||
10135 | /* route-map. */ | |
10136 | if (filter->map[RMAP_IN].name) | |
10137 | json_object_string_add( | |
10138 | json_addr, "routeMapForIncomingAdvertisements", | |
10139 | filter->map[RMAP_IN].name); | |
10140 | if (filter->map[RMAP_OUT].name) | |
10141 | json_object_string_add( | |
10142 | json_addr, "routeMapForOutgoingAdvertisements", | |
10143 | filter->map[RMAP_OUT].name); | |
10144 | ||
9dac9fc8 DA |
10145 | /* ebgp-requires-policy (inbound) */ |
10146 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10147 | && !bgp_inbound_policy_exists(p, filter)) | |
10148 | json_object_string_add( | |
10149 | json_addr, "inboundEbgpRequiresPolicy", | |
10150 | "Inbound updates discarded due to missing policy"); | |
10151 | ||
10152 | /* ebgp-requires-policy (outbound) */ | |
10153 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10154 | && (!bgp_outbound_policy_exists(p, filter))) | |
10155 | json_object_string_add( | |
10156 | json_addr, "outboundEbgpRequiresPolicy", | |
10157 | "Outbound updates discarded due to missing policy"); | |
10158 | ||
d62a17ae | 10159 | /* unsuppress-map */ |
10160 | if (filter->usmap.name) | |
10161 | json_object_string_add(json_addr, | |
10162 | "selectiveUnsuppressRouteMap", | |
10163 | filter->usmap.name); | |
10164 | ||
10165 | /* Receive prefix count */ | |
10166 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10167 | p->pcount[afi][safi]); | |
50e05855 AD |
10168 | if (paf && PAF_SUBGRP(paf)) |
10169 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10170 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10171 | |
fde246e8 DA |
10172 | /* Maximum prefix */ |
10173 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10174 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10175 | p->pmax_out[afi][safi]); | |
10176 | ||
d62a17ae | 10177 | /* Maximum prefix */ |
10178 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10179 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10180 | p->pmax[afi][safi]); | |
10181 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10182 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10183 | json_object_boolean_true_add( | |
10184 | json_addr, "prefixAllowedMaxWarning"); | |
10185 | json_object_int_add(json_addr, | |
10186 | "prefixAllowedWarningThresh", | |
10187 | p->pmax_threshold[afi][safi]); | |
10188 | if (p->pmax_restart[afi][safi]) | |
10189 | json_object_int_add( | |
10190 | json_addr, | |
10191 | "prefixAllowedRestartIntervalMsecs", | |
10192 | p->pmax_restart[afi][safi] * 60000); | |
10193 | } | |
2986cac2 | 10194 | json_object_object_add(json_neigh, |
10195 | get_afi_safi_str(afi, | |
10196 | safi, true), | |
d62a17ae | 10197 | json_addr); |
10198 | ||
10199 | } else { | |
10200 | filter = &p->filter[afi][safi]; | |
10201 | ||
10202 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10203 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10204 | |
10205 | if (peer_group_active(p)) | |
10206 | vty_out(vty, " %s peer-group member\n", | |
10207 | p->group->name); | |
10208 | ||
10209 | paf = peer_af_find(p, afi, safi); | |
10210 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10211 | vty_out(vty, " Update group %" PRIu64 |
10212 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10213 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10214 | vty_out(vty, " Packet Queue length %d\n", | |
10215 | bpacket_queue_virtual_length(paf)); | |
10216 | } else { | |
10217 | vty_out(vty, " Not part of any update group\n"); | |
10218 | } | |
10219 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10220 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10221 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10222 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10223 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10224 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10225 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10226 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10227 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10228 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10229 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10230 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10231 | ||
10232 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10233 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10234 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10235 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10236 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10237 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10238 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10239 | vty_out(vty, | |
10240 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10241 | ORF_TYPE_PREFIX); | |
10242 | bgp_show_peer_afi_orf_cap( | |
10243 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10244 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10245 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10246 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10247 | } | |
10248 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10249 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10250 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10251 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10252 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10253 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10254 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10255 | vty_out(vty, | |
10256 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10257 | ORF_TYPE_PREFIX_OLD); | |
10258 | bgp_show_peer_afi_orf_cap( | |
10259 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10260 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10261 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10262 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10263 | } | |
10264 | ||
10265 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
10266 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
10267 | NULL, afi, orf_pfx_name, use_json); | |
10268 | ||
10269 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10270 | PEER_STATUS_ORF_PREFIX_SEND) | |
10271 | || orf_pfx_count) { | |
10272 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10273 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10274 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10275 | vty_out(vty, " sent;"); | |
10276 | if (orf_pfx_count) | |
10277 | vty_out(vty, " received (%d entries)", | |
10278 | orf_pfx_count); | |
10279 | vty_out(vty, "\n"); | |
10280 | } | |
10281 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10282 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10283 | vty_out(vty, | |
10284 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10285 | ||
10286 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10287 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10288 | vty_out(vty, " Route-Reflector Client\n"); | |
10289 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10290 | PEER_FLAG_RSERVER_CLIENT)) | |
10291 | vty_out(vty, " Route-Server Client\n"); | |
10292 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10293 | vty_out(vty, | |
10294 | " Inbound soft reconfiguration allowed\n"); | |
10295 | ||
10296 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10297 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10298 | vty_out(vty, | |
10299 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10300 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10301 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10302 | vty_out(vty, | |
10303 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10304 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10305 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10306 | vty_out(vty, | |
10307 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10308 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10309 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10310 | vty_out(vty, | |
10311 | " Private AS numbers removed in updates to this neighbor\n"); | |
10312 | ||
dcc68b5e MS |
10313 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10314 | vty_out(vty, " %s\n", | |
10315 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10316 | ->human_description); | |
d62a17ae | 10317 | |
10318 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10319 | vty_out(vty, | |
10320 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10321 | ||
10322 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10323 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10324 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10325 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10326 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10327 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10328 | vty_out(vty, | |
10329 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10330 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10331 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10332 | vty_out(vty, | |
10333 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10334 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10335 | vty_out(vty, | |
10336 | " MED is propagated unchanged to this neighbor\n"); | |
10337 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10338 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10339 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10340 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10341 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10342 | vty_out(vty, | |
10343 | " Community attribute sent to this neighbor"); | |
10344 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10345 | PEER_FLAG_SEND_COMMUNITY) | |
10346 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10347 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10348 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10349 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10350 | vty_out(vty, "(all)\n"); | |
10351 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10352 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10353 | vty_out(vty, "(large)\n"); | |
10354 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10355 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10356 | vty_out(vty, "(extended)\n"); | |
10357 | else | |
10358 | vty_out(vty, "(standard)\n"); | |
10359 | } | |
10360 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10361 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10362 | vty_out(vty, " Default information originate,"); | |
10363 | ||
10364 | if (p->default_rmap[afi][safi].name) | |
10365 | vty_out(vty, " default route-map %s%s,", | |
10366 | p->default_rmap[afi][safi].map ? "*" | |
10367 | : "", | |
10368 | p->default_rmap[afi][safi].name); | |
10369 | if (paf && PAF_SUBGRP(paf) | |
10370 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10371 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10372 | vty_out(vty, " default sent\n"); | |
10373 | else | |
10374 | vty_out(vty, " default not sent\n"); | |
10375 | } | |
10376 | ||
dff8f48d MK |
10377 | /* advertise-vni-all */ |
10378 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10379 | if (is_evpn_enabled()) |
dff8f48d MK |
10380 | vty_out(vty, " advertise-all-vni\n"); |
10381 | } | |
10382 | ||
d62a17ae | 10383 | if (filter->plist[FILTER_IN].name |
10384 | || filter->dlist[FILTER_IN].name | |
10385 | || filter->aslist[FILTER_IN].name | |
10386 | || filter->map[RMAP_IN].name) | |
10387 | vty_out(vty, " Inbound path policy configured\n"); | |
10388 | if (filter->plist[FILTER_OUT].name | |
10389 | || filter->dlist[FILTER_OUT].name | |
10390 | || filter->aslist[FILTER_OUT].name | |
10391 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10392 | vty_out(vty, " Outbound path policy configured\n"); | |
10393 | ||
10394 | /* prefix-list */ | |
10395 | if (filter->plist[FILTER_IN].name) | |
10396 | vty_out(vty, | |
10397 | " Incoming update prefix filter list is %s%s\n", | |
10398 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10399 | filter->plist[FILTER_IN].name); | |
10400 | if (filter->plist[FILTER_OUT].name) | |
10401 | vty_out(vty, | |
10402 | " Outgoing update prefix filter list is %s%s\n", | |
10403 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10404 | filter->plist[FILTER_OUT].name); | |
10405 | ||
10406 | /* distribute-list */ | |
10407 | if (filter->dlist[FILTER_IN].name) | |
10408 | vty_out(vty, | |
10409 | " Incoming update network filter list is %s%s\n", | |
10410 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10411 | filter->dlist[FILTER_IN].name); | |
10412 | if (filter->dlist[FILTER_OUT].name) | |
10413 | vty_out(vty, | |
10414 | " Outgoing update network filter list is %s%s\n", | |
10415 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10416 | filter->dlist[FILTER_OUT].name); | |
10417 | ||
10418 | /* filter-list. */ | |
10419 | if (filter->aslist[FILTER_IN].name) | |
10420 | vty_out(vty, | |
10421 | " Incoming update AS path filter list is %s%s\n", | |
10422 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10423 | filter->aslist[FILTER_IN].name); | |
10424 | if (filter->aslist[FILTER_OUT].name) | |
10425 | vty_out(vty, | |
10426 | " Outgoing update AS path filter list is %s%s\n", | |
10427 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10428 | filter->aslist[FILTER_OUT].name); | |
10429 | ||
10430 | /* route-map. */ | |
10431 | if (filter->map[RMAP_IN].name) | |
10432 | vty_out(vty, | |
10433 | " Route map for incoming advertisements is %s%s\n", | |
10434 | filter->map[RMAP_IN].map ? "*" : "", | |
10435 | filter->map[RMAP_IN].name); | |
10436 | if (filter->map[RMAP_OUT].name) | |
10437 | vty_out(vty, | |
10438 | " Route map for outgoing advertisements is %s%s\n", | |
10439 | filter->map[RMAP_OUT].map ? "*" : "", | |
10440 | filter->map[RMAP_OUT].name); | |
10441 | ||
9dac9fc8 DA |
10442 | /* ebgp-requires-policy (inbound) */ |
10443 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10444 | && !bgp_inbound_policy_exists(p, filter)) | |
10445 | vty_out(vty, | |
10446 | " Inbound updates discarded due to missing policy\n"); | |
10447 | ||
10448 | /* ebgp-requires-policy (outbound) */ | |
10449 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10450 | && !bgp_outbound_policy_exists(p, filter)) | |
10451 | vty_out(vty, | |
10452 | " Outbound updates discarded due to missing policy\n"); | |
10453 | ||
d62a17ae | 10454 | /* unsuppress-map */ |
10455 | if (filter->usmap.name) | |
10456 | vty_out(vty, | |
10457 | " Route map for selective unsuppress is %s%s\n", | |
10458 | filter->usmap.map ? "*" : "", | |
10459 | filter->usmap.name); | |
10460 | ||
10461 | /* Receive prefix count */ | |
a0a87037 DA |
10462 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10463 | p->pcount[afi][safi]); | |
d62a17ae | 10464 | |
fde246e8 DA |
10465 | /* maximum-prefix-out */ |
10466 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10467 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10468 | vty_out(vty, | |
10469 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10470 | p->pmax_out[afi][safi]); | |
10471 | ||
d62a17ae | 10472 | /* Maximum prefix */ |
10473 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10474 | vty_out(vty, |
10475 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10476 | p->pmax[afi][safi], |
10477 | CHECK_FLAG(p->af_flags[afi][safi], | |
10478 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10479 | ? " (warning-only)" | |
10480 | : ""); | |
10481 | vty_out(vty, " Threshold for warning message %d%%", | |
10482 | p->pmax_threshold[afi][safi]); | |
10483 | if (p->pmax_restart[afi][safi]) | |
10484 | vty_out(vty, ", restart interval %d min", | |
10485 | p->pmax_restart[afi][safi]); | |
10486 | vty_out(vty, "\n"); | |
10487 | } | |
10488 | ||
10489 | vty_out(vty, "\n"); | |
10490 | } | |
10491 | } | |
10492 | ||
9f049418 | 10493 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10494 | json_object *json) |
718e3744 | 10495 | { |
d62a17ae | 10496 | struct bgp *bgp; |
10497 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10498 | char timebuf[BGP_UPTIME_LEN]; | |
10499 | char dn_flag[2]; | |
d62a17ae | 10500 | afi_t afi; |
10501 | safi_t safi; | |
d7c0a89a QY |
10502 | uint16_t i; |
10503 | uint8_t *msg; | |
d62a17ae | 10504 | json_object *json_neigh = NULL; |
10505 | time_t epoch_tbuf; | |
718e3744 | 10506 | |
d62a17ae | 10507 | bgp = p->bgp; |
10508 | ||
10509 | if (use_json) | |
10510 | json_neigh = json_object_new_object(); | |
10511 | ||
10512 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10513 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10514 | dn_flag[0] = '*'; | |
10515 | ||
10516 | if (!use_json) { | |
10517 | if (p->conf_if) /* Configured interface name. */ | |
10518 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10519 | BGP_PEER_SU_UNSPEC(p) | |
10520 | ? "None" | |
10521 | : sockunion2str(&p->su, buf, | |
10522 | SU_ADDRSTRLEN)); | |
10523 | else /* Configured IP address. */ | |
10524 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10525 | p->host); | |
10526 | } | |
10527 | ||
10528 | if (use_json) { | |
10529 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10530 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10531 | "none"); | |
10532 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10533 | json_object_string_add( | |
10534 | json_neigh, "bgpNeighborAddr", | |
10535 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10536 | ||
10537 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10538 | ||
10539 | if (p->change_local_as) | |
10540 | json_object_int_add(json_neigh, "localAs", | |
10541 | p->change_local_as); | |
10542 | else | |
10543 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10544 | ||
10545 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10546 | json_object_boolean_true_add(json_neigh, | |
10547 | "localAsNoPrepend"); | |
10548 | ||
10549 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10550 | json_object_boolean_true_add(json_neigh, | |
10551 | "localAsReplaceAs"); | |
10552 | } else { | |
10553 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10554 | || (p->as_type == AS_INTERNAL)) | |
10555 | vty_out(vty, "remote AS %u, ", p->as); | |
10556 | else | |
10557 | vty_out(vty, "remote AS Unspecified, "); | |
10558 | vty_out(vty, "local AS %u%s%s, ", | |
10559 | p->change_local_as ? p->change_local_as : p->local_as, | |
10560 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10561 | ? " no-prepend" | |
10562 | : "", | |
10563 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10564 | ? " replace-as" | |
10565 | : ""); | |
10566 | } | |
faa16034 DS |
10567 | /* peer type internal or confed-internal */ |
10568 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10569 | if (use_json) { |
10570 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10571 | json_object_boolean_true_add( | |
10572 | json_neigh, "nbrConfedInternalLink"); | |
10573 | else | |
10574 | json_object_boolean_true_add(json_neigh, | |
10575 | "nbrInternalLink"); | |
10576 | } else { | |
10577 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10578 | vty_out(vty, "confed-internal link\n"); | |
10579 | else | |
10580 | vty_out(vty, "internal link\n"); | |
10581 | } | |
faa16034 DS |
10582 | /* peer type external or confed-external */ |
10583 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10584 | if (use_json) { |
10585 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10586 | json_object_boolean_true_add( | |
10587 | json_neigh, "nbrConfedExternalLink"); | |
10588 | else | |
10589 | json_object_boolean_true_add(json_neigh, | |
10590 | "nbrExternalLink"); | |
10591 | } else { | |
10592 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10593 | vty_out(vty, "confed-external link\n"); | |
10594 | else | |
10595 | vty_out(vty, "external link\n"); | |
10596 | } | |
faa16034 DS |
10597 | } else { |
10598 | if (use_json) | |
10599 | json_object_boolean_true_add(json_neigh, | |
10600 | "nbrUnspecifiedLink"); | |
10601 | else | |
10602 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10603 | } |
10604 | ||
10605 | /* Description. */ | |
10606 | if (p->desc) { | |
10607 | if (use_json) | |
10608 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10609 | else | |
10610 | vty_out(vty, " Description: %s\n", p->desc); | |
10611 | } | |
10612 | ||
10613 | if (p->hostname) { | |
10614 | if (use_json) { | |
10615 | if (p->hostname) | |
10616 | json_object_string_add(json_neigh, "hostname", | |
10617 | p->hostname); | |
10618 | ||
10619 | if (p->domainname) | |
10620 | json_object_string_add(json_neigh, "domainname", | |
10621 | p->domainname); | |
10622 | } else { | |
10623 | if (p->domainname && (p->domainname[0] != '\0')) | |
10624 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10625 | p->domainname); | |
10626 | else | |
10627 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10628 | } | |
10629 | } | |
10630 | ||
10631 | /* Peer-group */ | |
10632 | if (p->group) { | |
10633 | if (use_json) { | |
10634 | json_object_string_add(json_neigh, "peerGroup", | |
10635 | p->group->name); | |
10636 | ||
10637 | if (dn_flag[0]) { | |
10638 | struct prefix prefix, *range = NULL; | |
10639 | ||
10640 | sockunion2hostprefix(&(p->su), &prefix); | |
10641 | range = peer_group_lookup_dynamic_neighbor_range( | |
10642 | p->group, &prefix); | |
10643 | ||
10644 | if (range) { | |
10645 | prefix2str(range, buf1, sizeof(buf1)); | |
10646 | json_object_string_add( | |
10647 | json_neigh, | |
10648 | "peerSubnetRangeGroup", buf1); | |
10649 | } | |
10650 | } | |
10651 | } else { | |
10652 | vty_out(vty, | |
10653 | " Member of peer-group %s for session parameters\n", | |
10654 | p->group->name); | |
10655 | ||
10656 | if (dn_flag[0]) { | |
10657 | struct prefix prefix, *range = NULL; | |
10658 | ||
10659 | sockunion2hostprefix(&(p->su), &prefix); | |
10660 | range = peer_group_lookup_dynamic_neighbor_range( | |
10661 | p->group, &prefix); | |
10662 | ||
10663 | if (range) { | |
10664 | prefix2str(range, buf1, sizeof(buf1)); | |
10665 | vty_out(vty, | |
10666 | " Belongs to the subnet range group: %s\n", | |
10667 | buf1); | |
10668 | } | |
10669 | } | |
10670 | } | |
10671 | } | |
10672 | ||
10673 | if (use_json) { | |
10674 | /* Administrative shutdown. */ | |
10675 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10676 | json_object_boolean_true_add(json_neigh, | |
10677 | "adminShutDown"); | |
10678 | ||
10679 | /* BGP Version. */ | |
10680 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10681 | json_object_string_add( | |
10682 | json_neigh, "remoteRouterId", | |
10683 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10684 | json_object_string_add( |
10685 | json_neigh, "localRouterId", | |
10686 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10687 | sizeof(buf1))); | |
d62a17ae | 10688 | |
10689 | /* Confederation */ | |
10690 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10691 | && bgp_confederation_peers_check(bgp, p->as)) | |
10692 | json_object_boolean_true_add(json_neigh, | |
10693 | "nbrCommonAdmin"); | |
10694 | ||
10695 | /* Status. */ | |
10696 | json_object_string_add( | |
10697 | json_neigh, "bgpState", | |
10698 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10699 | ||
10700 | if (p->status == Established) { | |
10701 | time_t uptime; | |
d62a17ae | 10702 | |
10703 | uptime = bgp_clock(); | |
10704 | uptime -= p->uptime; | |
d62a17ae | 10705 | epoch_tbuf = time(NULL) - uptime; |
10706 | ||
d3c7efed DS |
10707 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10708 | uptime * 1000); | |
d62a17ae | 10709 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10710 | peer_uptime(p->uptime, timebuf, | |
10711 | BGP_UPTIME_LEN, 0, | |
10712 | NULL)); | |
10713 | json_object_int_add(json_neigh, | |
10714 | "bgpTimerUpEstablishedEpoch", | |
10715 | epoch_tbuf); | |
10716 | } | |
10717 | ||
10718 | else if (p->status == Active) { | |
10719 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10720 | json_object_string_add(json_neigh, "bgpStateIs", | |
10721 | "passive"); | |
10722 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10723 | json_object_string_add(json_neigh, "bgpStateIs", | |
10724 | "passiveNSF"); | |
10725 | } | |
10726 | ||
10727 | /* read timer */ | |
10728 | time_t uptime; | |
10729 | struct tm *tm; | |
10730 | ||
10731 | uptime = bgp_clock(); | |
10732 | uptime -= p->readtime; | |
10733 | tm = gmtime(&uptime); | |
10734 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
10735 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10736 | + (tm->tm_hour * 3600000)); | |
10737 | ||
10738 | uptime = bgp_clock(); | |
10739 | uptime -= p->last_write; | |
10740 | tm = gmtime(&uptime); | |
10741 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
10742 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10743 | + (tm->tm_hour * 3600000)); | |
10744 | ||
10745 | uptime = bgp_clock(); | |
10746 | uptime -= p->update_time; | |
10747 | tm = gmtime(&uptime); | |
10748 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
10749 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10750 | + (tm->tm_hour * 3600000)); | |
10751 | ||
10752 | /* Configured timer values. */ | |
10753 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10754 | p->v_holdtime * 1000); | |
10755 | json_object_int_add(json_neigh, | |
10756 | "bgpTimerKeepAliveIntervalMsecs", | |
10757 | p->v_keepalive * 1000); | |
b90a8e13 | 10758 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10759 | json_object_int_add(json_neigh, |
10760 | "bgpTimerConfiguredHoldTimeMsecs", | |
10761 | p->holdtime * 1000); | |
10762 | json_object_int_add( | |
10763 | json_neigh, | |
10764 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10765 | p->keepalive * 1000); | |
5d5393b9 DL |
10766 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10767 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10768 | json_object_int_add(json_neigh, |
10769 | "bgpTimerConfiguredHoldTimeMsecs", | |
10770 | bgp->default_holdtime); | |
10771 | json_object_int_add( | |
10772 | json_neigh, | |
10773 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10774 | bgp->default_keepalive); | |
d62a17ae | 10775 | } |
10776 | } else { | |
10777 | /* Administrative shutdown. */ | |
10778 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10779 | vty_out(vty, " Administratively shut down\n"); | |
10780 | ||
10781 | /* BGP Version. */ | |
10782 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10783 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10784 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10785 | vty_out(vty, ", local router ID %s\n", |
10786 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10787 | sizeof(buf1))); | |
d62a17ae | 10788 | |
10789 | /* Confederation */ | |
10790 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10791 | && bgp_confederation_peers_check(bgp, p->as)) | |
10792 | vty_out(vty, | |
10793 | " Neighbor under common administration\n"); | |
10794 | ||
10795 | /* Status. */ | |
10796 | vty_out(vty, " BGP state = %s", | |
10797 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10798 | ||
10799 | if (p->status == Established) | |
10800 | vty_out(vty, ", up for %8s", | |
10801 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10802 | 0, NULL)); | |
10803 | ||
10804 | else if (p->status == Active) { | |
10805 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10806 | vty_out(vty, " (passive)"); | |
10807 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10808 | vty_out(vty, " (NSF passive)"); | |
10809 | } | |
10810 | vty_out(vty, "\n"); | |
10811 | ||
10812 | /* read timer */ | |
10813 | vty_out(vty, " Last read %s", | |
10814 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10815 | NULL)); | |
10816 | vty_out(vty, ", Last write %s\n", | |
10817 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10818 | NULL)); | |
10819 | ||
10820 | /* Configured timer values. */ | |
10821 | vty_out(vty, | |
10822 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10823 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10824 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10825 | vty_out(vty, " Configured hold time is %d", |
10826 | p->holdtime); | |
10827 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10828 | p->keepalive); | |
5d5393b9 DL |
10829 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10830 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10831 | vty_out(vty, " Configured hold time is %d", |
10832 | bgp->default_holdtime); | |
10833 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10834 | bgp->default_keepalive); | |
d62a17ae | 10835 | } |
10836 | } | |
10837 | /* Capability. */ | |
10838 | if (p->status == Established) { | |
10839 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10840 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10841 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10842 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10843 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10844 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10845 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10846 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10847 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10848 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10849 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10850 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10851 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10852 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10853 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10854 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10855 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10856 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10857 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10858 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10859 | if (use_json) { | |
10860 | json_object *json_cap = NULL; | |
10861 | ||
10862 | json_cap = json_object_new_object(); | |
10863 | ||
10864 | /* AS4 */ | |
10865 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10866 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10867 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10868 | && CHECK_FLAG(p->cap, | |
10869 | PEER_CAP_AS4_RCV)) | |
10870 | json_object_string_add( | |
10871 | json_cap, "4byteAs", | |
10872 | "advertisedAndReceived"); | |
10873 | else if (CHECK_FLAG(p->cap, | |
10874 | PEER_CAP_AS4_ADV)) | |
10875 | json_object_string_add( | |
10876 | json_cap, "4byteAs", | |
10877 | "advertised"); | |
10878 | else if (CHECK_FLAG(p->cap, | |
10879 | PEER_CAP_AS4_RCV)) | |
10880 | json_object_string_add( | |
10881 | json_cap, "4byteAs", | |
10882 | "received"); | |
10883 | } | |
10884 | ||
10885 | /* AddPath */ | |
10886 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10887 | || CHECK_FLAG(p->cap, | |
10888 | PEER_CAP_ADDPATH_ADV)) { | |
10889 | json_object *json_add = NULL; | |
10890 | const char *print_store; | |
10891 | ||
10892 | json_add = json_object_new_object(); | |
10893 | ||
05c7a1cc QY |
10894 | FOREACH_AFI_SAFI (afi, safi) { |
10895 | json_object *json_sub = NULL; | |
10896 | json_sub = | |
10897 | json_object_new_object(); | |
5cb5f4d0 DD |
10898 | print_store = get_afi_safi_str( |
10899 | afi, safi, true); | |
d62a17ae | 10900 | |
05c7a1cc QY |
10901 | if (CHECK_FLAG( |
10902 | p->af_cap[afi] | |
10903 | [safi], | |
10904 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10905 | || CHECK_FLAG( | |
10906 | p->af_cap[afi] | |
10907 | [safi], | |
10908 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10909 | if (CHECK_FLAG( |
10910 | p->af_cap | |
10911 | [afi] | |
10912 | [safi], | |
10913 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10914 | && CHECK_FLAG( |
d62a17ae | 10915 | p->af_cap |
10916 | [afi] | |
10917 | [safi], | |
05c7a1cc QY |
10918 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
10919 | json_object_boolean_true_add( | |
10920 | json_sub, | |
10921 | "txAdvertisedAndReceived"); | |
10922 | else if ( | |
10923 | CHECK_FLAG( | |
10924 | p->af_cap | |
10925 | [afi] | |
10926 | [safi], | |
10927 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
10928 | json_object_boolean_true_add( | |
10929 | json_sub, | |
10930 | "txAdvertised"); | |
10931 | else if ( | |
10932 | CHECK_FLAG( | |
10933 | p->af_cap | |
10934 | [afi] | |
10935 | [safi], | |
10936 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10937 | json_object_boolean_true_add( | |
10938 | json_sub, | |
10939 | "txReceived"); | |
10940 | } | |
d62a17ae | 10941 | |
05c7a1cc QY |
10942 | if (CHECK_FLAG( |
10943 | p->af_cap[afi] | |
10944 | [safi], | |
10945 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10946 | || CHECK_FLAG( | |
10947 | p->af_cap[afi] | |
10948 | [safi], | |
10949 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10950 | if (CHECK_FLAG( |
10951 | p->af_cap | |
10952 | [afi] | |
10953 | [safi], | |
10954 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10955 | && CHECK_FLAG( |
d62a17ae | 10956 | p->af_cap |
10957 | [afi] | |
10958 | [safi], | |
10959 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10960 | json_object_boolean_true_add( |
10961 | json_sub, | |
10962 | "rxAdvertisedAndReceived"); | |
10963 | else if ( | |
10964 | CHECK_FLAG( | |
10965 | p->af_cap | |
10966 | [afi] | |
10967 | [safi], | |
10968 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10969 | json_object_boolean_true_add( | |
10970 | json_sub, | |
10971 | "rxAdvertised"); | |
10972 | else if ( | |
10973 | CHECK_FLAG( | |
10974 | p->af_cap | |
10975 | [afi] | |
10976 | [safi], | |
10977 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10978 | json_object_boolean_true_add( | |
10979 | json_sub, | |
10980 | "rxReceived"); | |
d62a17ae | 10981 | } |
10982 | ||
05c7a1cc QY |
10983 | if (CHECK_FLAG( |
10984 | p->af_cap[afi] | |
10985 | [safi], | |
10986 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10987 | || CHECK_FLAG( | |
10988 | p->af_cap[afi] | |
10989 | [safi], | |
10990 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
10991 | || CHECK_FLAG( | |
10992 | p->af_cap[afi] | |
10993 | [safi], | |
10994 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10995 | || CHECK_FLAG( | |
10996 | p->af_cap[afi] | |
10997 | [safi], | |
10998 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10999 | json_object_object_add( | |
11000 | json_add, | |
11001 | print_store, | |
11002 | json_sub); | |
11003 | else | |
11004 | json_object_free( | |
11005 | json_sub); | |
11006 | } | |
11007 | ||
d62a17ae | 11008 | json_object_object_add( |
11009 | json_cap, "addPath", json_add); | |
11010 | } | |
11011 | ||
11012 | /* Dynamic */ | |
11013 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11014 | || CHECK_FLAG(p->cap, | |
11015 | PEER_CAP_DYNAMIC_ADV)) { | |
11016 | if (CHECK_FLAG(p->cap, | |
11017 | PEER_CAP_DYNAMIC_ADV) | |
11018 | && CHECK_FLAG(p->cap, | |
11019 | PEER_CAP_DYNAMIC_RCV)) | |
11020 | json_object_string_add( | |
11021 | json_cap, "dynamic", | |
11022 | "advertisedAndReceived"); | |
11023 | else if (CHECK_FLAG( | |
11024 | p->cap, | |
11025 | PEER_CAP_DYNAMIC_ADV)) | |
11026 | json_object_string_add( | |
11027 | json_cap, "dynamic", | |
11028 | "advertised"); | |
11029 | else if (CHECK_FLAG( | |
11030 | p->cap, | |
11031 | PEER_CAP_DYNAMIC_RCV)) | |
11032 | json_object_string_add( | |
11033 | json_cap, "dynamic", | |
11034 | "received"); | |
11035 | } | |
11036 | ||
11037 | /* Extended nexthop */ | |
11038 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11039 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11040 | json_object *json_nxt = NULL; | |
11041 | const char *print_store; | |
11042 | ||
11043 | ||
11044 | if (CHECK_FLAG(p->cap, | |
11045 | PEER_CAP_ENHE_ADV) | |
11046 | && CHECK_FLAG(p->cap, | |
11047 | PEER_CAP_ENHE_RCV)) | |
11048 | json_object_string_add( | |
11049 | json_cap, | |
11050 | "extendedNexthop", | |
11051 | "advertisedAndReceived"); | |
11052 | else if (CHECK_FLAG(p->cap, | |
11053 | PEER_CAP_ENHE_ADV)) | |
11054 | json_object_string_add( | |
11055 | json_cap, | |
11056 | "extendedNexthop", | |
11057 | "advertised"); | |
11058 | else if (CHECK_FLAG(p->cap, | |
11059 | PEER_CAP_ENHE_RCV)) | |
11060 | json_object_string_add( | |
11061 | json_cap, | |
11062 | "extendedNexthop", | |
11063 | "received"); | |
11064 | ||
11065 | if (CHECK_FLAG(p->cap, | |
11066 | PEER_CAP_ENHE_RCV)) { | |
11067 | json_nxt = | |
11068 | json_object_new_object(); | |
11069 | ||
11070 | for (safi = SAFI_UNICAST; | |
11071 | safi < SAFI_MAX; safi++) { | |
11072 | if (CHECK_FLAG( | |
11073 | p->af_cap | |
11074 | [AFI_IP] | |
11075 | [safi], | |
11076 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11077 | print_store = get_afi_safi_str( |
d62a17ae | 11078 | AFI_IP, |
5cb5f4d0 | 11079 | safi, true); |
d62a17ae | 11080 | json_object_string_add( |
11081 | json_nxt, | |
11082 | print_store, | |
54f29523 | 11083 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11084 | } |
11085 | } | |
11086 | json_object_object_add( | |
11087 | json_cap, | |
11088 | "extendedNexthopFamililesByPeer", | |
11089 | json_nxt); | |
11090 | } | |
11091 | } | |
11092 | ||
11093 | /* Route Refresh */ | |
11094 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11095 | || CHECK_FLAG(p->cap, | |
11096 | PEER_CAP_REFRESH_NEW_RCV) | |
11097 | || CHECK_FLAG(p->cap, | |
11098 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11099 | if (CHECK_FLAG(p->cap, | |
11100 | PEER_CAP_REFRESH_ADV) | |
11101 | && (CHECK_FLAG( | |
11102 | p->cap, | |
11103 | PEER_CAP_REFRESH_NEW_RCV) | |
11104 | || CHECK_FLAG( | |
11105 | p->cap, | |
11106 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11107 | if (CHECK_FLAG( | |
11108 | p->cap, | |
11109 | PEER_CAP_REFRESH_OLD_RCV) | |
11110 | && CHECK_FLAG( | |
11111 | p->cap, | |
11112 | PEER_CAP_REFRESH_NEW_RCV)) | |
11113 | json_object_string_add( | |
11114 | json_cap, | |
11115 | "routeRefresh", | |
11116 | "advertisedAndReceivedOldNew"); | |
11117 | else { | |
11118 | if (CHECK_FLAG( | |
11119 | p->cap, | |
11120 | PEER_CAP_REFRESH_OLD_RCV)) | |
11121 | json_object_string_add( | |
11122 | json_cap, | |
11123 | "routeRefresh", | |
11124 | "advertisedAndReceivedOld"); | |
11125 | else | |
11126 | json_object_string_add( | |
11127 | json_cap, | |
11128 | "routeRefresh", | |
11129 | "advertisedAndReceivedNew"); | |
11130 | } | |
11131 | } else if ( | |
11132 | CHECK_FLAG( | |
11133 | p->cap, | |
11134 | PEER_CAP_REFRESH_ADV)) | |
11135 | json_object_string_add( | |
11136 | json_cap, | |
11137 | "routeRefresh", | |
11138 | "advertised"); | |
11139 | else if ( | |
11140 | CHECK_FLAG( | |
11141 | p->cap, | |
11142 | PEER_CAP_REFRESH_NEW_RCV) | |
11143 | || CHECK_FLAG( | |
11144 | p->cap, | |
11145 | PEER_CAP_REFRESH_OLD_RCV)) | |
11146 | json_object_string_add( | |
11147 | json_cap, | |
11148 | "routeRefresh", | |
11149 | "received"); | |
11150 | } | |
11151 | ||
11152 | /* Multiprotocol Extensions */ | |
11153 | json_object *json_multi = NULL; | |
11154 | json_multi = json_object_new_object(); | |
11155 | ||
05c7a1cc QY |
11156 | FOREACH_AFI_SAFI (afi, safi) { |
11157 | if (p->afc_adv[afi][safi] | |
11158 | || p->afc_recv[afi][safi]) { | |
11159 | json_object *json_exten = NULL; | |
11160 | json_exten = | |
11161 | json_object_new_object(); | |
11162 | ||
d62a17ae | 11163 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11164 | && p->afc_recv[afi][safi]) |
11165 | json_object_boolean_true_add( | |
11166 | json_exten, | |
11167 | "advertisedAndReceived"); | |
11168 | else if (p->afc_adv[afi][safi]) | |
11169 | json_object_boolean_true_add( | |
11170 | json_exten, | |
11171 | "advertised"); | |
11172 | else if (p->afc_recv[afi][safi]) | |
11173 | json_object_boolean_true_add( | |
11174 | json_exten, | |
11175 | "received"); | |
d62a17ae | 11176 | |
05c7a1cc QY |
11177 | json_object_object_add( |
11178 | json_multi, | |
5cb5f4d0 DD |
11179 | get_afi_safi_str(afi, |
11180 | safi, | |
11181 | true), | |
05c7a1cc | 11182 | json_exten); |
d62a17ae | 11183 | } |
11184 | } | |
11185 | json_object_object_add( | |
11186 | json_cap, "multiprotocolExtensions", | |
11187 | json_multi); | |
11188 | ||
d77114b7 | 11189 | /* Hostname capabilities */ |
60466a63 | 11190 | json_object *json_hname = NULL; |
d77114b7 MK |
11191 | |
11192 | json_hname = json_object_new_object(); | |
11193 | ||
11194 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11195 | json_object_string_add( | |
60466a63 QY |
11196 | json_hname, "advHostName", |
11197 | bgp->peer_self->hostname | |
11198 | ? bgp->peer_self | |
11199 | ->hostname | |
d77114b7 MK |
11200 | : "n/a"); |
11201 | json_object_string_add( | |
60466a63 QY |
11202 | json_hname, "advDomainName", |
11203 | bgp->peer_self->domainname | |
11204 | ? bgp->peer_self | |
11205 | ->domainname | |
d77114b7 MK |
11206 | : "n/a"); |
11207 | } | |
11208 | ||
11209 | ||
11210 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11211 | json_object_string_add( | |
60466a63 QY |
11212 | json_hname, "rcvHostName", |
11213 | p->hostname ? p->hostname | |
11214 | : "n/a"); | |
d77114b7 | 11215 | json_object_string_add( |
60466a63 QY |
11216 | json_hname, "rcvDomainName", |
11217 | p->domainname ? p->domainname | |
11218 | : "n/a"); | |
d77114b7 MK |
11219 | } |
11220 | ||
60466a63 | 11221 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11222 | json_hname); |
11223 | ||
d62a17ae | 11224 | /* Gracefull Restart */ |
11225 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11226 | || CHECK_FLAG(p->cap, | |
11227 | PEER_CAP_RESTART_ADV)) { | |
11228 | if (CHECK_FLAG(p->cap, | |
11229 | PEER_CAP_RESTART_ADV) | |
11230 | && CHECK_FLAG(p->cap, | |
11231 | PEER_CAP_RESTART_RCV)) | |
11232 | json_object_string_add( | |
11233 | json_cap, | |
11234 | "gracefulRestart", | |
11235 | "advertisedAndReceived"); | |
11236 | else if (CHECK_FLAG( | |
11237 | p->cap, | |
11238 | PEER_CAP_RESTART_ADV)) | |
11239 | json_object_string_add( | |
11240 | json_cap, | |
11241 | "gracefulRestartCapability", | |
11242 | "advertised"); | |
11243 | else if (CHECK_FLAG( | |
11244 | p->cap, | |
11245 | PEER_CAP_RESTART_RCV)) | |
11246 | json_object_string_add( | |
11247 | json_cap, | |
11248 | "gracefulRestartCapability", | |
11249 | "received"); | |
11250 | ||
11251 | if (CHECK_FLAG(p->cap, | |
11252 | PEER_CAP_RESTART_RCV)) { | |
11253 | int restart_af_count = 0; | |
11254 | json_object *json_restart = | |
11255 | NULL; | |
11256 | json_restart = | |
11257 | json_object_new_object(); | |
11258 | ||
11259 | json_object_int_add( | |
11260 | json_cap, | |
11261 | "gracefulRestartRemoteTimerMsecs", | |
11262 | p->v_gr_restart * 1000); | |
11263 | ||
05c7a1cc QY |
11264 | FOREACH_AFI_SAFI (afi, safi) { |
11265 | if (CHECK_FLAG( | |
11266 | p->af_cap | |
11267 | [afi] | |
11268 | [safi], | |
11269 | PEER_CAP_RESTART_AF_RCV)) { | |
11270 | json_object * | |
11271 | json_sub = | |
11272 | NULL; | |
11273 | json_sub = | |
11274 | json_object_new_object(); | |
11275 | ||
d62a17ae | 11276 | if (CHECK_FLAG( |
11277 | p->af_cap | |
11278 | [afi] | |
11279 | [safi], | |
05c7a1cc QY |
11280 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11281 | json_object_boolean_true_add( | |
11282 | json_sub, | |
11283 | "preserved"); | |
11284 | restart_af_count++; | |
11285 | json_object_object_add( | |
11286 | json_restart, | |
5cb5f4d0 | 11287 | get_afi_safi_str( |
05c7a1cc | 11288 | afi, |
5cb5f4d0 DD |
11289 | safi, |
11290 | true), | |
05c7a1cc | 11291 | json_sub); |
d62a17ae | 11292 | } |
11293 | } | |
11294 | if (!restart_af_count) { | |
11295 | json_object_string_add( | |
11296 | json_cap, | |
11297 | "addressFamiliesByPeer", | |
11298 | "none"); | |
11299 | json_object_free( | |
11300 | json_restart); | |
11301 | } else | |
11302 | json_object_object_add( | |
11303 | json_cap, | |
11304 | "addressFamiliesByPeer", | |
11305 | json_restart); | |
11306 | } | |
11307 | } | |
11308 | json_object_object_add(json_neigh, | |
11309 | "neighborCapabilities", | |
11310 | json_cap); | |
11311 | } else { | |
11312 | vty_out(vty, " Neighbor capabilities:\n"); | |
11313 | ||
11314 | /* AS4 */ | |
11315 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11316 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11317 | vty_out(vty, " 4 Byte AS:"); | |
11318 | if (CHECK_FLAG(p->cap, | |
11319 | PEER_CAP_AS4_ADV)) | |
11320 | vty_out(vty, " advertised"); | |
11321 | if (CHECK_FLAG(p->cap, | |
11322 | PEER_CAP_AS4_RCV)) | |
11323 | vty_out(vty, " %sreceived", | |
11324 | CHECK_FLAG( | |
11325 | p->cap, | |
11326 | PEER_CAP_AS4_ADV) | |
11327 | ? "and " | |
11328 | : ""); | |
11329 | vty_out(vty, "\n"); | |
11330 | } | |
11331 | ||
11332 | /* AddPath */ | |
11333 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11334 | || CHECK_FLAG(p->cap, | |
11335 | PEER_CAP_ADDPATH_ADV)) { | |
11336 | vty_out(vty, " AddPath:\n"); | |
11337 | ||
05c7a1cc QY |
11338 | FOREACH_AFI_SAFI (afi, safi) { |
11339 | if (CHECK_FLAG( | |
11340 | p->af_cap[afi] | |
11341 | [safi], | |
11342 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11343 | || CHECK_FLAG( | |
11344 | p->af_cap[afi] | |
11345 | [safi], | |
11346 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11347 | vty_out(vty, | |
11348 | " %s: TX ", | |
5cb5f4d0 | 11349 | get_afi_safi_str( |
05c7a1cc | 11350 | afi, |
5cb5f4d0 DD |
11351 | safi, |
11352 | false)); | |
05c7a1cc | 11353 | |
d62a17ae | 11354 | if (CHECK_FLAG( |
11355 | p->af_cap | |
11356 | [afi] | |
11357 | [safi], | |
05c7a1cc | 11358 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11359 | vty_out(vty, |
05c7a1cc | 11360 | "advertised %s", |
5cb5f4d0 | 11361 | get_afi_safi_str( |
d62a17ae | 11362 | afi, |
5cb5f4d0 DD |
11363 | safi, |
11364 | false)); | |
d62a17ae | 11365 | |
05c7a1cc QY |
11366 | if (CHECK_FLAG( |
11367 | p->af_cap | |
11368 | [afi] | |
11369 | [safi], | |
11370 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11371 | vty_out(vty, | |
11372 | "%sreceived", | |
11373 | CHECK_FLAG( | |
11374 | p->af_cap | |
11375 | [afi] | |
11376 | [safi], | |
11377 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11378 | ? " and " | |
11379 | : ""); | |
d62a17ae | 11380 | |
05c7a1cc QY |
11381 | vty_out(vty, "\n"); |
11382 | } | |
d62a17ae | 11383 | |
05c7a1cc QY |
11384 | if (CHECK_FLAG( |
11385 | p->af_cap[afi] | |
11386 | [safi], | |
11387 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11388 | || CHECK_FLAG( | |
11389 | p->af_cap[afi] | |
11390 | [safi], | |
11391 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11392 | vty_out(vty, | |
11393 | " %s: RX ", | |
5cb5f4d0 | 11394 | get_afi_safi_str( |
05c7a1cc | 11395 | afi, |
5cb5f4d0 DD |
11396 | safi, |
11397 | false)); | |
d62a17ae | 11398 | |
11399 | if (CHECK_FLAG( | |
11400 | p->af_cap | |
11401 | [afi] | |
11402 | [safi], | |
05c7a1cc | 11403 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11404 | vty_out(vty, |
05c7a1cc | 11405 | "advertised %s", |
5cb5f4d0 | 11406 | get_afi_safi_str( |
d62a17ae | 11407 | afi, |
5cb5f4d0 DD |
11408 | safi, |
11409 | false)); | |
d62a17ae | 11410 | |
05c7a1cc QY |
11411 | if (CHECK_FLAG( |
11412 | p->af_cap | |
11413 | [afi] | |
11414 | [safi], | |
11415 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11416 | vty_out(vty, |
05c7a1cc QY |
11417 | "%sreceived", |
11418 | CHECK_FLAG( | |
11419 | p->af_cap | |
11420 | [afi] | |
11421 | [safi], | |
11422 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11423 | ? " and " | |
11424 | : ""); | |
11425 | ||
11426 | vty_out(vty, "\n"); | |
d62a17ae | 11427 | } |
05c7a1cc | 11428 | } |
d62a17ae | 11429 | } |
11430 | ||
11431 | /* Dynamic */ | |
11432 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11433 | || CHECK_FLAG(p->cap, | |
11434 | PEER_CAP_DYNAMIC_ADV)) { | |
11435 | vty_out(vty, " Dynamic:"); | |
11436 | if (CHECK_FLAG(p->cap, | |
11437 | PEER_CAP_DYNAMIC_ADV)) | |
11438 | vty_out(vty, " advertised"); | |
11439 | if (CHECK_FLAG(p->cap, | |
11440 | PEER_CAP_DYNAMIC_RCV)) | |
11441 | vty_out(vty, " %sreceived", | |
11442 | CHECK_FLAG( | |
11443 | p->cap, | |
11444 | PEER_CAP_DYNAMIC_ADV) | |
11445 | ? "and " | |
11446 | : ""); | |
11447 | vty_out(vty, "\n"); | |
11448 | } | |
11449 | ||
11450 | /* Extended nexthop */ | |
11451 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11452 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11453 | vty_out(vty, " Extended nexthop:"); | |
11454 | if (CHECK_FLAG(p->cap, | |
11455 | PEER_CAP_ENHE_ADV)) | |
11456 | vty_out(vty, " advertised"); | |
11457 | if (CHECK_FLAG(p->cap, | |
11458 | PEER_CAP_ENHE_RCV)) | |
11459 | vty_out(vty, " %sreceived", | |
11460 | CHECK_FLAG( | |
11461 | p->cap, | |
11462 | PEER_CAP_ENHE_ADV) | |
11463 | ? "and " | |
11464 | : ""); | |
11465 | vty_out(vty, "\n"); | |
11466 | ||
11467 | if (CHECK_FLAG(p->cap, | |
11468 | PEER_CAP_ENHE_RCV)) { | |
11469 | vty_out(vty, | |
11470 | " Address families by peer:\n "); | |
11471 | for (safi = SAFI_UNICAST; | |
11472 | safi < SAFI_MAX; safi++) | |
11473 | if (CHECK_FLAG( | |
11474 | p->af_cap | |
11475 | [AFI_IP] | |
11476 | [safi], | |
11477 | PEER_CAP_ENHE_AF_RCV)) | |
11478 | vty_out(vty, | |
11479 | " %s\n", | |
5cb5f4d0 | 11480 | get_afi_safi_str( |
d62a17ae | 11481 | AFI_IP, |
5cb5f4d0 DD |
11482 | safi, |
11483 | false)); | |
d62a17ae | 11484 | } |
11485 | } | |
11486 | ||
11487 | /* Route Refresh */ | |
11488 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11489 | || CHECK_FLAG(p->cap, | |
11490 | PEER_CAP_REFRESH_NEW_RCV) | |
11491 | || CHECK_FLAG(p->cap, | |
11492 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11493 | vty_out(vty, " Route refresh:"); | |
11494 | if (CHECK_FLAG(p->cap, | |
11495 | PEER_CAP_REFRESH_ADV)) | |
11496 | vty_out(vty, " advertised"); | |
11497 | if (CHECK_FLAG(p->cap, | |
11498 | PEER_CAP_REFRESH_NEW_RCV) | |
11499 | || CHECK_FLAG( | |
11500 | p->cap, | |
11501 | PEER_CAP_REFRESH_OLD_RCV)) | |
11502 | vty_out(vty, " %sreceived(%s)", | |
11503 | CHECK_FLAG( | |
11504 | p->cap, | |
11505 | PEER_CAP_REFRESH_ADV) | |
11506 | ? "and " | |
11507 | : "", | |
11508 | (CHECK_FLAG( | |
11509 | p->cap, | |
11510 | PEER_CAP_REFRESH_OLD_RCV) | |
11511 | && CHECK_FLAG( | |
11512 | p->cap, | |
11513 | PEER_CAP_REFRESH_NEW_RCV)) | |
11514 | ? "old & new" | |
11515 | : CHECK_FLAG( | |
11516 | p->cap, | |
11517 | PEER_CAP_REFRESH_OLD_RCV) | |
11518 | ? "old" | |
11519 | : "new"); | |
11520 | ||
11521 | vty_out(vty, "\n"); | |
11522 | } | |
11523 | ||
11524 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11525 | FOREACH_AFI_SAFI (afi, safi) |
11526 | if (p->afc_adv[afi][safi] | |
11527 | || p->afc_recv[afi][safi]) { | |
11528 | vty_out(vty, | |
11529 | " Address Family %s:", | |
5cb5f4d0 DD |
11530 | get_afi_safi_str( |
11531 | afi, | |
11532 | safi, | |
11533 | false)); | |
05c7a1cc | 11534 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11535 | vty_out(vty, |
05c7a1cc QY |
11536 | " advertised"); |
11537 | if (p->afc_recv[afi][safi]) | |
11538 | vty_out(vty, | |
11539 | " %sreceived", | |
11540 | p->afc_adv[afi] | |
11541 | [safi] | |
11542 | ? "and " | |
11543 | : ""); | |
11544 | vty_out(vty, "\n"); | |
11545 | } | |
d62a17ae | 11546 | |
11547 | /* Hostname capability */ | |
60466a63 | 11548 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11549 | |
11550 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11551 | vty_out(vty, |
11552 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11553 | bgp->peer_self->hostname |
11554 | ? bgp->peer_self | |
11555 | ->hostname | |
d77114b7 | 11556 | : "n/a", |
60466a63 QY |
11557 | bgp->peer_self->domainname |
11558 | ? bgp->peer_self | |
11559 | ->domainname | |
d77114b7 MK |
11560 | : "n/a"); |
11561 | } else { | |
11562 | vty_out(vty, " not advertised"); | |
d62a17ae | 11563 | } |
11564 | ||
d77114b7 | 11565 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11566 | vty_out(vty, |
11567 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11568 | p->hostname ? p->hostname |
11569 | : "n/a", | |
11570 | p->domainname ? p->domainname | |
11571 | : "n/a"); | |
d77114b7 MK |
11572 | } else { |
11573 | vty_out(vty, " not received"); | |
11574 | } | |
11575 | ||
11576 | vty_out(vty, "\n"); | |
11577 | ||
d62a17ae | 11578 | /* Gracefull Restart */ |
11579 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11580 | || CHECK_FLAG(p->cap, | |
11581 | PEER_CAP_RESTART_ADV)) { | |
11582 | vty_out(vty, | |
11583 | " Graceful Restart Capabilty:"); | |
11584 | if (CHECK_FLAG(p->cap, | |
11585 | PEER_CAP_RESTART_ADV)) | |
11586 | vty_out(vty, " advertised"); | |
11587 | if (CHECK_FLAG(p->cap, | |
11588 | PEER_CAP_RESTART_RCV)) | |
11589 | vty_out(vty, " %sreceived", | |
11590 | CHECK_FLAG( | |
11591 | p->cap, | |
11592 | PEER_CAP_RESTART_ADV) | |
11593 | ? "and " | |
11594 | : ""); | |
11595 | vty_out(vty, "\n"); | |
11596 | ||
11597 | if (CHECK_FLAG(p->cap, | |
11598 | PEER_CAP_RESTART_RCV)) { | |
11599 | int restart_af_count = 0; | |
11600 | ||
11601 | vty_out(vty, | |
11602 | " Remote Restart timer is %d seconds\n", | |
11603 | p->v_gr_restart); | |
11604 | vty_out(vty, | |
11605 | " Address families by peer:\n "); | |
11606 | ||
05c7a1cc QY |
11607 | FOREACH_AFI_SAFI (afi, safi) |
11608 | if (CHECK_FLAG( | |
11609 | p->af_cap | |
11610 | [afi] | |
11611 | [safi], | |
11612 | PEER_CAP_RESTART_AF_RCV)) { | |
11613 | vty_out(vty, | |
11614 | "%s%s(%s)", | |
11615 | restart_af_count | |
11616 | ? ", " | |
11617 | : "", | |
5cb5f4d0 | 11618 | get_afi_safi_str( |
05c7a1cc | 11619 | afi, |
5cb5f4d0 DD |
11620 | safi, |
11621 | false), | |
05c7a1cc QY |
11622 | CHECK_FLAG( |
11623 | p->af_cap | |
11624 | [afi] | |
11625 | [safi], | |
11626 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11627 | ? "preserved" | |
11628 | : "not preserved"); | |
11629 | restart_af_count++; | |
11630 | } | |
d62a17ae | 11631 | if (!restart_af_count) |
11632 | vty_out(vty, "none"); | |
11633 | vty_out(vty, "\n"); | |
11634 | } | |
2986cac2 | 11635 | } /* Gracefull Restart */ |
d62a17ae | 11636 | } |
11637 | } | |
11638 | } | |
11639 | ||
11640 | /* graceful restart information */ | |
d62a17ae | 11641 | json_object *json_grace = NULL; |
11642 | json_object *json_grace_send = NULL; | |
11643 | json_object *json_grace_recv = NULL; | |
11644 | int eor_send_af_count = 0; | |
11645 | int eor_receive_af_count = 0; | |
11646 | ||
11647 | if (use_json) { | |
11648 | json_grace = json_object_new_object(); | |
11649 | json_grace_send = json_object_new_object(); | |
11650 | json_grace_recv = json_object_new_object(); | |
11651 | ||
2986cac2 | 11652 | if ((p->status == Established) && |
11653 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11654 | FOREACH_AFI_SAFI (afi, safi) { |
11655 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
2986cac2 | 11656 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11657 | json_object_boolean_true_add( |
11658 | json_grace_send, | |
5cb5f4d0 DD |
11659 | get_afi_safi_str(afi, |
11660 | safi, | |
11661 | true)); | |
05c7a1cc | 11662 | eor_send_af_count++; |
d62a17ae | 11663 | } |
11664 | } | |
05c7a1cc QY |
11665 | FOREACH_AFI_SAFI (afi, safi) { |
11666 | if (CHECK_FLAG( | |
2986cac2 | 11667 | p->af_sflags[afi][safi], |
11668 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11669 | json_object_boolean_true_add( |
11670 | json_grace_recv, | |
5cb5f4d0 DD |
11671 | get_afi_safi_str(afi, |
11672 | safi, | |
11673 | true)); | |
05c7a1cc | 11674 | eor_receive_af_count++; |
d62a17ae | 11675 | } |
11676 | } | |
11677 | } | |
2986cac2 | 11678 | json_object_object_add(json_grace, |
11679 | "endOfRibSend", | |
11680 | json_grace_send); | |
11681 | json_object_object_add(json_grace, | |
11682 | "endOfRibRecv", | |
11683 | json_grace_recv); | |
d62a17ae | 11684 | |
d62a17ae | 11685 | |
11686 | if (p->t_gr_restart) | |
11687 | json_object_int_add(json_grace, | |
11688 | "gracefulRestartTimerMsecs", | |
11689 | thread_timer_remain_second( | |
11690 | p->t_gr_restart) | |
11691 | * 1000); | |
11692 | ||
11693 | if (p->t_gr_stale) | |
11694 | json_object_int_add( | |
11695 | json_grace, | |
11696 | "gracefulStalepathTimerMsecs", | |
11697 | thread_timer_remain_second( | |
11698 | p->t_gr_stale) | |
11699 | * 1000); | |
2986cac2 | 11700 | /* more gr info in new format */ |
11701 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
11702 | json_grace); | |
d62a17ae | 11703 | json_object_object_add( |
11704 | json_neigh, "gracefulRestartInfo", json_grace); | |
11705 | } else { | |
2986cac2 | 11706 | vty_out(vty, " Graceful restart informations:\n"); |
11707 | if ((p->status == Established) && | |
11708 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
11709 | ||
d62a17ae | 11710 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11711 | FOREACH_AFI_SAFI (afi, safi) { |
11712 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11713 | PEER_STATUS_EOR_SEND)) { | |
11714 | vty_out(vty, "%s%s", | |
11715 | eor_send_af_count ? ", " | |
11716 | : "", | |
5cb5f4d0 | 11717 | get_afi_safi_str(afi, |
2986cac2 | 11718 | safi, |
11719 | false)); | |
05c7a1cc | 11720 | eor_send_af_count++; |
d62a17ae | 11721 | } |
11722 | } | |
11723 | vty_out(vty, "\n"); | |
11724 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11725 | FOREACH_AFI_SAFI (afi, safi) { |
11726 | if (CHECK_FLAG( | |
11727 | p->af_sflags[afi][safi], | |
11728 | PEER_STATUS_EOR_RECEIVED)) { | |
11729 | vty_out(vty, "%s%s", | |
11730 | eor_receive_af_count | |
11731 | ? ", " | |
11732 | : "", | |
5cb5f4d0 DD |
11733 | get_afi_safi_str(afi, |
11734 | safi, | |
11735 | false)); | |
05c7a1cc | 11736 | eor_receive_af_count++; |
d62a17ae | 11737 | } |
11738 | } | |
11739 | vty_out(vty, "\n"); | |
11740 | } | |
11741 | ||
11742 | if (p->t_gr_restart) | |
11743 | vty_out(vty, | |
11744 | " The remaining time of restart timer is %ld\n", | |
11745 | thread_timer_remain_second( | |
11746 | p->t_gr_restart)); | |
11747 | ||
11748 | if (p->t_gr_stale) | |
11749 | vty_out(vty, | |
11750 | " The remaining time of stalepath timer is %ld\n", | |
11751 | thread_timer_remain_second( | |
11752 | p->t_gr_stale)); | |
2986cac2 | 11753 | |
11754 | /* more gr info in new format */ | |
11755 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11756 | } |
2986cac2 | 11757 | |
d62a17ae | 11758 | if (use_json) { |
11759 | json_object *json_stat = NULL; | |
11760 | json_stat = json_object_new_object(); | |
11761 | /* Packet counts. */ | |
11762 | json_object_int_add(json_stat, "depthInq", 0); | |
11763 | json_object_int_add(json_stat, "depthOutq", | |
11764 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
11765 | json_object_int_add(json_stat, "opensSent", |
11766 | atomic_load_explicit(&p->open_out, | |
11767 | memory_order_relaxed)); | |
11768 | json_object_int_add(json_stat, "opensRecv", | |
11769 | atomic_load_explicit(&p->open_in, | |
11770 | memory_order_relaxed)); | |
d62a17ae | 11771 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11772 | atomic_load_explicit(&p->notify_out, |
11773 | memory_order_relaxed)); | |
d62a17ae | 11774 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11775 | atomic_load_explicit(&p->notify_in, |
11776 | memory_order_relaxed)); | |
11777 | json_object_int_add(json_stat, "updatesSent", | |
11778 | atomic_load_explicit(&p->update_out, | |
11779 | memory_order_relaxed)); | |
11780 | json_object_int_add(json_stat, "updatesRecv", | |
11781 | atomic_load_explicit(&p->update_in, | |
11782 | memory_order_relaxed)); | |
d62a17ae | 11783 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11784 | atomic_load_explicit(&p->keepalive_out, |
11785 | memory_order_relaxed)); | |
d62a17ae | 11786 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11787 | atomic_load_explicit(&p->keepalive_in, |
11788 | memory_order_relaxed)); | |
d62a17ae | 11789 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11790 | atomic_load_explicit(&p->refresh_out, |
11791 | memory_order_relaxed)); | |
d62a17ae | 11792 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11793 | atomic_load_explicit(&p->refresh_in, |
11794 | memory_order_relaxed)); | |
d62a17ae | 11795 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11796 | atomic_load_explicit(&p->dynamic_cap_out, |
11797 | memory_order_relaxed)); | |
d62a17ae | 11798 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11799 | atomic_load_explicit(&p->dynamic_cap_in, |
11800 | memory_order_relaxed)); | |
11801 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11802 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11803 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11804 | } else { | |
11805 | /* Packet counts. */ | |
11806 | vty_out(vty, " Message statistics:\n"); | |
11807 | vty_out(vty, " Inq depth is 0\n"); | |
11808 | vty_out(vty, " Outq depth is %lu\n", | |
11809 | (unsigned long)p->obuf->count); | |
11810 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
11811 | vty_out(vty, " Opens: %10d %10d\n", |
11812 | atomic_load_explicit(&p->open_out, | |
11813 | memory_order_relaxed), | |
11814 | atomic_load_explicit(&p->open_in, | |
11815 | memory_order_relaxed)); | |
11816 | vty_out(vty, " Notifications: %10d %10d\n", | |
11817 | atomic_load_explicit(&p->notify_out, | |
11818 | memory_order_relaxed), | |
11819 | atomic_load_explicit(&p->notify_in, | |
11820 | memory_order_relaxed)); | |
11821 | vty_out(vty, " Updates: %10d %10d\n", | |
11822 | atomic_load_explicit(&p->update_out, | |
11823 | memory_order_relaxed), | |
11824 | atomic_load_explicit(&p->update_in, | |
11825 | memory_order_relaxed)); | |
11826 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11827 | atomic_load_explicit(&p->keepalive_out, | |
11828 | memory_order_relaxed), | |
11829 | atomic_load_explicit(&p->keepalive_in, | |
11830 | memory_order_relaxed)); | |
11831 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11832 | atomic_load_explicit(&p->refresh_out, | |
11833 | memory_order_relaxed), | |
11834 | atomic_load_explicit(&p->refresh_in, | |
11835 | memory_order_relaxed)); | |
d62a17ae | 11836 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11837 | atomic_load_explicit(&p->dynamic_cap_out, |
11838 | memory_order_relaxed), | |
11839 | atomic_load_explicit(&p->dynamic_cap_in, | |
11840 | memory_order_relaxed)); | |
11841 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11842 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11843 | } |
11844 | ||
11845 | if (use_json) { | |
11846 | /* advertisement-interval */ | |
11847 | json_object_int_add(json_neigh, | |
11848 | "minBtwnAdvertisementRunsTimerMsecs", | |
11849 | p->v_routeadv * 1000); | |
11850 | ||
11851 | /* Update-source. */ | |
11852 | if (p->update_if || p->update_source) { | |
11853 | if (p->update_if) | |
11854 | json_object_string_add(json_neigh, | |
11855 | "updateSource", | |
11856 | p->update_if); | |
11857 | else if (p->update_source) | |
11858 | json_object_string_add( | |
11859 | json_neigh, "updateSource", | |
11860 | sockunion2str(p->update_source, buf1, | |
11861 | SU_ADDRSTRLEN)); | |
11862 | } | |
11863 | } else { | |
11864 | /* advertisement-interval */ | |
11865 | vty_out(vty, | |
11866 | " Minimum time between advertisement runs is %d seconds\n", | |
11867 | p->v_routeadv); | |
11868 | ||
11869 | /* Update-source. */ | |
11870 | if (p->update_if || p->update_source) { | |
11871 | vty_out(vty, " Update source is "); | |
11872 | if (p->update_if) | |
11873 | vty_out(vty, "%s", p->update_if); | |
11874 | else if (p->update_source) | |
11875 | vty_out(vty, "%s", | |
11876 | sockunion2str(p->update_source, buf1, | |
11877 | SU_ADDRSTRLEN)); | |
11878 | vty_out(vty, "\n"); | |
11879 | } | |
11880 | ||
11881 | vty_out(vty, "\n"); | |
11882 | } | |
11883 | ||
11884 | /* Address Family Information */ | |
11885 | json_object *json_hold = NULL; | |
11886 | ||
11887 | if (use_json) | |
11888 | json_hold = json_object_new_object(); | |
11889 | ||
05c7a1cc QY |
11890 | FOREACH_AFI_SAFI (afi, safi) |
11891 | if (p->afc[afi][safi]) | |
11892 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11893 | json_hold); | |
d62a17ae | 11894 | |
11895 | if (use_json) { | |
11896 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11897 | json_hold); | |
11898 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11899 | p->established); | |
11900 | json_object_int_add(json_neigh, "connectionsDropped", | |
11901 | p->dropped); | |
11902 | } else | |
11903 | vty_out(vty, " Connections established %d; dropped %d\n", | |
11904 | p->established, p->dropped); | |
11905 | ||
11906 | if (!p->last_reset) { | |
11907 | if (use_json) | |
11908 | json_object_string_add(json_neigh, "lastReset", | |
11909 | "never"); | |
11910 | else | |
11911 | vty_out(vty, " Last reset never\n"); | |
11912 | } else { | |
11913 | if (use_json) { | |
11914 | time_t uptime; | |
11915 | struct tm *tm; | |
11916 | ||
11917 | uptime = bgp_clock(); | |
11918 | uptime -= p->resettime; | |
11919 | tm = gmtime(&uptime); | |
11920 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
11921 | (tm->tm_sec * 1000) | |
11922 | + (tm->tm_min * 60000) | |
11923 | + (tm->tm_hour * 3600000)); | |
3577f1c5 | 11924 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 11925 | } else { |
11926 | vty_out(vty, " Last reset %s, ", | |
11927 | peer_uptime(p->resettime, timebuf, | |
11928 | BGP_UPTIME_LEN, 0, NULL)); | |
11929 | ||
3577f1c5 | 11930 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 11931 | if (p->last_reset_cause_size) { |
11932 | msg = p->last_reset_cause; | |
11933 | vty_out(vty, | |
11934 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
11935 | for (i = 1; i <= p->last_reset_cause_size; | |
11936 | i++) { | |
11937 | vty_out(vty, "%02X", *msg++); | |
11938 | ||
11939 | if (i != p->last_reset_cause_size) { | |
11940 | if (i % 16 == 0) { | |
11941 | vty_out(vty, "\n "); | |
11942 | } else if (i % 4 == 0) { | |
11943 | vty_out(vty, " "); | |
11944 | } | |
11945 | } | |
11946 | } | |
11947 | vty_out(vty, "\n"); | |
11948 | } | |
11949 | } | |
11950 | } | |
11951 | ||
11952 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11953 | if (use_json) | |
11954 | json_object_boolean_true_add(json_neigh, | |
11955 | "prefixesConfigExceedMax"); | |
11956 | else | |
11957 | vty_out(vty, | |
11958 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11959 | ||
11960 | if (p->t_pmax_restart) { | |
11961 | if (use_json) { | |
11962 | json_object_boolean_true_add( | |
11963 | json_neigh, "reducePrefixNumFrom"); | |
11964 | json_object_int_add(json_neigh, | |
11965 | "restartInTimerMsec", | |
11966 | thread_timer_remain_second( | |
11967 | p->t_pmax_restart) | |
11968 | * 1000); | |
11969 | } else | |
11970 | vty_out(vty, | |
11971 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
11972 | p->host, thread_timer_remain_second( |
11973 | p->t_pmax_restart)); | |
d62a17ae | 11974 | } else { |
11975 | if (use_json) | |
11976 | json_object_boolean_true_add( | |
11977 | json_neigh, | |
11978 | "reducePrefixNumAndClearIpBgp"); | |
11979 | else | |
11980 | vty_out(vty, | |
11981 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
11982 | p->host); | |
11983 | } | |
11984 | } | |
11985 | ||
11986 | /* EBGP Multihop and GTSM */ | |
11987 | if (p->sort != BGP_PEER_IBGP) { | |
11988 | if (use_json) { | |
11989 | if (p->gtsm_hops > 0) | |
11990 | json_object_int_add(json_neigh, | |
11991 | "externalBgpNbrMaxHopsAway", | |
11992 | p->gtsm_hops); | |
c8d6f0d6 | 11993 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11994 | json_object_int_add(json_neigh, |
11995 | "externalBgpNbrMaxHopsAway", | |
11996 | p->ttl); | |
11997 | } else { | |
11998 | if (p->gtsm_hops > 0) | |
11999 | vty_out(vty, | |
12000 | " External BGP neighbor may be up to %d hops away.\n", | |
12001 | p->gtsm_hops); | |
c8d6f0d6 | 12002 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12003 | vty_out(vty, |
12004 | " External BGP neighbor may be up to %d hops away.\n", | |
12005 | p->ttl); | |
12006 | } | |
12007 | } else { | |
12008 | if (p->gtsm_hops > 0) { | |
12009 | if (use_json) | |
12010 | json_object_int_add(json_neigh, | |
12011 | "internalBgpNbrMaxHopsAway", | |
12012 | p->gtsm_hops); | |
12013 | else | |
12014 | vty_out(vty, | |
12015 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12016 | p->gtsm_hops); | |
12017 | } | |
12018 | } | |
12019 | ||
12020 | /* Local address. */ | |
12021 | if (p->su_local) { | |
12022 | if (use_json) { | |
12023 | json_object_string_add(json_neigh, "hostLocal", | |
12024 | sockunion2str(p->su_local, buf1, | |
12025 | SU_ADDRSTRLEN)); | |
12026 | json_object_int_add(json_neigh, "portLocal", | |
12027 | ntohs(p->su_local->sin.sin_port)); | |
12028 | } else | |
12029 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12030 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12031 | ntohs(p->su_local->sin.sin_port)); | |
12032 | } | |
12033 | ||
12034 | /* Remote address. */ | |
12035 | if (p->su_remote) { | |
12036 | if (use_json) { | |
12037 | json_object_string_add(json_neigh, "hostForeign", | |
12038 | sockunion2str(p->su_remote, buf1, | |
12039 | SU_ADDRSTRLEN)); | |
12040 | json_object_int_add(json_neigh, "portForeign", | |
12041 | ntohs(p->su_remote->sin.sin_port)); | |
12042 | } else | |
12043 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12044 | sockunion2str(p->su_remote, buf1, | |
12045 | SU_ADDRSTRLEN), | |
12046 | ntohs(p->su_remote->sin.sin_port)); | |
12047 | } | |
12048 | ||
12049 | /* Nexthop display. */ | |
12050 | if (p->su_local) { | |
12051 | if (use_json) { | |
12052 | json_object_string_add(json_neigh, "nexthop", | |
12053 | inet_ntop(AF_INET, | |
12054 | &p->nexthop.v4, buf1, | |
12055 | sizeof(buf1))); | |
12056 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12057 | inet_ntop(AF_INET6, | |
12058 | &p->nexthop.v6_global, | |
12059 | buf1, sizeof(buf1))); | |
12060 | json_object_string_add(json_neigh, "nexthopLocal", | |
12061 | inet_ntop(AF_INET6, | |
12062 | &p->nexthop.v6_local, | |
12063 | buf1, sizeof(buf1))); | |
12064 | if (p->shared_network) | |
12065 | json_object_string_add(json_neigh, | |
12066 | "bgpConnection", | |
12067 | "sharedNetwork"); | |
12068 | else | |
12069 | json_object_string_add(json_neigh, | |
12070 | "bgpConnection", | |
12071 | "nonSharedNetwork"); | |
12072 | } else { | |
12073 | vty_out(vty, "Nexthop: %s\n", | |
12074 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12075 | sizeof(buf1))); | |
12076 | vty_out(vty, "Nexthop global: %s\n", | |
12077 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12078 | sizeof(buf1))); | |
12079 | vty_out(vty, "Nexthop local: %s\n", | |
12080 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12081 | sizeof(buf1))); | |
12082 | vty_out(vty, "BGP connection: %s\n", | |
12083 | p->shared_network ? "shared network" | |
12084 | : "non shared network"); | |
12085 | } | |
12086 | } | |
12087 | ||
12088 | /* Timer information. */ | |
12089 | if (use_json) { | |
12090 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12091 | p->v_connect); | |
12092 | if (p->status == Established && p->rtt) | |
12093 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12094 | p->rtt); | |
12095 | if (p->t_start) | |
12096 | json_object_int_add( | |
12097 | json_neigh, "nextStartTimerDueInMsecs", | |
12098 | thread_timer_remain_second(p->t_start) * 1000); | |
12099 | if (p->t_connect) | |
12100 | json_object_int_add( | |
12101 | json_neigh, "nextConnectTimerDueInMsecs", | |
12102 | thread_timer_remain_second(p->t_connect) | |
12103 | * 1000); | |
12104 | if (p->t_routeadv) { | |
12105 | json_object_int_add(json_neigh, "mraiInterval", | |
12106 | p->v_routeadv); | |
12107 | json_object_int_add( | |
12108 | json_neigh, "mraiTimerExpireInMsecs", | |
12109 | thread_timer_remain_second(p->t_routeadv) | |
12110 | * 1000); | |
12111 | } | |
12112 | if (p->password) | |
12113 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12114 | 1); | |
12115 | ||
12116 | if (p->t_read) | |
12117 | json_object_string_add(json_neigh, "readThread", "on"); | |
12118 | else | |
12119 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12120 | |
12121 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12122 | json_object_string_add(json_neigh, "writeThread", "on"); |
12123 | else | |
12124 | json_object_string_add(json_neigh, "writeThread", | |
12125 | "off"); | |
12126 | } else { | |
12127 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12128 | p->v_connect); | |
12129 | if (p->status == Established && p->rtt) | |
12130 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12131 | p->rtt); | |
12132 | if (p->t_start) | |
12133 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12134 | thread_timer_remain_second(p->t_start)); | |
12135 | if (p->t_connect) | |
12136 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12137 | thread_timer_remain_second(p->t_connect)); | |
12138 | if (p->t_routeadv) | |
12139 | vty_out(vty, | |
12140 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12141 | p->v_routeadv, | |
12142 | thread_timer_remain_second(p->t_routeadv)); | |
12143 | if (p->password) | |
12144 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12145 | ||
cac9e917 | 12146 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12147 | p->t_read ? "on" : "off", |
12148 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12149 | ? "on" | |
cac9e917 | 12150 | : "off", p->fd); |
d62a17ae | 12151 | } |
12152 | ||
12153 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12154 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12155 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12156 | ||
12157 | if (!use_json) | |
12158 | vty_out(vty, "\n"); | |
12159 | ||
12160 | /* BFD information. */ | |
12161 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12162 | ||
12163 | if (use_json) { | |
12164 | if (p->conf_if) /* Configured interface name. */ | |
12165 | json_object_object_add(json, p->conf_if, json_neigh); | |
12166 | else /* Configured IP address. */ | |
12167 | json_object_object_add(json, p->host, json_neigh); | |
12168 | } | |
12169 | } | |
12170 | ||
2986cac2 | 12171 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, |
12172 | struct bgp *bgp, | |
12173 | enum show_type type, | |
12174 | union sockunion *su, | |
12175 | const char *conf_if, afi_t afi, | |
12176 | bool use_json, json_object *json) | |
12177 | { | |
12178 | struct listnode *node, *nnode; | |
12179 | struct peer *peer; | |
12180 | int find = 0; | |
12181 | safi_t safi = SAFI_UNICAST; | |
12182 | json_object *json_neighbor = NULL; | |
12183 | ||
12184 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12185 | ||
12186 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12187 | continue; | |
12188 | ||
12189 | if ((peer->afc[afi][safi]) == 0) | |
12190 | continue; | |
12191 | ||
12192 | if (use_json) | |
12193 | json_neighbor = json_object_new_object(); | |
12194 | ||
2ba1fe69 | 12195 | if (type == show_all) { |
2986cac2 | 12196 | bgp_show_peer_gr_status(vty, peer, use_json, |
12197 | json_neighbor); | |
12198 | ||
12199 | if (use_json) | |
12200 | json_object_object_add(json, | |
12201 | peer->host, json_neighbor); | |
12202 | ||
2ba1fe69 | 12203 | } else if (type == show_peer) { |
2986cac2 | 12204 | if (conf_if) { |
12205 | if ((peer->conf_if | |
12206 | && !strcmp(peer->conf_if, conf_if)) | |
12207 | || (peer->hostname | |
12208 | && !strcmp(peer->hostname, conf_if))) { | |
12209 | find = 1; | |
12210 | bgp_show_peer_gr_status(vty, | |
12211 | peer, use_json, | |
12212 | json_neighbor); | |
12213 | } | |
12214 | } else { | |
12215 | if (sockunion_same(&peer->su, su)) { | |
12216 | find = 1; | |
12217 | bgp_show_peer_gr_status(vty, | |
12218 | peer, use_json, | |
12219 | json_neighbor); | |
12220 | } | |
12221 | } | |
12222 | if (use_json && find) { | |
12223 | json_object_object_add(json, | |
12224 | peer->host, json_neighbor); | |
12225 | } | |
12226 | } | |
12227 | ||
12228 | if (find) | |
12229 | break; | |
12230 | } | |
12231 | ||
12232 | if (type == show_peer && !find) { | |
12233 | if (use_json) | |
12234 | json_object_boolean_true_add(json, | |
12235 | "bgpNoSuchNeighbor"); | |
12236 | else | |
12237 | vty_out(vty, "%% No such neighbor\n"); | |
12238 | } | |
12239 | if (use_json) { | |
12240 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
12241 | json, JSON_C_TO_STRING_PRETTY)); | |
12242 | } else { | |
12243 | vty_out(vty, "\n"); | |
12244 | } | |
12245 | ||
12246 | return CMD_SUCCESS; | |
12247 | } | |
12248 | ||
d62a17ae | 12249 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12250 | enum show_type type, union sockunion *su, | |
9f049418 | 12251 | const char *conf_if, bool use_json, |
d62a17ae | 12252 | json_object *json) |
12253 | { | |
12254 | struct listnode *node, *nnode; | |
12255 | struct peer *peer; | |
12256 | int find = 0; | |
9f049418 | 12257 | bool nbr_output = false; |
d1927ebe AS |
12258 | afi_t afi = AFI_MAX; |
12259 | safi_t safi = SAFI_MAX; | |
12260 | ||
12261 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12262 | afi = AFI_IP; | |
12263 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12264 | afi = AFI_IP6; | |
12265 | } | |
d62a17ae | 12266 | |
12267 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12268 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12269 | continue; | |
12270 | ||
12271 | switch (type) { | |
12272 | case show_all: | |
12273 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12274 | nbr_output = true; |
d62a17ae | 12275 | break; |
12276 | case show_peer: | |
12277 | if (conf_if) { | |
12278 | if ((peer->conf_if | |
12279 | && !strcmp(peer->conf_if, conf_if)) | |
12280 | || (peer->hostname | |
12281 | && !strcmp(peer->hostname, conf_if))) { | |
12282 | find = 1; | |
12283 | bgp_show_peer(vty, peer, use_json, | |
12284 | json); | |
12285 | } | |
12286 | } else { | |
12287 | if (sockunion_same(&peer->su, su)) { | |
12288 | find = 1; | |
12289 | bgp_show_peer(vty, peer, use_json, | |
12290 | json); | |
12291 | } | |
12292 | } | |
12293 | break; | |
d1927ebe AS |
12294 | case show_ipv4_peer: |
12295 | case show_ipv6_peer: | |
12296 | FOREACH_SAFI (safi) { | |
12297 | if (peer->afc[afi][safi]) { | |
12298 | if (conf_if) { | |
12299 | if ((peer->conf_if | |
12300 | && !strcmp(peer->conf_if, conf_if)) | |
12301 | || (peer->hostname | |
12302 | && !strcmp(peer->hostname, conf_if))) { | |
12303 | find = 1; | |
12304 | bgp_show_peer(vty, peer, use_json, | |
12305 | json); | |
12306 | break; | |
12307 | } | |
12308 | } else { | |
12309 | if (sockunion_same(&peer->su, su)) { | |
12310 | find = 1; | |
12311 | bgp_show_peer(vty, peer, use_json, | |
12312 | json); | |
12313 | break; | |
12314 | } | |
12315 | } | |
12316 | } | |
12317 | } | |
12318 | break; | |
12319 | case show_ipv4_all: | |
12320 | case show_ipv6_all: | |
12321 | FOREACH_SAFI (safi) { | |
12322 | if (peer->afc[afi][safi]) { | |
12323 | bgp_show_peer(vty, peer, use_json, json); | |
12324 | nbr_output = true; | |
12325 | break; | |
12326 | } | |
12327 | } | |
12328 | break; | |
d62a17ae | 12329 | } |
12330 | } | |
12331 | ||
d1927ebe AS |
12332 | if ((type == show_peer || type == show_ipv4_peer || |
12333 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12334 | if (use_json) |
12335 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12336 | else | |
88b7d255 | 12337 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12338 | } |
12339 | ||
d1927ebe AS |
12340 | if (type != show_peer && type != show_ipv4_peer && |
12341 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12342 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12343 | |
d62a17ae | 12344 | if (use_json) { |
996c9314 LB |
12345 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12346 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12347 | } else { |
12348 | vty_out(vty, "\n"); | |
12349 | } | |
12350 | ||
12351 | return CMD_SUCCESS; | |
12352 | } | |
12353 | ||
2986cac2 | 12354 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12355 | enum show_type type, const char *ip_str, | |
12356 | afi_t afi, bool use_json) | |
12357 | { | |
12358 | ||
12359 | int ret; | |
12360 | struct bgp *bgp; | |
12361 | union sockunion su; | |
12362 | json_object *json = NULL; | |
12363 | ||
12364 | bgp = bgp_get_default(); | |
12365 | ||
12366 | if (bgp) { | |
12367 | ||
12368 | if (!use_json) { | |
12369 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, | |
12370 | use_json, NULL); | |
12371 | } | |
12372 | ||
12373 | json = json_object_new_object(); | |
12374 | if (ip_str) { | |
12375 | ret = str2sockunion(ip_str, &su); | |
12376 | if (ret < 0) | |
12377 | bgp_show_neighbor_graceful_restart(vty, | |
12378 | bgp, type, NULL, ip_str, | |
12379 | afi, use_json, json); | |
12380 | else | |
12381 | bgp_show_neighbor_graceful_restart(vty, | |
12382 | bgp, type, &su, NULL, | |
12383 | afi, use_json, json); | |
12384 | } else { | |
12385 | bgp_show_neighbor_graceful_restart(vty, bgp, | |
12386 | type, NULL, NULL, afi, | |
12387 | use_json, json); | |
12388 | } | |
12389 | json_object_free(json); | |
12390 | } | |
12391 | ||
12392 | } | |
12393 | ||
d62a17ae | 12394 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12395 | enum show_type type, |
12396 | const char *ip_str, | |
9f049418 | 12397 | bool use_json) |
d62a17ae | 12398 | { |
0291c246 MK |
12399 | struct listnode *node, *nnode; |
12400 | struct bgp *bgp; | |
71aedaa3 | 12401 | union sockunion su; |
0291c246 | 12402 | json_object *json = NULL; |
71aedaa3 | 12403 | int ret, is_first = 1; |
9f049418 | 12404 | bool nbr_output = false; |
d62a17ae | 12405 | |
12406 | if (use_json) | |
12407 | vty_out(vty, "{\n"); | |
12408 | ||
12409 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12410 | nbr_output = true; |
d62a17ae | 12411 | if (use_json) { |
12412 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12413 | flog_err( |
e50f7cfd | 12414 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12415 | "Unable to allocate memory for JSON object"); |
12416 | vty_out(vty, | |
12417 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12418 | return; | |
12419 | } | |
12420 | ||
12421 | json_object_int_add(json, "vrfId", | |
12422 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12423 | ? -1 |
12424 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12425 | json_object_string_add( |
12426 | json, "vrfName", | |
12427 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12428 | ? VRF_DEFAULT_NAME |
d62a17ae | 12429 | : bgp->name); |
12430 | ||
12431 | if (!is_first) | |
12432 | vty_out(vty, ",\n"); | |
12433 | else | |
12434 | is_first = 0; | |
12435 | ||
12436 | vty_out(vty, "\"%s\":", | |
12437 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12438 | ? VRF_DEFAULT_NAME |
d62a17ae | 12439 | : bgp->name); |
12440 | } else { | |
12441 | vty_out(vty, "\nInstance %s:\n", | |
12442 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12443 | ? VRF_DEFAULT_NAME |
d62a17ae | 12444 | : bgp->name); |
12445 | } | |
71aedaa3 | 12446 | |
d1927ebe AS |
12447 | if (type == show_peer || type == show_ipv4_peer || |
12448 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12449 | ret = str2sockunion(ip_str, &su); |
12450 | if (ret < 0) | |
12451 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12452 | use_json, json); | |
12453 | else | |
12454 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12455 | use_json, json); | |
12456 | } else { | |
d1927ebe | 12457 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12458 | use_json, json); |
12459 | } | |
b77004d6 | 12460 | json_object_free(json); |
d62a17ae | 12461 | } |
12462 | ||
01cbfd04 | 12463 | if (use_json) { |
d62a17ae | 12464 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12465 | json_object_free(json); |
12466 | } | |
9f049418 DS |
12467 | else if (!nbr_output) |
12468 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12469 | } |
12470 | ||
12471 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12472 | enum show_type type, const char *ip_str, | |
9f049418 | 12473 | bool use_json) |
d62a17ae | 12474 | { |
12475 | int ret; | |
12476 | struct bgp *bgp; | |
12477 | union sockunion su; | |
12478 | json_object *json = NULL; | |
12479 | ||
12480 | if (name) { | |
12481 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12482 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12483 | use_json); | |
d62a17ae | 12484 | return CMD_SUCCESS; |
12485 | } else { | |
12486 | bgp = bgp_lookup_by_name(name); | |
12487 | if (!bgp) { | |
12488 | if (use_json) { | |
12489 | json = json_object_new_object(); | |
d62a17ae | 12490 | vty_out(vty, "%s\n", |
12491 | json_object_to_json_string_ext( | |
12492 | json, | |
12493 | JSON_C_TO_STRING_PRETTY)); | |
12494 | json_object_free(json); | |
12495 | } else | |
12496 | vty_out(vty, | |
9f049418 | 12497 | "%% BGP instance not found\n"); |
d62a17ae | 12498 | |
12499 | return CMD_WARNING; | |
12500 | } | |
12501 | } | |
12502 | } else { | |
12503 | bgp = bgp_get_default(); | |
12504 | } | |
12505 | ||
12506 | if (bgp) { | |
12507 | json = json_object_new_object(); | |
12508 | if (ip_str) { | |
12509 | ret = str2sockunion(ip_str, &su); | |
12510 | if (ret < 0) | |
12511 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12512 | use_json, json); | |
12513 | else | |
12514 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12515 | use_json, json); | |
12516 | } else { | |
12517 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12518 | json); | |
12519 | } | |
12520 | json_object_free(json); | |
ca61fd25 DS |
12521 | } else { |
12522 | if (use_json) | |
12523 | vty_out(vty, "{}\n"); | |
12524 | else | |
12525 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12526 | } |
12527 | ||
12528 | return CMD_SUCCESS; | |
4fb25c53 DW |
12529 | } |
12530 | ||
2986cac2 | 12531 | |
12532 | ||
12533 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12534 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12535 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12536 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12537 | SHOW_STR | |
12538 | BGP_STR | |
12539 | IP_STR | |
12540 | IPV6_STR | |
12541 | NEIGHBOR_STR | |
12542 | "Neighbor to display information about\n" | |
12543 | "Neighbor to display information about\n" | |
12544 | "Neighbor on BGP configured interface\n" | |
12545 | GR_SHOW | |
12546 | JSON_STR) | |
12547 | { | |
12548 | char *sh_arg = NULL; | |
12549 | enum show_type sh_type; | |
12550 | int idx = 0; | |
12551 | afi_t afi = AFI_MAX; | |
2986cac2 | 12552 | bool uj = use_json(argc, argv); |
12553 | ||
12554 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
12555 | afi = AFI_MAX; | |
12556 | ||
12557 | idx++; | |
12558 | ||
12559 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12560 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12561 | || argv_find(argv, argc, "WORD", &idx)) { | |
12562 | sh_type = show_peer; | |
12563 | sh_arg = argv[idx]->arg; | |
12564 | } else | |
12565 | sh_type = show_all; | |
12566 | ||
12567 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12568 | return CMD_SUCCESS; | |
12569 | ||
12570 | ||
12571 | return bgp_show_neighbor_graceful_restart_afi_all(vty, | |
12572 | sh_type, sh_arg, | |
12573 | afi, uj); | |
12574 | } | |
12575 | ||
716b2d8a | 12576 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12577 | DEFUN (show_ip_bgp_neighbors, |
12578 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12579 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12580 | SHOW_STR |
12581 | IP_STR | |
12582 | BGP_STR | |
f2a8972b | 12583 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12584 | "Address Family\n" |
12585 | "Address Family\n" | |
718e3744 | 12586 | "Detailed information on TCP and BGP neighbor connections\n" |
12587 | "Neighbor to display information about\n" | |
a80beece | 12588 | "Neighbor to display information about\n" |
91d37724 | 12589 | "Neighbor on BGP configured interface\n" |
9973d184 | 12590 | JSON_STR) |
718e3744 | 12591 | { |
d62a17ae | 12592 | char *vrf = NULL; |
12593 | char *sh_arg = NULL; | |
12594 | enum show_type sh_type; | |
d1927ebe | 12595 | afi_t afi = AFI_MAX; |
718e3744 | 12596 | |
9f049418 | 12597 | bool uj = use_json(argc, argv); |
718e3744 | 12598 | |
d62a17ae | 12599 | int idx = 0; |
718e3744 | 12600 | |
9a8bdf1c PG |
12601 | /* [<vrf> VIEWVRFNAME] */ |
12602 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12603 | vrf = argv[idx + 1]->arg; | |
12604 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12605 | vrf = NULL; | |
12606 | } else if (argv_find(argv, argc, "view", &idx)) | |
12607 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12608 | vrf = argv[idx + 1]->arg; |
718e3744 | 12609 | |
d62a17ae | 12610 | idx++; |
d1927ebe AS |
12611 | |
12612 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12613 | sh_type = show_ipv4_all; | |
12614 | afi = AFI_IP; | |
12615 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12616 | sh_type = show_ipv6_all; | |
12617 | afi = AFI_IP6; | |
12618 | } else { | |
12619 | sh_type = show_all; | |
12620 | } | |
12621 | ||
d62a17ae | 12622 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12623 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12624 | || argv_find(argv, argc, "WORD", &idx)) { | |
12625 | sh_type = show_peer; | |
12626 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12627 | } |
12628 | ||
12629 | if (sh_type == show_peer && afi == AFI_IP) { | |
12630 | sh_type = show_ipv4_peer; | |
12631 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12632 | sh_type = show_ipv6_peer; | |
12633 | } | |
856ca177 | 12634 | |
d62a17ae | 12635 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12636 | } |
12637 | ||
716b2d8a | 12638 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12639 | paths' and `show ip mbgp paths'. Those functions results are the |
12640 | same.*/ | |
f412b39a | 12641 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12642 | show_ip_bgp_paths_cmd, |
46f296b4 | 12643 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12644 | SHOW_STR |
12645 | IP_STR | |
12646 | BGP_STR | |
46f296b4 | 12647 | BGP_SAFI_HELP_STR |
718e3744 | 12648 | "Path information\n") |
12649 | { | |
d62a17ae | 12650 | vty_out(vty, "Address Refcnt Path\n"); |
12651 | aspath_print_all_vty(vty); | |
12652 | return CMD_SUCCESS; | |
718e3744 | 12653 | } |
12654 | ||
718e3744 | 12655 | #include "hash.h" |
12656 | ||
e3b78da8 | 12657 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12658 | struct vty *vty) |
718e3744 | 12659 | { |
d62a17ae | 12660 | struct community *com; |
718e3744 | 12661 | |
e3b78da8 | 12662 | com = (struct community *)bucket->data; |
3f65c5b1 | 12663 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12664 | community_str(com, false)); |
718e3744 | 12665 | } |
12666 | ||
12667 | /* Show BGP's community internal data. */ | |
f412b39a | 12668 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12669 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12670 | "show [ip] bgp community-info", |
718e3744 | 12671 | SHOW_STR |
12672 | IP_STR | |
12673 | BGP_STR | |
12674 | "List all bgp community information\n") | |
12675 | { | |
d62a17ae | 12676 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12677 | |
d62a17ae | 12678 | hash_iterate(community_hash(), |
e3b78da8 | 12679 | (void (*)(struct hash_bucket *, |
d62a17ae | 12680 | void *))community_show_all_iterator, |
12681 | vty); | |
718e3744 | 12682 | |
d62a17ae | 12683 | return CMD_SUCCESS; |
718e3744 | 12684 | } |
12685 | ||
e3b78da8 | 12686 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12687 | struct vty *vty) |
57d187bc | 12688 | { |
d62a17ae | 12689 | struct lcommunity *lcom; |
57d187bc | 12690 | |
e3b78da8 | 12691 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12692 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12693 | lcommunity_str(lcom, false)); |
57d187bc JS |
12694 | } |
12695 | ||
12696 | /* Show BGP's community internal data. */ | |
12697 | DEFUN (show_ip_bgp_lcommunity_info, | |
12698 | show_ip_bgp_lcommunity_info_cmd, | |
12699 | "show ip bgp large-community-info", | |
12700 | SHOW_STR | |
12701 | IP_STR | |
12702 | BGP_STR | |
12703 | "List all bgp large-community information\n") | |
12704 | { | |
d62a17ae | 12705 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12706 | |
d62a17ae | 12707 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12708 | (void (*)(struct hash_bucket *, |
d62a17ae | 12709 | void *))lcommunity_show_all_iterator, |
12710 | vty); | |
57d187bc | 12711 | |
d62a17ae | 12712 | return CMD_SUCCESS; |
57d187bc | 12713 | } |
2986cac2 | 12714 | /* Graceful Restart */ |
12715 | ||
12716 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
12717 | struct bgp *bgp, | |
12718 | bool use_json, | |
12719 | json_object *json) | |
12720 | { | |
57d187bc JS |
12721 | |
12722 | ||
2986cac2 | 12723 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12724 | ||
12725 | int bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); | |
12726 | ||
12727 | switch (bgp_global_gr_mode) { | |
12728 | ||
12729 | case GLOBAL_HELPER: | |
12730 | vty_out(vty, | |
2ba1fe69 | 12731 | "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12732 | break; |
12733 | ||
12734 | case GLOBAL_GR: | |
12735 | vty_out(vty, | |
2ba1fe69 | 12736 | "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12737 | break; |
12738 | ||
12739 | case GLOBAL_DISABLE: | |
12740 | vty_out(vty, | |
2ba1fe69 | 12741 | "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12742 | break; |
12743 | ||
12744 | case GLOBAL_INVALID: | |
12745 | default: | |
12746 | vty_out(vty, | |
2ba1fe69 | 12747 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12748 | break; |
12749 | } | |
12750 | vty_out(vty, "\n"); | |
12751 | } | |
12752 | ||
12753 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, | |
12754 | enum show_type type, | |
12755 | const char *ip_str, | |
12756 | afi_t afi, | |
12757 | bool use_json) | |
12758 | { | |
12759 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12760 | afi = AFI_IP; | |
12761 | ||
12762 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12763 | ||
12764 | bgp_show_neighbor_graceful_restart_vty(vty, | |
12765 | type, ip_str, | |
12766 | afi, use_json); | |
12767 | afi++; | |
12768 | } | |
12769 | } else if (afi != AFI_MAX) { | |
12770 | bgp_show_neighbor_graceful_restart_vty(vty, | |
12771 | type, ip_str, | |
12772 | afi, use_json); | |
12773 | } else { | |
12774 | return CMD_ERR_INCOMPLETE; | |
12775 | } | |
12776 | ||
12777 | return CMD_SUCCESS; | |
12778 | } | |
12779 | /* Graceful Restart */ | |
12780 | ||
f412b39a | 12781 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12782 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12783 | "show [ip] bgp attribute-info", |
718e3744 | 12784 | SHOW_STR |
12785 | IP_STR | |
12786 | BGP_STR | |
12787 | "List all bgp attribute information\n") | |
12788 | { | |
d62a17ae | 12789 | attr_show_all(vty); |
12790 | return CMD_SUCCESS; | |
718e3744 | 12791 | } |
6b0655a2 | 12792 | |
03915806 CS |
12793 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12794 | afi_t afi, safi_t safi, | |
12795 | bool use_json, json_object *json) | |
53089bec | 12796 | { |
12797 | struct bgp *bgp; | |
12798 | struct listnode *node; | |
12799 | char *vname; | |
12800 | char buf1[INET6_ADDRSTRLEN]; | |
12801 | char *ecom_str; | |
12802 | vpn_policy_direction_t dir; | |
12803 | ||
03915806 | 12804 | if (json) { |
b46dfd20 DS |
12805 | json_object *json_import_vrfs = NULL; |
12806 | json_object *json_export_vrfs = NULL; | |
12807 | ||
b46dfd20 DS |
12808 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12809 | ||
53089bec | 12810 | if (!bgp) { |
b46dfd20 DS |
12811 | vty_out(vty, "%s\n", |
12812 | json_object_to_json_string_ext( | |
12813 | json, | |
12814 | JSON_C_TO_STRING_PRETTY)); | |
12815 | json_object_free(json); | |
12816 | ||
53089bec | 12817 | return CMD_WARNING; |
12818 | } | |
b46dfd20 | 12819 | |
94d4c685 DS |
12820 | /* Provide context for the block */ |
12821 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12822 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12823 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12824 | |
b46dfd20 DS |
12825 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12826 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12827 | json_object_string_add(json, "importFromVrfs", "none"); | |
12828 | json_object_string_add(json, "importRts", "none"); | |
12829 | } else { | |
6ce24e52 DS |
12830 | json_import_vrfs = json_object_new_array(); |
12831 | ||
b46dfd20 DS |
12832 | for (ALL_LIST_ELEMENTS_RO( |
12833 | bgp->vpn_policy[afi].import_vrf, | |
12834 | node, vname)) | |
12835 | json_object_array_add(json_import_vrfs, | |
12836 | json_object_new_string(vname)); | |
12837 | ||
b20875ea CS |
12838 | json_object_object_add(json, "importFromVrfs", |
12839 | json_import_vrfs); | |
b46dfd20 | 12840 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12841 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12842 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12843 | bgp->vpn_policy[afi].rtlist[dir], |
12844 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12845 | json_object_string_add(json, "importRts", |
12846 | ecom_str); | |
12847 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12848 | } else | |
12849 | json_object_string_add(json, "importRts", | |
12850 | "none"); | |
b46dfd20 DS |
12851 | } |
12852 | ||
12853 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12854 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12855 | json_object_string_add(json, "exportToVrfs", "none"); | |
12856 | json_object_string_add(json, "routeDistinguisher", | |
12857 | "none"); | |
12858 | json_object_string_add(json, "exportRts", "none"); | |
12859 | } else { | |
6ce24e52 DS |
12860 | json_export_vrfs = json_object_new_array(); |
12861 | ||
b46dfd20 DS |
12862 | for (ALL_LIST_ELEMENTS_RO( |
12863 | bgp->vpn_policy[afi].export_vrf, | |
12864 | node, vname)) | |
12865 | json_object_array_add(json_export_vrfs, | |
12866 | json_object_new_string(vname)); | |
12867 | json_object_object_add(json, "exportToVrfs", | |
12868 | json_export_vrfs); | |
12869 | json_object_string_add(json, "routeDistinguisher", | |
12870 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12871 | buf1, RD_ADDRSTRLEN)); | |
12872 | ||
12873 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12874 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12875 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12876 | bgp->vpn_policy[afi].rtlist[dir], |
12877 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12878 | json_object_string_add(json, "exportRts", |
12879 | ecom_str); | |
12880 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12881 | } else | |
12882 | json_object_string_add(json, "exportRts", | |
12883 | "none"); | |
b46dfd20 DS |
12884 | } |
12885 | ||
03915806 CS |
12886 | if (use_json) { |
12887 | vty_out(vty, "%s\n", | |
12888 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12889 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12890 | json_object_free(json); |
12891 | } | |
53089bec | 12892 | } else { |
b46dfd20 DS |
12893 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12894 | ||
53089bec | 12895 | if (!bgp) { |
b46dfd20 | 12896 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12897 | return CMD_WARNING; |
12898 | } | |
53089bec | 12899 | |
b46dfd20 DS |
12900 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12901 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12902 | vty_out(vty, | |
12903 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12904 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12905 | else { |
12906 | vty_out(vty, | |
12907 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 12908 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12909 | |
12910 | for (ALL_LIST_ELEMENTS_RO( | |
12911 | bgp->vpn_policy[afi].import_vrf, | |
12912 | node, vname)) | |
12913 | vty_out(vty, " %s\n", vname); | |
12914 | ||
12915 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
12916 | ecom_str = NULL; |
12917 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
12918 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12919 | bgp->vpn_policy[afi].rtlist[dir], |
12920 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 12921 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 12922 | |
b20875ea CS |
12923 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
12924 | } else | |
12925 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12926 | } |
53089bec | 12927 | |
b46dfd20 DS |
12928 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12929 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12930 | vty_out(vty, | |
12931 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 12932 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12933 | else { |
12934 | vty_out(vty, | |
04c9077f | 12935 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 12936 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12937 | |
12938 | for (ALL_LIST_ELEMENTS_RO( | |
12939 | bgp->vpn_policy[afi].export_vrf, | |
12940 | node, vname)) | |
12941 | vty_out(vty, " %s\n", vname); | |
12942 | ||
12943 | vty_out(vty, "RD: %s\n", | |
12944 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12945 | buf1, RD_ADDRSTRLEN)); | |
12946 | ||
12947 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12948 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12949 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12950 | bgp->vpn_policy[afi].rtlist[dir], |
12951 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12952 | vty_out(vty, "Export RT: %s\n", ecom_str); |
12953 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12954 | } else | |
12955 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12956 | } |
53089bec | 12957 | } |
12958 | ||
12959 | return CMD_SUCCESS; | |
12960 | } | |
12961 | ||
03915806 CS |
12962 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
12963 | safi_t safi, bool use_json) | |
12964 | { | |
12965 | struct listnode *node, *nnode; | |
12966 | struct bgp *bgp; | |
12967 | char *vrf_name = NULL; | |
12968 | json_object *json = NULL; | |
12969 | json_object *json_vrf = NULL; | |
12970 | json_object *json_vrfs = NULL; | |
12971 | ||
12972 | if (use_json) { | |
12973 | json = json_object_new_object(); | |
12974 | json_vrfs = json_object_new_object(); | |
12975 | } | |
12976 | ||
12977 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
12978 | ||
12979 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
12980 | vrf_name = bgp->name; | |
12981 | ||
12982 | if (use_json) { | |
12983 | json_vrf = json_object_new_object(); | |
12984 | } else { | |
12985 | vty_out(vty, "\nInstance %s:\n", | |
12986 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12987 | ? VRF_DEFAULT_NAME : bgp->name); | |
12988 | } | |
12989 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
12990 | if (use_json) { | |
12991 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12992 | json_object_object_add(json_vrfs, | |
12993 | VRF_DEFAULT_NAME, json_vrf); | |
12994 | else | |
12995 | json_object_object_add(json_vrfs, vrf_name, | |
12996 | json_vrf); | |
12997 | } | |
12998 | } | |
12999 | ||
13000 | if (use_json) { | |
13001 | json_object_object_add(json, "vrfs", json_vrfs); | |
13002 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13003 | JSON_C_TO_STRING_PRETTY)); | |
13004 | json_object_free(json); | |
13005 | } | |
13006 | ||
13007 | return CMD_SUCCESS; | |
13008 | } | |
13009 | ||
53089bec | 13010 | /* "show [ip] bgp route-leak" command. */ |
13011 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13012 | show_ip_bgp_route_leak_cmd, |
13013 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13014 | SHOW_STR |
13015 | IP_STR | |
13016 | BGP_STR | |
13017 | BGP_INSTANCE_HELP_STR | |
13018 | BGP_AFI_HELP_STR | |
13019 | BGP_SAFI_HELP_STR | |
13020 | "Route leaking information\n" | |
13021 | JSON_STR) | |
53089bec | 13022 | { |
13023 | char *vrf = NULL; | |
13024 | afi_t afi = AFI_MAX; | |
13025 | safi_t safi = SAFI_MAX; | |
13026 | ||
9f049418 | 13027 | bool uj = use_json(argc, argv); |
53089bec | 13028 | int idx = 0; |
03915806 | 13029 | json_object *json = NULL; |
53089bec | 13030 | |
13031 | /* show [ip] bgp */ | |
13032 | if (argv_find(argv, argc, "ip", &idx)) { | |
13033 | afi = AFI_IP; | |
13034 | safi = SAFI_UNICAST; | |
13035 | } | |
13036 | /* [vrf VIEWVRFNAME] */ | |
13037 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13038 | vty_out(vty, |
13039 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13040 | return CMD_WARNING; |
13041 | } | |
13042 | ||
9a8bdf1c PG |
13043 | if (argv_find(argv, argc, "vrf", &idx)) { |
13044 | vrf = argv[idx + 1]->arg; | |
13045 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13046 | vrf = NULL; | |
13047 | } | |
53089bec | 13048 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13049 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13050 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13051 | } | |
13052 | ||
13053 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13054 | vty_out(vty, |
13055 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13056 | return CMD_WARNING; |
13057 | } | |
13058 | ||
03915806 CS |
13059 | if (vrf && strmatch(vrf, "all")) |
13060 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13061 | ||
13062 | if (uj) | |
13063 | json = json_object_new_object(); | |
13064 | ||
13065 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13066 | } |
13067 | ||
d62a17ae | 13068 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13069 | safi_t safi) | |
f186de26 | 13070 | { |
d62a17ae | 13071 | struct listnode *node, *nnode; |
13072 | struct bgp *bgp; | |
f186de26 | 13073 | |
d62a17ae | 13074 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13075 | vty_out(vty, "\nInstance %s:\n", | |
13076 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13077 | ? VRF_DEFAULT_NAME |
d62a17ae | 13078 | : bgp->name); |
13079 | update_group_show(bgp, afi, safi, vty, 0); | |
13080 | } | |
f186de26 | 13081 | } |
13082 | ||
d62a17ae | 13083 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13084 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13085 | { |
d62a17ae | 13086 | struct bgp *bgp; |
4fb25c53 | 13087 | |
d62a17ae | 13088 | if (name) { |
13089 | if (strmatch(name, "all")) { | |
13090 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13091 | return CMD_SUCCESS; | |
13092 | } else { | |
13093 | bgp = bgp_lookup_by_name(name); | |
13094 | } | |
13095 | } else { | |
13096 | bgp = bgp_get_default(); | |
13097 | } | |
4fb25c53 | 13098 | |
d62a17ae | 13099 | if (bgp) |
13100 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13101 | return CMD_SUCCESS; | |
4fb25c53 DW |
13102 | } |
13103 | ||
8fe8a7f6 DS |
13104 | DEFUN (show_ip_bgp_updgrps, |
13105 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13106 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13107 | SHOW_STR |
13108 | IP_STR | |
13109 | BGP_STR | |
13110 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13111 | BGP_AFI_HELP_STR |
9bedbb1e | 13112 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13113 | "Detailed info about dynamic update groups\n" |
13114 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13115 | { |
d62a17ae | 13116 | char *vrf = NULL; |
13117 | afi_t afi = AFI_IP6; | |
13118 | safi_t safi = SAFI_UNICAST; | |
13119 | uint64_t subgrp_id = 0; | |
13120 | ||
13121 | int idx = 0; | |
13122 | ||
13123 | /* show [ip] bgp */ | |
13124 | if (argv_find(argv, argc, "ip", &idx)) | |
13125 | afi = AFI_IP; | |
9a8bdf1c PG |
13126 | /* [<vrf> VIEWVRFNAME] */ |
13127 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13128 | vrf = argv[idx + 1]->arg; | |
13129 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13130 | vrf = NULL; | |
13131 | } else if (argv_find(argv, argc, "view", &idx)) | |
13132 | /* [<view> VIEWVRFNAME] */ | |
13133 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13134 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13135 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13136 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13137 | } | |
5bf15956 | 13138 | |
d62a17ae | 13139 | /* get subgroup id, if provided */ |
13140 | idx = argc - 1; | |
13141 | if (argv[idx]->type == VARIABLE_TKN) | |
13142 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13143 | |
d62a17ae | 13144 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13145 | } |
13146 | ||
f186de26 | 13147 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13148 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13149 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13150 | SHOW_STR |
716b2d8a | 13151 | IP_STR |
f186de26 | 13152 | BGP_STR |
13153 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13154 | "Detailed info about dynamic update groups\n") |
f186de26 | 13155 | { |
d62a17ae | 13156 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13157 | return CMD_SUCCESS; | |
f186de26 | 13158 | } |
13159 | ||
43d3f4fc DS |
13160 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13161 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13162 | "show [ip] bgp l2vpn evpn update-groups", | |
13163 | SHOW_STR | |
13164 | IP_STR | |
13165 | BGP_STR | |
13166 | "l2vpn address family\n" | |
13167 | "evpn sub-address family\n" | |
13168 | "Detailed info about dynamic update groups\n") | |
13169 | { | |
13170 | char *vrf = NULL; | |
13171 | uint64_t subgrp_id = 0; | |
13172 | ||
13173 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13174 | return CMD_SUCCESS; | |
13175 | } | |
13176 | ||
5bf15956 DW |
13177 | DEFUN (show_bgp_updgrps_stats, |
13178 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13179 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13180 | SHOW_STR |
716b2d8a | 13181 | IP_STR |
3f9c7369 | 13182 | BGP_STR |
0c7b1b01 | 13183 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13184 | "Statistics\n") |
13185 | { | |
d62a17ae | 13186 | struct bgp *bgp; |
3f9c7369 | 13187 | |
d62a17ae | 13188 | bgp = bgp_get_default(); |
13189 | if (bgp) | |
13190 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13191 | |
d62a17ae | 13192 | return CMD_SUCCESS; |
3f9c7369 DS |
13193 | } |
13194 | ||
8386ac43 | 13195 | DEFUN (show_bgp_instance_updgrps_stats, |
13196 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13197 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13198 | SHOW_STR |
716b2d8a | 13199 | IP_STR |
8386ac43 | 13200 | BGP_STR |
13201 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13202 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13203 | "Statistics\n") |
13204 | { | |
d62a17ae | 13205 | int idx_word = 3; |
13206 | struct bgp *bgp; | |
8386ac43 | 13207 | |
d62a17ae | 13208 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13209 | if (bgp) | |
13210 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13211 | |
d62a17ae | 13212 | return CMD_SUCCESS; |
8386ac43 | 13213 | } |
13214 | ||
d62a17ae | 13215 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13216 | afi_t afi, safi_t safi, | |
13217 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13218 | { |
d62a17ae | 13219 | struct bgp *bgp; |
8386ac43 | 13220 | |
d62a17ae | 13221 | if (name) |
13222 | bgp = bgp_lookup_by_name(name); | |
13223 | else | |
13224 | bgp = bgp_get_default(); | |
8386ac43 | 13225 | |
d62a17ae | 13226 | if (bgp) { |
13227 | if (!strcmp(what, "advertise-queue")) | |
13228 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13229 | subgrp_id); | |
13230 | else if (!strcmp(what, "advertised-routes")) | |
13231 | update_group_show_advertised(bgp, afi, safi, vty, | |
13232 | subgrp_id); | |
13233 | else if (!strcmp(what, "packet-queue")) | |
13234 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13235 | subgrp_id); | |
13236 | } | |
3f9c7369 DS |
13237 | } |
13238 | ||
dc64bdec QY |
13239 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13240 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13241 | "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", | |
13242 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13243 | BGP_SAFI_HELP_STR | |
13244 | "Detailed info about dynamic update groups\n" | |
13245 | "Specific subgroup to display info for\n" | |
13246 | "Advertisement queue\n" | |
13247 | "Announced routes\n" | |
13248 | "Packet queue\n") | |
3f9c7369 | 13249 | { |
dc64bdec QY |
13250 | uint64_t subgrp_id = 0; |
13251 | afi_t afiz; | |
13252 | safi_t safiz; | |
13253 | if (sgid) | |
13254 | subgrp_id = strtoull(sgid, NULL, 10); | |
13255 | ||
13256 | if (!ip && !afi) | |
13257 | afiz = AFI_IP6; | |
13258 | if (!ip && afi) | |
13259 | afiz = bgp_vty_afi_from_str(afi); | |
13260 | if (ip && !afi) | |
13261 | afiz = AFI_IP; | |
13262 | if (ip && afi) { | |
13263 | afiz = bgp_vty_afi_from_str(afi); | |
13264 | if (afiz != AFI_IP) | |
13265 | vty_out(vty, | |
13266 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13267 | return CMD_WARNING; | |
13268 | } | |
d62a17ae | 13269 | |
dc64bdec | 13270 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13271 | |
dc64bdec | 13272 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13273 | return CMD_SUCCESS; |
13274 | } | |
13275 | ||
d62a17ae | 13276 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13277 | { | |
13278 | struct listnode *node, *nnode; | |
13279 | struct prefix *range; | |
13280 | struct peer *conf; | |
13281 | struct peer *peer; | |
13282 | char buf[PREFIX2STR_BUFFER]; | |
13283 | afi_t afi; | |
13284 | safi_t safi; | |
13285 | const char *peer_status; | |
13286 | const char *af_str; | |
13287 | int lr_count; | |
13288 | int dynamic; | |
13289 | int af_cfgd; | |
13290 | ||
13291 | conf = group->conf; | |
13292 | ||
13293 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13294 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13295 | group->name, conf->as); | |
d62a17ae | 13296 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13297 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13298 | group->name, group->bgp->as); | |
d62a17ae | 13299 | } else { |
13300 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13301 | } | |
f14e6fdb | 13302 | |
d62a17ae | 13303 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13304 | vty_out(vty, " Peer-group type is internal\n"); | |
13305 | else | |
13306 | vty_out(vty, " Peer-group type is external\n"); | |
13307 | ||
13308 | /* Display AFs configured. */ | |
13309 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13310 | FOREACH_AFI_SAFI (afi, safi) { |
13311 | if (conf->afc[afi][safi]) { | |
13312 | af_cfgd = 1; | |
5cb5f4d0 | 13313 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13314 | } |
05c7a1cc | 13315 | } |
d62a17ae | 13316 | if (!af_cfgd) |
13317 | vty_out(vty, " none\n"); | |
13318 | else | |
13319 | vty_out(vty, "\n"); | |
13320 | ||
13321 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13322 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13323 | if (afi == AFI_IP) | |
13324 | af_str = "IPv4"; | |
13325 | else if (afi == AFI_IP6) | |
13326 | af_str = "IPv6"; | |
13327 | else | |
13328 | af_str = "???"; | |
13329 | lr_count = listcount(group->listen_range[afi]); | |
13330 | if (lr_count) { | |
13331 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13332 | af_str); | |
13333 | ||
13334 | ||
13335 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13336 | nnode, range)) { | |
13337 | prefix2str(range, buf, sizeof(buf)); | |
13338 | vty_out(vty, " %s\n", buf); | |
13339 | } | |
13340 | } | |
13341 | } | |
f14e6fdb | 13342 | |
d62a17ae | 13343 | /* Display group members and their status */ |
13344 | if (listcount(group->peer)) { | |
13345 | vty_out(vty, " Peer-group members:\n"); | |
13346 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13347 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13348 | peer_status = "Idle (Admin)"; | |
13349 | else if (CHECK_FLAG(peer->sflags, | |
13350 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13351 | peer_status = "Idle (PfxCt)"; | |
13352 | else | |
13353 | peer_status = lookup_msg(bgp_status_msg, | |
13354 | peer->status, NULL); | |
13355 | ||
13356 | dynamic = peer_dynamic_neighbor(peer); | |
13357 | vty_out(vty, " %s %s %s \n", peer->host, | |
13358 | dynamic ? "(dynamic)" : "", peer_status); | |
13359 | } | |
13360 | } | |
f14e6fdb | 13361 | |
d62a17ae | 13362 | return CMD_SUCCESS; |
13363 | } | |
13364 | ||
ff9959b0 QY |
13365 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13366 | const char *group_name) | |
d62a17ae | 13367 | { |
ff9959b0 | 13368 | struct bgp *bgp; |
d62a17ae | 13369 | struct listnode *node, *nnode; |
13370 | struct peer_group *group; | |
ff9959b0 QY |
13371 | bool found = false; |
13372 | ||
13373 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13374 | ||
13375 | if (!bgp) { | |
9f049418 | 13376 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13377 | return CMD_WARNING; |
13378 | } | |
d62a17ae | 13379 | |
13380 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13381 | if (group_name) { |
13382 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13383 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13384 | found = true; |
13385 | break; | |
d62a17ae | 13386 | } |
ff9959b0 QY |
13387 | } else { |
13388 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13389 | } |
f14e6fdb | 13390 | } |
f14e6fdb | 13391 | |
ff9959b0 | 13392 | if (group_name && !found) |
d62a17ae | 13393 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13394 | |
d62a17ae | 13395 | return CMD_SUCCESS; |
f14e6fdb DS |
13396 | } |
13397 | ||
f14e6fdb DS |
13398 | DEFUN (show_ip_bgp_peer_groups, |
13399 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13400 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13401 | SHOW_STR |
13402 | IP_STR | |
13403 | BGP_STR | |
8386ac43 | 13404 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13405 | "Detailed information on BGP peer groups\n" |
13406 | "Peer group name\n") | |
f14e6fdb | 13407 | { |
d62a17ae | 13408 | char *vrf, *pg; |
d62a17ae | 13409 | int idx = 0; |
f14e6fdb | 13410 | |
a4d82a8a PZ |
13411 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13412 | : NULL; | |
d62a17ae | 13413 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13414 | |
ff9959b0 | 13415 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13416 | } |
3f9c7369 | 13417 | |
d6e3c605 | 13418 | |
718e3744 | 13419 | /* Redistribute VTY commands. */ |
13420 | ||
718e3744 | 13421 | DEFUN (bgp_redistribute_ipv4, |
13422 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13423 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13424 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13425 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13426 | { |
d62a17ae | 13427 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13428 | int idx_protocol = 1; | |
13429 | int type; | |
718e3744 | 13430 | |
d62a17ae | 13431 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13432 | if (type < 0) { | |
13433 | vty_out(vty, "%% Invalid route type\n"); | |
13434 | return CMD_WARNING_CONFIG_FAILED; | |
13435 | } | |
7f323236 | 13436 | |
d62a17ae | 13437 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13438 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13439 | } |
13440 | ||
d62a17ae | 13441 | ALIAS_HIDDEN( |
13442 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13443 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13444 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13445 | |
718e3744 | 13446 | DEFUN (bgp_redistribute_ipv4_rmap, |
13447 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13448 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13449 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13450 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13451 | "Route map reference\n" |
13452 | "Pointer to route-map entries\n") | |
13453 | { | |
d62a17ae | 13454 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13455 | int idx_protocol = 1; | |
13456 | int idx_word = 3; | |
13457 | int type; | |
13458 | struct bgp_redist *red; | |
e923dd62 | 13459 | bool changed; |
1de27621 DA |
13460 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13461 | vty, argv[idx_word]->arg); | |
718e3744 | 13462 | |
d62a17ae | 13463 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13464 | if (type < 0) { | |
13465 | vty_out(vty, "%% Invalid route type\n"); | |
13466 | return CMD_WARNING_CONFIG_FAILED; | |
13467 | } | |
718e3744 | 13468 | |
d62a17ae | 13469 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13470 | changed = |
13471 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13472 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13473 | } |
13474 | ||
d62a17ae | 13475 | ALIAS_HIDDEN( |
13476 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13477 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13478 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13479 | "Route map reference\n" | |
13480 | "Pointer to route-map entries\n") | |
596c17ba | 13481 | |
718e3744 | 13482 | DEFUN (bgp_redistribute_ipv4_metric, |
13483 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13484 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13485 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13486 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13487 | "Metric for redistributed routes\n" |
13488 | "Default metric\n") | |
13489 | { | |
d62a17ae | 13490 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13491 | int idx_protocol = 1; | |
13492 | int idx_number = 3; | |
13493 | int type; | |
d7c0a89a | 13494 | uint32_t metric; |
d62a17ae | 13495 | struct bgp_redist *red; |
e923dd62 | 13496 | bool changed; |
d62a17ae | 13497 | |
13498 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13499 | if (type < 0) { | |
13500 | vty_out(vty, "%% Invalid route type\n"); | |
13501 | return CMD_WARNING_CONFIG_FAILED; | |
13502 | } | |
13503 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13504 | ||
13505 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13506 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13507 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13508 | } |
13509 | ||
13510 | ALIAS_HIDDEN( | |
13511 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13512 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13513 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13514 | "Metric for redistributed routes\n" | |
13515 | "Default metric\n") | |
596c17ba | 13516 | |
718e3744 | 13517 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13518 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13519 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13520 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13521 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13522 | "Route map reference\n" |
13523 | "Pointer to route-map entries\n" | |
13524 | "Metric for redistributed routes\n" | |
13525 | "Default metric\n") | |
13526 | { | |
d62a17ae | 13527 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13528 | int idx_protocol = 1; | |
13529 | int idx_word = 3; | |
13530 | int idx_number = 5; | |
13531 | int type; | |
d7c0a89a | 13532 | uint32_t metric; |
d62a17ae | 13533 | struct bgp_redist *red; |
e923dd62 | 13534 | bool changed; |
1de27621 DA |
13535 | struct route_map *route_map = |
13536 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13537 | |
13538 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13539 | if (type < 0) { | |
13540 | vty_out(vty, "%% Invalid route type\n"); | |
13541 | return CMD_WARNING_CONFIG_FAILED; | |
13542 | } | |
13543 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13544 | ||
13545 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13546 | changed = |
13547 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13548 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13549 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13550 | } |
13551 | ||
13552 | ALIAS_HIDDEN( | |
13553 | bgp_redistribute_ipv4_rmap_metric, | |
13554 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13555 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13556 | " route-map WORD metric (0-4294967295)", | |
13557 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13558 | "Route map reference\n" | |
13559 | "Pointer to route-map entries\n" | |
13560 | "Metric for redistributed routes\n" | |
13561 | "Default metric\n") | |
596c17ba | 13562 | |
718e3744 | 13563 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13564 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13565 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13566 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13567 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13568 | "Metric for redistributed routes\n" |
13569 | "Default metric\n" | |
13570 | "Route map reference\n" | |
13571 | "Pointer to route-map entries\n") | |
13572 | { | |
d62a17ae | 13573 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13574 | int idx_protocol = 1; | |
13575 | int idx_number = 3; | |
13576 | int idx_word = 5; | |
13577 | int type; | |
d7c0a89a | 13578 | uint32_t metric; |
d62a17ae | 13579 | struct bgp_redist *red; |
e923dd62 | 13580 | bool changed; |
1de27621 DA |
13581 | struct route_map *route_map = |
13582 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13583 | |
13584 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13585 | if (type < 0) { | |
13586 | vty_out(vty, "%% Invalid route type\n"); | |
13587 | return CMD_WARNING_CONFIG_FAILED; | |
13588 | } | |
13589 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13590 | ||
13591 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13592 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13593 | changed |= |
13594 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13595 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13596 | } |
13597 | ||
13598 | ALIAS_HIDDEN( | |
13599 | bgp_redistribute_ipv4_metric_rmap, | |
13600 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13601 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13602 | " metric (0-4294967295) route-map WORD", | |
13603 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13604 | "Metric for redistributed routes\n" | |
13605 | "Default metric\n" | |
13606 | "Route map reference\n" | |
13607 | "Pointer to route-map entries\n") | |
596c17ba | 13608 | |
7c8ff89e DS |
13609 | DEFUN (bgp_redistribute_ipv4_ospf, |
13610 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13611 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13612 | "Redistribute information from another routing protocol\n" |
13613 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13614 | "Non-main Kernel Routing Table\n" |
13615 | "Instance ID/Table ID\n") | |
7c8ff89e | 13616 | { |
d62a17ae | 13617 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13618 | int idx_ospf_table = 1; | |
13619 | int idx_number = 2; | |
d7c0a89a QY |
13620 | unsigned short instance; |
13621 | unsigned short protocol; | |
7c8ff89e | 13622 | |
d62a17ae | 13623 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13624 | |
d62a17ae | 13625 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13626 | protocol = ZEBRA_ROUTE_OSPF; | |
13627 | else | |
13628 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13629 | |
d62a17ae | 13630 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13631 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13632 | } |
13633 | ||
d62a17ae | 13634 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13635 | "redistribute <ospf|table> (1-65535)", | |
13636 | "Redistribute information from another routing protocol\n" | |
13637 | "Open Shortest Path First (OSPFv2)\n" | |
13638 | "Non-main Kernel Routing Table\n" | |
13639 | "Instance ID/Table ID\n") | |
596c17ba | 13640 | |
7c8ff89e DS |
13641 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13642 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13643 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13644 | "Redistribute information from another routing protocol\n" |
13645 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13646 | "Non-main Kernel Routing Table\n" |
13647 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13648 | "Route map reference\n" |
13649 | "Pointer to route-map entries\n") | |
13650 | { | |
d62a17ae | 13651 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13652 | int idx_ospf_table = 1; | |
13653 | int idx_number = 2; | |
13654 | int idx_word = 4; | |
13655 | struct bgp_redist *red; | |
d7c0a89a | 13656 | unsigned short instance; |
d62a17ae | 13657 | int protocol; |
e923dd62 | 13658 | bool changed; |
1de27621 DA |
13659 | struct route_map *route_map = |
13660 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13661 | |
13662 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13663 | protocol = ZEBRA_ROUTE_OSPF; | |
13664 | else | |
13665 | protocol = ZEBRA_ROUTE_TABLE; | |
13666 | ||
13667 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13668 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13669 | changed = |
13670 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13671 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13672 | } |
13673 | ||
13674 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13675 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13676 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13677 | "Redistribute information from another routing protocol\n" | |
13678 | "Open Shortest Path First (OSPFv2)\n" | |
13679 | "Non-main Kernel Routing Table\n" | |
13680 | "Instance ID/Table ID\n" | |
13681 | "Route map reference\n" | |
13682 | "Pointer to route-map entries\n") | |
596c17ba | 13683 | |
7c8ff89e DS |
13684 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13685 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13686 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13687 | "Redistribute information from another routing protocol\n" |
13688 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13689 | "Non-main Kernel Routing Table\n" |
13690 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13691 | "Metric for redistributed routes\n" |
13692 | "Default metric\n") | |
13693 | { | |
d62a17ae | 13694 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13695 | int idx_ospf_table = 1; | |
13696 | int idx_number = 2; | |
13697 | int idx_number_2 = 4; | |
d7c0a89a | 13698 | uint32_t metric; |
d62a17ae | 13699 | struct bgp_redist *red; |
d7c0a89a | 13700 | unsigned short instance; |
d62a17ae | 13701 | int protocol; |
e923dd62 | 13702 | bool changed; |
d62a17ae | 13703 | |
13704 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13705 | protocol = ZEBRA_ROUTE_OSPF; | |
13706 | else | |
13707 | protocol = ZEBRA_ROUTE_TABLE; | |
13708 | ||
13709 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13710 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13711 | ||
13712 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13713 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13714 | metric); | |
13715 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13716 | } |
13717 | ||
13718 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13719 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13720 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13721 | "Redistribute information from another routing protocol\n" | |
13722 | "Open Shortest Path First (OSPFv2)\n" | |
13723 | "Non-main Kernel Routing Table\n" | |
13724 | "Instance ID/Table ID\n" | |
13725 | "Metric for redistributed routes\n" | |
13726 | "Default metric\n") | |
596c17ba | 13727 | |
7c8ff89e DS |
13728 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13729 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13730 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13731 | "Redistribute information from another routing protocol\n" |
13732 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13733 | "Non-main Kernel Routing Table\n" |
13734 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13735 | "Route map reference\n" |
13736 | "Pointer to route-map entries\n" | |
13737 | "Metric for redistributed routes\n" | |
13738 | "Default metric\n") | |
13739 | { | |
d62a17ae | 13740 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13741 | int idx_ospf_table = 1; | |
13742 | int idx_number = 2; | |
13743 | int idx_word = 4; | |
13744 | int idx_number_2 = 6; | |
d7c0a89a | 13745 | uint32_t metric; |
d62a17ae | 13746 | struct bgp_redist *red; |
d7c0a89a | 13747 | unsigned short instance; |
d62a17ae | 13748 | int protocol; |
e923dd62 | 13749 | bool changed; |
1de27621 DA |
13750 | struct route_map *route_map = |
13751 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13752 | |
13753 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13754 | protocol = ZEBRA_ROUTE_OSPF; | |
13755 | else | |
13756 | protocol = ZEBRA_ROUTE_TABLE; | |
13757 | ||
13758 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13759 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13760 | ||
13761 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13762 | changed = |
13763 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13764 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13765 | metric); | |
13766 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13767 | } |
13768 | ||
13769 | ALIAS_HIDDEN( | |
13770 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13771 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13772 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13773 | "Redistribute information from another routing protocol\n" | |
13774 | "Open Shortest Path First (OSPFv2)\n" | |
13775 | "Non-main Kernel Routing Table\n" | |
13776 | "Instance ID/Table ID\n" | |
13777 | "Route map reference\n" | |
13778 | "Pointer to route-map entries\n" | |
13779 | "Metric for redistributed routes\n" | |
13780 | "Default metric\n") | |
596c17ba | 13781 | |
7c8ff89e DS |
13782 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13783 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13784 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13785 | "Redistribute information from another routing protocol\n" |
13786 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13787 | "Non-main Kernel Routing Table\n" |
13788 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13789 | "Metric for redistributed routes\n" |
13790 | "Default metric\n" | |
13791 | "Route map reference\n" | |
13792 | "Pointer to route-map entries\n") | |
13793 | { | |
d62a17ae | 13794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13795 | int idx_ospf_table = 1; | |
13796 | int idx_number = 2; | |
13797 | int idx_number_2 = 4; | |
13798 | int idx_word = 6; | |
d7c0a89a | 13799 | uint32_t metric; |
d62a17ae | 13800 | struct bgp_redist *red; |
d7c0a89a | 13801 | unsigned short instance; |
d62a17ae | 13802 | int protocol; |
e923dd62 | 13803 | bool changed; |
1de27621 DA |
13804 | struct route_map *route_map = |
13805 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13806 | |
13807 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13808 | protocol = ZEBRA_ROUTE_OSPF; | |
13809 | else | |
13810 | protocol = ZEBRA_ROUTE_TABLE; | |
13811 | ||
13812 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13813 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13814 | ||
13815 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13816 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13817 | metric); | |
1de27621 DA |
13818 | changed |= |
13819 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13820 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13821 | } |
13822 | ||
13823 | ALIAS_HIDDEN( | |
13824 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13825 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13826 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13827 | "Redistribute information from another routing protocol\n" | |
13828 | "Open Shortest Path First (OSPFv2)\n" | |
13829 | "Non-main Kernel Routing Table\n" | |
13830 | "Instance ID/Table ID\n" | |
13831 | "Metric for redistributed routes\n" | |
13832 | "Default metric\n" | |
13833 | "Route map reference\n" | |
13834 | "Pointer to route-map entries\n") | |
596c17ba | 13835 | |
7c8ff89e DS |
13836 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13837 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13838 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13839 | NO_STR |
13840 | "Redistribute information from another routing protocol\n" | |
13841 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13842 | "Non-main Kernel Routing Table\n" |
31500417 DW |
13843 | "Instance ID/Table ID\n" |
13844 | "Metric for redistributed routes\n" | |
13845 | "Default metric\n" | |
13846 | "Route map reference\n" | |
13847 | "Pointer to route-map entries\n") | |
7c8ff89e | 13848 | { |
d62a17ae | 13849 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13850 | int idx_ospf_table = 2; | |
13851 | int idx_number = 3; | |
d7c0a89a | 13852 | unsigned short instance; |
d62a17ae | 13853 | int protocol; |
13854 | ||
13855 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13856 | protocol = ZEBRA_ROUTE_OSPF; | |
13857 | else | |
13858 | protocol = ZEBRA_ROUTE_TABLE; | |
13859 | ||
13860 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13861 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13862 | } | |
13863 | ||
13864 | ALIAS_HIDDEN( | |
13865 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13866 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13867 | NO_STR |
13868 | "Redistribute information from another routing protocol\n" | |
13869 | "Open Shortest Path First (OSPFv2)\n" | |
13870 | "Non-main Kernel Routing Table\n" | |
13871 | "Instance ID/Table ID\n" | |
13872 | "Metric for redistributed routes\n" | |
13873 | "Default metric\n" | |
13874 | "Route map reference\n" | |
13875 | "Pointer to route-map entries\n") | |
596c17ba | 13876 | |
718e3744 | 13877 | DEFUN (no_bgp_redistribute_ipv4, |
13878 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13879 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13880 | NO_STR |
13881 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13882 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13883 | "Metric for redistributed routes\n" |
13884 | "Default metric\n" | |
13885 | "Route map reference\n" | |
13886 | "Pointer to route-map entries\n") | |
718e3744 | 13887 | { |
d62a17ae | 13888 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13889 | int idx_protocol = 2; | |
13890 | int type; | |
13891 | ||
13892 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13893 | if (type < 0) { | |
13894 | vty_out(vty, "%% Invalid route type\n"); | |
13895 | return CMD_WARNING_CONFIG_FAILED; | |
13896 | } | |
13897 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13898 | } | |
13899 | ||
13900 | ALIAS_HIDDEN( | |
13901 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13902 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13903 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13904 | NO_STR |
13905 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13906 | "Metric for redistributed routes\n" | |
13907 | "Default metric\n" | |
13908 | "Route map reference\n" | |
13909 | "Pointer to route-map entries\n") | |
596c17ba | 13910 | |
718e3744 | 13911 | DEFUN (bgp_redistribute_ipv6, |
13912 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 13913 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 13914 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13915 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 13916 | { |
d62a17ae | 13917 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13918 | int idx_protocol = 1; | |
13919 | int type; | |
718e3744 | 13920 | |
d62a17ae | 13921 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13922 | if (type < 0) { | |
13923 | vty_out(vty, "%% Invalid route type\n"); | |
13924 | return CMD_WARNING_CONFIG_FAILED; | |
13925 | } | |
718e3744 | 13926 | |
d62a17ae | 13927 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13928 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 13929 | } |
13930 | ||
13931 | DEFUN (bgp_redistribute_ipv6_rmap, | |
13932 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 13933 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13934 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13935 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13936 | "Route map reference\n" |
13937 | "Pointer to route-map entries\n") | |
13938 | { | |
d62a17ae | 13939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13940 | int idx_protocol = 1; | |
13941 | int idx_word = 3; | |
13942 | int type; | |
13943 | struct bgp_redist *red; | |
e923dd62 | 13944 | bool changed; |
1de27621 DA |
13945 | struct route_map *route_map = |
13946 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 13947 | |
d62a17ae | 13948 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13949 | if (type < 0) { | |
13950 | vty_out(vty, "%% Invalid route type\n"); | |
13951 | return CMD_WARNING_CONFIG_FAILED; | |
13952 | } | |
718e3744 | 13953 | |
d62a17ae | 13954 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13955 | changed = |
13956 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13957 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13958 | } |
13959 | ||
13960 | DEFUN (bgp_redistribute_ipv6_metric, | |
13961 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 13962 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13963 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13964 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13965 | "Metric for redistributed routes\n" |
13966 | "Default metric\n") | |
13967 | { | |
d62a17ae | 13968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13969 | int idx_protocol = 1; | |
13970 | int idx_number = 3; | |
13971 | int type; | |
d7c0a89a | 13972 | uint32_t metric; |
d62a17ae | 13973 | struct bgp_redist *red; |
e923dd62 | 13974 | bool changed; |
d62a17ae | 13975 | |
13976 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13977 | if (type < 0) { | |
13978 | vty_out(vty, "%% Invalid route type\n"); | |
13979 | return CMD_WARNING_CONFIG_FAILED; | |
13980 | } | |
13981 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13982 | |
d62a17ae | 13983 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13984 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
13985 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13986 | } |
13987 | ||
13988 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
13989 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 13990 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13991 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13992 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13993 | "Route map reference\n" |
13994 | "Pointer to route-map entries\n" | |
13995 | "Metric for redistributed routes\n" | |
13996 | "Default metric\n") | |
13997 | { | |
d62a17ae | 13998 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13999 | int idx_protocol = 1; | |
14000 | int idx_word = 3; | |
14001 | int idx_number = 5; | |
14002 | int type; | |
d7c0a89a | 14003 | uint32_t metric; |
d62a17ae | 14004 | struct bgp_redist *red; |
e923dd62 | 14005 | bool changed; |
1de27621 DA |
14006 | struct route_map *route_map = |
14007 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14008 | |
14009 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14010 | if (type < 0) { | |
14011 | vty_out(vty, "%% Invalid route type\n"); | |
14012 | return CMD_WARNING_CONFIG_FAILED; | |
14013 | } | |
14014 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14015 | |
d62a17ae | 14016 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14017 | changed = |
14018 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14019 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14020 | metric); | |
14021 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14022 | } |
14023 | ||
14024 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14025 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14026 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14027 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14028 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14029 | "Metric for redistributed routes\n" |
14030 | "Default metric\n" | |
14031 | "Route map reference\n" | |
14032 | "Pointer to route-map entries\n") | |
14033 | { | |
d62a17ae | 14034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14035 | int idx_protocol = 1; | |
14036 | int idx_number = 3; | |
14037 | int idx_word = 5; | |
14038 | int type; | |
d7c0a89a | 14039 | uint32_t metric; |
d62a17ae | 14040 | struct bgp_redist *red; |
e923dd62 | 14041 | bool changed; |
1de27621 DA |
14042 | struct route_map *route_map = |
14043 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14044 | |
14045 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14046 | if (type < 0) { | |
14047 | vty_out(vty, "%% Invalid route type\n"); | |
14048 | return CMD_WARNING_CONFIG_FAILED; | |
14049 | } | |
14050 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14051 | |
d62a17ae | 14052 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14053 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14054 | metric); | |
1de27621 DA |
14055 | changed |= |
14056 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14057 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14058 | } |
14059 | ||
14060 | DEFUN (no_bgp_redistribute_ipv6, | |
14061 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14062 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14063 | NO_STR |
14064 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14065 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14066 | "Metric for redistributed routes\n" |
14067 | "Default metric\n" | |
14068 | "Route map reference\n" | |
14069 | "Pointer to route-map entries\n") | |
718e3744 | 14070 | { |
d62a17ae | 14071 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14072 | int idx_protocol = 2; | |
14073 | int type; | |
718e3744 | 14074 | |
d62a17ae | 14075 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14076 | if (type < 0) { | |
14077 | vty_out(vty, "%% Invalid route type\n"); | |
14078 | return CMD_WARNING_CONFIG_FAILED; | |
14079 | } | |
718e3744 | 14080 | |
d62a17ae | 14081 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14082 | } | |
14083 | ||
dd65f45e DL |
14084 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14085 | afi_t afi, safi_t safi) | |
d62a17ae | 14086 | { |
14087 | int i; | |
14088 | ||
14089 | /* Unicast redistribution only. */ | |
14090 | if (safi != SAFI_UNICAST) | |
2b791107 | 14091 | return; |
d62a17ae | 14092 | |
14093 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14094 | /* Redistribute BGP does not make sense. */ | |
14095 | if (i != ZEBRA_ROUTE_BGP) { | |
14096 | struct list *red_list; | |
14097 | struct listnode *node; | |
14098 | struct bgp_redist *red; | |
14099 | ||
14100 | red_list = bgp->redist[afi][i]; | |
14101 | if (!red_list) | |
14102 | continue; | |
14103 | ||
14104 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14105 | /* "redistribute" configuration. */ |
14106 | vty_out(vty, " redistribute %s", | |
14107 | zebra_route_string(i)); | |
14108 | if (red->instance) | |
14109 | vty_out(vty, " %d", red->instance); | |
14110 | if (red->redist_metric_flag) | |
14111 | vty_out(vty, " metric %u", | |
14112 | red->redist_metric); | |
14113 | if (red->rmap.name) | |
14114 | vty_out(vty, " route-map %s", | |
14115 | red->rmap.name); | |
14116 | vty_out(vty, "\n"); | |
14117 | } | |
14118 | } | |
14119 | } | |
718e3744 | 14120 | } |
6b0655a2 | 14121 | |
dd65f45e DL |
14122 | /* peer-group helpers for config-write */ |
14123 | ||
14124 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14125 | { | |
14126 | if (!peer_group_active(peer)) { | |
14127 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14128 | return !CHECK_FLAG(peer->flags, flag); | |
14129 | else | |
14130 | return !!CHECK_FLAG(peer->flags, flag); | |
14131 | } | |
14132 | ||
14133 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14134 | } | |
14135 | ||
14136 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14137 | uint32_t flag) | |
14138 | { | |
14139 | if (!peer_group_active(peer)) { | |
14140 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14141 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14142 | else | |
14143 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14144 | } | |
14145 | ||
14146 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14147 | } | |
14148 | ||
14149 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14150 | uint8_t type, int direct) | |
14151 | { | |
14152 | struct bgp_filter *filter; | |
14153 | ||
14154 | if (peer_group_active(peer)) | |
14155 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14156 | type); | |
14157 | ||
14158 | filter = &peer->filter[afi][safi]; | |
14159 | switch (type) { | |
14160 | case PEER_FT_DISTRIBUTE_LIST: | |
14161 | return !!(filter->dlist[direct].name); | |
14162 | case PEER_FT_FILTER_LIST: | |
14163 | return !!(filter->aslist[direct].name); | |
14164 | case PEER_FT_PREFIX_LIST: | |
14165 | return !!(filter->plist[direct].name); | |
14166 | case PEER_FT_ROUTE_MAP: | |
14167 | return !!(filter->map[direct].name); | |
14168 | case PEER_FT_UNSUPPRESS_MAP: | |
14169 | return !!(filter->usmap.name); | |
14170 | default: | |
14171 | return false; | |
14172 | } | |
14173 | } | |
14174 | ||
14175 | /* Return true if the addpath type is set for peer and different from | |
14176 | * peer-group. | |
14177 | */ | |
14178 | static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi) | |
14179 | { | |
14180 | enum bgp_addpath_strat type, g_type; | |
14181 | ||
14182 | type = peer->addpath_type[afi][safi]; | |
14183 | ||
14184 | if (type != BGP_ADDPATH_NONE) { | |
14185 | if (peer_group_active(peer)) { | |
14186 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14187 | ||
14188 | if (type != g_type) | |
14189 | return 1; | |
14190 | else | |
14191 | return 0; | |
14192 | } | |
14193 | ||
14194 | return 1; | |
14195 | } | |
14196 | ||
14197 | return 0; | |
14198 | } | |
14199 | ||
b9c7bc5a | 14200 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14201 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14202 | afi_t afi) |
14203 | { | |
b9c7bc5a | 14204 | int indent = 2; |
ddb5b488 | 14205 | |
8a066a70 PG |
14206 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
14207 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
14208 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
14209 | bgp->vpn_policy[afi] | |
bb4f6190 | 14210 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14211 | else |
14212 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14213 | bgp->vpn_policy[afi] | |
14214 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14215 | } | |
12a844a5 DS |
14216 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14217 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14218 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14219 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14220 | return; | |
14221 | ||
e70e9f8e PZ |
14222 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14223 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14224 | ||
14225 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14226 | ||
14227 | } else { | |
14228 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14229 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14230 | bgp->vpn_policy[afi].tovpn_label); | |
14231 | } | |
ddb5b488 PZ |
14232 | } |
14233 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14234 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14235 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14236 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14237 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14238 | sizeof(buf))); | |
14239 | } | |
14240 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14241 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14242 | ||
14243 | char buf[PREFIX_STRLEN]; | |
14244 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14245 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14246 | sizeof(buf))) { | |
14247 | ||
b9c7bc5a PZ |
14248 | vty_out(vty, "%*snexthop vpn export %s\n", |
14249 | indent, "", buf); | |
ddb5b488 PZ |
14250 | } |
14251 | } | |
14252 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14253 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14254 | && ecommunity_cmp( | |
14255 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14256 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14257 | ||
14258 | char *b = ecommunity_ecom2str( | |
14259 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14260 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14261 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14262 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14263 | } else { | |
14264 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14265 | char *b = ecommunity_ecom2str( | |
14266 | bgp->vpn_policy[afi] | |
14267 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14268 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14269 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14270 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14271 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14272 | } | |
14273 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14274 | char *b = ecommunity_ecom2str( | |
14275 | bgp->vpn_policy[afi] | |
14276 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14277 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14278 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14279 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14280 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14281 | } | |
14282 | } | |
bb4f6190 DS |
14283 | |
14284 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14285 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14286 | bgp->vpn_policy[afi] |
14287 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14288 | |
301ad80a PG |
14289 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14290 | char *b = ecommunity_ecom2str( | |
14291 | bgp->vpn_policy[afi] | |
14292 | .import_redirect_rtlist, | |
14293 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14294 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14295 | |
301ad80a PG |
14296 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14297 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14298 | } | |
ddb5b488 PZ |
14299 | } |
14300 | ||
dd65f45e DL |
14301 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14302 | afi_t afi, safi_t safi) | |
14303 | { | |
14304 | struct bgp_filter *filter; | |
14305 | char *addr; | |
14306 | ||
14307 | addr = peer->host; | |
14308 | filter = &peer->filter[afi][safi]; | |
14309 | ||
14310 | /* distribute-list. */ | |
14311 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14312 | FILTER_IN)) | |
14313 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14314 | filter->dlist[FILTER_IN].name); | |
14315 | ||
14316 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14317 | FILTER_OUT)) | |
14318 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14319 | filter->dlist[FILTER_OUT].name); | |
14320 | ||
14321 | /* prefix-list. */ | |
14322 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14323 | FILTER_IN)) | |
14324 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14325 | filter->plist[FILTER_IN].name); | |
14326 | ||
14327 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14328 | FILTER_OUT)) | |
14329 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14330 | filter->plist[FILTER_OUT].name); | |
14331 | ||
14332 | /* route-map. */ | |
14333 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14334 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14335 | filter->map[RMAP_IN].name); | |
14336 | ||
14337 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14338 | RMAP_OUT)) | |
14339 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14340 | filter->map[RMAP_OUT].name); | |
14341 | ||
14342 | /* unsuppress-map */ | |
14343 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14344 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14345 | filter->usmap.name); | |
14346 | ||
14347 | /* filter-list. */ | |
14348 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14349 | FILTER_IN)) | |
14350 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14351 | filter->aslist[FILTER_IN].name); | |
14352 | ||
14353 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14354 | FILTER_OUT)) | |
14355 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14356 | filter->aslist[FILTER_OUT].name); | |
14357 | } | |
14358 | ||
14359 | /* BGP peer configuration display function. */ | |
14360 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14361 | struct peer *peer) | |
14362 | { | |
14363 | struct peer *g_peer = NULL; | |
14364 | char buf[SU_ADDRSTRLEN]; | |
14365 | char *addr; | |
14366 | int if_pg_printed = false; | |
14367 | int if_ras_printed = false; | |
14368 | ||
14369 | /* Skip dynamic neighbors. */ | |
14370 | if (peer_dynamic_neighbor(peer)) | |
14371 | return; | |
14372 | ||
14373 | if (peer->conf_if) | |
14374 | addr = peer->conf_if; | |
14375 | else | |
14376 | addr = peer->host; | |
14377 | ||
14378 | /************************************ | |
14379 | ****** Global to the neighbor ****** | |
14380 | ************************************/ | |
14381 | if (peer->conf_if) { | |
14382 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14383 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14384 | else | |
14385 | vty_out(vty, " neighbor %s interface", addr); | |
14386 | ||
14387 | if (peer_group_active(peer)) { | |
14388 | vty_out(vty, " peer-group %s", peer->group->name); | |
14389 | if_pg_printed = true; | |
14390 | } else if (peer->as_type == AS_SPECIFIED) { | |
14391 | vty_out(vty, " remote-as %u", peer->as); | |
14392 | if_ras_printed = true; | |
14393 | } else if (peer->as_type == AS_INTERNAL) { | |
14394 | vty_out(vty, " remote-as internal"); | |
14395 | if_ras_printed = true; | |
14396 | } else if (peer->as_type == AS_EXTERNAL) { | |
14397 | vty_out(vty, " remote-as external"); | |
14398 | if_ras_printed = true; | |
14399 | } | |
14400 | ||
14401 | vty_out(vty, "\n"); | |
14402 | } | |
14403 | ||
14404 | /* remote-as and peer-group */ | |
14405 | /* peer is a member of a peer-group */ | |
14406 | if (peer_group_active(peer)) { | |
14407 | g_peer = peer->group->conf; | |
14408 | ||
14409 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14410 | if (peer->as_type == AS_SPECIFIED) { | |
14411 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14412 | addr, peer->as); | |
14413 | } else if (peer->as_type == AS_INTERNAL) { | |
14414 | vty_out(vty, | |
14415 | " neighbor %s remote-as internal\n", | |
14416 | addr); | |
14417 | } else if (peer->as_type == AS_EXTERNAL) { | |
14418 | vty_out(vty, | |
14419 | " neighbor %s remote-as external\n", | |
14420 | addr); | |
14421 | } | |
14422 | } | |
14423 | ||
14424 | /* For swpX peers we displayed the peer-group | |
14425 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14426 | if (!if_pg_printed) | |
14427 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14428 | peer->group->name); | |
14429 | } | |
14430 | ||
14431 | /* peer is NOT a member of a peer-group */ | |
14432 | else { | |
14433 | /* peer is a peer-group, declare the peer-group */ | |
14434 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14435 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14436 | } | |
14437 | ||
14438 | if (!if_ras_printed) { | |
14439 | if (peer->as_type == AS_SPECIFIED) { | |
14440 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14441 | addr, peer->as); | |
14442 | } else if (peer->as_type == AS_INTERNAL) { | |
14443 | vty_out(vty, | |
14444 | " neighbor %s remote-as internal\n", | |
14445 | addr); | |
14446 | } else if (peer->as_type == AS_EXTERNAL) { | |
14447 | vty_out(vty, | |
14448 | " neighbor %s remote-as external\n", | |
14449 | addr); | |
14450 | } | |
14451 | } | |
14452 | } | |
14453 | ||
14454 | /* local-as */ | |
14455 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14456 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14457 | peer->change_local_as); | |
14458 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14459 | vty_out(vty, " no-prepend"); | |
14460 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14461 | vty_out(vty, " replace-as"); | |
14462 | vty_out(vty, "\n"); | |
14463 | } | |
14464 | ||
14465 | /* description */ | |
14466 | if (peer->desc) { | |
14467 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14468 | } | |
14469 | ||
14470 | /* shutdown */ | |
14471 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14472 | if (peer->tx_shutdown_message) | |
14473 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14474 | peer->tx_shutdown_message); | |
14475 | else | |
14476 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14477 | } | |
14478 | ||
14479 | /* bfd */ | |
14480 | if (peer->bfd_info) { | |
14481 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14482 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14483 | } | |
14484 | } | |
14485 | ||
14486 | /* password */ | |
14487 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14488 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14489 | peer->password); | |
14490 | ||
14491 | /* neighbor solo */ | |
14492 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14493 | if (!peer_group_active(peer)) { | |
14494 | vty_out(vty, " neighbor %s solo\n", addr); | |
14495 | } | |
14496 | } | |
14497 | ||
14498 | /* BGP port */ | |
14499 | if (peer->port != BGP_PORT_DEFAULT) { | |
14500 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14501 | } | |
14502 | ||
14503 | /* Local interface name */ | |
14504 | if (peer->ifname) { | |
14505 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14506 | } | |
14507 | ||
14508 | /* passive */ | |
14509 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14510 | vty_out(vty, " neighbor %s passive\n", addr); | |
14511 | ||
14512 | /* ebgp-multihop */ | |
14513 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
14514 | && !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) { | |
14515 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { | |
14516 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14517 | peer->ttl); | |
14518 | } | |
14519 | } | |
14520 | ||
14521 | /* ttl-security hops */ | |
14522 | if (peer->gtsm_hops != 0) { | |
14523 | if (!peer_group_active(peer) | |
14524 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14525 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14526 | addr, peer->gtsm_hops); | |
14527 | } | |
14528 | } | |
14529 | ||
14530 | /* disable-connected-check */ | |
14531 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14532 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14533 | ||
14534 | /* enforce-first-as */ | |
14535 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14536 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14537 | ||
14538 | /* update-source */ | |
14539 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14540 | if (peer->update_source) | |
14541 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14542 | sockunion2str(peer->update_source, buf, | |
14543 | SU_ADDRSTRLEN)); | |
14544 | else if (peer->update_if) | |
14545 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14546 | peer->update_if); | |
14547 | } | |
14548 | ||
14549 | /* advertisement-interval */ | |
14550 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14551 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14552 | peer->routeadv); | |
14553 | ||
14554 | /* timers */ | |
14555 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14556 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14557 | peer->keepalive, peer->holdtime); | |
14558 | ||
14559 | /* timers connect */ | |
14560 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14561 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14562 | peer->connect); | |
5d5393b9 DL |
14563 | /* need special-case handling for changed default values due to |
14564 | * config profile / version (because there is no "timers bgp connect" | |
14565 | * command, we need to save this per-peer :/) | |
14566 | */ | |
14567 | else if (!peer_group_active(peer) && !peer->connect && | |
14568 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14569 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14570 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14571 | |
14572 | /* capability dynamic */ | |
14573 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14574 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14575 | ||
14576 | /* capability extended-nexthop */ | |
14577 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14578 | if (!peer->conf_if) { | |
14579 | if (CHECK_FLAG(peer->flags_invert, | |
14580 | PEER_FLAG_CAPABILITY_ENHE)) | |
14581 | vty_out(vty, | |
14582 | " no neighbor %s capability extended-nexthop\n", | |
14583 | addr); | |
14584 | else | |
14585 | vty_out(vty, | |
14586 | " neighbor %s capability extended-nexthop\n", | |
14587 | addr); | |
14588 | } | |
14589 | } | |
14590 | ||
14591 | /* dont-capability-negotiation */ | |
14592 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14593 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14594 | ||
14595 | /* override-capability */ | |
14596 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14597 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14598 | ||
14599 | /* strict-capability-match */ | |
14600 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14601 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14602 | ||
14603 | /* Sender side AS path loop detection. */ | |
14604 | if (peer->as_path_loop_detection) | |
14605 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14606 | addr); | |
cfd47646 | 14607 | |
14608 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14609 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { | |
14610 | ||
14611 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14612 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { | |
14613 | vty_out(vty, | |
14614 | " neighbor %s graceful-restart-helper\n", addr); | |
14615 | } else if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14616 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
14617 | vty_out(vty, | |
14618 | " neighbor %s graceful-restart\n", addr); | |
14619 | } else if ((!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14620 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14621 | && !(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14622 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14623 | vty_out(vty, | |
14624 | " neighbor %s graceful-restart-disable\n", | |
14625 | addr); | |
14626 | } | |
14627 | } | |
dd65f45e DL |
14628 | } |
14629 | ||
14630 | /* BGP peer configuration display function. */ | |
14631 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14632 | struct peer *peer, afi_t afi, safi_t safi) | |
14633 | { | |
14634 | struct peer *g_peer = NULL; | |
14635 | char *addr; | |
14636 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14637 | ||
14638 | /* Skip dynamic neighbors. */ | |
14639 | if (peer_dynamic_neighbor(peer)) | |
14640 | return; | |
14641 | ||
14642 | if (peer->conf_if) | |
14643 | addr = peer->conf_if; | |
14644 | else | |
14645 | addr = peer->host; | |
14646 | ||
14647 | /************************************ | |
14648 | ****** Per AF to the neighbor ****** | |
14649 | ************************************/ | |
14650 | if (peer_group_active(peer)) { | |
14651 | g_peer = peer->group->conf; | |
14652 | ||
14653 | /* If the peer-group is active but peer is not, print a 'no | |
14654 | * activate' */ | |
14655 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14656 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14657 | } | |
14658 | ||
14659 | /* If the peer-group is not active but peer is, print an | |
14660 | 'activate' */ | |
14661 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14662 | vty_out(vty, " neighbor %s activate\n", addr); | |
14663 | } | |
14664 | } else { | |
14665 | if (peer->afc[afi][safi]) { | |
14666 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
14667 | if (bgp_flag_check(bgp, | |
14668 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
14669 | vty_out(vty, " neighbor %s activate\n", | |
14670 | addr); | |
14671 | } | |
14672 | } else | |
14673 | vty_out(vty, " neighbor %s activate\n", addr); | |
14674 | } else { | |
14675 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
14676 | if (!bgp_flag_check(bgp, | |
14677 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
14678 | vty_out(vty, | |
14679 | " no neighbor %s activate\n", | |
14680 | addr); | |
14681 | } | |
14682 | } | |
14683 | } | |
14684 | } | |
14685 | ||
14686 | /* addpath TX knobs */ | |
14687 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14688 | switch (peer->addpath_type[afi][safi]) { | |
14689 | case BGP_ADDPATH_ALL: | |
14690 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14691 | addr); | |
14692 | break; | |
14693 | case BGP_ADDPATH_BEST_PER_AS: | |
14694 | vty_out(vty, | |
14695 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14696 | addr); | |
14697 | break; | |
14698 | case BGP_ADDPATH_MAX: | |
14699 | case BGP_ADDPATH_NONE: | |
14700 | break; | |
14701 | } | |
14702 | } | |
14703 | ||
14704 | /* ORF capability. */ | |
14705 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14706 | || peergroup_af_flag_check(peer, afi, safi, | |
14707 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14708 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14709 | ||
14710 | if (peergroup_af_flag_check(peer, afi, safi, | |
14711 | PEER_FLAG_ORF_PREFIX_SM) | |
14712 | && peergroup_af_flag_check(peer, afi, safi, | |
14713 | PEER_FLAG_ORF_PREFIX_RM)) | |
14714 | vty_out(vty, " both"); | |
14715 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14716 | PEER_FLAG_ORF_PREFIX_SM)) | |
14717 | vty_out(vty, " send"); | |
14718 | else | |
14719 | vty_out(vty, " receive"); | |
14720 | vty_out(vty, "\n"); | |
14721 | } | |
14722 | ||
14723 | /* BGP flag dampening. */ | |
14724 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14725 | BGP_CONFIG_DAMPENING)) | |
14726 | bgp_config_write_damp(vty, afi, safi); | |
14727 | ||
14728 | /* Route reflector client. */ | |
14729 | if (peergroup_af_flag_check(peer, afi, safi, | |
14730 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14731 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14732 | } | |
14733 | ||
14734 | /* next-hop-self force */ | |
14735 | if (peergroup_af_flag_check(peer, afi, safi, | |
14736 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14737 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14738 | } | |
14739 | ||
14740 | /* next-hop-self */ | |
14741 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14742 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14743 | } | |
14744 | ||
14745 | /* remove-private-AS */ | |
14746 | if (peergroup_af_flag_check(peer, afi, safi, | |
14747 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14748 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14749 | addr); | |
14750 | } | |
14751 | ||
14752 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14753 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14754 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14755 | addr); | |
14756 | } | |
14757 | ||
14758 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14759 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14760 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14761 | } | |
14762 | ||
14763 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14764 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14765 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14766 | } | |
14767 | ||
14768 | /* as-override */ | |
14769 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14770 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14771 | } | |
14772 | ||
14773 | /* send-community print. */ | |
14774 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14775 | PEER_FLAG_SEND_COMMUNITY); | |
14776 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14777 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14778 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14779 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14780 | ||
14781 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14782 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14783 | } else { | |
14784 | if (flag_scomm) | |
14785 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14786 | if (flag_secomm) | |
14787 | vty_out(vty, | |
14788 | " no neighbor %s send-community extended\n", | |
14789 | addr); | |
14790 | ||
14791 | if (flag_slcomm) | |
14792 | vty_out(vty, " no neighbor %s send-community large\n", | |
14793 | addr); | |
14794 | } | |
14795 | ||
14796 | /* Default information */ | |
14797 | if (peergroup_af_flag_check(peer, afi, safi, | |
14798 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14799 | vty_out(vty, " neighbor %s default-originate", addr); | |
14800 | ||
14801 | if (peer->default_rmap[afi][safi].name) | |
14802 | vty_out(vty, " route-map %s", | |
14803 | peer->default_rmap[afi][safi].name); | |
14804 | ||
14805 | vty_out(vty, "\n"); | |
14806 | } | |
14807 | ||
14808 | /* Soft reconfiguration inbound. */ | |
14809 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14810 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14811 | addr); | |
14812 | } | |
14813 | ||
14814 | /* maximum-prefix. */ | |
14815 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14816 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14817 | peer->pmax[afi][safi]); | |
14818 | ||
14819 | if (peer->pmax_threshold[afi][safi] | |
14820 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14821 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14822 | if (peer_af_flag_check(peer, afi, safi, | |
14823 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14824 | vty_out(vty, " warning-only"); | |
14825 | if (peer->pmax_restart[afi][safi]) | |
14826 | vty_out(vty, " restart %u", | |
14827 | peer->pmax_restart[afi][safi]); | |
14828 | ||
14829 | vty_out(vty, "\n"); | |
14830 | } | |
14831 | ||
fde246e8 DA |
14832 | /* maximum-prefix-out */ |
14833 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14834 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14835 | addr, peer->pmax_out[afi][safi]); | |
14836 | ||
dd65f45e DL |
14837 | /* Route server client. */ |
14838 | if (peergroup_af_flag_check(peer, afi, safi, | |
14839 | PEER_FLAG_RSERVER_CLIENT)) { | |
14840 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14841 | } | |
14842 | ||
14843 | /* Nexthop-local unchanged. */ | |
14844 | if (peergroup_af_flag_check(peer, afi, safi, | |
14845 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14846 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14847 | } | |
14848 | ||
14849 | /* allowas-in <1-10> */ | |
14850 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14851 | if (peer_af_flag_check(peer, afi, safi, | |
14852 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14853 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14854 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14855 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14856 | } else { | |
14857 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14858 | peer->allowas_in[afi][safi]); | |
14859 | } | |
14860 | } | |
14861 | ||
14862 | /* weight */ | |
14863 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14864 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14865 | peer->weight[afi][safi]); | |
14866 | ||
14867 | /* Filter. */ | |
14868 | bgp_config_write_filter(vty, peer, afi, safi); | |
14869 | ||
14870 | /* atribute-unchanged. */ | |
14871 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14872 | || (safi != SAFI_EVPN | |
14873 | && peer_af_flag_check(peer, afi, safi, | |
14874 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14875 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14876 | ||
14877 | if (!peer_group_active(peer) | |
14878 | || peergroup_af_flag_check(peer, afi, safi, | |
14879 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14880 | || peergroup_af_flag_check(peer, afi, safi, | |
14881 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14882 | || peergroup_af_flag_check(peer, afi, safi, | |
14883 | PEER_FLAG_MED_UNCHANGED)) { | |
14884 | ||
14885 | vty_out(vty, | |
14886 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14887 | addr, | |
14888 | peer_af_flag_check(peer, afi, safi, | |
14889 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14890 | ? " as-path" | |
14891 | : "", | |
14892 | peer_af_flag_check(peer, afi, safi, | |
14893 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14894 | ? " next-hop" | |
14895 | : "", | |
14896 | peer_af_flag_check(peer, afi, safi, | |
14897 | PEER_FLAG_MED_UNCHANGED) | |
14898 | ? " med" | |
14899 | : ""); | |
14900 | } | |
14901 | } | |
14902 | } | |
14903 | ||
14904 | /* Address family based peer configuration display. */ | |
14905 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14906 | safi_t safi) | |
14907 | { | |
14908 | struct peer *peer; | |
14909 | struct peer_group *group; | |
14910 | struct listnode *node, *nnode; | |
14911 | ||
14912 | ||
14913 | vty_frame(vty, " !\n address-family "); | |
14914 | if (afi == AFI_IP) { | |
14915 | if (safi == SAFI_UNICAST) | |
14916 | vty_frame(vty, "ipv4 unicast"); | |
14917 | else if (safi == SAFI_LABELED_UNICAST) | |
14918 | vty_frame(vty, "ipv4 labeled-unicast"); | |
14919 | else if (safi == SAFI_MULTICAST) | |
14920 | vty_frame(vty, "ipv4 multicast"); | |
14921 | else if (safi == SAFI_MPLS_VPN) | |
14922 | vty_frame(vty, "ipv4 vpn"); | |
14923 | else if (safi == SAFI_ENCAP) | |
14924 | vty_frame(vty, "ipv4 encap"); | |
14925 | else if (safi == SAFI_FLOWSPEC) | |
14926 | vty_frame(vty, "ipv4 flowspec"); | |
14927 | } else if (afi == AFI_IP6) { | |
14928 | if (safi == SAFI_UNICAST) | |
14929 | vty_frame(vty, "ipv6 unicast"); | |
14930 | else if (safi == SAFI_LABELED_UNICAST) | |
14931 | vty_frame(vty, "ipv6 labeled-unicast"); | |
14932 | else if (safi == SAFI_MULTICAST) | |
14933 | vty_frame(vty, "ipv6 multicast"); | |
14934 | else if (safi == SAFI_MPLS_VPN) | |
14935 | vty_frame(vty, "ipv6 vpn"); | |
14936 | else if (safi == SAFI_ENCAP) | |
14937 | vty_frame(vty, "ipv6 encap"); | |
14938 | else if (safi == SAFI_FLOWSPEC) | |
14939 | vty_frame(vty, "ipv6 flowspec"); | |
14940 | } else if (afi == AFI_L2VPN) { | |
14941 | if (safi == SAFI_EVPN) | |
14942 | vty_frame(vty, "l2vpn evpn"); | |
14943 | } | |
14944 | vty_frame(vty, "\n"); | |
14945 | ||
14946 | bgp_config_write_distance(vty, bgp, afi, safi); | |
14947 | ||
14948 | bgp_config_write_network(vty, bgp, afi, safi); | |
14949 | ||
14950 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
14951 | ||
14952 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
14953 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
14954 | ||
14955 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14956 | /* Skip dynamic neighbors. */ | |
14957 | if (peer_dynamic_neighbor(peer)) | |
14958 | continue; | |
14959 | ||
14960 | /* Do not display doppelganger peers */ | |
14961 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14962 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
14963 | } | |
14964 | ||
14965 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
14966 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
14967 | ||
14968 | if (safi == SAFI_EVPN) | |
14969 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
14970 | ||
14971 | if (safi == SAFI_FLOWSPEC) | |
14972 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
14973 | ||
14974 | if (safi == SAFI_UNICAST) { | |
14975 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
14976 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14977 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
14978 | ||
14979 | vty_out(vty, " export vpn\n"); | |
14980 | } | |
14981 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14982 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
14983 | ||
14984 | vty_out(vty, " import vpn\n"); | |
14985 | } | |
14986 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14987 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14988 | char *name; | |
14989 | ||
14990 | for (ALL_LIST_ELEMENTS_RO( | |
14991 | bgp->vpn_policy[afi].import_vrf, node, | |
14992 | name)) | |
14993 | vty_out(vty, " import vrf %s\n", name); | |
14994 | } | |
14995 | } | |
14996 | ||
14997 | vty_endframe(vty, " exit-address-family\n"); | |
14998 | } | |
14999 | ||
15000 | int bgp_config_write(struct vty *vty) | |
15001 | { | |
15002 | struct bgp *bgp; | |
15003 | struct peer_group *group; | |
15004 | struct peer *peer; | |
15005 | struct listnode *node, *nnode; | |
15006 | struct listnode *mnode, *mnnode; | |
15007 | ||
15008 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15009 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15010 | bm->rmap_update_timer); | |
15011 | ||
15012 | /* BGP configuration. */ | |
15013 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15014 | ||
15015 | /* skip all auto created vrf as they dont have user config */ | |
15016 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15017 | continue; | |
15018 | ||
15019 | /* Router bgp ASN */ | |
15020 | vty_out(vty, "router bgp %u", bgp->as); | |
15021 | ||
15022 | if (bgp->name) | |
15023 | vty_out(vty, " %s %s", | |
15024 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15025 | ? "view" : "vrf", bgp->name); | |
15026 | vty_out(vty, "\n"); | |
15027 | ||
15028 | /* BGP fast-external-failover. */ | |
15029 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15030 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15031 | ||
15032 | /* BGP router ID. */ | |
15033 | if (bgp->router_id_static.s_addr != 0) | |
15034 | vty_out(vty, " bgp router-id %s\n", | |
15035 | inet_ntoa(bgp->router_id_static)); | |
15036 | ||
15037 | /* BGP log-neighbor-changes. */ | |
15038 | if (!!bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
5d5393b9 | 15039 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e DL |
15040 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
15041 | bgp_flag_check(bgp, | |
15042 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
15043 | ? "" | |
15044 | : "no "); | |
15045 | ||
15046 | /* BGP configuration. */ | |
15047 | if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED)) | |
15048 | vty_out(vty, " bgp always-compare-med\n"); | |
15049 | ||
15050 | /* RFC8212 default eBGP policy. */ | |
15051 | if (bgp->ebgp_requires_policy | |
15052 | == DEFAULT_EBGP_POLICY_ENABLED) | |
15053 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
15054 | ||
15055 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
15056 | if (bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) | |
15057 | vty_out(vty, " bgp reject-as-sets\n"); | |
15058 | ||
15059 | /* BGP default ipv4-unicast. */ | |
15060 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)) | |
15061 | vty_out(vty, " no bgp default ipv4-unicast\n"); | |
15062 | ||
15063 | /* BGP default local-preference. */ | |
15064 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15065 | vty_out(vty, " bgp default local-preference %u\n", | |
15066 | bgp->default_local_pref); | |
15067 | ||
15068 | /* BGP default show-hostname */ | |
15069 | if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
5d5393b9 | 15070 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e DL |
15071 | vty_out(vty, " %sbgp default show-hostname\n", |
15072 | bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
15073 | ? "" | |
15074 | : "no "); | |
15075 | ||
15076 | /* BGP default subgroup-pkt-queue-max. */ | |
15077 | if (bgp->default_subgroup_pkt_queue_max | |
15078 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15079 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15080 | bgp->default_subgroup_pkt_queue_max); | |
15081 | ||
15082 | /* BGP client-to-client reflection. */ | |
15083 | if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
15084 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
15085 | ||
15086 | /* BGP cluster ID. */ | |
15087 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15088 | vty_out(vty, " bgp cluster-id %s\n", | |
15089 | inet_ntoa(bgp->cluster_id)); | |
15090 | ||
15091 | /* Disable ebgp connected nexthop check */ | |
15092 | if (bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
15093 | vty_out(vty, | |
15094 | " bgp disable-ebgp-connected-route-check\n"); | |
15095 | ||
15096 | /* Confederation identifier*/ | |
15097 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15098 | vty_out(vty, " bgp confederation identifier %u\n", | |
15099 | bgp->confed_id); | |
15100 | ||
15101 | /* Confederation peer */ | |
15102 | if (bgp->confed_peers_cnt > 0) { | |
15103 | int i; | |
15104 | ||
15105 | vty_out(vty, " bgp confederation peers"); | |
15106 | ||
15107 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15108 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15109 | ||
15110 | vty_out(vty, "\n"); | |
15111 | } | |
15112 | ||
15113 | /* BGP deterministic-med. */ | |
15114 | if (!!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
5d5393b9 | 15115 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e DL |
15116 | vty_out(vty, " %sbgp deterministic-med\n", |
15117 | bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
15118 | ? "" | |
15119 | : "no "); | |
15120 | ||
15121 | /* BGP update-delay. */ | |
15122 | bgp_config_write_update_delay(vty, bgp); | |
15123 | ||
15124 | if (bgp->v_maxmed_onstartup | |
15125 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15126 | vty_out(vty, " bgp max-med on-startup %u", | |
15127 | bgp->v_maxmed_onstartup); | |
15128 | if (bgp->maxmed_onstartup_value | |
15129 | != BGP_MAXMED_VALUE_DEFAULT) | |
15130 | vty_out(vty, " %u", | |
15131 | bgp->maxmed_onstartup_value); | |
15132 | vty_out(vty, "\n"); | |
15133 | } | |
15134 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15135 | vty_out(vty, " bgp max-med administrative"); | |
15136 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15137 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15138 | vty_out(vty, "\n"); | |
15139 | } | |
15140 | ||
15141 | /* write quanta */ | |
15142 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15143 | /* read quanta */ | |
15144 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15145 | ||
15146 | /* coalesce time */ | |
15147 | bgp_config_write_coalesce_time(vty, bgp); | |
15148 | ||
15149 | /* BGP graceful-restart. */ | |
15150 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15151 | vty_out(vty, | |
15152 | " bgp graceful-restart stalepath-time %u\n", | |
15153 | bgp->stalepath_time); | |
cfd47646 | 15154 | |
dd65f45e DL |
15155 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15156 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15157 | bgp->restart_time); | |
cfd47646 | 15158 | |
15159 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15160 | vty_out(vty, | |
15161 | " bgp graceful-restart select-defer-time %u\n", | |
15162 | bgp->select_defer_time); | |
15163 | ||
15164 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15165 | vty_out(vty, " bgp graceful-restart\n"); |
15166 | ||
cfd47646 | 15167 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15168 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15169 | ||
dd65f45e DL |
15170 | /* BGP graceful-shutdown */ |
15171 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
15172 | vty_out(vty, " bgp graceful-shutdown\n"); | |
15173 | ||
15174 | /* BGP graceful-restart Preserve State F bit. */ | |
15175 | if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD)) | |
15176 | vty_out(vty, | |
15177 | " bgp graceful-restart preserve-fw-state\n"); | |
15178 | ||
dc95985f | 15179 | /* Stale timer for RIB */ |
15180 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15181 | vty_out(vty, | |
15182 | " bgp graceful-restart rib-stale-time %u\n", | |
15183 | bgp->rib_stale_time); | |
15184 | ||
dd65f45e DL |
15185 | /* BGP bestpath method. */ |
15186 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
15187 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
15188 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
15189 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
15190 | ||
15191 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
15192 | if (bgp_flag_check(bgp, | |
15193 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
15194 | vty_out(vty, | |
15195 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15196 | } else { | |
15197 | vty_out(vty, | |
15198 | " bgp bestpath as-path multipath-relax\n"); | |
15199 | } | |
15200 | } | |
15201 | ||
15202 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
15203 | vty_out(vty, | |
15204 | " bgp route-reflector allow-outbound-policy\n"); | |
15205 | } | |
15206 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
15207 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
15208 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
15209 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
15210 | vty_out(vty, " bgp bestpath med"); | |
15211 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
15212 | vty_out(vty, " confed"); | |
15213 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
15214 | vty_out(vty, " missing-as-worst"); | |
15215 | vty_out(vty, "\n"); | |
15216 | } | |
15217 | ||
15218 | /* BGP network import check. */ | |
15219 | if (!!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
5d5393b9 | 15220 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e DL |
15221 | vty_out(vty, " %sbgp network import-check\n", |
15222 | bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
15223 | ? "" | |
15224 | : "no "); | |
15225 | ||
15226 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15227 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15228 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15229 | vty_out(vty, " timers bgp %u %u\n", |
15230 | bgp->default_keepalive, bgp->default_holdtime); | |
15231 | ||
15232 | /* peer-group */ | |
15233 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15234 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15235 | } | |
15236 | ||
15237 | /* Normal neighbor configuration. */ | |
15238 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15239 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15240 | bgp_config_write_peer_global(vty, bgp, peer); | |
15241 | } | |
15242 | ||
15243 | /* listen range and limit for dynamic BGP neighbors */ | |
15244 | bgp_config_write_listen(vty, bgp); | |
15245 | ||
15246 | /* | |
15247 | * BGP default autoshutdown neighbors | |
15248 | * | |
15249 | * This must be placed after any peer and peer-group | |
15250 | * configuration, to avoid setting all peers to shutdown after | |
15251 | * a daemon restart, which is undesired behavior. (see #2286) | |
15252 | */ | |
15253 | if (bgp->autoshutdown) | |
15254 | vty_out(vty, " bgp default shutdown\n"); | |
15255 | ||
15256 | /* IPv4 unicast configuration. */ | |
15257 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15258 | ||
15259 | /* IPv4 multicast configuration. */ | |
15260 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15261 | ||
15262 | /* IPv4 labeled-unicast configuration. */ | |
15263 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15264 | ||
15265 | /* IPv4 VPN configuration. */ | |
15266 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15267 | ||
15268 | /* ENCAPv4 configuration. */ | |
15269 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15270 | ||
15271 | /* FLOWSPEC v4 configuration. */ | |
15272 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15273 | ||
15274 | /* IPv6 unicast configuration. */ | |
15275 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15276 | ||
15277 | /* IPv6 multicast configuration. */ | |
15278 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15279 | ||
15280 | /* IPv6 labeled-unicast configuration. */ | |
15281 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15282 | SAFI_LABELED_UNICAST); | |
15283 | ||
15284 | /* IPv6 VPN configuration. */ | |
15285 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15286 | ||
15287 | /* ENCAPv6 configuration. */ | |
15288 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15289 | ||
15290 | /* FLOWSPEC v6 configuration. */ | |
15291 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15292 | ||
15293 | /* EVPN configuration. */ | |
15294 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15295 | ||
15296 | hook_call(bgp_inst_config_write, bgp, vty); | |
15297 | ||
15298 | #if ENABLE_BGP_VNC | |
15299 | bgp_rfapi_cfg_write(vty, bgp); | |
15300 | #endif | |
15301 | ||
15302 | vty_out(vty, "!\n"); | |
15303 | } | |
15304 | return 0; | |
15305 | } | |
15306 | ||
ddb5b488 | 15307 | |
718e3744 | 15308 | /* BGP node structure. */ |
d62a17ae | 15309 | static struct cmd_node bgp_node = { |
9d303b37 | 15310 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 15311 | }; |
15312 | ||
d62a17ae | 15313 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 15314 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15315 | }; |
15316 | ||
d62a17ae | 15317 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 15318 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15319 | }; |
15320 | ||
d62a17ae | 15321 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 15322 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15323 | }; |
15324 | ||
d62a17ae | 15325 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 15326 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15327 | }; |
15328 | ||
d62a17ae | 15329 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 15330 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 15331 | }; |
15332 | ||
d62a17ae | 15333 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 15334 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15335 | }; |
15336 | ||
d62a17ae | 15337 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
15338 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 15339 | |
d62a17ae | 15340 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
15341 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 15342 | |
d62a17ae | 15343 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
15344 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 15345 | |
d62a17ae | 15346 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
15347 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 15348 | |
7c40bf39 | 15349 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
15350 | "%s(config-router-af)# ", 1}; | |
15351 | ||
15352 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
15353 | "%s(config-router-af-vpnv6)# ", 1}; | |
15354 | ||
d62a17ae | 15355 | static void community_list_vty(void); |
1f8ae70b | 15356 | |
d62a17ae | 15357 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15358 | { |
d62a17ae | 15359 | struct bgp *bgp; |
15360 | struct peer *peer; | |
d62a17ae | 15361 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15362 | |
d62a17ae | 15363 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15364 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15365 | /* only provide suggestions on the appropriate input | |
15366 | * token type, | |
15367 | * they'll otherwise show up multiple times */ | |
15368 | enum cmd_token_type match_type; | |
15369 | char *name = peer->host; | |
d48ed3e0 | 15370 | |
d62a17ae | 15371 | if (peer->conf_if) { |
15372 | match_type = VARIABLE_TKN; | |
15373 | name = peer->conf_if; | |
15374 | } else if (strchr(peer->host, ':')) | |
15375 | match_type = IPV6_TKN; | |
15376 | else | |
15377 | match_type = IPV4_TKN; | |
d48ed3e0 | 15378 | |
d62a17ae | 15379 | if (token->type != match_type) |
15380 | continue; | |
d48ed3e0 | 15381 | |
d62a17ae | 15382 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15383 | } | |
d62a17ae | 15384 | } |
b8a815e5 DL |
15385 | } |
15386 | ||
15387 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15388 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15389 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15390 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15391 | {.completions = NULL}}; |
15392 | ||
47a306a0 DS |
15393 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15394 | { | |
15395 | struct bgp *bgp; | |
15396 | struct peer_group *group; | |
15397 | struct listnode *lnbgp, *lnpeer; | |
15398 | ||
15399 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15400 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15401 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15402 | group->name)); | |
15403 | } | |
15404 | } | |
15405 | ||
15406 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15407 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15408 | {.completions = NULL} }; | |
15409 | ||
d62a17ae | 15410 | void bgp_vty_init(void) |
15411 | { | |
15412 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15413 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15414 | |
15415 | /* Install bgp top node. */ | |
15416 | install_node(&bgp_node, bgp_config_write); | |
15417 | install_node(&bgp_ipv4_unicast_node, NULL); | |
15418 | install_node(&bgp_ipv4_multicast_node, NULL); | |
15419 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
15420 | install_node(&bgp_ipv6_unicast_node, NULL); | |
15421 | install_node(&bgp_ipv6_multicast_node, NULL); | |
15422 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
15423 | install_node(&bgp_vpnv4_node, NULL); | |
15424 | install_node(&bgp_vpnv6_node, NULL); | |
15425 | install_node(&bgp_evpn_node, NULL); | |
15426 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 15427 | install_node(&bgp_flowspecv4_node, NULL); |
15428 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 15429 | |
15430 | /* Install default VTY commands to new nodes. */ | |
15431 | install_default(BGP_NODE); | |
15432 | install_default(BGP_IPV4_NODE); | |
15433 | install_default(BGP_IPV4M_NODE); | |
15434 | install_default(BGP_IPV4L_NODE); | |
15435 | install_default(BGP_IPV6_NODE); | |
15436 | install_default(BGP_IPV6M_NODE); | |
15437 | install_default(BGP_IPV6L_NODE); | |
15438 | install_default(BGP_VPNV4_NODE); | |
15439 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15440 | install_default(BGP_FLOWSPECV4_NODE); |
15441 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15442 | install_default(BGP_EVPN_NODE); |
15443 | install_default(BGP_EVPN_VNI_NODE); | |
15444 | ||
8029b216 AK |
15445 | /* "bgp local-mac" hidden commands. */ |
15446 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15447 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15448 | ||
d62a17ae | 15449 | /* bgp route-map delay-timer commands. */ |
15450 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15451 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15452 | ||
15453 | /* Dummy commands (Currently not supported) */ | |
15454 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15455 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15456 | ||
15457 | /* "router bgp" commands. */ | |
15458 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15459 | ||
15460 | /* "no router bgp" commands. */ | |
15461 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15462 | ||
15463 | /* "bgp router-id" commands. */ | |
15464 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15465 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15466 | ||
15467 | /* "bgp cluster-id" commands. */ | |
15468 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15469 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15470 | ||
15471 | /* "bgp confederation" commands. */ | |
15472 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15473 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15474 | ||
15475 | /* "bgp confederation peers" commands. */ | |
15476 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15477 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15478 | ||
15479 | /* bgp max-med command */ | |
15480 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15481 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15482 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15483 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15484 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15485 | ||
15486 | /* bgp disable-ebgp-connected-nh-check */ | |
15487 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15488 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15489 | ||
15490 | /* bgp update-delay command */ | |
15491 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15492 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15493 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15494 | ||
15495 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15496 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15497 | |
15498 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15499 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15500 | ||
15501 | /* "maximum-paths" commands. */ | |
15502 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15503 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15504 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15505 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15506 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15507 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15508 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15509 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15510 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15511 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15512 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15513 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15514 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15515 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15516 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15517 | ||
15518 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15519 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15520 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15521 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15522 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15523 | ||
15524 | /* "timers bgp" commands. */ | |
15525 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15526 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15527 | ||
15528 | /* route-map delay-timer commands - per instance for backwards compat. | |
15529 | */ | |
15530 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15531 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15532 | ||
15533 | /* "bgp client-to-client reflection" commands */ | |
15534 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15535 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15536 | ||
15537 | /* "bgp always-compare-med" commands */ | |
15538 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15539 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15540 | ||
9dac9fc8 DA |
15541 | /* bgp ebgp-requires-policy */ |
15542 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15543 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15544 | ||
fb29348a DA |
15545 | /* bgp reject-as-sets */ |
15546 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15547 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15548 | ||
d62a17ae | 15549 | /* "bgp deterministic-med" commands */ |
15550 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15551 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15552 | ||
055679e9 | 15553 | /* "bgp graceful-restart" command */ |
15554 | install_element(BGP_NODE, | |
15555 | &bgp_graceful_restart_cmd); | |
15556 | install_element(BGP_NODE, | |
15557 | &no_bgp_graceful_restart_cmd); | |
15558 | ||
15559 | /* "bgp graceful-restart-disable" command */ | |
15560 | install_element(BGP_NODE, | |
15561 | &bgp_graceful_restart_disable_cmd); | |
15562 | install_element(BGP_NODE, | |
15563 | &no_bgp_graceful_restart_disable_cmd); | |
15564 | ||
15565 | /* "neighbor a:b:c:d graceful-restart" command */ | |
15566 | install_element(BGP_NODE, | |
15567 | &bgp_neighbor_graceful_restart_set_cmd); | |
15568 | install_element(BGP_NODE, | |
15569 | &no_bgp_neighbor_graceful_restart_set_cmd); | |
15570 | ||
15571 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15572 | install_element(BGP_NODE, | |
15573 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15574 | install_element(BGP_NODE, | |
15575 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15576 | ||
15577 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15578 | install_element(BGP_NODE, | |
15579 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15580 | install_element(BGP_NODE, | |
15581 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15582 | ||
d62a17ae | 15583 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15584 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15585 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15586 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15587 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15588 | install_element(BGP_NODE, |
15589 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15590 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15591 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15592 | ||
d6e3c15b | 15593 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15594 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15595 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15596 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15597 | |
7f323236 DW |
15598 | /* "bgp graceful-shutdown" commands */ |
15599 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15600 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15601 | ||
d62a17ae | 15602 | /* "bgp fast-external-failover" commands */ |
15603 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15604 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15605 | ||
d62a17ae | 15606 | /* "bgp bestpath compare-routerid" commands */ |
15607 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15608 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15609 | ||
15610 | /* "bgp bestpath as-path ignore" commands */ | |
15611 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15612 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15613 | ||
15614 | /* "bgp bestpath as-path confed" commands */ | |
15615 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15616 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15617 | ||
15618 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15619 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15620 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15621 | ||
15622 | /* "bgp log-neighbor-changes" commands */ | |
15623 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15624 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15625 | ||
15626 | /* "bgp bestpath med" commands */ | |
15627 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15628 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15629 | ||
15630 | /* "no bgp default ipv4-unicast" commands. */ | |
15631 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15632 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15633 | ||
15634 | /* "bgp network import-check" commands. */ | |
15635 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15636 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15637 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15638 | ||
15639 | /* "bgp default local-preference" commands. */ | |
15640 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15641 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15642 | ||
15643 | /* bgp default show-hostname */ | |
15644 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15645 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15646 | ||
15647 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15648 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15649 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15650 | ||
15651 | /* bgp ibgp-allow-policy-mods command */ | |
15652 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15653 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15654 | ||
15655 | /* "bgp listen limit" commands. */ | |
15656 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15657 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15658 | ||
15659 | /* "bgp listen range" commands. */ | |
15660 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15661 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15662 | ||
8175f54a | 15663 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15664 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15665 | ||
d62a17ae | 15666 | /* "neighbor remote-as" commands. */ |
15667 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15668 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15669 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15670 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15671 | install_element(BGP_NODE, | |
15672 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15673 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15674 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15675 | ||
15676 | /* "neighbor peer-group" commands. */ | |
15677 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15678 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15679 | install_element(BGP_NODE, | |
15680 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15681 | ||
15682 | /* "neighbor local-as" commands. */ | |
15683 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15684 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15685 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15686 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15687 | ||
15688 | /* "neighbor solo" commands. */ | |
15689 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15690 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15691 | ||
15692 | /* "neighbor password" commands. */ | |
15693 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15694 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15695 | ||
15696 | /* "neighbor activate" commands. */ | |
15697 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15698 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15699 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15700 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15701 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15702 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15703 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15704 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15705 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15706 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15707 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15708 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15709 | ||
15710 | /* "no neighbor activate" commands. */ | |
15711 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15712 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15713 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15714 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15715 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15716 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15717 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15718 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15719 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15720 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15721 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15722 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15723 | ||
15724 | /* "neighbor peer-group" set commands. */ | |
15725 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15726 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15727 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15728 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15729 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15730 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15731 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15732 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15733 | install_element(BGP_FLOWSPECV4_NODE, |
15734 | &neighbor_set_peer_group_hidden_cmd); | |
15735 | install_element(BGP_FLOWSPECV6_NODE, | |
15736 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15737 | |
15738 | /* "no neighbor peer-group unset" commands. */ | |
15739 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15740 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15741 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15742 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15743 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15744 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15745 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15746 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15747 | install_element(BGP_FLOWSPECV4_NODE, |
15748 | &no_neighbor_set_peer_group_hidden_cmd); | |
15749 | install_element(BGP_FLOWSPECV6_NODE, | |
15750 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15751 | |
15752 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15753 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15754 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15755 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15756 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15757 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15758 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15759 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15760 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15761 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15762 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15763 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15764 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15765 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15766 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15767 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15768 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15769 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15770 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15771 | install_element(BGP_FLOWSPECV4_NODE, |
15772 | &neighbor_soft_reconfiguration_cmd); | |
15773 | install_element(BGP_FLOWSPECV4_NODE, | |
15774 | &no_neighbor_soft_reconfiguration_cmd); | |
15775 | install_element(BGP_FLOWSPECV6_NODE, | |
15776 | &neighbor_soft_reconfiguration_cmd); | |
15777 | install_element(BGP_FLOWSPECV6_NODE, | |
15778 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15779 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15780 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15781 | |
15782 | /* "neighbor attribute-unchanged" commands. */ | |
15783 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15784 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15785 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15786 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15787 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15788 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15789 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15790 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15791 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15792 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15793 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15794 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15795 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15796 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15797 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15798 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15799 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15800 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15801 | ||
15802 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15803 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15804 | ||
15805 | /* "nexthop-local unchanged" commands */ | |
15806 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15807 | install_element(BGP_IPV6_NODE, | |
15808 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15809 | ||
15810 | /* "neighbor next-hop-self" commands. */ | |
15811 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15812 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15813 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15814 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15815 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15816 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15817 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15818 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15819 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15820 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15821 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15822 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15823 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15824 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15825 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15826 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15827 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15828 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15829 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15830 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15831 | |
15832 | /* "neighbor next-hop-self force" commands. */ | |
15833 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15834 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15835 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15836 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15837 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15838 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15839 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15840 | install_element(BGP_IPV4_NODE, | |
15841 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15842 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15843 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15844 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15845 | install_element(BGP_IPV4M_NODE, | |
15846 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15847 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
15848 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15849 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15850 | install_element(BGP_IPV4L_NODE, | |
15851 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15852 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
15853 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15854 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15855 | install_element(BGP_IPV6_NODE, | |
15856 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15857 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
15858 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15859 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15860 | install_element(BGP_IPV6M_NODE, | |
15861 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15862 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
15863 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15864 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15865 | install_element(BGP_IPV6L_NODE, | |
15866 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15867 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
15868 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15869 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15870 | install_element(BGP_VPNV4_NODE, | |
15871 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15872 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
15873 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15874 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15875 | install_element(BGP_VPNV6_NODE, | |
15876 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15877 | |
15878 | /* "neighbor as-override" commands. */ | |
15879 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
15880 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
15881 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
15882 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
15883 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
15884 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
15885 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
15886 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
15887 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
15888 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
15889 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
15890 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
15891 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
15892 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
15893 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
15894 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
15895 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
15896 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
15897 | ||
15898 | /* "neighbor remove-private-AS" commands. */ | |
15899 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
15900 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
15901 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
15902 | install_element(BGP_NODE, | |
15903 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
15904 | install_element(BGP_NODE, | |
15905 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
15906 | install_element(BGP_NODE, | |
15907 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
15908 | install_element(BGP_NODE, | |
15909 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15910 | install_element( | |
15911 | BGP_NODE, | |
15912 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15913 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
15914 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15915 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15916 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15917 | install_element(BGP_IPV4_NODE, | |
15918 | &neighbor_remove_private_as_replace_as_cmd); | |
15919 | install_element(BGP_IPV4_NODE, | |
15920 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15921 | install_element(BGP_IPV4_NODE, | |
15922 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15923 | install_element(BGP_IPV4_NODE, | |
15924 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15925 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
15926 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
15927 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
15928 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15929 | install_element(BGP_IPV4M_NODE, | |
15930 | &neighbor_remove_private_as_replace_as_cmd); | |
15931 | install_element(BGP_IPV4M_NODE, | |
15932 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15933 | install_element(BGP_IPV4M_NODE, | |
15934 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15935 | install_element(BGP_IPV4M_NODE, | |
15936 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15937 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
15938 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
15939 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
15940 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15941 | install_element(BGP_IPV4L_NODE, | |
15942 | &neighbor_remove_private_as_replace_as_cmd); | |
15943 | install_element(BGP_IPV4L_NODE, | |
15944 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15945 | install_element(BGP_IPV4L_NODE, | |
15946 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15947 | install_element(BGP_IPV4L_NODE, | |
15948 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15949 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
15950 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15951 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15952 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15953 | install_element(BGP_IPV6_NODE, | |
15954 | &neighbor_remove_private_as_replace_as_cmd); | |
15955 | install_element(BGP_IPV6_NODE, | |
15956 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15957 | install_element(BGP_IPV6_NODE, | |
15958 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15959 | install_element(BGP_IPV6_NODE, | |
15960 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15961 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
15962 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
15963 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
15964 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15965 | install_element(BGP_IPV6M_NODE, | |
15966 | &neighbor_remove_private_as_replace_as_cmd); | |
15967 | install_element(BGP_IPV6M_NODE, | |
15968 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15969 | install_element(BGP_IPV6M_NODE, | |
15970 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15971 | install_element(BGP_IPV6M_NODE, | |
15972 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15973 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
15974 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
15975 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
15976 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15977 | install_element(BGP_IPV6L_NODE, | |
15978 | &neighbor_remove_private_as_replace_as_cmd); | |
15979 | install_element(BGP_IPV6L_NODE, | |
15980 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15981 | install_element(BGP_IPV6L_NODE, | |
15982 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15983 | install_element(BGP_IPV6L_NODE, | |
15984 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15985 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
15986 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15987 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15988 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15989 | install_element(BGP_VPNV4_NODE, | |
15990 | &neighbor_remove_private_as_replace_as_cmd); | |
15991 | install_element(BGP_VPNV4_NODE, | |
15992 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15993 | install_element(BGP_VPNV4_NODE, | |
15994 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15995 | install_element(BGP_VPNV4_NODE, | |
15996 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15997 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
15998 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15999 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16000 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16001 | install_element(BGP_VPNV6_NODE, | |
16002 | &neighbor_remove_private_as_replace_as_cmd); | |
16003 | install_element(BGP_VPNV6_NODE, | |
16004 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16005 | install_element(BGP_VPNV6_NODE, | |
16006 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16007 | install_element(BGP_VPNV6_NODE, | |
16008 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16009 | ||
16010 | /* "neighbor send-community" commands.*/ | |
16011 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
16012 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
16013 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
16014 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
16015 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
16016 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
16017 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
16018 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
16019 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
16020 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
16021 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
16022 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
16023 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
16024 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
16025 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
16026 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
16027 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
16028 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
16029 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
16030 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
16031 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
16032 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
16033 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
16034 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
16035 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
16036 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
16037 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
16038 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
16039 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
16040 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
16041 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
16042 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
16043 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
16044 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
16045 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
16046 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
16047 | ||
16048 | /* "neighbor route-reflector" commands.*/ | |
16049 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
16050 | install_element(BGP_NODE, | |
16051 | &no_neighbor_route_reflector_client_hidden_cmd); | |
16052 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
16053 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
16054 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
16055 | install_element(BGP_IPV4M_NODE, | |
16056 | &no_neighbor_route_reflector_client_cmd); | |
16057 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
16058 | install_element(BGP_IPV4L_NODE, | |
16059 | &no_neighbor_route_reflector_client_cmd); | |
16060 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16061 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16062 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16063 | install_element(BGP_IPV6M_NODE, | |
16064 | &no_neighbor_route_reflector_client_cmd); | |
16065 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16066 | install_element(BGP_IPV6L_NODE, | |
16067 | &no_neighbor_route_reflector_client_cmd); | |
16068 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16069 | install_element(BGP_VPNV4_NODE, | |
16070 | &no_neighbor_route_reflector_client_cmd); | |
16071 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16072 | install_element(BGP_VPNV6_NODE, | |
16073 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16074 | install_element(BGP_FLOWSPECV4_NODE, |
16075 | &neighbor_route_reflector_client_cmd); | |
16076 | install_element(BGP_FLOWSPECV4_NODE, | |
16077 | &no_neighbor_route_reflector_client_cmd); | |
16078 | install_element(BGP_FLOWSPECV6_NODE, | |
16079 | &neighbor_route_reflector_client_cmd); | |
16080 | install_element(BGP_FLOWSPECV6_NODE, | |
16081 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16082 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16083 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16084 | ||
16085 | /* "neighbor route-server" commands.*/ | |
16086 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16087 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16088 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16089 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16090 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16091 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16092 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16093 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16094 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16095 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16096 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16097 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16098 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16099 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16100 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16101 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16102 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16103 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16104 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16105 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16106 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16107 | install_element(BGP_FLOWSPECV4_NODE, | |
16108 | &no_neighbor_route_server_client_cmd); | |
16109 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16110 | install_element(BGP_FLOWSPECV6_NODE, | |
16111 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16112 | |
16113 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16114 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16115 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16116 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16117 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16118 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16119 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16120 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16121 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16122 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16123 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16124 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16125 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16126 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16127 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16128 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16129 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16130 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16131 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16132 | ||
16133 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16134 | install_element(BGP_NODE, | |
16135 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16136 | install_element(BGP_NODE, | |
16137 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16138 | install_element(BGP_IPV4_NODE, | |
16139 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16140 | install_element(BGP_IPV4_NODE, | |
16141 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16142 | install_element(BGP_IPV4M_NODE, | |
16143 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16144 | install_element(BGP_IPV4M_NODE, | |
16145 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16146 | install_element(BGP_IPV4L_NODE, | |
16147 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16148 | install_element(BGP_IPV4L_NODE, | |
16149 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16150 | install_element(BGP_IPV6_NODE, | |
16151 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16152 | install_element(BGP_IPV6_NODE, | |
16153 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16154 | install_element(BGP_IPV6M_NODE, | |
16155 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16156 | install_element(BGP_IPV6M_NODE, | |
16157 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16158 | install_element(BGP_IPV6L_NODE, | |
16159 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16160 | install_element(BGP_IPV6L_NODE, | |
16161 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16162 | install_element(BGP_VPNV4_NODE, | |
16163 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16164 | install_element(BGP_VPNV4_NODE, | |
16165 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16166 | install_element(BGP_VPNV6_NODE, | |
16167 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16168 | install_element(BGP_VPNV6_NODE, | |
16169 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16170 | ||
2b31007c RZ |
16171 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16172 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16173 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16174 | ||
d62a17ae | 16175 | /* "neighbor passive" commands. */ |
16176 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16177 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16178 | ||
16179 | ||
16180 | /* "neighbor shutdown" commands. */ | |
16181 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16182 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16183 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16184 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16185 | ||
16186 | /* "neighbor capability extended-nexthop" commands.*/ | |
16187 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16188 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16189 | ||
16190 | /* "neighbor capability orf prefix-list" commands.*/ | |
16191 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16192 | install_element(BGP_NODE, | |
16193 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16194 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16195 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16196 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16197 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16198 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16199 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16200 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16201 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16202 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16203 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16204 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16205 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16206 | ||
16207 | /* "neighbor capability dynamic" commands.*/ | |
16208 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16209 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16210 | ||
16211 | /* "neighbor dont-capability-negotiate" commands. */ | |
16212 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16213 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16214 | ||
16215 | /* "neighbor ebgp-multihop" commands. */ | |
16216 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16217 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16218 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16219 | ||
16220 | /* "neighbor disable-connected-check" commands. */ | |
16221 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16222 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16223 | ||
47cbc09b PM |
16224 | /* "neighbor enforce-first-as" commands. */ |
16225 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16226 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16227 | ||
d62a17ae | 16228 | /* "neighbor description" commands. */ |
16229 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16230 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16231 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16232 | |
16233 | /* "neighbor update-source" commands. "*/ | |
16234 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16235 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16236 | ||
16237 | /* "neighbor default-originate" commands. */ | |
16238 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16239 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16240 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16241 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16242 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16243 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16244 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16245 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16246 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16247 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16248 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16249 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16250 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16251 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16252 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16253 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16254 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16255 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16256 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16257 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16258 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16259 | ||
16260 | /* "neighbor port" commands. */ | |
16261 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16262 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16263 | ||
16264 | /* "neighbor weight" commands. */ | |
16265 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16266 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16267 | ||
16268 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16269 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16270 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16271 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16272 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16273 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16274 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16275 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16276 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16277 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16278 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16279 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16280 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16281 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16282 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16283 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16284 | ||
16285 | /* "neighbor override-capability" commands. */ | |
16286 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16287 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16288 | ||
16289 | /* "neighbor strict-capability-match" commands. */ | |
16290 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16291 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16292 | ||
16293 | /* "neighbor timers" commands. */ | |
16294 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16295 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16296 | ||
16297 | /* "neighbor timers connect" commands. */ | |
16298 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16299 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16300 | ||
16301 | /* "neighbor advertisement-interval" commands. */ | |
16302 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16303 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16304 | ||
16305 | /* "neighbor interface" commands. */ | |
16306 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16307 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16308 | ||
16309 | /* "neighbor distribute" commands. */ | |
16310 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16311 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16312 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16313 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16314 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16315 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16316 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16317 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16318 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16319 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16320 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16321 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16322 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16323 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16324 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16325 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16326 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16327 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16328 | ||
16329 | /* "neighbor prefix-list" commands. */ | |
16330 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16331 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16332 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16333 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16334 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16335 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16336 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16337 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16338 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16339 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16340 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16341 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16342 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16343 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16344 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16345 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16346 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16347 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16348 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16349 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16350 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16351 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16352 | |
16353 | /* "neighbor filter-list" commands. */ | |
16354 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16355 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16356 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16357 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16358 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16359 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16360 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16361 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16362 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16363 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16364 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16365 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16366 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16367 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16368 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16369 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16370 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16371 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16372 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16373 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16374 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16375 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16376 | |
16377 | /* "neighbor route-map" commands. */ | |
16378 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16379 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16380 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16381 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16382 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16383 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16384 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16385 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16386 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16387 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16388 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16389 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16390 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16391 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16392 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16393 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16394 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16395 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16396 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16397 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16398 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16399 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16400 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16401 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16402 | |
16403 | /* "neighbor unsuppress-map" commands. */ | |
16404 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16405 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16406 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16407 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16408 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16409 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16410 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16411 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16412 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16413 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16414 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16415 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16416 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16417 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16418 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16419 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16420 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16421 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16422 | ||
fde246e8 DA |
16423 | /* neighbor maximum-prefix-out commands. */ |
16424 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16425 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16426 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16427 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16428 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16429 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16430 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16431 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16432 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16433 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16434 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16435 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16436 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16437 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16438 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16439 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16440 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16441 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16442 | ||
d62a17ae | 16443 | /* "neighbor maximum-prefix" commands. */ |
16444 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16445 | install_element(BGP_NODE, | |
16446 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16447 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16448 | install_element(BGP_NODE, | |
16449 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16450 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16451 | install_element(BGP_NODE, | |
16452 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16453 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16454 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16455 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16456 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16457 | install_element(BGP_IPV4_NODE, | |
16458 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16459 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16460 | install_element(BGP_IPV4_NODE, | |
16461 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16462 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16463 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16464 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16465 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16466 | install_element(BGP_IPV4M_NODE, | |
16467 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16468 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16469 | install_element(BGP_IPV4M_NODE, | |
16470 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16471 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16472 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16473 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16474 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16475 | install_element(BGP_IPV4L_NODE, | |
16476 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16477 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16478 | install_element(BGP_IPV4L_NODE, | |
16479 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16480 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16481 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16482 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16483 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16484 | install_element(BGP_IPV6_NODE, | |
16485 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16486 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16487 | install_element(BGP_IPV6_NODE, | |
16488 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16489 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16490 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16491 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16492 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16493 | install_element(BGP_IPV6M_NODE, | |
16494 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16495 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16496 | install_element(BGP_IPV6M_NODE, | |
16497 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16498 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16499 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16500 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16501 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16502 | install_element(BGP_IPV6L_NODE, | |
16503 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16504 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16505 | install_element(BGP_IPV6L_NODE, | |
16506 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16507 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16508 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16509 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16510 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16511 | install_element(BGP_VPNV4_NODE, | |
16512 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16513 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16514 | install_element(BGP_VPNV4_NODE, | |
16515 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16516 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16517 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16518 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16519 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16520 | install_element(BGP_VPNV6_NODE, | |
16521 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16522 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16523 | install_element(BGP_VPNV6_NODE, | |
16524 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16525 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16526 | ||
16527 | /* "neighbor allowas-in" */ | |
16528 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16529 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16530 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16531 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16532 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16533 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16534 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16535 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16536 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16537 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16538 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16539 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16540 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16541 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16542 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16543 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16544 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16545 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16546 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16547 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16548 | ||
16549 | /* address-family commands. */ | |
16550 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16551 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16552 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16553 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16554 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16555 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16556 | |
d62a17ae | 16557 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16558 | ||
16559 | /* "exit-address-family" command. */ | |
16560 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16561 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16562 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16563 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16564 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16565 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16566 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16567 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16568 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16569 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16570 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16571 | ||
16572 | /* "clear ip bgp commands" */ | |
16573 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16574 | ||
16575 | /* clear ip bgp prefix */ | |
16576 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16577 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16578 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16579 | ||
16580 | /* "show [ip] bgp summary" commands. */ | |
16581 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16582 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16583 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16584 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16585 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16586 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16587 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16588 | ||
16589 | /* "show [ip] bgp neighbors" commands. */ | |
16590 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16591 | ||
2986cac2 | 16592 | install_element(VIEW_NODE, |
16593 | &show_ip_bgp_neighbors_graceful_restart_cmd); | |
16594 | ||
d62a17ae | 16595 | /* "show [ip] bgp peer-group" commands. */ |
16596 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16597 | ||
16598 | /* "show [ip] bgp paths" commands. */ | |
16599 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16600 | ||
16601 | /* "show [ip] bgp community" commands. */ | |
16602 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16603 | ||
16604 | /* "show ip bgp large-community" commands. */ | |
16605 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16606 | /* "show [ip] bgp attribute-info" commands. */ | |
16607 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16608 | /* "show [ip] bgp route-leak" command */ |
16609 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16610 | |
16611 | /* "redistribute" commands. */ | |
16612 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16613 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16614 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16615 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16616 | install_element(BGP_NODE, | |
16617 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16618 | install_element(BGP_NODE, | |
16619 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16620 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16621 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16622 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16623 | install_element(BGP_NODE, | |
16624 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16625 | install_element(BGP_NODE, | |
16626 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16627 | install_element(BGP_NODE, | |
16628 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16629 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16630 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16631 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16632 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16633 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16634 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16635 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16636 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16637 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16638 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16639 | install_element(BGP_IPV4_NODE, | |
16640 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16641 | install_element(BGP_IPV4_NODE, | |
16642 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16643 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16644 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16645 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16646 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16647 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16648 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16649 | ||
b9c7bc5a PZ |
16650 | /* import|export vpn [route-map WORD] */ |
16651 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16652 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16653 | |
12a844a5 DS |
16654 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16655 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16656 | ||
d62a17ae | 16657 | /* ttl_security commands */ |
16658 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16659 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16660 | ||
16661 | /* "show [ip] bgp memory" commands. */ | |
16662 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16663 | ||
acf71666 MK |
16664 | /* "show bgp martian next-hop" */ |
16665 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16666 | ||
48ecf8f5 DS |
16667 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16668 | ||
d62a17ae | 16669 | /* "show [ip] bgp views" commands. */ |
16670 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16671 | ||
16672 | /* "show [ip] bgp vrfs" commands. */ | |
16673 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16674 | ||
16675 | /* Community-list. */ | |
16676 | community_list_vty(); | |
ddb5b488 PZ |
16677 | |
16678 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16679 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16680 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16681 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16682 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16683 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16684 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16685 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16686 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16687 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16688 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16689 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16690 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16691 | |
301ad80a PG |
16692 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16693 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16694 | ||
b9c7bc5a PZ |
16695 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16696 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16697 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16698 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
16699 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
16700 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
16701 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
16702 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16703 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16704 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16705 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16706 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16707 | } |
6b0655a2 | 16708 | |
718e3744 | 16709 | #include "memory.h" |
16710 | #include "bgp_regex.h" | |
16711 | #include "bgp_clist.h" | |
16712 | #include "bgp_ecommunity.h" | |
16713 | ||
16714 | /* VTY functions. */ | |
16715 | ||
16716 | /* Direction value to string conversion. */ | |
d62a17ae | 16717 | static const char *community_direct_str(int direct) |
16718 | { | |
16719 | switch (direct) { | |
16720 | case COMMUNITY_DENY: | |
16721 | return "deny"; | |
16722 | case COMMUNITY_PERMIT: | |
16723 | return "permit"; | |
16724 | default: | |
16725 | return "unknown"; | |
16726 | } | |
718e3744 | 16727 | } |
16728 | ||
16729 | /* Display error string. */ | |
d62a17ae | 16730 | static void community_list_perror(struct vty *vty, int ret) |
16731 | { | |
16732 | switch (ret) { | |
16733 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16734 | vty_out(vty, "%% Can't find community-list\n"); | |
16735 | break; | |
16736 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16737 | vty_out(vty, "%% Malformed community-list value\n"); | |
16738 | break; | |
16739 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16740 | vty_out(vty, | |
16741 | "%% Community name conflict, previously defined as standard community\n"); | |
16742 | break; | |
16743 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16744 | vty_out(vty, | |
16745 | "%% Community name conflict, previously defined as expanded community\n"); | |
16746 | break; | |
16747 | } | |
718e3744 | 16748 | } |
16749 | ||
5bf15956 DW |
16750 | /* "community-list" keyword help string. */ |
16751 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16752 | ||
7336e101 SP |
16753 | /*community-list standard */ |
16754 | DEFUN (community_list_standard, | |
16755 | bgp_community_list_standard_cmd, | |
16756 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
16757 | BGP_STR | |
718e3744 | 16758 | COMMUNITY_LIST_STR |
16759 | "Community list number (standard)\n" | |
5bf15956 | 16760 | "Add an standard community-list entry\n" |
718e3744 | 16761 | "Community list name\n" |
16762 | "Specify community to reject\n" | |
16763 | "Specify community to accept\n" | |
16764 | COMMUNITY_VAL_STR) | |
16765 | { | |
d62a17ae | 16766 | char *cl_name_or_number = NULL; |
16767 | int direct = 0; | |
16768 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16769 | int idx = 0; |
7336e101 | 16770 | |
d62a17ae | 16771 | argv_find(argv, argc, "(1-99)", &idx); |
16772 | argv_find(argv, argc, "WORD", &idx); | |
16773 | cl_name_or_number = argv[idx]->arg; | |
16774 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16775 | : COMMUNITY_DENY; | |
16776 | argv_find(argv, argc, "AA:NN", &idx); | |
16777 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16778 | |
d62a17ae | 16779 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
16780 | style); | |
42f914d4 | 16781 | |
d62a17ae | 16782 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16783 | |
d62a17ae | 16784 | if (ret < 0) { |
16785 | /* Display error string. */ | |
16786 | community_list_perror(vty, ret); | |
16787 | return CMD_WARNING_CONFIG_FAILED; | |
16788 | } | |
42f914d4 | 16789 | |
d62a17ae | 16790 | return CMD_SUCCESS; |
718e3744 | 16791 | } |
16792 | ||
7336e101 SP |
16793 | DEFUN (no_community_list_standard_all, |
16794 | no_bgp_community_list_standard_all_cmd, | |
16795 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
16796 | NO_STR | |
16797 | BGP_STR | |
16798 | COMMUNITY_LIST_STR | |
16799 | "Community list number (standard)\n" | |
16800 | "Add an standard community-list entry\n" | |
16801 | "Community list name\n" | |
16802 | "Specify community to reject\n" | |
16803 | "Specify community to accept\n" | |
16804 | COMMUNITY_VAL_STR) | |
718e3744 | 16805 | { |
d62a17ae | 16806 | char *cl_name_or_number = NULL; |
174b5cb9 | 16807 | char *str = NULL; |
d62a17ae | 16808 | int direct = 0; |
16809 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 16810 | |
d62a17ae | 16811 | int idx = 0; |
7336e101 | 16812 | |
174b5cb9 DA |
16813 | argv_find(argv, argc, "permit", &idx); |
16814 | argv_find(argv, argc, "deny", &idx); | |
16815 | ||
16816 | if (idx) { | |
16817 | direct = argv_find(argv, argc, "permit", &idx) | |
16818 | ? COMMUNITY_PERMIT | |
16819 | : COMMUNITY_DENY; | |
16820 | ||
16821 | idx = 0; | |
16822 | argv_find(argv, argc, "AA:NN", &idx); | |
16823 | str = argv_concat(argv, argc, idx); | |
16824 | } | |
16825 | ||
16826 | idx = 0; | |
d62a17ae | 16827 | argv_find(argv, argc, "(1-99)", &idx); |
16828 | argv_find(argv, argc, "WORD", &idx); | |
16829 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16830 | |
d62a17ae | 16831 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 16832 | direct, style); |
42f914d4 | 16833 | |
d62a17ae | 16834 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16835 | |
d62a17ae | 16836 | if (ret < 0) { |
16837 | community_list_perror(vty, ret); | |
16838 | return CMD_WARNING_CONFIG_FAILED; | |
16839 | } | |
42f914d4 | 16840 | |
d62a17ae | 16841 | return CMD_SUCCESS; |
718e3744 | 16842 | } |
7336e101 | 16843 | |
174b5cb9 DA |
16844 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
16845 | "no bgp community-list <(1-99)|standard WORD>", | |
16846 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
16847 | "Community list number (standard)\n" | |
16848 | "Add an standard community-list entry\n" | |
16849 | "Community list name\n") | |
16850 | ||
7336e101 SP |
16851 | /*community-list expanded */ |
16852 | DEFUN (community_list_expanded_all, | |
16853 | bgp_community_list_expanded_all_cmd, | |
16854 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
16855 | BGP_STR | |
16856 | COMMUNITY_LIST_STR | |
718e3744 | 16857 | "Community list number (expanded)\n" |
5bf15956 | 16858 | "Add an expanded community-list entry\n" |
718e3744 | 16859 | "Community list name\n" |
16860 | "Specify community to reject\n" | |
16861 | "Specify community to accept\n" | |
16862 | COMMUNITY_VAL_STR) | |
16863 | { | |
d62a17ae | 16864 | char *cl_name_or_number = NULL; |
16865 | int direct = 0; | |
16866 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 16867 | |
d62a17ae | 16868 | int idx = 0; |
7b9a4750 | 16869 | |
d62a17ae | 16870 | argv_find(argv, argc, "(100-500)", &idx); |
16871 | argv_find(argv, argc, "WORD", &idx); | |
16872 | cl_name_or_number = argv[idx]->arg; | |
16873 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16874 | : COMMUNITY_DENY; | |
16875 | argv_find(argv, argc, "AA:NN", &idx); | |
16876 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16877 | |
d62a17ae | 16878 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
16879 | style); | |
42f914d4 | 16880 | |
d62a17ae | 16881 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16882 | |
d62a17ae | 16883 | if (ret < 0) { |
16884 | /* Display error string. */ | |
16885 | community_list_perror(vty, ret); | |
16886 | return CMD_WARNING_CONFIG_FAILED; | |
16887 | } | |
42f914d4 | 16888 | |
d62a17ae | 16889 | return CMD_SUCCESS; |
718e3744 | 16890 | } |
16891 | ||
7336e101 SP |
16892 | DEFUN (no_community_list_expanded_all, |
16893 | no_bgp_community_list_expanded_all_cmd, | |
16894 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
16895 | NO_STR | |
16896 | BGP_STR | |
16897 | COMMUNITY_LIST_STR | |
16898 | "Community list number (expanded)\n" | |
16899 | "Add an expanded community-list entry\n" | |
16900 | "Community list name\n" | |
16901 | "Specify community to reject\n" | |
16902 | "Specify community to accept\n" | |
16903 | COMMUNITY_VAL_STR) | |
718e3744 | 16904 | { |
d62a17ae | 16905 | char *cl_name_or_number = NULL; |
174b5cb9 | 16906 | char *str = NULL; |
d62a17ae | 16907 | int direct = 0; |
16908 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 16909 | |
d62a17ae | 16910 | int idx = 0; |
174b5cb9 DA |
16911 | |
16912 | argv_find(argv, argc, "permit", &idx); | |
16913 | argv_find(argv, argc, "deny", &idx); | |
16914 | ||
16915 | if (idx) { | |
16916 | direct = argv_find(argv, argc, "permit", &idx) | |
16917 | ? COMMUNITY_PERMIT | |
16918 | : COMMUNITY_DENY; | |
16919 | ||
16920 | idx = 0; | |
16921 | argv_find(argv, argc, "AA:NN", &idx); | |
16922 | str = argv_concat(argv, argc, idx); | |
7336e101 | 16923 | } |
174b5cb9 DA |
16924 | |
16925 | idx = 0; | |
d62a17ae | 16926 | argv_find(argv, argc, "(100-500)", &idx); |
16927 | argv_find(argv, argc, "WORD", &idx); | |
16928 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16929 | |
d62a17ae | 16930 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 16931 | direct, style); |
42f914d4 | 16932 | |
d62a17ae | 16933 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16934 | |
d62a17ae | 16935 | if (ret < 0) { |
16936 | community_list_perror(vty, ret); | |
16937 | return CMD_WARNING_CONFIG_FAILED; | |
16938 | } | |
42f914d4 | 16939 | |
d62a17ae | 16940 | return CMD_SUCCESS; |
718e3744 | 16941 | } |
16942 | ||
174b5cb9 DA |
16943 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
16944 | "no bgp community-list <(100-500)|expanded WORD>", | |
16945 | NO_STR IP_STR COMMUNITY_LIST_STR | |
16946 | "Community list number (expanded)\n" | |
16947 | "Add an expanded community-list entry\n" | |
16948 | "Community list name\n") | |
16949 | ||
8d9b8ed9 PM |
16950 | /* Return configuration string of community-list entry. */ |
16951 | static const char *community_list_config_str(struct community_entry *entry) | |
16952 | { | |
16953 | const char *str; | |
16954 | ||
16955 | if (entry->any) | |
16956 | str = ""; | |
16957 | else { | |
16958 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
16959 | str = community_str(entry->u.com, false); | |
16960 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
16961 | str = lcommunity_str(entry->u.lcom, false); | |
16962 | else | |
16963 | str = entry->config; | |
16964 | } | |
16965 | return str; | |
16966 | } | |
16967 | ||
d62a17ae | 16968 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 16969 | { |
d62a17ae | 16970 | struct community_entry *entry; |
718e3744 | 16971 | |
d62a17ae | 16972 | for (entry = list->head; entry; entry = entry->next) { |
16973 | if (entry == list->head) { | |
16974 | if (all_digit(list->name)) | |
16975 | vty_out(vty, "Community %s list %s\n", | |
16976 | entry->style == COMMUNITY_LIST_STANDARD | |
16977 | ? "standard" | |
16978 | : "(expanded) access", | |
16979 | list->name); | |
16980 | else | |
16981 | vty_out(vty, "Named Community %s list %s\n", | |
16982 | entry->style == COMMUNITY_LIST_STANDARD | |
16983 | ? "standard" | |
16984 | : "expanded", | |
16985 | list->name); | |
16986 | } | |
16987 | if (entry->any) | |
16988 | vty_out(vty, " %s\n", | |
16989 | community_direct_str(entry->direct)); | |
16990 | else | |
16991 | vty_out(vty, " %s %s\n", | |
16992 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16993 | community_list_config_str(entry)); |
d62a17ae | 16994 | } |
718e3744 | 16995 | } |
16996 | ||
7336e101 SP |
16997 | DEFUN (show_community_list, |
16998 | show_bgp_community_list_cmd, | |
16999 | "show bgp community-list", | |
718e3744 | 17000 | SHOW_STR |
7336e101 | 17001 | BGP_STR |
718e3744 | 17002 | "List community-list\n") |
17003 | { | |
d62a17ae | 17004 | struct community_list *list; |
17005 | struct community_list_master *cm; | |
718e3744 | 17006 | |
d62a17ae | 17007 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
17008 | if (!cm) | |
17009 | return CMD_SUCCESS; | |
718e3744 | 17010 | |
d62a17ae | 17011 | for (list = cm->num.head; list; list = list->next) |
17012 | community_list_show(vty, list); | |
718e3744 | 17013 | |
d62a17ae | 17014 | for (list = cm->str.head; list; list = list->next) |
17015 | community_list_show(vty, list); | |
718e3744 | 17016 | |
d62a17ae | 17017 | return CMD_SUCCESS; |
718e3744 | 17018 | } |
17019 | ||
7336e101 SP |
17020 | DEFUN (show_community_list_arg, |
17021 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 17022 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
17023 | SHOW_STR |
17024 | BGP_STR | |
718e3744 | 17025 | "List community-list\n" |
17026 | "Community-list number\n" | |
960b69b9 | 17027 | "Community-list name\n" |
17028 | "Detailed information on community-list\n") | |
718e3744 | 17029 | { |
d62a17ae | 17030 | int idx_comm_list = 3; |
17031 | struct community_list *list; | |
718e3744 | 17032 | |
e237b0d2 | 17033 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17034 | COMMUNITY_LIST_MASTER); |
17035 | if (!list) { | |
17036 | vty_out(vty, "%% Can't find community-list\n"); | |
17037 | return CMD_WARNING; | |
17038 | } | |
718e3744 | 17039 | |
d62a17ae | 17040 | community_list_show(vty, list); |
718e3744 | 17041 | |
d62a17ae | 17042 | return CMD_SUCCESS; |
718e3744 | 17043 | } |
6b0655a2 | 17044 | |
57d187bc JS |
17045 | /* |
17046 | * Large Community code. | |
17047 | */ | |
d62a17ae | 17048 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17049 | struct cmd_token **argv, int style, | |
17050 | int reject_all_digit_name) | |
17051 | { | |
17052 | int ret; | |
17053 | int direct; | |
17054 | char *str; | |
17055 | int idx = 0; | |
17056 | char *cl_name; | |
17057 | ||
17058 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17059 | : COMMUNITY_DENY; | |
17060 | ||
17061 | /* All digit name check. */ | |
17062 | idx = 0; | |
17063 | argv_find(argv, argc, "WORD", &idx); | |
17064 | argv_find(argv, argc, "(1-99)", &idx); | |
17065 | argv_find(argv, argc, "(100-500)", &idx); | |
17066 | cl_name = argv[idx]->arg; | |
17067 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17068 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17069 | return CMD_WARNING_CONFIG_FAILED; | |
17070 | } | |
17071 | ||
17072 | idx = 0; | |
17073 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17074 | argv_find(argv, argc, "LINE", &idx); | |
17075 | /* Concat community string argument. */ | |
17076 | if (idx) | |
17077 | str = argv_concat(argv, argc, idx); | |
17078 | else | |
17079 | str = NULL; | |
17080 | ||
17081 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
17082 | ||
17083 | /* Free temporary community list string allocated by | |
17084 | argv_concat(). */ | |
0a22ddfb | 17085 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17086 | |
17087 | if (ret < 0) { | |
17088 | community_list_perror(vty, ret); | |
17089 | return CMD_WARNING_CONFIG_FAILED; | |
17090 | } | |
17091 | return CMD_SUCCESS; | |
17092 | } | |
17093 | ||
17094 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17095 | struct cmd_token **argv, int style) | |
17096 | { | |
17097 | int ret; | |
17098 | int direct = 0; | |
17099 | char *str = NULL; | |
17100 | int idx = 0; | |
17101 | ||
17102 | argv_find(argv, argc, "permit", &idx); | |
17103 | argv_find(argv, argc, "deny", &idx); | |
17104 | ||
17105 | if (idx) { | |
17106 | /* Check the list direct. */ | |
17107 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17108 | direct = COMMUNITY_PERMIT; | |
17109 | else | |
17110 | direct = COMMUNITY_DENY; | |
17111 | ||
17112 | idx = 0; | |
17113 | argv_find(argv, argc, "LINE", &idx); | |
17114 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17115 | /* Concat community string argument. */ | |
17116 | str = argv_concat(argv, argc, idx); | |
17117 | } | |
17118 | ||
17119 | idx = 0; | |
17120 | argv_find(argv, argc, "(1-99)", &idx); | |
17121 | argv_find(argv, argc, "(100-500)", &idx); | |
17122 | argv_find(argv, argc, "WORD", &idx); | |
17123 | ||
17124 | /* Unset community list. */ | |
17125 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
17126 | style); | |
17127 | ||
17128 | /* Free temporary community list string allocated by | |
17129 | argv_concat(). */ | |
0a22ddfb | 17130 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17131 | |
17132 | if (ret < 0) { | |
17133 | community_list_perror(vty, ret); | |
17134 | return CMD_WARNING_CONFIG_FAILED; | |
17135 | } | |
17136 | ||
17137 | return CMD_SUCCESS; | |
57d187bc JS |
17138 | } |
17139 | ||
17140 | /* "large-community-list" keyword help string. */ | |
17141 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17142 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17143 | ||
7336e101 SP |
17144 | DEFUN (lcommunity_list_standard, |
17145 | bgp_lcommunity_list_standard_cmd, | |
7336e101 SP |
17146 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", |
17147 | BGP_STR | |
17148 | LCOMMUNITY_LIST_STR | |
17149 | "Large Community list number (standard)\n" | |
17150 | "Specify large community to reject\n" | |
17151 | "Specify large community to accept\n" | |
17152 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17153 | { |
d62a17ae | 17154 | return lcommunity_list_set_vty(vty, argc, argv, |
17155 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17156 | } |
17157 | ||
7336e101 SP |
17158 | DEFUN (lcommunity_list_expanded, |
17159 | bgp_lcommunity_list_expanded_cmd, | |
17160 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
17161 | BGP_STR | |
17162 | LCOMMUNITY_LIST_STR | |
17163 | "Large Community list number (expanded)\n" | |
17164 | "Specify large community to reject\n" | |
17165 | "Specify large community to accept\n" | |
17166 | "An ordered list as a regular-expression\n") | |
57d187bc | 17167 | { |
d62a17ae | 17168 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17169 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17170 | } |
17171 | ||
7336e101 SP |
17172 | DEFUN (lcommunity_list_name_standard, |
17173 | bgp_lcommunity_list_name_standard_cmd, | |
7336e101 SP |
17174 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", |
17175 | BGP_STR | |
17176 | LCOMMUNITY_LIST_STR | |
17177 | "Specify standard large-community-list\n" | |
17178 | "Large Community list name\n" | |
17179 | "Specify large community to reject\n" | |
17180 | "Specify large community to accept\n" | |
17181 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17182 | { |
d62a17ae | 17183 | return lcommunity_list_set_vty(vty, argc, argv, |
17184 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17185 | } |
17186 | ||
7336e101 SP |
17187 | DEFUN (lcommunity_list_name_expanded, |
17188 | bgp_lcommunity_list_name_expanded_cmd, | |
17189 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
17190 | BGP_STR | |
17191 | LCOMMUNITY_LIST_STR | |
17192 | "Specify expanded large-community-list\n" | |
17193 | "Large Community list name\n" | |
17194 | "Specify large community to reject\n" | |
17195 | "Specify large community to accept\n" | |
17196 | "An ordered list as a regular-expression\n") | |
57d187bc | 17197 | { |
d62a17ae | 17198 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17199 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17200 | } |
17201 | ||
7336e101 SP |
17202 | DEFUN (no_lcommunity_list_standard_all, |
17203 | no_bgp_lcommunity_list_standard_all_cmd, | |
17204 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
17205 | NO_STR | |
17206 | BGP_STR | |
17207 | LCOMMUNITY_LIST_STR | |
17208 | "Large Community list number (standard)\n" | |
17209 | "Large Community list number (expanded)\n" | |
17210 | "Large Community list name\n") | |
57d187bc | 17211 | { |
7336e101 SP |
17212 | return lcommunity_list_unset_vty(vty, argc, argv, |
17213 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17214 | } |
17215 | ||
7336e101 SP |
17216 | DEFUN (no_lcommunity_list_name_expanded_all, |
17217 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17218 | "no bgp large-community-list expanded WORD", | |
17219 | NO_STR | |
17220 | BGP_STR | |
17221 | LCOMMUNITY_LIST_STR | |
17222 | "Specify expanded large-community-list\n" | |
17223 | "Large Community list name\n") | |
57d187bc | 17224 | { |
d62a17ae | 17225 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17226 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17227 | } |
17228 | ||
7336e101 SP |
17229 | DEFUN (no_lcommunity_list_standard, |
17230 | no_bgp_lcommunity_list_standard_cmd, | |
17231 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
17232 | NO_STR | |
17233 | BGP_STR | |
17234 | LCOMMUNITY_LIST_STR | |
17235 | "Large Community list number (standard)\n" | |
17236 | "Specify large community to reject\n" | |
17237 | "Specify large community to accept\n" | |
17238 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17239 | { |
d62a17ae | 17240 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17241 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17242 | } |
17243 | ||
7336e101 SP |
17244 | DEFUN (no_lcommunity_list_expanded, |
17245 | no_bgp_lcommunity_list_expanded_cmd, | |
17246 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
17247 | NO_STR | |
17248 | BGP_STR | |
17249 | LCOMMUNITY_LIST_STR | |
17250 | "Large Community list number (expanded)\n" | |
17251 | "Specify large community to reject\n" | |
17252 | "Specify large community to accept\n" | |
17253 | "An ordered list as a regular-expression\n") | |
57d187bc | 17254 | { |
d62a17ae | 17255 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17256 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17257 | } |
17258 | ||
7336e101 SP |
17259 | DEFUN (no_lcommunity_list_name_standard, |
17260 | no_bgp_lcommunity_list_name_standard_cmd, | |
17261 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
17262 | NO_STR | |
17263 | BGP_STR | |
17264 | LCOMMUNITY_LIST_STR | |
17265 | "Specify standard large-community-list\n" | |
17266 | "Large Community list name\n" | |
17267 | "Specify large community to reject\n" | |
17268 | "Specify large community to accept\n" | |
17269 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17270 | { |
d62a17ae | 17271 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17272 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17273 | } |
17274 | ||
7336e101 SP |
17275 | DEFUN (no_lcommunity_list_name_expanded, |
17276 | no_bgp_lcommunity_list_name_expanded_cmd, | |
17277 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
17278 | NO_STR | |
17279 | BGP_STR | |
17280 | LCOMMUNITY_LIST_STR | |
17281 | "Specify expanded large-community-list\n" | |
17282 | "Large community list name\n" | |
17283 | "Specify large community to reject\n" | |
17284 | "Specify large community to accept\n" | |
17285 | "An ordered list as a regular-expression\n") | |
57d187bc | 17286 | { |
d62a17ae | 17287 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17288 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17289 | } |
17290 | ||
d62a17ae | 17291 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17292 | { | |
17293 | struct community_entry *entry; | |
17294 | ||
17295 | for (entry = list->head; entry; entry = entry->next) { | |
17296 | if (entry == list->head) { | |
17297 | if (all_digit(list->name)) | |
17298 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17299 | entry->style == |
17300 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17301 | ? "standard" |
17302 | : "(expanded) access", | |
17303 | list->name); | |
17304 | else | |
17305 | vty_out(vty, | |
17306 | "Named large community %s list %s\n", | |
169b72c8 | 17307 | entry->style == |
17308 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17309 | ? "standard" |
17310 | : "expanded", | |
17311 | list->name); | |
17312 | } | |
17313 | if (entry->any) | |
17314 | vty_out(vty, " %s\n", | |
17315 | community_direct_str(entry->direct)); | |
17316 | else | |
17317 | vty_out(vty, " %s %s\n", | |
17318 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17319 | community_list_config_str(entry)); |
d62a17ae | 17320 | } |
57d187bc JS |
17321 | } |
17322 | ||
7336e101 SP |
17323 | DEFUN (show_lcommunity_list, |
17324 | show_bgp_lcommunity_list_cmd, | |
17325 | "show bgp large-community-list", | |
57d187bc | 17326 | SHOW_STR |
7336e101 | 17327 | BGP_STR |
57d187bc JS |
17328 | "List large-community list\n") |
17329 | { | |
d62a17ae | 17330 | struct community_list *list; |
17331 | struct community_list_master *cm; | |
57d187bc | 17332 | |
d62a17ae | 17333 | cm = community_list_master_lookup(bgp_clist, |
17334 | LARGE_COMMUNITY_LIST_MASTER); | |
17335 | if (!cm) | |
17336 | return CMD_SUCCESS; | |
57d187bc | 17337 | |
d62a17ae | 17338 | for (list = cm->num.head; list; list = list->next) |
17339 | lcommunity_list_show(vty, list); | |
57d187bc | 17340 | |
d62a17ae | 17341 | for (list = cm->str.head; list; list = list->next) |
17342 | lcommunity_list_show(vty, list); | |
57d187bc | 17343 | |
d62a17ae | 17344 | return CMD_SUCCESS; |
57d187bc JS |
17345 | } |
17346 | ||
7336e101 SP |
17347 | DEFUN (show_lcommunity_list_arg, |
17348 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17349 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17350 | SHOW_STR |
17351 | BGP_STR | |
57d187bc | 17352 | "List large-community list\n" |
960b69b9 | 17353 | "Large-community-list number\n" |
17354 | "Large-community-list name\n" | |
17355 | "Detailed information on large-community-list\n") | |
57d187bc | 17356 | { |
d62a17ae | 17357 | struct community_list *list; |
57d187bc | 17358 | |
e237b0d2 | 17359 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17360 | LARGE_COMMUNITY_LIST_MASTER); |
17361 | if (!list) { | |
960b69b9 | 17362 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17363 | return CMD_WARNING; |
17364 | } | |
57d187bc | 17365 | |
d62a17ae | 17366 | lcommunity_list_show(vty, list); |
57d187bc | 17367 | |
d62a17ae | 17368 | return CMD_SUCCESS; |
57d187bc JS |
17369 | } |
17370 | ||
718e3744 | 17371 | /* "extcommunity-list" keyword help string. */ |
17372 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17373 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17374 | ||
7336e101 SP |
17375 | DEFUN (extcommunity_list_standard, |
17376 | bgp_extcommunity_list_standard_cmd, | |
17377 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
17378 | BGP_STR | |
718e3744 | 17379 | EXTCOMMUNITY_LIST_STR |
17380 | "Extended Community list number (standard)\n" | |
718e3744 | 17381 | "Specify standard extcommunity-list\n" |
5bf15956 | 17382 | "Community list name\n" |
718e3744 | 17383 | "Specify community to reject\n" |
17384 | "Specify community to accept\n" | |
17385 | EXTCOMMUNITY_VAL_STR) | |
17386 | { | |
d62a17ae | 17387 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17388 | int direct = 0; | |
17389 | char *cl_number_or_name = NULL; | |
42f914d4 | 17390 | |
d62a17ae | 17391 | int idx = 0; |
7b9a4750 | 17392 | |
d62a17ae | 17393 | argv_find(argv, argc, "(1-99)", &idx); |
17394 | argv_find(argv, argc, "WORD", &idx); | |
17395 | cl_number_or_name = argv[idx]->arg; | |
17396 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17397 | : COMMUNITY_DENY; | |
17398 | argv_find(argv, argc, "AA:NN", &idx); | |
17399 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17400 | |
d62a17ae | 17401 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
17402 | direct, style); | |
42f914d4 | 17403 | |
d62a17ae | 17404 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17405 | |
d62a17ae | 17406 | if (ret < 0) { |
17407 | community_list_perror(vty, ret); | |
17408 | return CMD_WARNING_CONFIG_FAILED; | |
17409 | } | |
42f914d4 | 17410 | |
d62a17ae | 17411 | return CMD_SUCCESS; |
718e3744 | 17412 | } |
17413 | ||
7336e101 SP |
17414 | DEFUN (extcommunity_list_name_expanded, |
17415 | bgp_extcommunity_list_name_expanded_cmd, | |
17416 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
17417 | BGP_STR | |
17418 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17419 | "Extended Community list number (expanded)\n" |
718e3744 | 17420 | "Specify expanded extcommunity-list\n" |
17421 | "Extended Community list name\n" | |
17422 | "Specify community to reject\n" | |
17423 | "Specify community to accept\n" | |
17424 | "An ordered list as a regular-expression\n") | |
17425 | { | |
d62a17ae | 17426 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17427 | int direct = 0; | |
17428 | char *cl_number_or_name = NULL; | |
d62a17ae | 17429 | int idx = 0; |
7336e101 | 17430 | |
d62a17ae | 17431 | argv_find(argv, argc, "(100-500)", &idx); |
17432 | argv_find(argv, argc, "WORD", &idx); | |
17433 | cl_number_or_name = argv[idx]->arg; | |
17434 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17435 | : COMMUNITY_DENY; | |
17436 | argv_find(argv, argc, "LINE", &idx); | |
17437 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17438 | |
d62a17ae | 17439 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
17440 | direct, style); | |
42f914d4 | 17441 | |
d62a17ae | 17442 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17443 | |
d62a17ae | 17444 | if (ret < 0) { |
17445 | community_list_perror(vty, ret); | |
17446 | return CMD_WARNING_CONFIG_FAILED; | |
17447 | } | |
42f914d4 | 17448 | |
d62a17ae | 17449 | return CMD_SUCCESS; |
718e3744 | 17450 | } |
17451 | ||
7336e101 SP |
17452 | DEFUN (no_extcommunity_list_standard_all, |
17453 | no_bgp_extcommunity_list_standard_all_cmd, | |
17454 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
17455 | NO_STR | |
17456 | BGP_STR | |
17457 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17458 | "Extended Community list number (standard)\n" |
718e3744 | 17459 | "Specify standard extcommunity-list\n" |
5bf15956 | 17460 | "Community list name\n" |
718e3744 | 17461 | "Specify community to reject\n" |
17462 | "Specify community to accept\n" | |
17463 | EXTCOMMUNITY_VAL_STR) | |
17464 | { | |
d62a17ae | 17465 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17466 | int direct = 0; | |
17467 | char *cl_number_or_name = NULL; | |
d4455c89 | 17468 | char *str = NULL; |
d62a17ae | 17469 | int idx = 0; |
d4455c89 | 17470 | |
d4455c89 DA |
17471 | argv_find(argv, argc, "permit", &idx); |
17472 | argv_find(argv, argc, "deny", &idx); | |
17473 | ||
17474 | if (idx) { | |
17475 | direct = argv_find(argv, argc, "permit", &idx) | |
17476 | ? COMMUNITY_PERMIT | |
17477 | : COMMUNITY_DENY; | |
17478 | ||
17479 | idx = 0; | |
17480 | argv_find(argv, argc, "AA:NN", &idx); | |
17481 | str = argv_concat(argv, argc, idx); | |
17482 | } | |
17483 | ||
17484 | idx = 0; | |
d62a17ae | 17485 | argv_find(argv, argc, "(1-99)", &idx); |
17486 | argv_find(argv, argc, "WORD", &idx); | |
17487 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17488 | |
d62a17ae | 17489 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 17490 | direct, style); |
42f914d4 | 17491 | |
d62a17ae | 17492 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17493 | |
d62a17ae | 17494 | if (ret < 0) { |
17495 | community_list_perror(vty, ret); | |
17496 | return CMD_WARNING_CONFIG_FAILED; | |
17497 | } | |
42f914d4 | 17498 | |
d62a17ae | 17499 | return CMD_SUCCESS; |
718e3744 | 17500 | } |
17501 | ||
d4455c89 DA |
17502 | ALIAS(no_extcommunity_list_standard_all, |
17503 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17504 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17505 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17506 | "Extended Community list number (standard)\n" | |
17507 | "Specify standard extcommunity-list\n" | |
17508 | "Community list name\n") | |
17509 | ||
7336e101 SP |
17510 | DEFUN (no_extcommunity_list_expanded_all, |
17511 | no_bgp_extcommunity_list_expanded_all_cmd, | |
17512 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
17513 | NO_STR | |
17514 | BGP_STR | |
17515 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17516 | "Extended Community list number (expanded)\n" |
718e3744 | 17517 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17518 | "Extended Community list name\n" |
718e3744 | 17519 | "Specify community to reject\n" |
17520 | "Specify community to accept\n" | |
17521 | "An ordered list as a regular-expression\n") | |
17522 | { | |
d62a17ae | 17523 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17524 | int direct = 0; | |
17525 | char *cl_number_or_name = NULL; | |
d4455c89 | 17526 | char *str = NULL; |
d62a17ae | 17527 | int idx = 0; |
d4455c89 | 17528 | |
d4455c89 DA |
17529 | argv_find(argv, argc, "permit", &idx); |
17530 | argv_find(argv, argc, "deny", &idx); | |
17531 | ||
17532 | if (idx) { | |
17533 | direct = argv_find(argv, argc, "permit", &idx) | |
17534 | ? COMMUNITY_PERMIT | |
17535 | : COMMUNITY_DENY; | |
17536 | ||
17537 | idx = 0; | |
17538 | argv_find(argv, argc, "LINE", &idx); | |
17539 | str = argv_concat(argv, argc, idx); | |
17540 | } | |
17541 | ||
17542 | idx = 0; | |
d62a17ae | 17543 | argv_find(argv, argc, "(100-500)", &idx); |
17544 | argv_find(argv, argc, "WORD", &idx); | |
17545 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17546 | |
d62a17ae | 17547 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 17548 | direct, style); |
42f914d4 | 17549 | |
d62a17ae | 17550 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17551 | |
d62a17ae | 17552 | if (ret < 0) { |
17553 | community_list_perror(vty, ret); | |
17554 | return CMD_WARNING_CONFIG_FAILED; | |
17555 | } | |
42f914d4 | 17556 | |
d62a17ae | 17557 | return CMD_SUCCESS; |
718e3744 | 17558 | } |
17559 | ||
d4455c89 DA |
17560 | ALIAS(no_extcommunity_list_expanded_all, |
17561 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17562 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17563 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17564 | "Extended Community list number (expanded)\n" | |
17565 | "Specify expanded extcommunity-list\n" | |
17566 | "Extended Community list name\n") | |
17567 | ||
d62a17ae | 17568 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17569 | { |
d62a17ae | 17570 | struct community_entry *entry; |
718e3744 | 17571 | |
d62a17ae | 17572 | for (entry = list->head; entry; entry = entry->next) { |
17573 | if (entry == list->head) { | |
17574 | if (all_digit(list->name)) | |
17575 | vty_out(vty, "Extended community %s list %s\n", | |
17576 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17577 | ? "standard" | |
17578 | : "(expanded) access", | |
17579 | list->name); | |
17580 | else | |
17581 | vty_out(vty, | |
17582 | "Named extended community %s list %s\n", | |
17583 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17584 | ? "standard" | |
17585 | : "expanded", | |
17586 | list->name); | |
17587 | } | |
17588 | if (entry->any) | |
17589 | vty_out(vty, " %s\n", | |
17590 | community_direct_str(entry->direct)); | |
17591 | else | |
17592 | vty_out(vty, " %s %s\n", | |
17593 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17594 | community_list_config_str(entry)); |
d62a17ae | 17595 | } |
718e3744 | 17596 | } |
17597 | ||
7336e101 SP |
17598 | DEFUN (show_extcommunity_list, |
17599 | show_bgp_extcommunity_list_cmd, | |
17600 | "show bgp extcommunity-list", | |
718e3744 | 17601 | SHOW_STR |
7336e101 | 17602 | BGP_STR |
718e3744 | 17603 | "List extended-community list\n") |
17604 | { | |
d62a17ae | 17605 | struct community_list *list; |
17606 | struct community_list_master *cm; | |
718e3744 | 17607 | |
d62a17ae | 17608 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17609 | if (!cm) | |
17610 | return CMD_SUCCESS; | |
718e3744 | 17611 | |
d62a17ae | 17612 | for (list = cm->num.head; list; list = list->next) |
17613 | extcommunity_list_show(vty, list); | |
718e3744 | 17614 | |
d62a17ae | 17615 | for (list = cm->str.head; list; list = list->next) |
17616 | extcommunity_list_show(vty, list); | |
718e3744 | 17617 | |
d62a17ae | 17618 | return CMD_SUCCESS; |
718e3744 | 17619 | } |
17620 | ||
7336e101 SP |
17621 | DEFUN (show_extcommunity_list_arg, |
17622 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17623 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17624 | SHOW_STR |
17625 | BGP_STR | |
718e3744 | 17626 | "List extended-community list\n" |
17627 | "Extcommunity-list number\n" | |
960b69b9 | 17628 | "Extcommunity-list name\n" |
17629 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17630 | { |
d62a17ae | 17631 | int idx_comm_list = 3; |
17632 | struct community_list *list; | |
718e3744 | 17633 | |
e237b0d2 | 17634 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17635 | EXTCOMMUNITY_LIST_MASTER); |
17636 | if (!list) { | |
17637 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17638 | return CMD_WARNING; | |
17639 | } | |
718e3744 | 17640 | |
d62a17ae | 17641 | extcommunity_list_show(vty, list); |
718e3744 | 17642 | |
d62a17ae | 17643 | return CMD_SUCCESS; |
718e3744 | 17644 | } |
6b0655a2 | 17645 | |
718e3744 | 17646 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17647 | static int community_list_config_write(struct vty *vty) |
17648 | { | |
17649 | struct community_list *list; | |
17650 | struct community_entry *entry; | |
17651 | struct community_list_master *cm; | |
17652 | int write = 0; | |
17653 | ||
17654 | /* Community-list. */ | |
17655 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17656 | ||
17657 | for (list = cm->num.head; list; list = list->next) | |
17658 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17659 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 17660 | community_direct_str(entry->direct), |
17661 | community_list_config_str(entry)); | |
17662 | write++; | |
17663 | } | |
17664 | for (list = cm->str.head; list; list = list->next) | |
17665 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17666 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 17667 | entry->style == COMMUNITY_LIST_STANDARD |
17668 | ? "standard" | |
17669 | : "expanded", | |
17670 | list->name, community_direct_str(entry->direct), | |
17671 | community_list_config_str(entry)); | |
17672 | write++; | |
17673 | } | |
17674 | ||
17675 | /* Extcommunity-list. */ | |
17676 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17677 | ||
17678 | for (list = cm->num.head; list; list = list->next) | |
17679 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17680 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 17681 | list->name, community_direct_str(entry->direct), |
17682 | community_list_config_str(entry)); | |
17683 | write++; | |
17684 | } | |
17685 | for (list = cm->str.head; list; list = list->next) | |
17686 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17687 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 17688 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17689 | ? "standard" | |
17690 | : "expanded", | |
17691 | list->name, community_direct_str(entry->direct), | |
17692 | community_list_config_str(entry)); | |
17693 | write++; | |
17694 | } | |
17695 | ||
17696 | ||
17697 | /* lcommunity-list. */ | |
17698 | cm = community_list_master_lookup(bgp_clist, | |
17699 | LARGE_COMMUNITY_LIST_MASTER); | |
17700 | ||
17701 | for (list = cm->num.head; list; list = list->next) | |
17702 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17703 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 17704 | list->name, community_direct_str(entry->direct), |
17705 | community_list_config_str(entry)); | |
17706 | write++; | |
17707 | } | |
17708 | for (list = cm->str.head; list; list = list->next) | |
17709 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17710 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 17711 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17712 | ? "standard" | |
17713 | : "expanded", | |
17714 | list->name, community_direct_str(entry->direct), | |
17715 | community_list_config_str(entry)); | |
17716 | write++; | |
17717 | } | |
17718 | ||
17719 | return write; | |
17720 | } | |
17721 | ||
17722 | static struct cmd_node community_list_node = { | |
17723 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 17724 | }; |
17725 | ||
d62a17ae | 17726 | static void community_list_vty(void) |
17727 | { | |
17728 | install_node(&community_list_node, community_list_config_write); | |
17729 | ||
17730 | /* Community-list. */ | |
7336e101 SP |
17731 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
17732 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
17733 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 17734 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 17735 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 17736 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
17737 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
17738 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 17739 | |
17740 | /* Extcommunity-list. */ | |
7336e101 SP |
17741 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
17742 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
17743 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
17744 | install_element(CONFIG_NODE, |
17745 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 17746 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
17747 | install_element(CONFIG_NODE, |
17748 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
17749 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
17750 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 17751 | |
17752 | /* Large Community List */ | |
7336e101 | 17753 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
17754 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
17755 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 SP |
17756 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
17757 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
17758 | install_element(CONFIG_NODE, | |
17759 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
17760 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
17761 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
17762 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
17763 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
17764 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
17765 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 17766 | } |