]>
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 | |
055679e9 | 108 | #define GR_NO_OPER "The Graceful Restart No Operation was executed as cmd same as previous one" |
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 | ||
055679e9 | 784 | bgp_peer_gr_flags_update(peer); |
785 | ||
dc912615 DS |
786 | if (stype == BGP_CLEAR_SOFT_NONE) |
787 | ret = peer_clear(peer, &nnode); | |
788 | else | |
789 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
790 | stype); | |
791 | } | |
792 | /* if afi specified and safi not, spin thru safis on this afi */ | |
793 | } else if (safi == SAFI_UNSPEC) { | |
794 | safi_t tmp_safi; | |
795 | ||
796 | for (tmp_safi = SAFI_UNICAST; | |
797 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
798 | if (!peer->afc[afi][tmp_safi]) | |
799 | continue; | |
800 | ||
2986cac2 | 801 | bgp_peer_gr_flags_update(peer); |
802 | ||
dc912615 DS |
803 | if (stype == BGP_CLEAR_SOFT_NONE) |
804 | ret = peer_clear(peer, &nnode); | |
805 | else | |
806 | ret = peer_clear_soft(peer, afi, | |
807 | tmp_safi, stype); | |
808 | } | |
809 | /* both afi/safi specified, let the caller know if not defined */ | |
810 | } else { | |
811 | if (!peer->afc[afi][safi]) | |
812 | return 1; | |
813 | ||
814 | if (stype == BGP_CLEAR_SOFT_NONE) | |
815 | ret = peer_clear(peer, &nnode); | |
816 | else | |
817 | ret = peer_clear_soft(peer, afi, safi, stype); | |
818 | } | |
819 | ||
820 | return ret; | |
821 | } | |
822 | ||
7aafcaca | 823 | /* `clear ip bgp' functions. */ |
d62a17ae | 824 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
825 | enum clear_sort sort, enum bgp_clear_type stype, | |
826 | const char *arg) | |
827 | { | |
dc912615 | 828 | int ret = 0; |
3ae8bfa5 | 829 | bool found = false; |
d62a17ae | 830 | struct peer *peer; |
831 | struct listnode *node, *nnode; | |
832 | ||
833 | /* Clear all neighbors. */ | |
834 | /* | |
835 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
836 | * nodes on the BGP instance as that may get freed if it is a |
837 | * doppelganger | |
d62a17ae | 838 | */ |
839 | if (sort == clear_all) { | |
840 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc912615 DS |
841 | ret = bgp_peer_clear(peer, afi, safi, nnode, |
842 | stype); | |
d62a17ae | 843 | |
844 | if (ret < 0) | |
845 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
5cce3f05 | 846 | |
847 | bgp_peer_gr_flags_update(peer); | |
04b6bdc0 | 848 | } |
d62a17ae | 849 | |
850 | /* This is to apply read-only mode on this clear. */ | |
851 | if (stype == BGP_CLEAR_SOFT_NONE) | |
852 | bgp->update_delay_over = 0; | |
853 | ||
854 | return CMD_SUCCESS; | |
7aafcaca DS |
855 | } |
856 | ||
3ae8bfa5 | 857 | /* Clear specified neighbor. */ |
d62a17ae | 858 | if (sort == clear_peer) { |
859 | union sockunion su; | |
d62a17ae | 860 | |
861 | /* Make sockunion for lookup. */ | |
862 | ret = str2sockunion(arg, &su); | |
863 | if (ret < 0) { | |
864 | peer = peer_lookup_by_conf_if(bgp, arg); | |
865 | if (!peer) { | |
866 | peer = peer_lookup_by_hostname(bgp, arg); | |
867 | if (!peer) { | |
868 | vty_out(vty, | |
869 | "Malformed address or name: %s\n", | |
870 | arg); | |
871 | return CMD_WARNING; | |
872 | } | |
873 | } | |
874 | } else { | |
875 | peer = peer_lookup(bgp, &su); | |
876 | if (!peer) { | |
877 | vty_out(vty, | |
878 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
879 | arg); | |
880 | return CMD_WARNING; | |
881 | } | |
882 | } | |
7aafcaca | 883 | |
dc912615 DS |
884 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
885 | ||
886 | /* if afi/safi not defined for this peer, let caller know */ | |
887 | if (ret == 1) | |
3ae8bfa5 | 888 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 889 | |
d62a17ae | 890 | if (ret < 0) |
891 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 892 | |
d62a17ae | 893 | return CMD_SUCCESS; |
7aafcaca | 894 | } |
7aafcaca | 895 | |
3ae8bfa5 | 896 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 897 | if (sort == clear_group) { |
898 | struct peer_group *group; | |
7aafcaca | 899 | |
d62a17ae | 900 | group = peer_group_lookup(bgp, arg); |
901 | if (!group) { | |
902 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
903 | return CMD_WARNING; | |
904 | } | |
905 | ||
906 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
dc912615 | 907 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 908 | |
d62a17ae | 909 | if (ret < 0) |
910 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
911 | else |
912 | found = true; | |
d62a17ae | 913 | } |
3ae8bfa5 PM |
914 | |
915 | if (!found) | |
916 | vty_out(vty, | |
917 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 918 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 919 | |
d62a17ae | 920 | return CMD_SUCCESS; |
7aafcaca | 921 | } |
7aafcaca | 922 | |
3ae8bfa5 | 923 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 924 | if (sort == clear_external) { |
925 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
926 | if (peer->sort == BGP_PEER_IBGP) | |
927 | continue; | |
7aafcaca | 928 | |
dc912615 | 929 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
7aafcaca | 930 | |
d62a17ae | 931 | if (ret < 0) |
932 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
933 | else |
934 | found = true; | |
d62a17ae | 935 | } |
3ae8bfa5 PM |
936 | |
937 | if (!found) | |
938 | vty_out(vty, | |
939 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 940 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 941 | |
d62a17ae | 942 | return CMD_SUCCESS; |
943 | } | |
944 | ||
3ae8bfa5 | 945 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 946 | if (sort == clear_as) { |
3ae8bfa5 | 947 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 948 | |
949 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
950 | if (peer->as != as) | |
951 | continue; | |
952 | ||
dc912615 | 953 | ret = bgp_peer_clear(peer, afi, safi, nnode, stype); |
d62a17ae | 954 | |
955 | if (ret < 0) | |
956 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
957 | else |
958 | found = true; | |
d62a17ae | 959 | } |
3ae8bfa5 PM |
960 | |
961 | if (!found) | |
d62a17ae | 962 | vty_out(vty, |
3ae8bfa5 | 963 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 964 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 965 | |
d62a17ae | 966 | return CMD_SUCCESS; |
967 | } | |
968 | ||
969 | return CMD_SUCCESS; | |
970 | } | |
971 | ||
972 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
973 | safi_t safi, enum clear_sort sort, | |
974 | enum bgp_clear_type stype, const char *arg) | |
975 | { | |
976 | struct bgp *bgp; | |
977 | ||
978 | /* BGP structure lookup. */ | |
979 | if (name) { | |
980 | bgp = bgp_lookup_by_name(name); | |
981 | if (bgp == NULL) { | |
982 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
983 | return CMD_WARNING; | |
984 | } | |
985 | } else { | |
986 | bgp = bgp_get_default(); | |
987 | if (bgp == NULL) { | |
988 | vty_out(vty, "No BGP process is configured\n"); | |
989 | return CMD_WARNING; | |
990 | } | |
991 | } | |
992 | ||
993 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
994 | } |
995 | ||
996 | /* clear soft inbound */ | |
d62a17ae | 997 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 998 | { |
99b3ebd3 NS |
999 | afi_t afi; |
1000 | safi_t safi; | |
1001 | ||
1002 | FOREACH_AFI_SAFI (afi, safi) | |
1003 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1004 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1005 | } |
1006 | ||
1007 | /* clear soft outbound */ | |
d62a17ae | 1008 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1009 | { |
99b3ebd3 NS |
1010 | afi_t afi; |
1011 | safi_t safi; | |
1012 | ||
1013 | FOREACH_AFI_SAFI (afi, safi) | |
1014 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1015 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1016 | } |
1017 | ||
1018 | ||
f787d7a0 | 1019 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1020 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1021 | #endif |
1022 | ||
8029b216 AK |
1023 | DEFUN_HIDDEN (bgp_local_mac, |
1024 | bgp_local_mac_cmd, | |
093e3f23 | 1025 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1026 | BGP_STR |
1027 | "Local MAC config\n" | |
1028 | "VxLAN Network Identifier\n" | |
1029 | "VNI number\n" | |
1030 | "local mac\n" | |
1031 | "mac address\n" | |
1032 | "mac-mobility sequence\n" | |
1033 | "seq number\n") | |
1034 | { | |
1035 | int rv; | |
1036 | vni_t vni; | |
1037 | struct ethaddr mac; | |
1038 | struct ipaddr ip; | |
1039 | uint32_t seq; | |
1040 | struct bgp *bgp; | |
1041 | ||
1042 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1043 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1044 | vty_out(vty, "%% Malformed MAC address\n"); | |
1045 | return CMD_WARNING; | |
1046 | } | |
1047 | memset(&ip, 0, sizeof(ip)); | |
1048 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1049 | ||
1050 | bgp = bgp_get_default(); | |
1051 | if (!bgp) { | |
1052 | vty_out(vty, "Default BGP instance is not there\n"); | |
1053 | return CMD_WARNING; | |
1054 | } | |
1055 | ||
1056 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1057 | if (rv < 0) { | |
1058 | vty_out(vty, "Internal error\n"); | |
1059 | return CMD_WARNING; | |
1060 | } | |
1061 | ||
1062 | return CMD_SUCCESS; | |
1063 | } | |
1064 | ||
1065 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1066 | no_bgp_local_mac_cmd, | |
093e3f23 | 1067 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1068 | NO_STR |
1069 | BGP_STR | |
1070 | "Local MAC config\n" | |
1071 | "VxLAN Network Identifier\n" | |
1072 | "VNI number\n" | |
1073 | "local mac\n" | |
1074 | "mac address\n") | |
1075 | { | |
1076 | int rv; | |
1077 | vni_t vni; | |
1078 | struct ethaddr mac; | |
1079 | struct ipaddr ip; | |
1080 | struct bgp *bgp; | |
1081 | ||
1082 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1083 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1084 | vty_out(vty, "%% Malformed MAC address\n"); | |
1085 | return CMD_WARNING; | |
1086 | } | |
1087 | memset(&ip, 0, sizeof(ip)); | |
1088 | ||
1089 | bgp = bgp_get_default(); | |
1090 | if (!bgp) { | |
1091 | vty_out(vty, "Default BGP instance is not there\n"); | |
1092 | return CMD_WARNING; | |
1093 | } | |
1094 | ||
ec0ab544 | 1095 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1096 | if (rv < 0) { |
1097 | vty_out(vty, "Internal error\n"); | |
1098 | return CMD_WARNING; | |
1099 | } | |
1100 | ||
1101 | return CMD_SUCCESS; | |
1102 | } | |
1103 | ||
718e3744 | 1104 | DEFUN (no_synchronization, |
1105 | no_synchronization_cmd, | |
1106 | "no synchronization", | |
1107 | NO_STR | |
1108 | "Perform IGP synchronization\n") | |
1109 | { | |
d62a17ae | 1110 | return CMD_SUCCESS; |
718e3744 | 1111 | } |
1112 | ||
1113 | DEFUN (no_auto_summary, | |
1114 | no_auto_summary_cmd, | |
1115 | "no auto-summary", | |
1116 | NO_STR | |
1117 | "Enable automatic network number summarization\n") | |
1118 | { | |
d62a17ae | 1119 | return CMD_SUCCESS; |
718e3744 | 1120 | } |
3d515fd9 | 1121 | |
718e3744 | 1122 | /* "router bgp" commands. */ |
505e5056 | 1123 | DEFUN_NOSH (router_bgp, |
f412b39a | 1124 | router_bgp_cmd, |
2ed9fe4a | 1125 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1126 | ROUTER_STR |
1127 | BGP_STR | |
31500417 DW |
1128 | AS_STR |
1129 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1130 | { |
d62a17ae | 1131 | int idx_asn = 2; |
1132 | int idx_view_vrf = 3; | |
1133 | int idx_vrf = 4; | |
ecec9495 | 1134 | int is_new_bgp = 0; |
d62a17ae | 1135 | int ret; |
1136 | as_t as; | |
1137 | struct bgp *bgp; | |
1138 | const char *name = NULL; | |
1139 | enum bgp_instance_type inst_type; | |
1140 | ||
1141 | // "router bgp" without an ASN | |
1142 | if (argc == 2) { | |
1143 | // Pending: Make VRF option available for ASN less config | |
1144 | bgp = bgp_get_default(); | |
1145 | ||
1146 | if (bgp == NULL) { | |
1147 | vty_out(vty, "%% No BGP process is configured\n"); | |
1148 | return CMD_WARNING_CONFIG_FAILED; | |
1149 | } | |
1150 | ||
1151 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1152 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1153 | return CMD_WARNING_CONFIG_FAILED; |
1154 | } | |
1155 | } | |
1156 | ||
1157 | // "router bgp X" | |
1158 | else { | |
1159 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1160 | ||
1161 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1162 | if (argc > 3) { | |
1163 | name = argv[idx_vrf]->arg; | |
1164 | ||
9a8bdf1c PG |
1165 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1166 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1167 | name = NULL; | |
1168 | else | |
1169 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1170 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1171 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1172 | } | |
1173 | ||
ecec9495 AD |
1174 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1175 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1176 | ||
5d5393b9 | 1177 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1178 | switch (ret) { |
d62a17ae | 1179 | case BGP_ERR_AS_MISMATCH: |
1180 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1181 | return CMD_WARNING_CONFIG_FAILED; | |
1182 | case BGP_ERR_INSTANCE_MISMATCH: | |
1183 | vty_out(vty, | |
1184 | "BGP instance name and AS number mismatch\n"); | |
1185 | vty_out(vty, | |
1186 | "BGP instance is already running; AS is %u\n", | |
1187 | as); | |
1188 | return CMD_WARNING_CONFIG_FAILED; | |
1189 | } | |
1190 | ||
3bd70bf8 PZ |
1191 | /* |
1192 | * If we just instantiated the default instance, complete | |
1193 | * any pending VRF-VPN leaking that was configured via | |
1194 | * earlier "router bgp X vrf FOO" blocks. | |
1195 | */ | |
ecec9495 | 1196 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1197 | vpn_leak_postchange_all(); |
1198 | ||
48381346 CS |
1199 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1200 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1201 | /* Pending: handle when user tries to change a view to vrf n vv. |
1202 | */ | |
1203 | } | |
1204 | ||
0b5131c9 MK |
1205 | /* unset the auto created flag as the user config is now present */ |
1206 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1207 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1208 | ||
1209 | return CMD_SUCCESS; | |
718e3744 | 1210 | } |
1211 | ||
718e3744 | 1212 | /* "no router bgp" commands. */ |
1213 | DEFUN (no_router_bgp, | |
1214 | no_router_bgp_cmd, | |
2ed9fe4a | 1215 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1216 | NO_STR |
1217 | ROUTER_STR | |
1218 | BGP_STR | |
31500417 DW |
1219 | AS_STR |
1220 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1221 | { |
d62a17ae | 1222 | int idx_asn = 3; |
1223 | int idx_vrf = 5; | |
1224 | as_t as; | |
1225 | struct bgp *bgp; | |
1226 | const char *name = NULL; | |
718e3744 | 1227 | |
d62a17ae | 1228 | // "no router bgp" without an ASN |
1229 | if (argc == 3) { | |
1230 | // Pending: Make VRF option available for ASN less config | |
1231 | bgp = bgp_get_default(); | |
718e3744 | 1232 | |
d62a17ae | 1233 | if (bgp == NULL) { |
1234 | vty_out(vty, "%% No BGP process is configured\n"); | |
1235 | return CMD_WARNING_CONFIG_FAILED; | |
1236 | } | |
7fb21a9f | 1237 | |
d62a17ae | 1238 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1239 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1240 | return CMD_WARNING_CONFIG_FAILED; |
1241 | } | |
0b5131c9 MK |
1242 | |
1243 | if (bgp->l3vni) { | |
1244 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1245 | bgp->l3vni); | |
1246 | return CMD_WARNING_CONFIG_FAILED; | |
1247 | } | |
d62a17ae | 1248 | } else { |
1249 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1250 | |
d62a17ae | 1251 | if (argc > 4) |
1252 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1253 | |
d62a17ae | 1254 | /* Lookup bgp structure. */ |
1255 | bgp = bgp_lookup(as, name); | |
1256 | if (!bgp) { | |
1257 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1258 | return CMD_WARNING_CONFIG_FAILED; | |
1259 | } | |
0b5131c9 MK |
1260 | |
1261 | if (bgp->l3vni) { | |
dd5868c2 | 1262 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1263 | bgp->l3vni); |
1264 | return CMD_WARNING_CONFIG_FAILED; | |
1265 | } | |
dd5868c2 DS |
1266 | |
1267 | /* Cannot delete default instance if vrf instances exist */ | |
1268 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1269 | struct listnode *node; | |
1270 | struct bgp *tmp_bgp; | |
1271 | ||
1272 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1273 | if (tmp_bgp->inst_type | |
1274 | == BGP_INSTANCE_TYPE_VRF) { | |
1275 | vty_out(vty, | |
1276 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1277 | return CMD_WARNING_CONFIG_FAILED; | |
1278 | } | |
1279 | } | |
1280 | } | |
d62a17ae | 1281 | } |
718e3744 | 1282 | |
9ecf931b CS |
1283 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1284 | return CMD_WARNING_CONFIG_FAILED; | |
1285 | ||
d62a17ae | 1286 | bgp_delete(bgp); |
718e3744 | 1287 | |
d62a17ae | 1288 | return CMD_SUCCESS; |
718e3744 | 1289 | } |
1290 | ||
6b0655a2 | 1291 | |
718e3744 | 1292 | /* BGP router-id. */ |
1293 | ||
f787d7a0 | 1294 | DEFPY (bgp_router_id, |
718e3744 | 1295 | bgp_router_id_cmd, |
1296 | "bgp router-id A.B.C.D", | |
1297 | BGP_STR | |
1298 | "Override configured router identifier\n" | |
1299 | "Manually configured router identifier\n") | |
1300 | { | |
d62a17ae | 1301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1302 | bgp_router_id_static_set(bgp, router_id); | |
1303 | return CMD_SUCCESS; | |
718e3744 | 1304 | } |
1305 | ||
f787d7a0 | 1306 | DEFPY (no_bgp_router_id, |
718e3744 | 1307 | no_bgp_router_id_cmd, |
31500417 | 1308 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1309 | NO_STR |
1310 | BGP_STR | |
31500417 DW |
1311 | "Override configured router identifier\n" |
1312 | "Manually configured router identifier\n") | |
718e3744 | 1313 | { |
d62a17ae | 1314 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1315 | |
d62a17ae | 1316 | if (router_id_str) { |
1317 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1318 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1319 | return CMD_WARNING_CONFIG_FAILED; | |
1320 | } | |
e018c7cc | 1321 | } |
718e3744 | 1322 | |
d62a17ae | 1323 | router_id.s_addr = 0; |
1324 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1325 | |
d62a17ae | 1326 | return CMD_SUCCESS; |
718e3744 | 1327 | } |
1328 | ||
6b0655a2 | 1329 | |
718e3744 | 1330 | /* BGP Cluster ID. */ |
718e3744 | 1331 | DEFUN (bgp_cluster_id, |
1332 | bgp_cluster_id_cmd, | |
838758ac | 1333 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1334 | BGP_STR |
1335 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1336 | "Route-Reflector Cluster-id in IP address format\n" |
1337 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1338 | { |
d62a17ae | 1339 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1340 | int idx_ipv4 = 2; | |
1341 | int ret; | |
1342 | struct in_addr cluster; | |
718e3744 | 1343 | |
d62a17ae | 1344 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1345 | if (!ret) { | |
1346 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1347 | return CMD_WARNING_CONFIG_FAILED; | |
1348 | } | |
718e3744 | 1349 | |
d62a17ae | 1350 | bgp_cluster_id_set(bgp, &cluster); |
1351 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1352 | |
d62a17ae | 1353 | return CMD_SUCCESS; |
718e3744 | 1354 | } |
1355 | ||
718e3744 | 1356 | DEFUN (no_bgp_cluster_id, |
1357 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1358 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1359 | NO_STR |
1360 | BGP_STR | |
838758ac DW |
1361 | "Configure Route-Reflector Cluster-id\n" |
1362 | "Route-Reflector Cluster-id in IP address format\n" | |
1363 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1364 | { |
d62a17ae | 1365 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1366 | bgp_cluster_id_unset(bgp); | |
1367 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1368 | |
d62a17ae | 1369 | return CMD_SUCCESS; |
718e3744 | 1370 | } |
1371 | ||
718e3744 | 1372 | DEFUN (bgp_confederation_identifier, |
1373 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1374 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1375 | "BGP specific commands\n" |
1376 | "AS confederation parameters\n" | |
1377 | "AS number\n" | |
1378 | "Set routing domain confederation AS\n") | |
1379 | { | |
d62a17ae | 1380 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1381 | int idx_number = 3; | |
1382 | as_t as; | |
718e3744 | 1383 | |
d62a17ae | 1384 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1385 | |
d62a17ae | 1386 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1387 | |
d62a17ae | 1388 | return CMD_SUCCESS; |
718e3744 | 1389 | } |
1390 | ||
1391 | DEFUN (no_bgp_confederation_identifier, | |
1392 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1393 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1394 | NO_STR |
1395 | "BGP specific commands\n" | |
1396 | "AS confederation parameters\n" | |
3a2d747c QY |
1397 | "AS number\n" |
1398 | "Set routing domain confederation AS\n") | |
718e3744 | 1399 | { |
d62a17ae | 1400 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1401 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1402 | |
d62a17ae | 1403 | return CMD_SUCCESS; |
718e3744 | 1404 | } |
1405 | ||
718e3744 | 1406 | DEFUN (bgp_confederation_peers, |
1407 | bgp_confederation_peers_cmd, | |
12dcf78e | 1408 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1409 | "BGP specific commands\n" |
1410 | "AS confederation parameters\n" | |
1411 | "Peer ASs in BGP confederation\n" | |
1412 | AS_STR) | |
1413 | { | |
d62a17ae | 1414 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1415 | int idx_asn = 3; | |
1416 | as_t as; | |
1417 | int i; | |
718e3744 | 1418 | |
d62a17ae | 1419 | for (i = idx_asn; i < argc; i++) { |
1420 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1421 | |
d62a17ae | 1422 | if (bgp->as == as) { |
1423 | vty_out(vty, | |
1424 | "%% Local member-AS not allowed in confed peer list\n"); | |
1425 | continue; | |
1426 | } | |
718e3744 | 1427 | |
d62a17ae | 1428 | bgp_confederation_peers_add(bgp, as); |
1429 | } | |
1430 | return CMD_SUCCESS; | |
718e3744 | 1431 | } |
1432 | ||
1433 | DEFUN (no_bgp_confederation_peers, | |
1434 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1435 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1436 | NO_STR |
1437 | "BGP specific commands\n" | |
1438 | "AS confederation parameters\n" | |
1439 | "Peer ASs in BGP confederation\n" | |
1440 | AS_STR) | |
1441 | { | |
d62a17ae | 1442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1443 | int idx_asn = 4; | |
1444 | as_t as; | |
1445 | int i; | |
718e3744 | 1446 | |
d62a17ae | 1447 | for (i = idx_asn; i < argc; i++) { |
1448 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1449 | |
d62a17ae | 1450 | bgp_confederation_peers_remove(bgp, as); |
1451 | } | |
1452 | return CMD_SUCCESS; | |
718e3744 | 1453 | } |
6b0655a2 | 1454 | |
5e242b0d DS |
1455 | /** |
1456 | * Central routine for maximum-paths configuration. | |
1457 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1458 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1459 | */ | |
d62a17ae | 1460 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1461 | const char *mpaths, uint16_t options, |
d62a17ae | 1462 | int set) |
1463 | { | |
1464 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1465 | uint16_t maxpaths = 0; |
d62a17ae | 1466 | int ret; |
1467 | afi_t afi; | |
1468 | safi_t safi; | |
1469 | ||
1470 | afi = bgp_node_afi(vty); | |
1471 | safi = bgp_node_safi(vty); | |
1472 | ||
1473 | if (set) { | |
1474 | maxpaths = strtol(mpaths, NULL, 10); | |
1475 | if (maxpaths > multipath_num) { | |
1476 | vty_out(vty, | |
1477 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1478 | maxpaths, multipath_num); | |
1479 | return CMD_WARNING_CONFIG_FAILED; | |
1480 | } | |
1481 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1482 | options); | |
1483 | } else | |
1484 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1485 | ||
1486 | if (ret < 0) { | |
1487 | vty_out(vty, | |
1488 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1489 | (set == 1) ? "" : "un", | |
1490 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1491 | maxpaths, afi, safi); | |
1492 | return CMD_WARNING_CONFIG_FAILED; | |
1493 | } | |
1494 | ||
1495 | bgp_recalculate_all_bestpaths(bgp); | |
1496 | ||
1497 | return CMD_SUCCESS; | |
165b5fff JB |
1498 | } |
1499 | ||
abc920f8 DS |
1500 | DEFUN (bgp_maxmed_admin, |
1501 | bgp_maxmed_admin_cmd, | |
1502 | "bgp max-med administrative ", | |
1503 | BGP_STR | |
1504 | "Advertise routes with max-med\n" | |
1505 | "Administratively applied, for an indefinite period\n") | |
1506 | { | |
d62a17ae | 1507 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1508 | |
d62a17ae | 1509 | bgp->v_maxmed_admin = 1; |
1510 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1511 | |
d62a17ae | 1512 | bgp_maxmed_update(bgp); |
abc920f8 | 1513 | |
d62a17ae | 1514 | return CMD_SUCCESS; |
abc920f8 DS |
1515 | } |
1516 | ||
1517 | DEFUN (bgp_maxmed_admin_medv, | |
1518 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1519 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1520 | BGP_STR |
1521 | "Advertise routes with max-med\n" | |
1522 | "Administratively applied, for an indefinite period\n" | |
1523 | "Max MED value to be used\n") | |
1524 | { | |
d62a17ae | 1525 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1526 | int idx_number = 3; | |
abc920f8 | 1527 | |
d62a17ae | 1528 | bgp->v_maxmed_admin = 1; |
1529 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1530 | |
d62a17ae | 1531 | bgp_maxmed_update(bgp); |
abc920f8 | 1532 | |
d62a17ae | 1533 | return CMD_SUCCESS; |
abc920f8 DS |
1534 | } |
1535 | ||
1536 | DEFUN (no_bgp_maxmed_admin, | |
1537 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1538 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1539 | NO_STR |
1540 | BGP_STR | |
1541 | "Advertise routes with max-med\n" | |
838758ac DW |
1542 | "Administratively applied, for an indefinite period\n" |
1543 | "Max MED value to be used\n") | |
abc920f8 | 1544 | { |
d62a17ae | 1545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1546 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1547 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1548 | bgp_maxmed_update(bgp); | |
abc920f8 | 1549 | |
d62a17ae | 1550 | return CMD_SUCCESS; |
abc920f8 DS |
1551 | } |
1552 | ||
abc920f8 DS |
1553 | DEFUN (bgp_maxmed_onstartup, |
1554 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1555 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1556 | BGP_STR |
1557 | "Advertise routes with max-med\n" | |
1558 | "Effective on a startup\n" | |
1559 | "Time (seconds) period for max-med\n" | |
1560 | "Max MED value to be used\n") | |
1561 | { | |
d62a17ae | 1562 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1563 | int idx = 0; | |
4668a151 | 1564 | |
d62a17ae | 1565 | argv_find(argv, argc, "(5-86400)", &idx); |
1566 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1567 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1568 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1569 | else | |
1570 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1571 | |
d62a17ae | 1572 | bgp_maxmed_update(bgp); |
abc920f8 | 1573 | |
d62a17ae | 1574 | return CMD_SUCCESS; |
abc920f8 DS |
1575 | } |
1576 | ||
1577 | DEFUN (no_bgp_maxmed_onstartup, | |
1578 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1579 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1580 | NO_STR |
1581 | BGP_STR | |
1582 | "Advertise routes with max-med\n" | |
838758ac DW |
1583 | "Effective on a startup\n" |
1584 | "Time (seconds) period for max-med\n" | |
1585 | "Max MED value to be used\n") | |
abc920f8 | 1586 | { |
d62a17ae | 1587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1588 | |
d62a17ae | 1589 | /* Cancel max-med onstartup if its on */ |
1590 | if (bgp->t_maxmed_onstartup) { | |
1591 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1592 | bgp->maxmed_onstartup_over = 1; | |
1593 | } | |
abc920f8 | 1594 | |
d62a17ae | 1595 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1596 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1597 | |
d62a17ae | 1598 | bgp_maxmed_update(bgp); |
abc920f8 | 1599 | |
d62a17ae | 1600 | return CMD_SUCCESS; |
abc920f8 DS |
1601 | } |
1602 | ||
d62a17ae | 1603 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1604 | const char *wait) | |
f188f2c4 | 1605 | { |
d62a17ae | 1606 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1607 | uint16_t update_delay; |
1608 | uint16_t establish_wait; | |
f188f2c4 | 1609 | |
d62a17ae | 1610 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1611 | |
d62a17ae | 1612 | if (!wait) /* update-delay <delay> */ |
1613 | { | |
1614 | bgp->v_update_delay = update_delay; | |
1615 | bgp->v_establish_wait = bgp->v_update_delay; | |
1616 | return CMD_SUCCESS; | |
1617 | } | |
f188f2c4 | 1618 | |
d62a17ae | 1619 | /* update-delay <delay> <establish-wait> */ |
1620 | establish_wait = atoi(wait); | |
1621 | if (update_delay < establish_wait) { | |
1622 | vty_out(vty, | |
1623 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1624 | return CMD_WARNING_CONFIG_FAILED; | |
1625 | } | |
f188f2c4 | 1626 | |
d62a17ae | 1627 | bgp->v_update_delay = update_delay; |
1628 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1629 | |
d62a17ae | 1630 | return CMD_SUCCESS; |
f188f2c4 DS |
1631 | } |
1632 | ||
d62a17ae | 1633 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1634 | { |
d62a17ae | 1635 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1636 | |
d62a17ae | 1637 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1638 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1639 | |
d62a17ae | 1640 | return CMD_SUCCESS; |
f188f2c4 DS |
1641 | } |
1642 | ||
2b791107 | 1643 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1644 | { |
d62a17ae | 1645 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1646 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1647 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1648 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1649 | vty_out(vty, "\n"); | |
1650 | } | |
f188f2c4 DS |
1651 | } |
1652 | ||
1653 | ||
1654 | /* Update-delay configuration */ | |
1655 | DEFUN (bgp_update_delay, | |
1656 | bgp_update_delay_cmd, | |
6147e2c6 | 1657 | "update-delay (0-3600)", |
f188f2c4 DS |
1658 | "Force initial delay for best-path and updates\n" |
1659 | "Seconds\n") | |
1660 | { | |
d62a17ae | 1661 | int idx_number = 1; |
1662 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1663 | } |
1664 | ||
1665 | DEFUN (bgp_update_delay_establish_wait, | |
1666 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1667 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1668 | "Force initial delay for best-path and updates\n" |
1669 | "Seconds\n" | |
f188f2c4 DS |
1670 | "Seconds\n") |
1671 | { | |
d62a17ae | 1672 | int idx_number = 1; |
1673 | int idx_number_2 = 2; | |
1674 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1675 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1676 | } |
1677 | ||
1678 | /* Update-delay deconfiguration */ | |
1679 | DEFUN (no_bgp_update_delay, | |
1680 | no_bgp_update_delay_cmd, | |
838758ac DW |
1681 | "no update-delay [(0-3600) [(1-3600)]]", |
1682 | NO_STR | |
f188f2c4 | 1683 | "Force initial delay for best-path and updates\n" |
838758ac | 1684 | "Seconds\n" |
7111c1a0 | 1685 | "Seconds\n") |
f188f2c4 | 1686 | { |
d62a17ae | 1687 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1688 | } |
1689 | ||
5e242b0d | 1690 | |
8fa7732f QY |
1691 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1692 | bool set) | |
cb1faec9 | 1693 | { |
d62a17ae | 1694 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1695 | |
8fa7732f QY |
1696 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1697 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1698 | |
1699 | return CMD_SUCCESS; | |
1700 | } | |
1701 | ||
8fa7732f QY |
1702 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1703 | bool set) | |
555e09d4 QY |
1704 | { |
1705 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1706 | ||
8fa7732f QY |
1707 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1708 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1709 | |
d62a17ae | 1710 | return CMD_SUCCESS; |
cb1faec9 DS |
1711 | } |
1712 | ||
2b791107 | 1713 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1714 | { |
555e09d4 QY |
1715 | uint32_t quanta = |
1716 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1717 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1718 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1719 | } |
1720 | ||
555e09d4 QY |
1721 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1722 | { | |
1723 | uint32_t quanta = | |
1724 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1725 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1726 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1727 | } |
cb1faec9 | 1728 | |
8fa7732f QY |
1729 | /* Packet quanta configuration |
1730 | * | |
1731 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1732 | * thread. When changing these limits be careful to prevent stack overflow. | |
1733 | * | |
1734 | * Furthermore, the maximums used here should correspond to | |
1735 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1736 | */ | |
1737 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1738 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1739 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1740 | NO_STR |
8fa7732f | 1741 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1742 | "Number of packets\n") |
1743 | { | |
8fa7732f | 1744 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1745 | } |
1746 | ||
8fa7732f | 1747 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1748 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1749 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1750 | NO_STR |
1751 | "How many packets to read from peer socket per I/O cycle\n" | |
1752 | "Number of packets\n") | |
1753 | { | |
8fa7732f | 1754 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1755 | } |
1756 | ||
2b791107 | 1757 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1758 | { |
37a333fe | 1759 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1760 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1761 | } |
1762 | ||
1763 | ||
1764 | DEFUN (bgp_coalesce_time, | |
1765 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1766 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1767 | "Subgroup coalesce timer\n" |
1768 | "Subgroup coalesce timer value (in ms)\n") | |
1769 | { | |
d62a17ae | 1770 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1771 | |
d62a17ae | 1772 | int idx = 0; |
1773 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1774 | bgp->heuristic_coalesce = false; |
d62a17ae | 1775 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1776 | return CMD_SUCCESS; | |
3f9c7369 DS |
1777 | } |
1778 | ||
1779 | DEFUN (no_bgp_coalesce_time, | |
1780 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1781 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1782 | NO_STR |
3f9c7369 DS |
1783 | "Subgroup coalesce timer\n" |
1784 | "Subgroup coalesce timer value (in ms)\n") | |
1785 | { | |
d62a17ae | 1786 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1787 | |
37a333fe | 1788 | bgp->heuristic_coalesce = true; |
d62a17ae | 1789 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1790 | return CMD_SUCCESS; | |
3f9c7369 DS |
1791 | } |
1792 | ||
5e242b0d DS |
1793 | /* Maximum-paths configuration */ |
1794 | DEFUN (bgp_maxpaths, | |
1795 | bgp_maxpaths_cmd, | |
6319fd63 | 1796 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1797 | "Forward packets over multiple paths\n" |
1798 | "Number of paths\n") | |
1799 | { | |
d62a17ae | 1800 | int idx_number = 1; |
1801 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1802 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1803 | } |
1804 | ||
d62a17ae | 1805 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1806 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1807 | "Forward packets over multiple paths\n" | |
1808 | "Number of paths\n") | |
596c17ba | 1809 | |
165b5fff JB |
1810 | DEFUN (bgp_maxpaths_ibgp, |
1811 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1812 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1813 | "Forward packets over multiple paths\n" |
1814 | "iBGP-multipath\n" | |
1815 | "Number of paths\n") | |
1816 | { | |
d62a17ae | 1817 | int idx_number = 2; |
1818 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1819 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1820 | } |
165b5fff | 1821 | |
d62a17ae | 1822 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1823 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1824 | "Forward packets over multiple paths\n" | |
1825 | "iBGP-multipath\n" | |
1826 | "Number of paths\n") | |
596c17ba | 1827 | |
5e242b0d DS |
1828 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1829 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1830 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1831 | "Forward packets over multiple paths\n" |
1832 | "iBGP-multipath\n" | |
1833 | "Number of paths\n" | |
1834 | "Match the cluster length\n") | |
1835 | { | |
d62a17ae | 1836 | int idx_number = 2; |
1837 | return bgp_maxpaths_config_vty( | |
1838 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1839 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1840 | } |
1841 | ||
d62a17ae | 1842 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1843 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1844 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1845 | "Forward packets over multiple paths\n" | |
1846 | "iBGP-multipath\n" | |
1847 | "Number of paths\n" | |
1848 | "Match the cluster length\n") | |
596c17ba | 1849 | |
165b5fff JB |
1850 | DEFUN (no_bgp_maxpaths, |
1851 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1852 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1853 | NO_STR |
1854 | "Forward packets over multiple paths\n" | |
1855 | "Number of paths\n") | |
1856 | { | |
d62a17ae | 1857 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1858 | } |
1859 | ||
d62a17ae | 1860 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1861 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1862 | "Forward packets over multiple paths\n" |
1863 | "Number of paths\n") | |
596c17ba | 1864 | |
165b5fff JB |
1865 | DEFUN (no_bgp_maxpaths_ibgp, |
1866 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1867 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1868 | NO_STR |
1869 | "Forward packets over multiple paths\n" | |
1870 | "iBGP-multipath\n" | |
838758ac DW |
1871 | "Number of paths\n" |
1872 | "Match the cluster length\n") | |
165b5fff | 1873 | { |
d62a17ae | 1874 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1875 | } |
1876 | ||
d62a17ae | 1877 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1878 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1879 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1880 | NO_STR | |
1881 | "Forward packets over multiple paths\n" | |
1882 | "iBGP-multipath\n" | |
1883 | "Number of paths\n" | |
1884 | "Match the cluster length\n") | |
596c17ba | 1885 | |
dd65f45e DL |
1886 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1887 | afi_t afi, safi_t safi) | |
165b5fff | 1888 | { |
d62a17ae | 1889 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1890 | vty_out(vty, " maximum-paths %d\n", |
1891 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1892 | } | |
165b5fff | 1893 | |
d62a17ae | 1894 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1895 | vty_out(vty, " maximum-paths ibgp %d", |
1896 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1897 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1898 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1899 | vty_out(vty, " equal-cluster-length"); | |
1900 | vty_out(vty, "\n"); | |
1901 | } | |
165b5fff | 1902 | } |
6b0655a2 | 1903 | |
718e3744 | 1904 | /* BGP timers. */ |
1905 | ||
1906 | DEFUN (bgp_timers, | |
1907 | bgp_timers_cmd, | |
6147e2c6 | 1908 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1909 | "Adjust routing timers\n" |
1910 | "BGP timers\n" | |
1911 | "Keepalive interval\n" | |
1912 | "Holdtime\n") | |
1913 | { | |
d62a17ae | 1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1915 | int idx_number = 2; | |
1916 | int idx_number_2 = 3; | |
1917 | unsigned long keepalive = 0; | |
1918 | unsigned long holdtime = 0; | |
718e3744 | 1919 | |
d62a17ae | 1920 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1921 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1922 | |
d62a17ae | 1923 | /* Holdtime value check. */ |
1924 | if (holdtime < 3 && holdtime != 0) { | |
1925 | vty_out(vty, | |
1926 | "%% hold time value must be either 0 or greater than 3\n"); | |
1927 | return CMD_WARNING_CONFIG_FAILED; | |
1928 | } | |
718e3744 | 1929 | |
5d5393b9 | 1930 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1931 | |
d62a17ae | 1932 | return CMD_SUCCESS; |
718e3744 | 1933 | } |
1934 | ||
1935 | DEFUN (no_bgp_timers, | |
1936 | no_bgp_timers_cmd, | |
838758ac | 1937 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1938 | NO_STR |
1939 | "Adjust routing timers\n" | |
838758ac DW |
1940 | "BGP timers\n" |
1941 | "Keepalive interval\n" | |
1942 | "Holdtime\n") | |
718e3744 | 1943 | { |
d62a17ae | 1944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1945 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1946 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1947 | |
d62a17ae | 1948 | return CMD_SUCCESS; |
718e3744 | 1949 | } |
1950 | ||
6b0655a2 | 1951 | |
718e3744 | 1952 | DEFUN (bgp_client_to_client_reflection, |
1953 | bgp_client_to_client_reflection_cmd, | |
1954 | "bgp client-to-client reflection", | |
1955 | "BGP specific commands\n" | |
1956 | "Configure client to client route reflection\n" | |
1957 | "reflection of routes allowed\n") | |
1958 | { | |
d62a17ae | 1959 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1960 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1961 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1962 | |
d62a17ae | 1963 | return CMD_SUCCESS; |
718e3744 | 1964 | } |
1965 | ||
1966 | DEFUN (no_bgp_client_to_client_reflection, | |
1967 | no_bgp_client_to_client_reflection_cmd, | |
1968 | "no bgp client-to-client reflection", | |
1969 | NO_STR | |
1970 | "BGP specific commands\n" | |
1971 | "Configure client to client route reflection\n" | |
1972 | "reflection of routes allowed\n") | |
1973 | { | |
d62a17ae | 1974 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1975 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1976 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1977 | |
d62a17ae | 1978 | return CMD_SUCCESS; |
718e3744 | 1979 | } |
1980 | ||
1981 | /* "bgp always-compare-med" configuration. */ | |
1982 | DEFUN (bgp_always_compare_med, | |
1983 | bgp_always_compare_med_cmd, | |
1984 | "bgp always-compare-med", | |
1985 | "BGP specific commands\n" | |
1986 | "Allow comparing MED from different neighbors\n") | |
1987 | { | |
d62a17ae | 1988 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1989 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1990 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1991 | |
d62a17ae | 1992 | return CMD_SUCCESS; |
718e3744 | 1993 | } |
1994 | ||
1995 | DEFUN (no_bgp_always_compare_med, | |
1996 | no_bgp_always_compare_med_cmd, | |
1997 | "no bgp always-compare-med", | |
1998 | NO_STR | |
1999 | "BGP specific commands\n" | |
2000 | "Allow comparing MED from different neighbors\n") | |
2001 | { | |
d62a17ae | 2002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2003 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2004 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2005 | |
d62a17ae | 2006 | return CMD_SUCCESS; |
718e3744 | 2007 | } |
6b0655a2 | 2008 | |
9dac9fc8 DA |
2009 | |
2010 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2011 | "bgp ebgp-requires-policy", | |
2012 | "BGP specific commands\n" | |
2013 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2014 | { | |
2015 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2016 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
2017 | return CMD_SUCCESS; | |
2018 | } | |
2019 | ||
2020 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2021 | "no bgp ebgp-requires-policy", | |
2022 | NO_STR | |
2023 | "BGP specific commands\n" | |
2024 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2025 | { | |
2026 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2027 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
2028 | return CMD_SUCCESS; | |
2029 | } | |
2030 | ||
fb29348a DA |
2031 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2032 | "bgp reject-as-sets", | |
2033 | "BGP specific commands\n" | |
2034 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2035 | { | |
2036 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2037 | struct listnode *node, *nnode; | |
2038 | struct peer *peer; | |
2039 | ||
2040 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_ENABLED; | |
2041 | ||
2042 | /* Reset existing BGP sessions to reject routes | |
2043 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2044 | */ | |
2045 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2046 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2047 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2048 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2049 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2050 | } | |
2051 | } | |
2052 | ||
2053 | return CMD_SUCCESS; | |
2054 | } | |
2055 | ||
2056 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2057 | "no bgp reject-as-sets", | |
2058 | NO_STR | |
2059 | "BGP specific commands\n" | |
2060 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2061 | { | |
2062 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2063 | struct listnode *node, *nnode; | |
2064 | struct peer *peer; | |
2065 | ||
2066 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_DISABLED; | |
2067 | ||
2068 | /* Reset existing BGP sessions to reject routes | |
2069 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2070 | */ | |
2071 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2072 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2073 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2074 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2075 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2076 | } | |
2077 | } | |
2078 | ||
2079 | return CMD_SUCCESS; | |
2080 | } | |
9dac9fc8 | 2081 | |
718e3744 | 2082 | /* "bgp deterministic-med" configuration. */ |
2083 | DEFUN (bgp_deterministic_med, | |
2084 | bgp_deterministic_med_cmd, | |
2085 | "bgp deterministic-med", | |
2086 | "BGP specific commands\n" | |
2087 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2088 | { | |
d62a17ae | 2089 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2090 | |
d62a17ae | 2091 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
2092 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2093 | bgp_recalculate_all_bestpaths(bgp); | |
2094 | } | |
7aafcaca | 2095 | |
d62a17ae | 2096 | return CMD_SUCCESS; |
718e3744 | 2097 | } |
2098 | ||
2099 | DEFUN (no_bgp_deterministic_med, | |
2100 | no_bgp_deterministic_med_cmd, | |
2101 | "no bgp deterministic-med", | |
2102 | NO_STR | |
2103 | "BGP specific commands\n" | |
2104 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2105 | { | |
d62a17ae | 2106 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2107 | int bestpath_per_as_used; | |
2108 | afi_t afi; | |
2109 | safi_t safi; | |
2110 | struct peer *peer; | |
2111 | struct listnode *node, *nnode; | |
2112 | ||
2113 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
2114 | bestpath_per_as_used = 0; | |
2115 | ||
2116 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2117 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2118 | if (bgp_addpath_dmed_required( |
2119 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2120 | bestpath_per_as_used = 1; |
2121 | break; | |
2122 | } | |
d62a17ae | 2123 | |
2124 | if (bestpath_per_as_used) | |
2125 | break; | |
2126 | } | |
2127 | ||
2128 | if (bestpath_per_as_used) { | |
2129 | vty_out(vty, | |
2130 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2131 | return CMD_WARNING_CONFIG_FAILED; | |
2132 | } else { | |
2133 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
2134 | bgp_recalculate_all_bestpaths(bgp); | |
2135 | } | |
2136 | } | |
2137 | ||
2138 | return CMD_SUCCESS; | |
718e3744 | 2139 | } |
538621f2 | 2140 | |
055679e9 | 2141 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2142 | DEFUN (bgp_graceful_restart, |
055679e9 | 2143 | bgp_graceful_restart_cmd, |
2144 | "bgp graceful-restart", | |
2145 | "BGP specific commands\n" | |
2146 | GR_CMD | |
2147 | ) | |
538621f2 | 2148 | { |
055679e9 | 2149 | int ret = BGP_GR_FAILURE; |
5cce3f05 | 2150 | struct peer *peer; |
2151 | struct listnode *node = {0}; | |
2152 | struct listnode *nnode = {0}; | |
055679e9 | 2153 | |
2154 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2155 | zlog_debug("BGP_GR:: bgp_graceful_restart_cmd : START "); | |
d62a17ae | 2156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2157 | |
2158 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2159 | ||
5cce3f05 | 2160 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
2161 | if (peer->bgp->t_startup) | |
2162 | bgp_peer_gr_flags_update(peer); | |
2163 | } | |
2164 | ||
055679e9 | 2165 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2166 | zlog_debug("BGP_GR:: bgp_graceful_restart_cmd : END "); | |
2167 | return bgp_vty_return(vty, ret); | |
538621f2 | 2168 | } |
2169 | ||
2170 | DEFUN (no_bgp_graceful_restart, | |
055679e9 | 2171 | no_bgp_graceful_restart_cmd, |
2172 | "no bgp graceful-restart", | |
2173 | NO_STR | |
2174 | "BGP specific commands\n" | |
2175 | NO_GR_CMD | |
2176 | ) | |
538621f2 | 2177 | { |
d62a17ae | 2178 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5cce3f05 | 2179 | struct peer *peer; |
2180 | struct listnode *node = {0}; | |
2181 | struct listnode *nnode = {0}; | |
055679e9 | 2182 | |
2183 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2184 | zlog_debug("BGP_GR:: no_bgp_graceful_restart_cmd : START "); | |
2185 | ||
2186 | int ret = BGP_GR_FAILURE; | |
2187 | ||
2188 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2189 | ||
5cce3f05 | 2190 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
2191 | if (peer->bgp->t_startup) | |
2192 | bgp_peer_gr_flags_update(peer); | |
2193 | } | |
2194 | ||
055679e9 | 2195 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2196 | zlog_debug("BGP_GR:: no_bgp_graceful_restart_cmd : END "); | |
2197 | ||
2198 | return bgp_vty_return(vty, ret); | |
538621f2 | 2199 | } |
2200 | ||
93406d87 | 2201 | DEFUN (bgp_graceful_restart_stalepath_time, |
055679e9 | 2202 | bgp_graceful_restart_stalepath_time_cmd, |
2203 | "bgp graceful-restart stalepath-time (1-4095)", | |
2204 | "BGP specific commands\n" | |
2205 | "Graceful restart capability parameters\n" | |
2206 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2207 | "Delay value (seconds)\n") | |
93406d87 | 2208 | { |
d62a17ae | 2209 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2210 | int idx_number = 3; | |
d7c0a89a | 2211 | uint32_t stalepath; |
93406d87 | 2212 | |
d62a17ae | 2213 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2214 | bgp->stalepath_time = stalepath; | |
2215 | return CMD_SUCCESS; | |
93406d87 | 2216 | } |
2217 | ||
eb6f1b41 | 2218 | DEFUN (bgp_graceful_restart_restart_time, |
055679e9 | 2219 | bgp_graceful_restart_restart_time_cmd, |
2220 | "bgp graceful-restart restart-time (1-4095)", | |
2221 | "BGP specific commands\n" | |
2222 | "Graceful restart capability parameters\n" | |
2223 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2224 | "Delay value (seconds)\n") | |
eb6f1b41 | 2225 | { |
d62a17ae | 2226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2227 | int idx_number = 3; | |
d7c0a89a | 2228 | uint32_t restart; |
eb6f1b41 | 2229 | |
d62a17ae | 2230 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2231 | bgp->restart_time = restart; | |
2232 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2233 | } |
2234 | ||
cfd47646 | 2235 | DEFUN (bgp_graceful_restart_select_defer_time, |
2236 | bgp_graceful_restart_select_defer_time_cmd, | |
2237 | "bgp graceful-restart select-defer-time (0-3600)", | |
2238 | "BGP specific commands\n" | |
2239 | "Graceful restart capability parameters\n" | |
2240 | "Set the time to defer the BGP route selection after restart\n" | |
2241 | "Delay value (seconds, 0 - disable)\n") | |
2242 | { | |
2243 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2244 | int idx_number = 3; | |
2245 | uint32_t defer_time; | |
2246 | ||
2247 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2248 | bgp->select_defer_time = defer_time; | |
2249 | if (defer_time == 0) | |
2250 | bgp_flag_set(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2251 | else | |
2252 | bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2253 | ||
2254 | return CMD_SUCCESS; | |
2255 | } | |
2256 | ||
93406d87 | 2257 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
055679e9 | 2258 | no_bgp_graceful_restart_stalepath_time_cmd, |
2259 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2260 | NO_STR | |
2261 | "BGP specific commands\n" | |
2262 | "Graceful restart capability parameters\n" | |
2263 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2264 | "Delay value (seconds)\n") | |
93406d87 | 2265 | { |
d62a17ae | 2266 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2267 | |
d62a17ae | 2268 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2269 | return CMD_SUCCESS; | |
93406d87 | 2270 | } |
2271 | ||
eb6f1b41 | 2272 | DEFUN (no_bgp_graceful_restart_restart_time, |
055679e9 | 2273 | no_bgp_graceful_restart_restart_time_cmd, |
2274 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2275 | NO_STR | |
2276 | "BGP specific commands\n" | |
2277 | "Graceful restart capability parameters\n" | |
2278 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2279 | "Delay value (seconds)\n") | |
eb6f1b41 | 2280 | { |
d62a17ae | 2281 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2282 | |
d62a17ae | 2283 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2284 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2285 | } |
2286 | ||
cfd47646 | 2287 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2288 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2289 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2290 | NO_STR | |
2291 | "BGP specific commands\n" | |
2292 | "Graceful restart capability parameters\n" | |
2293 | "Set the time to defer the BGP route selection after restart\n" | |
2294 | "Delay value (seconds)\n") | |
2295 | { | |
2296 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2297 | ||
2298 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
2299 | bgp_flag_unset(bgp, BGP_FLAG_SELECT_DEFER_DISABLE); | |
2300 | ||
2301 | return CMD_SUCCESS; | |
2302 | } | |
2303 | ||
43fc21b3 | 2304 | DEFUN (bgp_graceful_restart_preserve_fw, |
055679e9 | 2305 | bgp_graceful_restart_preserve_fw_cmd, |
2306 | "bgp graceful-restart preserve-fw-state", | |
2307 | "BGP specific commands\n" | |
2308 | "Graceful restart capability parameters\n" | |
2309 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2310 | { |
d62a17ae | 2311 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2312 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2313 | return CMD_SUCCESS; | |
43fc21b3 JC |
2314 | } |
2315 | ||
2316 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
055679e9 | 2317 | no_bgp_graceful_restart_preserve_fw_cmd, |
2318 | "no bgp graceful-restart preserve-fw-state", | |
2319 | NO_STR | |
2320 | "BGP specific commands\n" | |
2321 | "Graceful restart capability parameters\n" | |
2322 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2323 | { |
d62a17ae | 2324 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2325 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2326 | return CMD_SUCCESS; | |
43fc21b3 JC |
2327 | } |
2328 | ||
055679e9 | 2329 | DEFUN (bgp_graceful_restart_disable, |
2330 | bgp_graceful_restart_disable_cmd, | |
2331 | "bgp graceful-restart-disable", | |
2332 | "BGP specific commands\n" | |
2333 | GR_DISABLE) | |
2334 | { | |
2335 | int ret = BGP_GR_FAILURE; | |
5cce3f05 | 2336 | struct peer *peer; |
2337 | struct listnode *node = {0}; | |
2338 | struct listnode *nnode = {0}; | |
055679e9 | 2339 | |
2340 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2341 | zlog_debug( | |
2342 | "BGP_GR:: bgp_graceful_restart_disable_cmd : START "); | |
2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2344 | ||
2345 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2346 | ||
5cce3f05 | 2347 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
2348 | if (peer->bgp->t_startup) | |
2349 | bgp_peer_gr_flags_update(peer); | |
2350 | } | |
2351 | ||
055679e9 | 2352 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2353 | zlog_debug( | |
2354 | "BGP_GR:: bgp_graceful_restart_disable_cmd : END "); | |
2355 | return bgp_vty_return(vty, ret); | |
2356 | } | |
2357 | ||
2358 | DEFUN (no_bgp_graceful_restart_disable, | |
2359 | no_bgp_graceful_restart_disable_cmd, | |
2360 | "no bgp graceful-restart-disable", | |
2361 | NO_STR | |
2362 | "BGP specific commands\n" | |
2363 | NO_GR_DISABLE | |
2364 | ) | |
2365 | { | |
2366 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
5cce3f05 | 2367 | struct peer *peer; |
2368 | struct listnode *node = {0}; | |
2369 | struct listnode *nnode = {0}; | |
055679e9 | 2370 | |
2371 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2372 | zlog_debug( | |
2373 | "BGP_GR:: no_bgp_graceful_restart_disable_cmd : START "); | |
2374 | ||
2375 | int ret = BGP_GR_FAILURE; | |
2376 | ||
2377 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2378 | ||
5cce3f05 | 2379 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
2380 | if (peer->bgp->t_startup) | |
2381 | bgp_peer_gr_flags_update(peer); | |
2382 | } | |
2383 | ||
055679e9 | 2384 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2385 | zlog_debug( | |
2386 | "BGP_GR:: no_bgp_graceful_restart_disable_cmd : END "); | |
2387 | ||
2388 | return bgp_vty_return(vty, ret); | |
2389 | } | |
2390 | ||
2391 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2392 | bgp_neighbor_graceful_restart_set_cmd, | |
2393 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2394 | NEIGHBOR_STR | |
2395 | NEIGHBOR_ADDR_STR2 | |
2396 | GR_NEIGHBOR_CMD | |
2397 | ) | |
2398 | { | |
2399 | int idx_peer = 1; | |
2400 | struct peer *peer; | |
2401 | int ret = BGP_GR_FAILURE; | |
2402 | ||
2403 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2404 | zlog_debug( | |
2405 | "BGP_GR:: bgp_neighbor_graceful_restart_set_cmd : START "); | |
2406 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2407 | if (!peer) | |
2408 | return CMD_WARNING_CONFIG_FAILED; | |
2409 | ||
2410 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2411 | ||
2412 | if (peer->bgp->t_startup) | |
2413 | bgp_peer_gr_flags_update(peer); | |
2414 | ||
2415 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2416 | zlog_debug( | |
2417 | "BGP_GR:: bgp_neighbor_graceful_restart_set_cmd : END "); | |
2418 | ||
2419 | return bgp_vty_return(vty, ret); | |
2420 | } | |
2421 | ||
2422 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2423 | no_bgp_neighbor_graceful_restart_set_cmd, | |
2424 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2425 | NO_STR | |
2426 | NEIGHBOR_STR | |
2427 | NEIGHBOR_ADDR_STR2 | |
2428 | NO_GR_NEIGHBOR_CMD | |
2429 | ) | |
2430 | { | |
2431 | int idx_peer = 2; | |
2432 | int ret = BGP_GR_FAILURE; | |
2433 | struct peer *peer; | |
2434 | ||
2435 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2436 | if (!peer) | |
2437 | return CMD_WARNING_CONFIG_FAILED; | |
2438 | ||
2439 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2440 | zlog_debug( | |
2441 | "BGP_GR:: no_bgp_neighbor_graceful_restart_set_cmd : START "); | |
2442 | ||
2443 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2444 | ||
2445 | if (peer->bgp->t_startup) | |
2446 | bgp_peer_gr_flags_update(peer); | |
2447 | ||
2448 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2449 | zlog_debug( | |
5cce3f05 | 2450 | "BGP_GR:: no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
055679e9 | 2451 | |
2452 | return bgp_vty_return(vty, ret); | |
2453 | } | |
2454 | ||
2455 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2456 | bgp_neighbor_graceful_restart_helper_set_cmd, | |
2457 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2458 | NEIGHBOR_STR | |
2459 | NEIGHBOR_ADDR_STR2 | |
2460 | GR_NEIGHBOR_HELPER_CMD | |
2461 | ) | |
2462 | { | |
2463 | int idx_peer = 1; | |
2464 | struct peer *peer; | |
2465 | int ret = BGP_GR_FAILURE; | |
2466 | ||
2467 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2468 | zlog_debug( | |
5cce3f05 | 2469 | "BGP_GR:: bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2470 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2471 | ||
055679e9 | 2472 | if (!peer) |
2473 | return CMD_WARNING_CONFIG_FAILED; | |
2474 | ||
2475 | ||
2476 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2477 | |
2478 | if (peer->bgp->t_startup) | |
2479 | bgp_peer_gr_flags_update(peer); | |
2480 | ||
055679e9 | 2481 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2482 | zlog_debug( | |
2483 | "BGP_GR:: bgp_neighbor_graceful_restart_helper_set_cmd : END "); | |
2484 | ||
2485 | return bgp_vty_return(vty, ret); | |
2486 | } | |
2487 | ||
2488 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2489 | no_bgp_neighbor_graceful_restart_helper_set_cmd, | |
2490 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2491 | NO_STR | |
2492 | NEIGHBOR_STR | |
2493 | NEIGHBOR_ADDR_STR2 | |
2494 | NO_GR_NEIGHBOR_HELPER_CMD | |
2495 | ) | |
2496 | { | |
2497 | int idx_peer = 2; | |
2498 | int ret = BGP_GR_FAILURE; | |
2499 | struct peer *peer; | |
2500 | ||
2501 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2502 | if (!peer) | |
2503 | return CMD_WARNING_CONFIG_FAILED; | |
2504 | ||
2505 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2506 | zlog_debug( | |
2507 | "BGP_GR:: no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); | |
2508 | ||
2509 | ret = bgp_neighbor_graceful_restart(peer, | |
2510 | NO_PEER_HELPER_CMD); | |
2511 | ||
2512 | if (peer->bgp->t_startup) | |
2513 | bgp_peer_gr_flags_update(peer); | |
2514 | ||
2515 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2516 | zlog_debug( | |
5cce3f05 | 2517 | "BGP_GR:: no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
055679e9 | 2518 | |
2519 | return bgp_vty_return(vty, ret); | |
2520 | } | |
2521 | ||
2522 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2523 | bgp_neighbor_graceful_restart_disable_set_cmd, | |
2524 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2525 | NEIGHBOR_STR | |
2526 | NEIGHBOR_ADDR_STR2 | |
2527 | GR_NEIGHBOR_DISABLE_CMD | |
2528 | ) | |
2529 | { | |
2530 | int idx_peer = 1; | |
2531 | struct peer *peer; | |
2532 | int ret = BGP_GR_FAILURE; | |
2533 | ||
2534 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2535 | zlog_debug( | |
2536 | "BGP_GR:: bgp_neighbor_graceful_restart_disable_set_cmd : START "); | |
2537 | ||
2538 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2539 | if (!peer) | |
2540 | return CMD_WARNING_CONFIG_FAILED; | |
2541 | ||
2542 | ||
2543 | ret = bgp_neighbor_graceful_restart(peer, | |
5cce3f05 | 2544 | PEER_DISABLE_cmd); |
055679e9 | 2545 | |
2546 | if (peer->bgp->t_startup) | |
2547 | bgp_peer_gr_flags_update(peer); | |
2548 | ||
2549 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2550 | zlog_debug( | |
2551 | "BGP_GR::bgp_neighbor_graceful_restart_disable_set_cmd : END "); | |
2552 | ||
2553 | return bgp_vty_return(vty, ret); | |
2554 | } | |
2555 | ||
2556 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2557 | no_bgp_neighbor_graceful_restart_disable_set_cmd, | |
2558 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2559 | NO_STR | |
2560 | NEIGHBOR_STR | |
2561 | NEIGHBOR_ADDR_STR2 | |
2562 | NO_GR_NEIGHBOR_DISABLE_CMD | |
2563 | ) | |
2564 | { | |
2565 | int idx_peer = 2; | |
2566 | int ret = BGP_GR_FAILURE; | |
2567 | struct peer *peer; | |
2568 | ||
2569 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2570 | if (!peer) | |
2571 | return CMD_WARNING_CONFIG_FAILED; | |
2572 | ||
2573 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2574 | zlog_debug( | |
2575 | "BGP_GR:: no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); | |
2576 | ||
2577 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2578 | ||
2579 | if (peer->bgp->t_startup) | |
2580 | bgp_peer_gr_flags_update(peer); | |
2581 | ||
2582 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2583 | zlog_debug( | |
2584 | "BGP_GR:: no_bgp_neighbor_graceful_restart_set_cmd : END "); | |
2585 | ||
2586 | return bgp_vty_return(vty, ret); | |
2587 | } | |
2588 | ||
7f323236 DW |
2589 | /* "bgp graceful-shutdown" configuration */ |
2590 | DEFUN (bgp_graceful_shutdown, | |
2591 | bgp_graceful_shutdown_cmd, | |
2592 | "bgp graceful-shutdown", | |
2593 | BGP_STR | |
2594 | "Graceful shutdown parameters\n") | |
2595 | { | |
2596 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2597 | ||
2598 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2599 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2600 | bgp_static_redo_import_check(bgp); | |
2601 | bgp_redistribute_redo(bgp); | |
2602 | bgp_clear_star_soft_out(vty, bgp->name); | |
2603 | bgp_clear_star_soft_in(vty, bgp->name); | |
2604 | } | |
2605 | ||
2606 | return CMD_SUCCESS; | |
2607 | } | |
2608 | ||
2609 | DEFUN (no_bgp_graceful_shutdown, | |
2610 | no_bgp_graceful_shutdown_cmd, | |
2611 | "no bgp graceful-shutdown", | |
2612 | NO_STR | |
2613 | BGP_STR | |
2614 | "Graceful shutdown parameters\n") | |
2615 | { | |
2616 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2617 | ||
2618 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2619 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2620 | bgp_static_redo_import_check(bgp); | |
2621 | bgp_redistribute_redo(bgp); | |
2622 | bgp_clear_star_soft_out(vty, bgp->name); | |
2623 | bgp_clear_star_soft_in(vty, bgp->name); | |
2624 | } | |
2625 | ||
2626 | return CMD_SUCCESS; | |
2627 | } | |
2628 | ||
718e3744 | 2629 | /* "bgp fast-external-failover" configuration. */ |
2630 | DEFUN (bgp_fast_external_failover, | |
2631 | bgp_fast_external_failover_cmd, | |
2632 | "bgp fast-external-failover", | |
2633 | BGP_STR | |
2634 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2635 | { | |
d62a17ae | 2636 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2637 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2638 | return CMD_SUCCESS; | |
718e3744 | 2639 | } |
2640 | ||
2641 | DEFUN (no_bgp_fast_external_failover, | |
2642 | no_bgp_fast_external_failover_cmd, | |
2643 | "no bgp fast-external-failover", | |
2644 | NO_STR | |
2645 | BGP_STR | |
2646 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2647 | { | |
d62a17ae | 2648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2649 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2650 | return CMD_SUCCESS; | |
718e3744 | 2651 | } |
6b0655a2 | 2652 | |
718e3744 | 2653 | /* "bgp bestpath compare-routerid" configuration. */ |
2654 | DEFUN (bgp_bestpath_compare_router_id, | |
2655 | bgp_bestpath_compare_router_id_cmd, | |
2656 | "bgp bestpath compare-routerid", | |
2657 | "BGP specific commands\n" | |
2658 | "Change the default bestpath selection\n" | |
2659 | "Compare router-id for identical EBGP paths\n") | |
2660 | { | |
d62a17ae | 2661 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2662 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2663 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2664 | |
d62a17ae | 2665 | return CMD_SUCCESS; |
718e3744 | 2666 | } |
2667 | ||
2668 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2669 | no_bgp_bestpath_compare_router_id_cmd, | |
2670 | "no bgp bestpath compare-routerid", | |
2671 | NO_STR | |
2672 | "BGP specific commands\n" | |
2673 | "Change the default bestpath selection\n" | |
2674 | "Compare router-id for identical EBGP paths\n") | |
2675 | { | |
d62a17ae | 2676 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2677 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2678 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2679 | |
d62a17ae | 2680 | return CMD_SUCCESS; |
718e3744 | 2681 | } |
6b0655a2 | 2682 | |
718e3744 | 2683 | /* "bgp bestpath as-path ignore" configuration. */ |
2684 | DEFUN (bgp_bestpath_aspath_ignore, | |
2685 | bgp_bestpath_aspath_ignore_cmd, | |
2686 | "bgp bestpath as-path ignore", | |
2687 | "BGP specific commands\n" | |
2688 | "Change the default bestpath selection\n" | |
2689 | "AS-path attribute\n" | |
2690 | "Ignore as-path length in selecting a route\n") | |
2691 | { | |
d62a17ae | 2692 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2693 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2694 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2695 | |
d62a17ae | 2696 | return CMD_SUCCESS; |
718e3744 | 2697 | } |
2698 | ||
2699 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2700 | no_bgp_bestpath_aspath_ignore_cmd, | |
2701 | "no bgp bestpath as-path ignore", | |
2702 | NO_STR | |
2703 | "BGP specific commands\n" | |
2704 | "Change the default bestpath selection\n" | |
2705 | "AS-path attribute\n" | |
2706 | "Ignore as-path length in selecting a route\n") | |
2707 | { | |
d62a17ae | 2708 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2709 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2710 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2711 | |
d62a17ae | 2712 | return CMD_SUCCESS; |
718e3744 | 2713 | } |
6b0655a2 | 2714 | |
6811845b | 2715 | /* "bgp bestpath as-path confed" configuration. */ |
2716 | DEFUN (bgp_bestpath_aspath_confed, | |
2717 | bgp_bestpath_aspath_confed_cmd, | |
2718 | "bgp bestpath as-path confed", | |
2719 | "BGP specific commands\n" | |
2720 | "Change the default bestpath selection\n" | |
2721 | "AS-path attribute\n" | |
2722 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2723 | { | |
d62a17ae | 2724 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2725 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2726 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2727 | |
d62a17ae | 2728 | return CMD_SUCCESS; |
6811845b | 2729 | } |
2730 | ||
2731 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2732 | no_bgp_bestpath_aspath_confed_cmd, | |
2733 | "no bgp bestpath as-path confed", | |
2734 | NO_STR | |
2735 | "BGP specific commands\n" | |
2736 | "Change the default bestpath selection\n" | |
2737 | "AS-path attribute\n" | |
2738 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2739 | { | |
d62a17ae | 2740 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2741 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2742 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2743 | |
d62a17ae | 2744 | return CMD_SUCCESS; |
6811845b | 2745 | } |
6b0655a2 | 2746 | |
2fdd455c PM |
2747 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2748 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2749 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2750 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2751 | "BGP specific commands\n" |
2752 | "Change the default bestpath selection\n" | |
2753 | "AS-path attribute\n" | |
2754 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2755 | "Generate an AS_SET\n" |
16fc1eec DS |
2756 | "Do not generate an AS_SET\n") |
2757 | { | |
d62a17ae | 2758 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2759 | int idx = 0; | |
2760 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2761 | |
d62a17ae | 2762 | /* no-as-set is now the default behavior so we can silently |
2763 | * ignore it */ | |
2764 | if (argv_find(argv, argc, "as-set", &idx)) | |
2765 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2766 | else | |
2767 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2768 | |
d62a17ae | 2769 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2770 | |
d62a17ae | 2771 | return CMD_SUCCESS; |
16fc1eec DS |
2772 | } |
2773 | ||
219178b6 DW |
2774 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2775 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2776 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2777 | NO_STR |
2778 | "BGP specific commands\n" | |
2779 | "Change the default bestpath selection\n" | |
2780 | "AS-path attribute\n" | |
2781 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2782 | "Generate an AS_SET\n" |
16fc1eec DS |
2783 | "Do not generate an AS_SET\n") |
2784 | { | |
d62a17ae | 2785 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2786 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2787 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2788 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2789 | |
d62a17ae | 2790 | return CMD_SUCCESS; |
2fdd455c | 2791 | } |
6b0655a2 | 2792 | |
848973c7 | 2793 | /* "bgp log-neighbor-changes" configuration. */ |
2794 | DEFUN (bgp_log_neighbor_changes, | |
2795 | bgp_log_neighbor_changes_cmd, | |
2796 | "bgp log-neighbor-changes", | |
2797 | "BGP specific commands\n" | |
2798 | "Log neighbor up/down and reset reason\n") | |
2799 | { | |
d62a17ae | 2800 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2801 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2802 | return CMD_SUCCESS; | |
848973c7 | 2803 | } |
2804 | ||
2805 | DEFUN (no_bgp_log_neighbor_changes, | |
2806 | no_bgp_log_neighbor_changes_cmd, | |
2807 | "no bgp log-neighbor-changes", | |
2808 | NO_STR | |
2809 | "BGP specific commands\n" | |
2810 | "Log neighbor up/down and reset reason\n") | |
2811 | { | |
d62a17ae | 2812 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2813 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2814 | return CMD_SUCCESS; | |
848973c7 | 2815 | } |
6b0655a2 | 2816 | |
718e3744 | 2817 | /* "bgp bestpath med" configuration. */ |
2818 | DEFUN (bgp_bestpath_med, | |
2819 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2820 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2821 | "BGP specific commands\n" |
2822 | "Change the default bestpath selection\n" | |
2823 | "MED attribute\n" | |
2824 | "Compare MED among confederation paths\n" | |
838758ac DW |
2825 | "Treat missing MED as the least preferred one\n" |
2826 | "Treat missing MED as the least preferred one\n" | |
2827 | "Compare MED among confederation paths\n") | |
718e3744 | 2828 | { |
d62a17ae | 2829 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2830 | |
d62a17ae | 2831 | int idx = 0; |
2832 | if (argv_find(argv, argc, "confed", &idx)) | |
2833 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2834 | idx = 0; | |
2835 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2836 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2837 | |
d62a17ae | 2838 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2839 | |
d62a17ae | 2840 | return CMD_SUCCESS; |
718e3744 | 2841 | } |
2842 | ||
718e3744 | 2843 | DEFUN (no_bgp_bestpath_med, |
2844 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2845 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2846 | NO_STR |
2847 | "BGP specific commands\n" | |
2848 | "Change the default bestpath selection\n" | |
2849 | "MED attribute\n" | |
2850 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2851 | "Treat missing MED as the least preferred one\n" |
2852 | "Treat missing MED as the least preferred one\n" | |
2853 | "Compare MED among confederation paths\n") | |
718e3744 | 2854 | { |
d62a17ae | 2855 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2856 | |
d62a17ae | 2857 | int idx = 0; |
2858 | if (argv_find(argv, argc, "confed", &idx)) | |
2859 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2860 | idx = 0; | |
2861 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2862 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2863 | |
d62a17ae | 2864 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2865 | |
d62a17ae | 2866 | return CMD_SUCCESS; |
718e3744 | 2867 | } |
2868 | ||
718e3744 | 2869 | /* "no bgp default ipv4-unicast". */ |
2870 | DEFUN (no_bgp_default_ipv4_unicast, | |
2871 | no_bgp_default_ipv4_unicast_cmd, | |
2872 | "no bgp default ipv4-unicast", | |
2873 | NO_STR | |
2874 | "BGP specific commands\n" | |
2875 | "Configure BGP defaults\n" | |
2876 | "Activate ipv4-unicast for a peer by default\n") | |
2877 | { | |
d62a17ae | 2878 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2879 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2880 | return CMD_SUCCESS; | |
718e3744 | 2881 | } |
2882 | ||
2883 | DEFUN (bgp_default_ipv4_unicast, | |
2884 | bgp_default_ipv4_unicast_cmd, | |
2885 | "bgp default ipv4-unicast", | |
2886 | "BGP specific commands\n" | |
2887 | "Configure BGP defaults\n" | |
2888 | "Activate ipv4-unicast for a peer by default\n") | |
2889 | { | |
d62a17ae | 2890 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2891 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2892 | return CMD_SUCCESS; | |
718e3744 | 2893 | } |
6b0655a2 | 2894 | |
04b6bdc0 DW |
2895 | /* Display hostname in certain command outputs */ |
2896 | DEFUN (bgp_default_show_hostname, | |
2897 | bgp_default_show_hostname_cmd, | |
2898 | "bgp default show-hostname", | |
2899 | "BGP specific commands\n" | |
2900 | "Configure BGP defaults\n" | |
0437e105 | 2901 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2902 | { |
d62a17ae | 2903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2904 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2905 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2906 | } |
2907 | ||
2908 | DEFUN (no_bgp_default_show_hostname, | |
2909 | no_bgp_default_show_hostname_cmd, | |
2910 | "no bgp default show-hostname", | |
2911 | NO_STR | |
2912 | "BGP specific commands\n" | |
2913 | "Configure BGP defaults\n" | |
0437e105 | 2914 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2915 | { |
d62a17ae | 2916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2917 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2918 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2919 | } |
2920 | ||
8233ef81 | 2921 | /* "bgp network import-check" configuration. */ |
718e3744 | 2922 | DEFUN (bgp_network_import_check, |
2923 | bgp_network_import_check_cmd, | |
5623e905 | 2924 | "bgp network import-check", |
718e3744 | 2925 | "BGP specific commands\n" |
2926 | "BGP network command\n" | |
5623e905 | 2927 | "Check BGP network route exists in IGP\n") |
718e3744 | 2928 | { |
d62a17ae | 2929 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2930 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2931 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2932 | bgp_static_redo_import_check(bgp); | |
2933 | } | |
078430f6 | 2934 | |
d62a17ae | 2935 | return CMD_SUCCESS; |
718e3744 | 2936 | } |
2937 | ||
d62a17ae | 2938 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2939 | "bgp network import-check exact", | |
2940 | "BGP specific commands\n" | |
2941 | "BGP network command\n" | |
2942 | "Check BGP network route exists in IGP\n" | |
2943 | "Match route precisely\n") | |
8233ef81 | 2944 | |
718e3744 | 2945 | DEFUN (no_bgp_network_import_check, |
2946 | no_bgp_network_import_check_cmd, | |
5623e905 | 2947 | "no bgp network import-check", |
718e3744 | 2948 | NO_STR |
2949 | "BGP specific commands\n" | |
2950 | "BGP network command\n" | |
2951 | "Check BGP network route exists in IGP\n") | |
2952 | { | |
d62a17ae | 2953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2954 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2955 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2956 | bgp_static_redo_import_check(bgp); | |
2957 | } | |
5623e905 | 2958 | |
d62a17ae | 2959 | return CMD_SUCCESS; |
718e3744 | 2960 | } |
6b0655a2 | 2961 | |
718e3744 | 2962 | DEFUN (bgp_default_local_preference, |
2963 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2964 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2965 | "BGP specific commands\n" |
2966 | "Configure BGP defaults\n" | |
2967 | "local preference (higher=more preferred)\n" | |
2968 | "Configure default local preference value\n") | |
2969 | { | |
d62a17ae | 2970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2971 | int idx_number = 3; | |
d7c0a89a | 2972 | uint32_t local_pref; |
718e3744 | 2973 | |
d62a17ae | 2974 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2975 | |
d62a17ae | 2976 | bgp_default_local_preference_set(bgp, local_pref); |
2977 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2978 | |
d62a17ae | 2979 | return CMD_SUCCESS; |
718e3744 | 2980 | } |
2981 | ||
2982 | DEFUN (no_bgp_default_local_preference, | |
2983 | no_bgp_default_local_preference_cmd, | |
838758ac | 2984 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2985 | NO_STR |
2986 | "BGP specific commands\n" | |
2987 | "Configure BGP defaults\n" | |
838758ac DW |
2988 | "local preference (higher=more preferred)\n" |
2989 | "Configure default local preference value\n") | |
718e3744 | 2990 | { |
d62a17ae | 2991 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2992 | bgp_default_local_preference_unset(bgp); | |
2993 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2994 | |
d62a17ae | 2995 | return CMD_SUCCESS; |
718e3744 | 2996 | } |
2997 | ||
6b0655a2 | 2998 | |
3f9c7369 DS |
2999 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3000 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3001 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3002 | "BGP specific commands\n" |
3003 | "Configure BGP defaults\n" | |
3004 | "subgroup-pkt-queue-max\n" | |
3005 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3006 | { |
d62a17ae | 3007 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3008 | int idx_number = 3; | |
d7c0a89a | 3009 | uint32_t max_size; |
8bd9d948 | 3010 | |
d62a17ae | 3011 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3012 | |
d62a17ae | 3013 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3014 | |
d62a17ae | 3015 | return CMD_SUCCESS; |
3f9c7369 DS |
3016 | } |
3017 | ||
3018 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3019 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3020 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3021 | NO_STR |
3022 | "BGP specific commands\n" | |
3023 | "Configure BGP defaults\n" | |
838758ac DW |
3024 | "subgroup-pkt-queue-max\n" |
3025 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3026 | { |
d62a17ae | 3027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3028 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3029 | return CMD_SUCCESS; | |
8bd9d948 DS |
3030 | } |
3031 | ||
813d4307 | 3032 | |
8bd9d948 DS |
3033 | DEFUN (bgp_rr_allow_outbound_policy, |
3034 | bgp_rr_allow_outbound_policy_cmd, | |
3035 | "bgp route-reflector allow-outbound-policy", | |
3036 | "BGP specific commands\n" | |
3037 | "Allow modifications made by out route-map\n" | |
3038 | "on ibgp neighbors\n") | |
3039 | { | |
d62a17ae | 3040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3041 | |
d62a17ae | 3042 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3043 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3044 | update_group_announce_rrclients(bgp); | |
3045 | bgp_clear_star_soft_out(vty, bgp->name); | |
3046 | } | |
8bd9d948 | 3047 | |
d62a17ae | 3048 | return CMD_SUCCESS; |
8bd9d948 DS |
3049 | } |
3050 | ||
3051 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3052 | no_bgp_rr_allow_outbound_policy_cmd, | |
3053 | "no bgp route-reflector allow-outbound-policy", | |
3054 | NO_STR | |
3055 | "BGP specific commands\n" | |
3056 | "Allow modifications made by out route-map\n" | |
3057 | "on ibgp neighbors\n") | |
3058 | { | |
d62a17ae | 3059 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3060 | |
d62a17ae | 3061 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3062 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3063 | update_group_announce_rrclients(bgp); | |
3064 | bgp_clear_star_soft_out(vty, bgp->name); | |
3065 | } | |
8bd9d948 | 3066 | |
d62a17ae | 3067 | return CMD_SUCCESS; |
8bd9d948 DS |
3068 | } |
3069 | ||
f14e6fdb DS |
3070 | DEFUN (bgp_listen_limit, |
3071 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3072 | "bgp listen limit (1-5000)", |
f14e6fdb | 3073 | "BGP specific commands\n" |
1601a46f | 3074 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3075 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3076 | "Configure Dynamic Neighbors listen limit value\n") |
3077 | { | |
d62a17ae | 3078 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3079 | int idx_number = 3; | |
3080 | int listen_limit; | |
f14e6fdb | 3081 | |
d62a17ae | 3082 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3083 | |
d62a17ae | 3084 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3085 | |
d62a17ae | 3086 | return CMD_SUCCESS; |
f14e6fdb DS |
3087 | } |
3088 | ||
3089 | DEFUN (no_bgp_listen_limit, | |
3090 | no_bgp_listen_limit_cmd, | |
838758ac | 3091 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3092 | NO_STR |
f14e6fdb | 3093 | "BGP specific commands\n" |
1601a46f | 3094 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3095 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3096 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3097 | { |
d62a17ae | 3098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3099 | bgp_listen_limit_unset(bgp); | |
3100 | return CMD_SUCCESS; | |
f14e6fdb DS |
3101 | } |
3102 | ||
3103 | ||
20eb8864 | 3104 | /* |
3105 | * Check if this listen range is already configured. Check for exact | |
3106 | * match or overlap based on input. | |
3107 | */ | |
d62a17ae | 3108 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3109 | struct prefix *range, int exact) | |
3110 | { | |
3111 | struct listnode *node, *nnode; | |
3112 | struct listnode *node1, *nnode1; | |
3113 | struct peer_group *group; | |
3114 | struct prefix *lr; | |
3115 | afi_t afi; | |
3116 | int match; | |
3117 | ||
3118 | afi = family2afi(range->family); | |
3119 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3120 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3121 | lr)) { | |
3122 | if (exact) | |
3123 | match = prefix_same(range, lr); | |
3124 | else | |
3125 | match = (prefix_match(range, lr) | |
3126 | || prefix_match(lr, range)); | |
3127 | if (match) | |
3128 | return group; | |
3129 | } | |
3130 | } | |
3131 | ||
3132 | return NULL; | |
20eb8864 | 3133 | } |
3134 | ||
f14e6fdb DS |
3135 | DEFUN (bgp_listen_range, |
3136 | bgp_listen_range_cmd, | |
d7b9898c | 3137 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3138 | "BGP specific commands\n" |
d7fa34c1 QY |
3139 | "Configure BGP dynamic neighbors listen range\n" |
3140 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3141 | NEIGHBOR_ADDR_STR |
3142 | "Member of the peer-group\n" | |
3143 | "Peer-group name\n") | |
f14e6fdb | 3144 | { |
d62a17ae | 3145 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3146 | struct prefix range; | |
3147 | struct peer_group *group, *existing_group; | |
3148 | afi_t afi; | |
3149 | int ret; | |
3150 | int idx = 0; | |
3151 | ||
3152 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3153 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3154 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3155 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3156 | char *peergroup = argv[idx]->arg; |
3157 | ||
3158 | /* Convert IP prefix string to struct prefix. */ | |
3159 | ret = str2prefix(prefix, &range); | |
3160 | if (!ret) { | |
3161 | vty_out(vty, "%% Malformed listen range\n"); | |
3162 | return CMD_WARNING_CONFIG_FAILED; | |
3163 | } | |
3164 | ||
3165 | afi = family2afi(range.family); | |
3166 | ||
3167 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3168 | vty_out(vty, | |
3169 | "%% Malformed listen range (link-local address)\n"); | |
3170 | return CMD_WARNING_CONFIG_FAILED; | |
3171 | } | |
3172 | ||
3173 | apply_mask(&range); | |
3174 | ||
3175 | /* Check if same listen range is already configured. */ | |
3176 | existing_group = listen_range_exists(bgp, &range, 1); | |
3177 | if (existing_group) { | |
3178 | if (strcmp(existing_group->name, peergroup) == 0) | |
3179 | return CMD_SUCCESS; | |
3180 | else { | |
3181 | vty_out(vty, | |
3182 | "%% Same listen range is attached to peer-group %s\n", | |
3183 | existing_group->name); | |
3184 | return CMD_WARNING_CONFIG_FAILED; | |
3185 | } | |
3186 | } | |
3187 | ||
3188 | /* Check if an overlapping listen range exists. */ | |
3189 | if (listen_range_exists(bgp, &range, 0)) { | |
3190 | vty_out(vty, | |
3191 | "%% Listen range overlaps with existing listen range\n"); | |
3192 | return CMD_WARNING_CONFIG_FAILED; | |
3193 | } | |
3194 | ||
3195 | group = peer_group_lookup(bgp, peergroup); | |
3196 | if (!group) { | |
3197 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3198 | return CMD_WARNING_CONFIG_FAILED; | |
3199 | } | |
3200 | ||
3201 | ret = peer_group_listen_range_add(group, &range); | |
3202 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3203 | } |
3204 | ||
3205 | DEFUN (no_bgp_listen_range, | |
3206 | no_bgp_listen_range_cmd, | |
d7b9898c | 3207 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3208 | NO_STR |
f14e6fdb | 3209 | "BGP specific commands\n" |
d7fa34c1 QY |
3210 | "Unconfigure BGP dynamic neighbors listen range\n" |
3211 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3212 | NEIGHBOR_ADDR_STR | |
3213 | "Member of the peer-group\n" | |
3214 | "Peer-group name\n") | |
f14e6fdb | 3215 | { |
d62a17ae | 3216 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3217 | struct prefix range; | |
3218 | struct peer_group *group; | |
3219 | afi_t afi; | |
3220 | int ret; | |
3221 | int idx = 0; | |
3222 | ||
3223 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3224 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3225 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3226 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3227 | char *peergroup = argv[idx]->arg; |
3228 | ||
3229 | /* Convert IP prefix string to struct prefix. */ | |
3230 | ret = str2prefix(prefix, &range); | |
3231 | if (!ret) { | |
3232 | vty_out(vty, "%% Malformed listen range\n"); | |
3233 | return CMD_WARNING_CONFIG_FAILED; | |
3234 | } | |
3235 | ||
3236 | afi = family2afi(range.family); | |
3237 | ||
3238 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3239 | vty_out(vty, | |
3240 | "%% Malformed listen range (link-local address)\n"); | |
3241 | return CMD_WARNING_CONFIG_FAILED; | |
3242 | } | |
3243 | ||
3244 | apply_mask(&range); | |
3245 | ||
3246 | group = peer_group_lookup(bgp, peergroup); | |
3247 | if (!group) { | |
3248 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3249 | return CMD_WARNING_CONFIG_FAILED; | |
3250 | } | |
3251 | ||
3252 | ret = peer_group_listen_range_del(group, &range); | |
3253 | return bgp_vty_return(vty, ret); | |
3254 | } | |
3255 | ||
2b791107 | 3256 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3257 | { |
3258 | struct peer_group *group; | |
3259 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3260 | struct prefix *range; | |
3261 | afi_t afi; | |
3262 | char buf[PREFIX2STR_BUFFER]; | |
3263 | ||
3264 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3265 | vty_out(vty, " bgp listen limit %d\n", | |
3266 | bgp->dynamic_neighbors_limit); | |
3267 | ||
3268 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3269 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3270 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3271 | nrnode, range)) { | |
3272 | prefix2str(range, buf, sizeof(buf)); | |
3273 | vty_out(vty, | |
3274 | " bgp listen range %s peer-group %s\n", | |
3275 | buf, group->name); | |
3276 | } | |
3277 | } | |
3278 | } | |
f14e6fdb DS |
3279 | } |
3280 | ||
3281 | ||
907f92c8 DS |
3282 | DEFUN (bgp_disable_connected_route_check, |
3283 | bgp_disable_connected_route_check_cmd, | |
3284 | "bgp disable-ebgp-connected-route-check", | |
3285 | "BGP specific commands\n" | |
3286 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3287 | { | |
d62a17ae | 3288 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3289 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
3290 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3291 | |
d62a17ae | 3292 | return CMD_SUCCESS; |
907f92c8 DS |
3293 | } |
3294 | ||
3295 | DEFUN (no_bgp_disable_connected_route_check, | |
3296 | no_bgp_disable_connected_route_check_cmd, | |
3297 | "no bgp disable-ebgp-connected-route-check", | |
3298 | NO_STR | |
3299 | "BGP specific commands\n" | |
3300 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3301 | { | |
d62a17ae | 3302 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3303 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
3304 | bgp_clear_star_soft_in(vty, bgp->name); | |
3305 | ||
3306 | return CMD_SUCCESS; | |
3307 | } | |
3308 | ||
3309 | ||
3310 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3311 | const char *as_str, afi_t afi, safi_t safi) | |
3312 | { | |
3313 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3314 | int ret; | |
3315 | as_t as; | |
3316 | int as_type = AS_SPECIFIED; | |
3317 | union sockunion su; | |
3318 | ||
3319 | if (as_str[0] == 'i') { | |
3320 | as = 0; | |
3321 | as_type = AS_INTERNAL; | |
3322 | } else if (as_str[0] == 'e') { | |
3323 | as = 0; | |
3324 | as_type = AS_EXTERNAL; | |
3325 | } else { | |
3326 | /* Get AS number. */ | |
3327 | as = strtoul(as_str, NULL, 10); | |
3328 | } | |
3329 | ||
390485fd | 3330 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3331 | ret = str2sockunion(peer_str, &su); |
3332 | if (ret < 0) { | |
390485fd DS |
3333 | struct peer *peer; |
3334 | ||
3335 | /* Check if existing interface peer */ | |
3336 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3337 | ||
d62a17ae | 3338 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3339 | safi); | |
390485fd DS |
3340 | |
3341 | /* if not interface peer, check peer-group settings */ | |
3342 | if (ret < 0 && !peer) { | |
d62a17ae | 3343 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3344 | if (ret < 0) { | |
3345 | vty_out(vty, | |
390485fd | 3346 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3347 | return CMD_WARNING_CONFIG_FAILED; |
3348 | } | |
3349 | return CMD_SUCCESS; | |
3350 | } | |
3351 | } else { | |
3352 | if (peer_address_self_check(bgp, &su)) { | |
3353 | vty_out(vty, | |
3354 | "%% Can not configure the local system as neighbor\n"); | |
3355 | return CMD_WARNING_CONFIG_FAILED; | |
3356 | } | |
3357 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3358 | } | |
3359 | ||
3360 | /* This peer belongs to peer group. */ | |
3361 | switch (ret) { | |
3362 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3363 | vty_out(vty, | |
faa16034 | 3364 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3365 | return CMD_WARNING_CONFIG_FAILED; |
3366 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3367 | vty_out(vty, | |
faa16034 | 3368 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3369 | return CMD_WARNING_CONFIG_FAILED; |
3370 | } | |
3371 | return bgp_vty_return(vty, ret); | |
718e3744 | 3372 | } |
3373 | ||
f26845f9 QY |
3374 | DEFUN (bgp_default_shutdown, |
3375 | bgp_default_shutdown_cmd, | |
3376 | "[no] bgp default shutdown", | |
3377 | NO_STR | |
3378 | BGP_STR | |
3379 | "Configure BGP defaults\n" | |
b012cbe2 | 3380 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3381 | { |
3382 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3383 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3384 | return CMD_SUCCESS; | |
3385 | } | |
3386 | ||
718e3744 | 3387 | DEFUN (neighbor_remote_as, |
3388 | neighbor_remote_as_cmd, | |
3a2d747c | 3389 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3390 | NEIGHBOR_STR |
3391 | NEIGHBOR_ADDR_STR2 | |
3392 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3393 | AS_STR |
3a2d747c QY |
3394 | "Internal BGP peer\n" |
3395 | "External BGP peer\n") | |
718e3744 | 3396 | { |
d62a17ae | 3397 | int idx_peer = 1; |
3398 | int idx_remote_as = 3; | |
3399 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3400 | argv[idx_remote_as]->arg, AFI_IP, | |
3401 | SAFI_UNICAST); | |
3402 | } | |
3403 | ||
3404 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3405 | afi_t afi, safi_t safi, int v6only, | |
3406 | const char *peer_group_name, | |
3407 | const char *as_str) | |
3408 | { | |
3409 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3410 | as_t as = 0; | |
3411 | int as_type = AS_UNSPECIFIED; | |
3412 | struct peer *peer; | |
3413 | struct peer_group *group; | |
3414 | int ret = 0; | |
3415 | union sockunion su; | |
3416 | ||
3417 | group = peer_group_lookup(bgp, conf_if); | |
3418 | ||
3419 | if (group) { | |
3420 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3421 | return CMD_WARNING_CONFIG_FAILED; | |
3422 | } | |
3423 | ||
3424 | if (as_str) { | |
3425 | if (as_str[0] == 'i') { | |
3426 | as_type = AS_INTERNAL; | |
3427 | } else if (as_str[0] == 'e') { | |
3428 | as_type = AS_EXTERNAL; | |
3429 | } else { | |
3430 | /* Get AS number. */ | |
3431 | as = strtoul(as_str, NULL, 10); | |
3432 | as_type = AS_SPECIFIED; | |
3433 | } | |
3434 | } | |
3435 | ||
3436 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3437 | if (peer) { | |
3438 | if (as_str) | |
cc4d4ce8 | 3439 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3440 | afi, safi); |
3441 | } else { | |
3442 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
3443 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
3444 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3445 | as_type, 0, 0, NULL); | |
3446 | else | |
3447 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3448 | as_type, afi, safi, NULL); | |
3449 | ||
3450 | if (!peer) { | |
3451 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3452 | return CMD_WARNING_CONFIG_FAILED; | |
3453 | } | |
3454 | ||
3455 | if (v6only) | |
527de3dc | 3456 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3457 | |
3458 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3459 | * this | |
3460 | * any unnumbered peer in order to not worry about run-time | |
3461 | * transitions | |
3462 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3463 | * address | |
3464 | * gets deleted later etc.) | |
3465 | */ | |
3466 | if (peer->ifp) | |
3467 | bgp_zebra_initiate_radv(bgp, peer); | |
3468 | } | |
3469 | ||
3470 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3471 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3472 | if (v6only) | |
527de3dc | 3473 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3474 | else |
527de3dc | 3475 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3476 | |
3477 | /* v6only flag changed. Reset bgp seesion */ | |
3478 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3479 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3480 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3481 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3482 | } else | |
3483 | bgp_session_reset(peer); | |
3484 | } | |
3485 | ||
9fb964de PM |
3486 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3487 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3488 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3489 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3490 | } |
d62a17ae | 3491 | |
3492 | if (peer_group_name) { | |
3493 | group = peer_group_lookup(bgp, peer_group_name); | |
3494 | if (!group) { | |
3495 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3496 | return CMD_WARNING_CONFIG_FAILED; | |
3497 | } | |
3498 | ||
3499 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3500 | } | |
3501 | ||
3502 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3503 | } |
3504 | ||
4c48cf63 DW |
3505 | DEFUN (neighbor_interface_config, |
3506 | neighbor_interface_config_cmd, | |
d7b9898c | 3507 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3508 | NEIGHBOR_STR |
3509 | "Interface name or neighbor tag\n" | |
31500417 DW |
3510 | "Enable BGP on interface\n" |
3511 | "Member of the peer-group\n" | |
16cedbb0 | 3512 | "Peer-group name\n") |
4c48cf63 | 3513 | { |
d62a17ae | 3514 | int idx_word = 1; |
3515 | int idx_peer_group_word = 4; | |
31500417 | 3516 | |
d62a17ae | 3517 | if (argc > idx_peer_group_word) |
3518 | return peer_conf_interface_get( | |
3519 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3520 | argv[idx_peer_group_word]->arg, NULL); | |
3521 | else | |
3522 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3523 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3524 | } |
3525 | ||
4c48cf63 DW |
3526 | DEFUN (neighbor_interface_config_v6only, |
3527 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3528 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3529 | NEIGHBOR_STR |
3530 | "Interface name or neighbor tag\n" | |
3531 | "Enable BGP on interface\n" | |
31500417 DW |
3532 | "Enable BGP with v6 link-local only\n" |
3533 | "Member of the peer-group\n" | |
16cedbb0 | 3534 | "Peer-group name\n") |
4c48cf63 | 3535 | { |
d62a17ae | 3536 | int idx_word = 1; |
3537 | int idx_peer_group_word = 5; | |
31500417 | 3538 | |
d62a17ae | 3539 | if (argc > idx_peer_group_word) |
3540 | return peer_conf_interface_get( | |
3541 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3542 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3543 | |
d62a17ae | 3544 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3545 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3546 | } |
3547 | ||
a80beece | 3548 | |
b3a39dc5 DD |
3549 | DEFUN (neighbor_interface_config_remote_as, |
3550 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3551 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3552 | NEIGHBOR_STR |
3553 | "Interface name or neighbor tag\n" | |
3554 | "Enable BGP on interface\n" | |
3a2d747c | 3555 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3556 | AS_STR |
3a2d747c QY |
3557 | "Internal BGP peer\n" |
3558 | "External BGP peer\n") | |
b3a39dc5 | 3559 | { |
d62a17ae | 3560 | int idx_word = 1; |
3561 | int idx_remote_as = 4; | |
3562 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3563 | SAFI_UNICAST, 0, NULL, | |
3564 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3565 | } |
3566 | ||
3567 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3568 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3569 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3570 | NEIGHBOR_STR |
3571 | "Interface name or neighbor tag\n" | |
3a2d747c | 3572 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3573 | "Enable BGP on interface\n" |
3a2d747c | 3574 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3575 | AS_STR |
3a2d747c QY |
3576 | "Internal BGP peer\n" |
3577 | "External BGP peer\n") | |
b3a39dc5 | 3578 | { |
d62a17ae | 3579 | int idx_word = 1; |
3580 | int idx_remote_as = 5; | |
3581 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3582 | SAFI_UNICAST, 1, NULL, | |
3583 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3584 | } |
3585 | ||
718e3744 | 3586 | DEFUN (neighbor_peer_group, |
3587 | neighbor_peer_group_cmd, | |
3588 | "neighbor WORD peer-group", | |
3589 | NEIGHBOR_STR | |
a80beece | 3590 | "Interface name or neighbor tag\n" |
718e3744 | 3591 | "Configure peer-group\n") |
3592 | { | |
d62a17ae | 3593 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3594 | int idx_word = 1; | |
3595 | struct peer *peer; | |
3596 | struct peer_group *group; | |
718e3744 | 3597 | |
d62a17ae | 3598 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3599 | if (peer) { | |
3600 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3601 | return CMD_WARNING_CONFIG_FAILED; | |
3602 | } | |
718e3744 | 3603 | |
d62a17ae | 3604 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3605 | if (!group) { | |
3606 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3607 | return CMD_WARNING_CONFIG_FAILED; | |
3608 | } | |
718e3744 | 3609 | |
d62a17ae | 3610 | return CMD_SUCCESS; |
718e3744 | 3611 | } |
3612 | ||
3613 | DEFUN (no_neighbor, | |
3614 | no_neighbor_cmd, | |
dab8cd00 | 3615 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3616 | NO_STR |
3617 | NEIGHBOR_STR | |
3a2d747c QY |
3618 | NEIGHBOR_ADDR_STR2 |
3619 | "Specify a BGP neighbor\n" | |
3620 | AS_STR | |
3621 | "Internal BGP peer\n" | |
3622 | "External BGP peer\n") | |
718e3744 | 3623 | { |
d62a17ae | 3624 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3625 | int idx_peer = 2; | |
3626 | int ret; | |
3627 | union sockunion su; | |
3628 | struct peer_group *group; | |
3629 | struct peer *peer; | |
3630 | struct peer *other; | |
3631 | ||
3632 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3633 | if (ret < 0) { | |
3634 | /* look up for neighbor by interface name config. */ | |
3635 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3636 | if (peer) { | |
3637 | /* Request zebra to terminate IPv6 RAs on this | |
3638 | * interface. */ | |
3639 | if (peer->ifp) | |
3640 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3641 | peer_notify_unconfig(peer); |
d62a17ae | 3642 | peer_delete(peer); |
3643 | return CMD_SUCCESS; | |
3644 | } | |
f14e6fdb | 3645 | |
d62a17ae | 3646 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3647 | if (group) { |
3648 | peer_group_notify_unconfig(group); | |
d62a17ae | 3649 | peer_group_delete(group); |
4e2786df | 3650 | } else { |
d62a17ae | 3651 | vty_out(vty, "%% Create the peer-group first\n"); |
3652 | return CMD_WARNING_CONFIG_FAILED; | |
3653 | } | |
3654 | } else { | |
3655 | peer = peer_lookup(bgp, &su); | |
3656 | if (peer) { | |
3657 | if (peer_dynamic_neighbor(peer)) { | |
3658 | vty_out(vty, | |
3659 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3660 | return CMD_WARNING_CONFIG_FAILED; | |
3661 | } | |
3662 | ||
3663 | other = peer->doppelganger; | |
4e2786df | 3664 | peer_notify_unconfig(peer); |
d62a17ae | 3665 | peer_delete(peer); |
4e2786df DA |
3666 | if (other && other->status != Deleted) { |
3667 | peer_notify_unconfig(other); | |
d62a17ae | 3668 | peer_delete(other); |
4e2786df | 3669 | } |
d62a17ae | 3670 | } |
1ff9a340 | 3671 | } |
718e3744 | 3672 | |
d62a17ae | 3673 | return CMD_SUCCESS; |
718e3744 | 3674 | } |
3675 | ||
a80beece DS |
3676 | DEFUN (no_neighbor_interface_config, |
3677 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3678 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3679 | NO_STR |
3680 | NEIGHBOR_STR | |
3681 | "Interface name\n" | |
31500417 DW |
3682 | "Configure BGP on interface\n" |
3683 | "Enable BGP with v6 link-local only\n" | |
3684 | "Member of the peer-group\n" | |
16cedbb0 | 3685 | "Peer-group name\n" |
3a2d747c QY |
3686 | "Specify a BGP neighbor\n" |
3687 | AS_STR | |
3688 | "Internal BGP peer\n" | |
3689 | "External BGP peer\n") | |
a80beece | 3690 | { |
d62a17ae | 3691 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3692 | int idx_word = 2; | |
3693 | struct peer *peer; | |
3694 | ||
3695 | /* look up for neighbor by interface name config. */ | |
3696 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3697 | if (peer) { | |
3698 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3699 | if (peer->ifp) | |
3700 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3701 | peer_notify_unconfig(peer); |
d62a17ae | 3702 | peer_delete(peer); |
3703 | } else { | |
3704 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3705 | return CMD_WARNING_CONFIG_FAILED; | |
3706 | } | |
3707 | return CMD_SUCCESS; | |
a80beece DS |
3708 | } |
3709 | ||
718e3744 | 3710 | DEFUN (no_neighbor_peer_group, |
3711 | no_neighbor_peer_group_cmd, | |
3712 | "no neighbor WORD peer-group", | |
3713 | NO_STR | |
3714 | NEIGHBOR_STR | |
3715 | "Neighbor tag\n" | |
3716 | "Configure peer-group\n") | |
3717 | { | |
d62a17ae | 3718 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3719 | int idx_word = 2; | |
3720 | struct peer_group *group; | |
718e3744 | 3721 | |
d62a17ae | 3722 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3723 | if (group) { |
3724 | peer_group_notify_unconfig(group); | |
d62a17ae | 3725 | peer_group_delete(group); |
4e2786df | 3726 | } else { |
d62a17ae | 3727 | vty_out(vty, "%% Create the peer-group first\n"); |
3728 | return CMD_WARNING_CONFIG_FAILED; | |
3729 | } | |
3730 | return CMD_SUCCESS; | |
718e3744 | 3731 | } |
3732 | ||
a80beece DS |
3733 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3734 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3735 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3736 | NO_STR |
3737 | NEIGHBOR_STR | |
a80beece | 3738 | "Interface name or neighbor tag\n" |
718e3744 | 3739 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3740 | AS_STR |
3741 | "Internal BGP peer\n" | |
3742 | "External BGP peer\n") | |
718e3744 | 3743 | { |
d62a17ae | 3744 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3745 | int idx_word = 2; | |
3746 | struct peer_group *group; | |
3747 | struct peer *peer; | |
3748 | ||
3749 | /* look up for neighbor by interface name config. */ | |
3750 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3751 | if (peer) { | |
390485fd | 3752 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3753 | return CMD_SUCCESS; |
3754 | } | |
3755 | ||
3756 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3757 | if (group) | |
3758 | peer_group_remote_as_delete(group); | |
3759 | else { | |
3760 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3761 | return CMD_WARNING_CONFIG_FAILED; | |
3762 | } | |
3763 | return CMD_SUCCESS; | |
718e3744 | 3764 | } |
6b0655a2 | 3765 | |
718e3744 | 3766 | DEFUN (neighbor_local_as, |
3767 | neighbor_local_as_cmd, | |
9ccf14f7 | 3768 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3769 | NEIGHBOR_STR |
3770 | NEIGHBOR_ADDR_STR2 | |
3771 | "Specify a local-as number\n" | |
3772 | "AS number used as local AS\n") | |
3773 | { | |
d62a17ae | 3774 | int idx_peer = 1; |
3775 | int idx_number = 3; | |
3776 | struct peer *peer; | |
3777 | int ret; | |
3778 | as_t as; | |
718e3744 | 3779 | |
d62a17ae | 3780 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3781 | if (!peer) | |
3782 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3783 | |
d62a17ae | 3784 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3785 | ret = peer_local_as_set(peer, as, 0, 0); | |
3786 | return bgp_vty_return(vty, ret); | |
718e3744 | 3787 | } |
3788 | ||
3789 | DEFUN (neighbor_local_as_no_prepend, | |
3790 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3791 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3792 | NEIGHBOR_STR |
3793 | NEIGHBOR_ADDR_STR2 | |
3794 | "Specify a local-as number\n" | |
3795 | "AS number used as local AS\n" | |
3796 | "Do not prepend local-as to updates from ebgp peers\n") | |
3797 | { | |
d62a17ae | 3798 | int idx_peer = 1; |
3799 | int idx_number = 3; | |
3800 | struct peer *peer; | |
3801 | int ret; | |
3802 | as_t as; | |
718e3744 | 3803 | |
d62a17ae | 3804 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3805 | if (!peer) | |
3806 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3807 | |
d62a17ae | 3808 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3809 | ret = peer_local_as_set(peer, as, 1, 0); | |
3810 | return bgp_vty_return(vty, ret); | |
718e3744 | 3811 | } |
3812 | ||
9d3f9705 AC |
3813 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3814 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3815 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3816 | NEIGHBOR_STR |
3817 | NEIGHBOR_ADDR_STR2 | |
3818 | "Specify a local-as number\n" | |
3819 | "AS number used as local AS\n" | |
3820 | "Do not prepend local-as to updates from ebgp peers\n" | |
3821 | "Do not prepend local-as to updates from ibgp peers\n") | |
3822 | { | |
d62a17ae | 3823 | int idx_peer = 1; |
3824 | int idx_number = 3; | |
3825 | struct peer *peer; | |
3826 | int ret; | |
3827 | as_t as; | |
9d3f9705 | 3828 | |
d62a17ae | 3829 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3830 | if (!peer) | |
3831 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3832 | |
d62a17ae | 3833 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3834 | ret = peer_local_as_set(peer, as, 1, 1); | |
3835 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3836 | } |
3837 | ||
718e3744 | 3838 | DEFUN (no_neighbor_local_as, |
3839 | no_neighbor_local_as_cmd, | |
a636c635 | 3840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3841 | NO_STR |
3842 | NEIGHBOR_STR | |
3843 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3844 | "Specify a local-as number\n" |
3845 | "AS number used as local AS\n" | |
3846 | "Do not prepend local-as to updates from ebgp peers\n" | |
3847 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3848 | { |
d62a17ae | 3849 | int idx_peer = 2; |
3850 | struct peer *peer; | |
3851 | int ret; | |
718e3744 | 3852 | |
d62a17ae | 3853 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3854 | if (!peer) | |
3855 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3856 | |
d62a17ae | 3857 | ret = peer_local_as_unset(peer); |
3858 | return bgp_vty_return(vty, ret); | |
718e3744 | 3859 | } |
3860 | ||
718e3744 | 3861 | |
3f9c7369 DS |
3862 | DEFUN (neighbor_solo, |
3863 | neighbor_solo_cmd, | |
9ccf14f7 | 3864 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3865 | NEIGHBOR_STR |
3866 | NEIGHBOR_ADDR_STR2 | |
3867 | "Solo peer - part of its own update group\n") | |
3868 | { | |
d62a17ae | 3869 | int idx_peer = 1; |
3870 | struct peer *peer; | |
3871 | int ret; | |
3f9c7369 | 3872 | |
d62a17ae | 3873 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3874 | if (!peer) | |
3875 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3876 | |
d62a17ae | 3877 | ret = update_group_adjust_soloness(peer, 1); |
3878 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3879 | } |
3880 | ||
3881 | DEFUN (no_neighbor_solo, | |
3882 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3883 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3884 | NO_STR |
3885 | NEIGHBOR_STR | |
3886 | NEIGHBOR_ADDR_STR2 | |
3887 | "Solo peer - part of its own update group\n") | |
3888 | { | |
d62a17ae | 3889 | int idx_peer = 2; |
3890 | struct peer *peer; | |
3891 | int ret; | |
3f9c7369 | 3892 | |
d62a17ae | 3893 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3894 | if (!peer) | |
3895 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3896 | |
d62a17ae | 3897 | ret = update_group_adjust_soloness(peer, 0); |
3898 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3899 | } |
3900 | ||
0df7c91f PJ |
3901 | DEFUN (neighbor_password, |
3902 | neighbor_password_cmd, | |
9ccf14f7 | 3903 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3904 | NEIGHBOR_STR |
3905 | NEIGHBOR_ADDR_STR2 | |
3906 | "Set a password\n" | |
3907 | "The password\n") | |
3908 | { | |
d62a17ae | 3909 | int idx_peer = 1; |
3910 | int idx_line = 3; | |
3911 | struct peer *peer; | |
3912 | int ret; | |
0df7c91f | 3913 | |
d62a17ae | 3914 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3915 | if (!peer) | |
3916 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3917 | |
d62a17ae | 3918 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3919 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3920 | } |
3921 | ||
3922 | DEFUN (no_neighbor_password, | |
3923 | no_neighbor_password_cmd, | |
a636c635 | 3924 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3925 | NO_STR |
3926 | NEIGHBOR_STR | |
3927 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3928 | "Set a password\n" |
3929 | "The password\n") | |
0df7c91f | 3930 | { |
d62a17ae | 3931 | int idx_peer = 2; |
3932 | struct peer *peer; | |
3933 | int ret; | |
0df7c91f | 3934 | |
d62a17ae | 3935 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3936 | if (!peer) | |
3937 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3938 | |
d62a17ae | 3939 | ret = peer_password_unset(peer); |
3940 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3941 | } |
6b0655a2 | 3942 | |
718e3744 | 3943 | DEFUN (neighbor_activate, |
3944 | neighbor_activate_cmd, | |
9ccf14f7 | 3945 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3946 | NEIGHBOR_STR |
3947 | NEIGHBOR_ADDR_STR2 | |
3948 | "Enable the Address Family for this Neighbor\n") | |
3949 | { | |
d62a17ae | 3950 | int idx_peer = 1; |
3951 | int ret; | |
3952 | struct peer *peer; | |
718e3744 | 3953 | |
d62a17ae | 3954 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3955 | if (!peer) | |
3956 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3957 | |
d62a17ae | 3958 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3959 | return bgp_vty_return(vty, ret); | |
718e3744 | 3960 | } |
3961 | ||
d62a17ae | 3962 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3963 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3964 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3965 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3966 | |
718e3744 | 3967 | DEFUN (no_neighbor_activate, |
3968 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3969 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3970 | NO_STR |
3971 | NEIGHBOR_STR | |
3972 | NEIGHBOR_ADDR_STR2 | |
3973 | "Enable the Address Family for this Neighbor\n") | |
3974 | { | |
d62a17ae | 3975 | int idx_peer = 2; |
3976 | int ret; | |
3977 | struct peer *peer; | |
718e3744 | 3978 | |
d62a17ae | 3979 | /* Lookup peer. */ |
3980 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3981 | if (!peer) | |
3982 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3983 | |
d62a17ae | 3984 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3985 | return bgp_vty_return(vty, ret); | |
718e3744 | 3986 | } |
6b0655a2 | 3987 | |
d62a17ae | 3988 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3989 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3990 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3991 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3992 | |
718e3744 | 3993 | DEFUN (neighbor_set_peer_group, |
3994 | neighbor_set_peer_group_cmd, | |
d7b9898c | 3995 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3996 | NEIGHBOR_STR |
a80beece | 3997 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3998 | "Member of the peer-group\n" |
16cedbb0 | 3999 | "Peer-group name\n") |
718e3744 | 4000 | { |
d62a17ae | 4001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4002 | int idx_peer = 1; | |
4003 | int idx_word = 3; | |
4004 | int ret; | |
4005 | as_t as; | |
4006 | union sockunion su; | |
4007 | struct peer *peer; | |
4008 | struct peer_group *group; | |
4009 | ||
d62a17ae | 4010 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4011 | if (ret < 0) { | |
4012 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4013 | if (!peer) { | |
4014 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4015 | argv[idx_peer]->arg); | |
4016 | return CMD_WARNING_CONFIG_FAILED; | |
4017 | } | |
4018 | } else { | |
4019 | if (peer_address_self_check(bgp, &su)) { | |
4020 | vty_out(vty, | |
4021 | "%% Can not configure the local system as neighbor\n"); | |
4022 | return CMD_WARNING_CONFIG_FAILED; | |
4023 | } | |
4024 | ||
4025 | /* Disallow for dynamic neighbor. */ | |
4026 | peer = peer_lookup(bgp, &su); | |
4027 | if (peer && peer_dynamic_neighbor(peer)) { | |
4028 | vty_out(vty, | |
4029 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4030 | return CMD_WARNING_CONFIG_FAILED; | |
4031 | } | |
4032 | } | |
4033 | ||
4034 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4035 | if (!group) { | |
4036 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4037 | return CMD_WARNING_CONFIG_FAILED; | |
4038 | } | |
4039 | ||
4040 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4041 | ||
4042 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4043 | vty_out(vty, | |
4044 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4045 | as); | |
4046 | return CMD_WARNING_CONFIG_FAILED; | |
4047 | } | |
4048 | ||
4049 | return bgp_vty_return(vty, ret); | |
4050 | } | |
4051 | ||
4052 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4053 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4054 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4055 | "Member of the peer-group\n" | |
4056 | "Peer-group name\n") | |
596c17ba | 4057 | |
718e3744 | 4058 | DEFUN (no_neighbor_set_peer_group, |
4059 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4061 | NO_STR |
4062 | NEIGHBOR_STR | |
a80beece | 4063 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4064 | "Member of the peer-group\n" |
16cedbb0 | 4065 | "Peer-group name\n") |
718e3744 | 4066 | { |
d62a17ae | 4067 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4068 | int idx_peer = 2; | |
4069 | int idx_word = 4; | |
4070 | int ret; | |
4071 | struct peer *peer; | |
4072 | struct peer_group *group; | |
4073 | ||
4074 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4075 | if (!peer) | |
4076 | return CMD_WARNING_CONFIG_FAILED; | |
4077 | ||
4078 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4079 | if (!group) { | |
4080 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4081 | return CMD_WARNING_CONFIG_FAILED; | |
4082 | } | |
718e3744 | 4083 | |
4e2786df | 4084 | peer_notify_unconfig(peer); |
827ed707 | 4085 | ret = peer_delete(peer); |
718e3744 | 4086 | |
d62a17ae | 4087 | return bgp_vty_return(vty, ret); |
718e3744 | 4088 | } |
6b0655a2 | 4089 | |
d62a17ae | 4090 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4092 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4093 | "Member of the peer-group\n" | |
4094 | "Peer-group name\n") | |
596c17ba | 4095 | |
d62a17ae | 4096 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4097 | uint32_t flag, int set) |
718e3744 | 4098 | { |
d62a17ae | 4099 | int ret; |
4100 | struct peer *peer; | |
718e3744 | 4101 | |
d62a17ae | 4102 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4103 | if (!peer) | |
4104 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4105 | |
7ebe625c QY |
4106 | /* |
4107 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4108 | * we should not accept disable-connected-check. | |
4109 | */ | |
4110 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4111 | vty_out(vty, | |
4112 | "%s is directly connected peer, cannot accept disable-" | |
4113 | "connected-check\n", | |
4114 | ip_str); | |
4115 | return CMD_WARNING_CONFIG_FAILED; | |
4116 | } | |
4117 | ||
d62a17ae | 4118 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4119 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4120 | |
d62a17ae | 4121 | if (set) |
4122 | ret = peer_flag_set(peer, flag); | |
4123 | else | |
4124 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4125 | |
d62a17ae | 4126 | return bgp_vty_return(vty, ret); |
718e3744 | 4127 | } |
4128 | ||
47cbc09b | 4129 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4130 | { |
d62a17ae | 4131 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4132 | } |
4133 | ||
d62a17ae | 4134 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4135 | uint32_t flag) |
718e3744 | 4136 | { |
d62a17ae | 4137 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4138 | } |
4139 | ||
4140 | /* neighbor passive. */ | |
4141 | DEFUN (neighbor_passive, | |
4142 | neighbor_passive_cmd, | |
9ccf14f7 | 4143 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4144 | NEIGHBOR_STR |
4145 | NEIGHBOR_ADDR_STR2 | |
4146 | "Don't send open messages to this neighbor\n") | |
4147 | { | |
d62a17ae | 4148 | int idx_peer = 1; |
4149 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4150 | } |
4151 | ||
4152 | DEFUN (no_neighbor_passive, | |
4153 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4155 | NO_STR |
4156 | NEIGHBOR_STR | |
4157 | NEIGHBOR_ADDR_STR2 | |
4158 | "Don't send open messages to this neighbor\n") | |
4159 | { | |
d62a17ae | 4160 | int idx_peer = 2; |
4161 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4162 | } |
6b0655a2 | 4163 | |
718e3744 | 4164 | /* neighbor shutdown. */ |
73d70fa6 DL |
4165 | DEFUN (neighbor_shutdown_msg, |
4166 | neighbor_shutdown_msg_cmd, | |
4167 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4168 | NEIGHBOR_STR |
4169 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
4170 | "Administratively shut down this neighbor\n" |
4171 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4172 | "Shutdown message\n") | |
718e3744 | 4173 | { |
d62a17ae | 4174 | int idx_peer = 1; |
73d70fa6 | 4175 | |
d62a17ae | 4176 | if (argc >= 5) { |
4177 | struct peer *peer = | |
4178 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4179 | char *message; | |
73d70fa6 | 4180 | |
d62a17ae | 4181 | if (!peer) |
4182 | return CMD_WARNING_CONFIG_FAILED; | |
4183 | message = argv_concat(argv, argc, 4); | |
4184 | peer_tx_shutdown_message_set(peer, message); | |
4185 | XFREE(MTYPE_TMP, message); | |
4186 | } | |
73d70fa6 | 4187 | |
d62a17ae | 4188 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4189 | } |
4190 | ||
d62a17ae | 4191 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4192 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4193 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4194 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4195 | |
4196 | DEFUN (no_neighbor_shutdown_msg, | |
4197 | no_neighbor_shutdown_msg_cmd, | |
4198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4199 | NO_STR | |
4200 | NEIGHBOR_STR | |
4201 | NEIGHBOR_ADDR_STR2 | |
4202 | "Administratively shut down this neighbor\n" | |
4203 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4204 | "Shutdown message\n") | |
718e3744 | 4205 | { |
d62a17ae | 4206 | int idx_peer = 2; |
73d70fa6 | 4207 | |
d62a17ae | 4208 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4209 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4210 | } |
6b0655a2 | 4211 | |
d62a17ae | 4212 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4213 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4214 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4215 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4216 | |
718e3744 | 4217 | /* neighbor capability dynamic. */ |
4218 | DEFUN (neighbor_capability_dynamic, | |
4219 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4220 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4221 | NEIGHBOR_STR |
4222 | NEIGHBOR_ADDR_STR2 | |
4223 | "Advertise capability to the peer\n" | |
4224 | "Advertise dynamic capability to this neighbor\n") | |
4225 | { | |
d62a17ae | 4226 | int idx_peer = 1; |
4227 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4228 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4229 | } |
4230 | ||
4231 | DEFUN (no_neighbor_capability_dynamic, | |
4232 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4233 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4234 | NO_STR |
4235 | NEIGHBOR_STR | |
4236 | NEIGHBOR_ADDR_STR2 | |
4237 | "Advertise capability to the peer\n" | |
4238 | "Advertise dynamic capability to this neighbor\n") | |
4239 | { | |
d62a17ae | 4240 | int idx_peer = 2; |
4241 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4242 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4243 | } |
6b0655a2 | 4244 | |
718e3744 | 4245 | /* neighbor dont-capability-negotiate */ |
4246 | DEFUN (neighbor_dont_capability_negotiate, | |
4247 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4248 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4249 | NEIGHBOR_STR |
4250 | NEIGHBOR_ADDR_STR2 | |
4251 | "Do not perform capability negotiation\n") | |
4252 | { | |
d62a17ae | 4253 | int idx_peer = 1; |
4254 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4255 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4256 | } |
4257 | ||
4258 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4259 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4260 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4261 | NO_STR |
4262 | NEIGHBOR_STR | |
4263 | NEIGHBOR_ADDR_STR2 | |
4264 | "Do not perform capability negotiation\n") | |
4265 | { | |
d62a17ae | 4266 | int idx_peer = 2; |
4267 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4268 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4269 | } |
6b0655a2 | 4270 | |
8a92a8a0 DS |
4271 | /* neighbor capability extended next hop encoding */ |
4272 | DEFUN (neighbor_capability_enhe, | |
4273 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4274 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4275 | NEIGHBOR_STR |
4276 | NEIGHBOR_ADDR_STR2 | |
4277 | "Advertise capability to the peer\n" | |
4278 | "Advertise extended next-hop capability to the peer\n") | |
4279 | { | |
d62a17ae | 4280 | int idx_peer = 1; |
4281 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4282 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4283 | } |
4284 | ||
4285 | DEFUN (no_neighbor_capability_enhe, | |
4286 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4287 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4288 | NO_STR |
4289 | NEIGHBOR_STR | |
4290 | NEIGHBOR_ADDR_STR2 | |
4291 | "Advertise capability to the peer\n" | |
4292 | "Advertise extended next-hop capability to the peer\n") | |
4293 | { | |
d62a17ae | 4294 | int idx_peer = 2; |
4295 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4296 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4297 | } |
4298 | ||
d62a17ae | 4299 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4300 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4301 | int set) |
718e3744 | 4302 | { |
d62a17ae | 4303 | int ret; |
4304 | struct peer *peer; | |
718e3744 | 4305 | |
d62a17ae | 4306 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4307 | if (!peer) | |
4308 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4309 | |
d62a17ae | 4310 | if (set) |
4311 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4312 | else | |
4313 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4314 | |
d62a17ae | 4315 | return bgp_vty_return(vty, ret); |
718e3744 | 4316 | } |
4317 | ||
d62a17ae | 4318 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4319 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4320 | { |
d62a17ae | 4321 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4322 | } |
4323 | ||
d62a17ae | 4324 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4325 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4326 | { |
d62a17ae | 4327 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4328 | } |
6b0655a2 | 4329 | |
718e3744 | 4330 | /* neighbor capability orf prefix-list. */ |
4331 | DEFUN (neighbor_capability_orf_prefix, | |
4332 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4333 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4334 | NEIGHBOR_STR |
4335 | NEIGHBOR_ADDR_STR2 | |
4336 | "Advertise capability to the peer\n" | |
4337 | "Advertise ORF capability to the peer\n" | |
4338 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4339 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4340 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4341 | "Capability to SEND the ORF to this neighbor\n") | |
4342 | { | |
d62a17ae | 4343 | int idx_peer = 1; |
4344 | int idx_send_recv = 5; | |
d7c0a89a | 4345 | uint16_t flag = 0; |
d62a17ae | 4346 | |
4347 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4348 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4349 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4350 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4351 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4352 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4353 | else { | |
4354 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4355 | return CMD_WARNING_CONFIG_FAILED; | |
4356 | } | |
4357 | ||
4358 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4359 | bgp_node_safi(vty), flag); | |
4360 | } | |
4361 | ||
4362 | ALIAS_HIDDEN( | |
4363 | neighbor_capability_orf_prefix, | |
4364 | neighbor_capability_orf_prefix_hidden_cmd, | |
4365 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4366 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4367 | "Advertise capability to the peer\n" | |
4368 | "Advertise ORF capability to the peer\n" | |
4369 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4370 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4371 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4372 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4373 | |
718e3744 | 4374 | DEFUN (no_neighbor_capability_orf_prefix, |
4375 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4376 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4377 | NO_STR |
4378 | NEIGHBOR_STR | |
4379 | NEIGHBOR_ADDR_STR2 | |
4380 | "Advertise capability to the peer\n" | |
4381 | "Advertise ORF capability to the peer\n" | |
4382 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4383 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4384 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4385 | "Capability to SEND the ORF to this neighbor\n") | |
4386 | { | |
d62a17ae | 4387 | int idx_peer = 2; |
4388 | int idx_send_recv = 6; | |
d7c0a89a | 4389 | uint16_t flag = 0; |
d62a17ae | 4390 | |
4391 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4392 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4393 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4394 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4395 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4396 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4397 | else { | |
4398 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4399 | return CMD_WARNING_CONFIG_FAILED; | |
4400 | } | |
4401 | ||
4402 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4403 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4404 | flag); | |
4405 | } | |
4406 | ||
4407 | ALIAS_HIDDEN( | |
4408 | no_neighbor_capability_orf_prefix, | |
4409 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4411 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4412 | "Advertise capability to the peer\n" | |
4413 | "Advertise ORF capability to the peer\n" | |
4414 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4415 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4416 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4417 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4418 | |
718e3744 | 4419 | /* neighbor next-hop-self. */ |
4420 | DEFUN (neighbor_nexthop_self, | |
4421 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4422 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4423 | NEIGHBOR_STR |
4424 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4425 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4426 | { |
d62a17ae | 4427 | int idx_peer = 1; |
4428 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4429 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4430 | } |
9e7a53c1 | 4431 | |
d62a17ae | 4432 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4433 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4434 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4435 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4436 | |
a538debe DS |
4437 | /* neighbor next-hop-self. */ |
4438 | DEFUN (neighbor_nexthop_self_force, | |
4439 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4440 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4441 | NEIGHBOR_STR |
4442 | NEIGHBOR_ADDR_STR2 | |
4443 | "Disable the next hop calculation for this neighbor\n" | |
4444 | "Set the next hop to self for reflected routes\n") | |
4445 | { | |
d62a17ae | 4446 | int idx_peer = 1; |
4447 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4448 | bgp_node_safi(vty), | |
4449 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4450 | } |
4451 | ||
d62a17ae | 4452 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4453 | neighbor_nexthop_self_force_hidden_cmd, | |
4454 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4455 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4456 | "Disable the next hop calculation for this neighbor\n" | |
4457 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4458 | |
1bc4e531 DA |
4459 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4460 | neighbor_nexthop_self_all_hidden_cmd, | |
4461 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4462 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4463 | "Disable the next hop calculation for this neighbor\n" | |
4464 | "Set the next hop to self for reflected routes\n") | |
4465 | ||
718e3744 | 4466 | DEFUN (no_neighbor_nexthop_self, |
4467 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4468 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4469 | NO_STR |
4470 | NEIGHBOR_STR | |
4471 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4472 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4473 | { |
d62a17ae | 4474 | int idx_peer = 2; |
4475 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4476 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4477 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4478 | } |
6b0655a2 | 4479 | |
d62a17ae | 4480 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4481 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4482 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4483 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4484 | |
88b8ed8d | 4485 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4486 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4487 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4488 | NO_STR |
4489 | NEIGHBOR_STR | |
4490 | NEIGHBOR_ADDR_STR2 | |
4491 | "Disable the next hop calculation for this neighbor\n" | |
4492 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4493 | { |
d62a17ae | 4494 | int idx_peer = 2; |
4495 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4496 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4497 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4498 | } |
a538debe | 4499 | |
d62a17ae | 4500 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4501 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4502 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4503 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4504 | "Disable the next hop calculation for this neighbor\n" | |
4505 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4506 | |
1bc4e531 DA |
4507 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4508 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4509 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4510 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4511 | "Disable the next hop calculation for this neighbor\n" | |
4512 | "Set the next hop to self for reflected routes\n") | |
4513 | ||
c7122e14 DS |
4514 | /* neighbor as-override */ |
4515 | DEFUN (neighbor_as_override, | |
4516 | neighbor_as_override_cmd, | |
9ccf14f7 | 4517 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4518 | NEIGHBOR_STR |
4519 | NEIGHBOR_ADDR_STR2 | |
4520 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4521 | { | |
d62a17ae | 4522 | int idx_peer = 1; |
4523 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4524 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4525 | } |
4526 | ||
d62a17ae | 4527 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4528 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4529 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4530 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4531 | |
c7122e14 DS |
4532 | DEFUN (no_neighbor_as_override, |
4533 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4534 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4535 | NO_STR |
4536 | NEIGHBOR_STR | |
4537 | NEIGHBOR_ADDR_STR2 | |
4538 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4539 | { | |
d62a17ae | 4540 | int idx_peer = 2; |
4541 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4542 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4543 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4544 | } |
4545 | ||
d62a17ae | 4546 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4548 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4549 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4550 | |
718e3744 | 4551 | /* neighbor remove-private-AS. */ |
4552 | DEFUN (neighbor_remove_private_as, | |
4553 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4554 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4555 | NEIGHBOR_STR |
4556 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4557 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4558 | { |
d62a17ae | 4559 | int idx_peer = 1; |
4560 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4561 | bgp_node_safi(vty), | |
4562 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4563 | } |
4564 | ||
d62a17ae | 4565 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4566 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4567 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4568 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4569 | |
5000f21c DS |
4570 | DEFUN (neighbor_remove_private_as_all, |
4571 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4572 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4573 | NEIGHBOR_STR |
4574 | NEIGHBOR_ADDR_STR2 | |
4575 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4576 | "Apply to all AS numbers\n") |
5000f21c | 4577 | { |
d62a17ae | 4578 | int idx_peer = 1; |
4579 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4580 | bgp_node_safi(vty), | |
4581 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4582 | } |
4583 | ||
d62a17ae | 4584 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4585 | neighbor_remove_private_as_all_hidden_cmd, | |
4586 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4587 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4588 | "Remove private ASNs in outbound updates\n" | |
4589 | "Apply to all AS numbers") | |
596c17ba | 4590 | |
5000f21c DS |
4591 | DEFUN (neighbor_remove_private_as_replace_as, |
4592 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4593 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4594 | NEIGHBOR_STR |
4595 | NEIGHBOR_ADDR_STR2 | |
4596 | "Remove private ASNs in outbound updates\n" | |
4597 | "Replace private ASNs with our ASN in outbound updates\n") | |
4598 | { | |
d62a17ae | 4599 | int idx_peer = 1; |
4600 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4601 | bgp_node_safi(vty), | |
4602 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4603 | } |
4604 | ||
d62a17ae | 4605 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4606 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4607 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4608 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4609 | "Remove private ASNs in outbound updates\n" | |
4610 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4611 | |
5000f21c DS |
4612 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4613 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4614 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4615 | NEIGHBOR_STR |
4616 | NEIGHBOR_ADDR_STR2 | |
4617 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4618 | "Apply to all AS numbers\n" |
5000f21c DS |
4619 | "Replace private ASNs with our ASN in outbound updates\n") |
4620 | { | |
d62a17ae | 4621 | int idx_peer = 1; |
4622 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4623 | bgp_node_safi(vty), | |
4624 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4625 | } |
4626 | ||
d62a17ae | 4627 | ALIAS_HIDDEN( |
4628 | neighbor_remove_private_as_all_replace_as, | |
4629 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4630 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4631 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4632 | "Remove private ASNs in outbound updates\n" | |
4633 | "Apply to all AS numbers\n" | |
4634 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4635 | |
718e3744 | 4636 | DEFUN (no_neighbor_remove_private_as, |
4637 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4638 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4639 | NO_STR |
4640 | NEIGHBOR_STR | |
4641 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4642 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4643 | { |
d62a17ae | 4644 | int idx_peer = 2; |
4645 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4646 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4647 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4648 | } |
6b0655a2 | 4649 | |
d62a17ae | 4650 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4651 | no_neighbor_remove_private_as_hidden_cmd, | |
4652 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4653 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4654 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4655 | |
88b8ed8d | 4656 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4657 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4658 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4659 | NO_STR |
4660 | NEIGHBOR_STR | |
4661 | NEIGHBOR_ADDR_STR2 | |
4662 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4663 | "Apply to all AS numbers\n") |
88b8ed8d | 4664 | { |
d62a17ae | 4665 | int idx_peer = 2; |
4666 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4667 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4668 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4669 | } |
5000f21c | 4670 | |
d62a17ae | 4671 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4672 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4673 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4674 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4675 | "Remove private ASNs in outbound updates\n" | |
4676 | "Apply to all AS numbers\n") | |
596c17ba | 4677 | |
88b8ed8d | 4678 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4679 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4680 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4681 | NO_STR |
4682 | NEIGHBOR_STR | |
4683 | NEIGHBOR_ADDR_STR2 | |
4684 | "Remove private ASNs in outbound updates\n" | |
4685 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4686 | { |
d62a17ae | 4687 | int idx_peer = 2; |
4688 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4689 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4690 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4691 | } |
5000f21c | 4692 | |
d62a17ae | 4693 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4694 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4695 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4696 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4697 | "Remove private ASNs in outbound updates\n" | |
4698 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4699 | |
88b8ed8d | 4700 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4701 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4702 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4703 | NO_STR |
4704 | NEIGHBOR_STR | |
4705 | NEIGHBOR_ADDR_STR2 | |
4706 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4707 | "Apply to all AS numbers\n" |
5000f21c | 4708 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4709 | { |
d62a17ae | 4710 | int idx_peer = 2; |
4711 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4712 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4713 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4714 | } |
5000f21c | 4715 | |
d62a17ae | 4716 | ALIAS_HIDDEN( |
4717 | no_neighbor_remove_private_as_all_replace_as, | |
4718 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4719 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4720 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4721 | "Remove private ASNs in outbound updates\n" | |
4722 | "Apply to all AS numbers\n" | |
4723 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4724 | |
5000f21c | 4725 | |
718e3744 | 4726 | /* neighbor send-community. */ |
4727 | DEFUN (neighbor_send_community, | |
4728 | neighbor_send_community_cmd, | |
9ccf14f7 | 4729 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4730 | NEIGHBOR_STR |
4731 | NEIGHBOR_ADDR_STR2 | |
4732 | "Send Community attribute to this neighbor\n") | |
4733 | { | |
d62a17ae | 4734 | int idx_peer = 1; |
27c05d4d | 4735 | |
d62a17ae | 4736 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4737 | bgp_node_safi(vty), | |
4738 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4739 | } |
4740 | ||
d62a17ae | 4741 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4742 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4743 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4744 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4745 | |
718e3744 | 4746 | DEFUN (no_neighbor_send_community, |
4747 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4748 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4749 | NO_STR |
4750 | NEIGHBOR_STR | |
4751 | NEIGHBOR_ADDR_STR2 | |
4752 | "Send Community attribute to this neighbor\n") | |
4753 | { | |
d62a17ae | 4754 | int idx_peer = 2; |
27c05d4d | 4755 | |
d62a17ae | 4756 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4757 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4758 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4759 | } |
6b0655a2 | 4760 | |
d62a17ae | 4761 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4762 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4763 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4764 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4765 | |
718e3744 | 4766 | /* neighbor send-community extended. */ |
4767 | DEFUN (neighbor_send_community_type, | |
4768 | neighbor_send_community_type_cmd, | |
57d187bc | 4769 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4770 | NEIGHBOR_STR |
4771 | NEIGHBOR_ADDR_STR2 | |
4772 | "Send Community attribute to this neighbor\n" | |
4773 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4774 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4775 | "Send Extended Community attributes\n" |
57d187bc JS |
4776 | "Send Standard Community attributes\n" |
4777 | "Send Large Community attributes\n") | |
718e3744 | 4778 | { |
27c05d4d | 4779 | int idx_peer = 1; |
d7c0a89a | 4780 | uint32_t flag = 0; |
27c05d4d | 4781 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4782 | |
27c05d4d | 4783 | if (strmatch(type, "standard")) { |
d62a17ae | 4784 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4785 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4786 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4787 | } else if (strmatch(type, "large")) { |
d62a17ae | 4788 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4789 | } else if (strmatch(type, "both")) { |
d62a17ae | 4790 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4791 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4792 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4793 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4794 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4795 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4796 | } | |
4797 | ||
27c05d4d | 4798 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4799 | bgp_node_safi(vty), flag); |
4800 | } | |
4801 | ||
4802 | ALIAS_HIDDEN( | |
4803 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4804 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4805 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4806 | "Send Community attribute to this neighbor\n" | |
4807 | "Send Standard and Extended Community attributes\n" | |
4808 | "Send Standard, Large and Extended Community attributes\n" | |
4809 | "Send Extended Community attributes\n" | |
4810 | "Send Standard Community attributes\n" | |
4811 | "Send Large Community attributes\n") | |
596c17ba | 4812 | |
718e3744 | 4813 | DEFUN (no_neighbor_send_community_type, |
4814 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4815 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4816 | NO_STR |
4817 | NEIGHBOR_STR | |
4818 | NEIGHBOR_ADDR_STR2 | |
4819 | "Send Community attribute to this neighbor\n" | |
4820 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4821 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4822 | "Send Extended Community attributes\n" |
57d187bc JS |
4823 | "Send Standard Community attributes\n" |
4824 | "Send Large Community attributes\n") | |
718e3744 | 4825 | { |
d62a17ae | 4826 | int idx_peer = 2; |
27c05d4d | 4827 | uint32_t flag = 0; |
d62a17ae | 4828 | const char *type = argv[argc - 1]->text; |
4829 | ||
27c05d4d PM |
4830 | if (strmatch(type, "standard")) { |
4831 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4832 | } else if (strmatch(type, "extended")) { | |
4833 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4834 | } else if (strmatch(type, "large")) { | |
4835 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4836 | } else if (strmatch(type, "both")) { | |
4837 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4838 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4839 | } else { /* if (strmatch(type, "all")) */ | |
4840 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4841 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4842 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4843 | } | |
4844 | ||
4845 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4846 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4847 | flag); | |
d62a17ae | 4848 | } |
4849 | ||
4850 | ALIAS_HIDDEN( | |
4851 | no_neighbor_send_community_type, | |
4852 | no_neighbor_send_community_type_hidden_cmd, | |
4853 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4854 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4855 | "Send Community attribute to this neighbor\n" | |
4856 | "Send Standard and Extended Community attributes\n" | |
4857 | "Send Standard, Large and Extended Community attributes\n" | |
4858 | "Send Extended Community attributes\n" | |
4859 | "Send Standard Community attributes\n" | |
4860 | "Send Large Community attributes\n") | |
596c17ba | 4861 | |
718e3744 | 4862 | /* neighbor soft-reconfig. */ |
4863 | DEFUN (neighbor_soft_reconfiguration, | |
4864 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4865 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4866 | NEIGHBOR_STR |
4867 | NEIGHBOR_ADDR_STR2 | |
4868 | "Per neighbor soft reconfiguration\n" | |
4869 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4870 | { | |
d62a17ae | 4871 | int idx_peer = 1; |
4872 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4873 | bgp_node_safi(vty), | |
4874 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4875 | } |
4876 | ||
d62a17ae | 4877 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4878 | neighbor_soft_reconfiguration_hidden_cmd, | |
4879 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4880 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4881 | "Per neighbor soft reconfiguration\n" | |
4882 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4883 | |
718e3744 | 4884 | DEFUN (no_neighbor_soft_reconfiguration, |
4885 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4886 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4887 | NO_STR |
4888 | NEIGHBOR_STR | |
4889 | NEIGHBOR_ADDR_STR2 | |
4890 | "Per neighbor soft reconfiguration\n" | |
4891 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4892 | { | |
d62a17ae | 4893 | int idx_peer = 2; |
4894 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4895 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4896 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4897 | } |
6b0655a2 | 4898 | |
d62a17ae | 4899 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4900 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4901 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4902 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4903 | "Per neighbor soft reconfiguration\n" | |
4904 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4905 | |
718e3744 | 4906 | DEFUN (neighbor_route_reflector_client, |
4907 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4908 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4909 | NEIGHBOR_STR |
4910 | NEIGHBOR_ADDR_STR2 | |
4911 | "Configure a neighbor as Route Reflector client\n") | |
4912 | { | |
d62a17ae | 4913 | int idx_peer = 1; |
4914 | struct peer *peer; | |
718e3744 | 4915 | |
4916 | ||
d62a17ae | 4917 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4918 | if (!peer) | |
4919 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4920 | |
d62a17ae | 4921 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4922 | bgp_node_safi(vty), | |
4923 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4924 | } |
4925 | ||
d62a17ae | 4926 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4927 | neighbor_route_reflector_client_hidden_cmd, | |
4928 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4929 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4930 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4931 | |
718e3744 | 4932 | DEFUN (no_neighbor_route_reflector_client, |
4933 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4934 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4935 | NO_STR |
4936 | NEIGHBOR_STR | |
4937 | NEIGHBOR_ADDR_STR2 | |
4938 | "Configure a neighbor as Route Reflector client\n") | |
4939 | { | |
d62a17ae | 4940 | int idx_peer = 2; |
4941 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4942 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4943 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4944 | } |
6b0655a2 | 4945 | |
d62a17ae | 4946 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4947 | no_neighbor_route_reflector_client_hidden_cmd, | |
4948 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4949 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4950 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4951 | |
718e3744 | 4952 | /* neighbor route-server-client. */ |
4953 | DEFUN (neighbor_route_server_client, | |
4954 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4955 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4956 | NEIGHBOR_STR |
4957 | NEIGHBOR_ADDR_STR2 | |
4958 | "Configure a neighbor as Route Server client\n") | |
4959 | { | |
d62a17ae | 4960 | int idx_peer = 1; |
4961 | struct peer *peer; | |
2a3d5731 | 4962 | |
d62a17ae | 4963 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4964 | if (!peer) | |
4965 | return CMD_WARNING_CONFIG_FAILED; | |
4966 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4967 | bgp_node_safi(vty), | |
4968 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4969 | } |
4970 | ||
d62a17ae | 4971 | ALIAS_HIDDEN(neighbor_route_server_client, |
4972 | neighbor_route_server_client_hidden_cmd, | |
4973 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4974 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4975 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4976 | |
718e3744 | 4977 | DEFUN (no_neighbor_route_server_client, |
4978 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4979 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4980 | NO_STR |
4981 | NEIGHBOR_STR | |
4982 | NEIGHBOR_ADDR_STR2 | |
4983 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4984 | { |
d62a17ae | 4985 | int idx_peer = 2; |
4986 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4987 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4988 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4989 | } |
6b0655a2 | 4990 | |
d62a17ae | 4991 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4992 | no_neighbor_route_server_client_hidden_cmd, | |
4993 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4994 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4995 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4996 | |
fee0f4c6 | 4997 | DEFUN (neighbor_nexthop_local_unchanged, |
4998 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4999 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5000 | NEIGHBOR_STR |
5001 | NEIGHBOR_ADDR_STR2 | |
5002 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5003 | "Leave link-local nexthop unchanged for this peer\n") | |
5004 | { | |
d62a17ae | 5005 | int idx_peer = 1; |
5006 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5007 | bgp_node_safi(vty), | |
5008 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5009 | } |
6b0655a2 | 5010 | |
fee0f4c6 | 5011 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5012 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5013 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5014 | NO_STR |
5015 | NEIGHBOR_STR | |
5016 | NEIGHBOR_ADDR_STR2 | |
5017 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5018 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5019 | { |
d62a17ae | 5020 | int idx_peer = 2; |
5021 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5022 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5023 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5024 | } |
6b0655a2 | 5025 | |
718e3744 | 5026 | DEFUN (neighbor_attr_unchanged, |
5027 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5028 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5029 | NEIGHBOR_STR |
5030 | NEIGHBOR_ADDR_STR2 | |
5031 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5032 | "As-path attribute\n" | |
5033 | "Nexthop attribute\n" | |
a8206004 | 5034 | "Med attribute\n") |
718e3744 | 5035 | { |
d62a17ae | 5036 | int idx = 0; |
8eeb0335 DW |
5037 | char *peer_str = argv[1]->arg; |
5038 | struct peer *peer; | |
d7c0a89a | 5039 | uint16_t flags = 0; |
8eeb0335 DW |
5040 | afi_t afi = bgp_node_afi(vty); |
5041 | safi_t safi = bgp_node_safi(vty); | |
5042 | ||
5043 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5044 | if (!peer) | |
5045 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5046 | |
5047 | if (argv_find(argv, argc, "as-path", &idx)) | |
5048 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5049 | idx = 0; | |
5050 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5051 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5052 | idx = 0; | |
5053 | if (argv_find(argv, argc, "med", &idx)) | |
5054 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5055 | ||
8eeb0335 DW |
5056 | /* no flags means all of them! */ |
5057 | if (!flags) { | |
d62a17ae | 5058 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
5059 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5060 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5061 | } else { |
a4d82a8a PZ |
5062 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
5063 | && peer_af_flag_check(peer, afi, safi, | |
5064 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
5065 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5066 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5067 | } | |
5068 | ||
a4d82a8a PZ |
5069 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
5070 | && peer_af_flag_check(peer, afi, safi, | |
5071 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
5072 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5073 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5074 | } | |
5075 | ||
a4d82a8a PZ |
5076 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
5077 | && peer_af_flag_check(peer, afi, safi, | |
5078 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
5079 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5080 | PEER_FLAG_MED_UNCHANGED); | |
5081 | } | |
d62a17ae | 5082 | } |
5083 | ||
8eeb0335 | 5084 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 5085 | } |
5086 | ||
5087 | ALIAS_HIDDEN( | |
5088 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5089 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5090 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5091 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5092 | "As-path attribute\n" | |
5093 | "Nexthop attribute\n" | |
5094 | "Med attribute\n") | |
596c17ba | 5095 | |
718e3744 | 5096 | DEFUN (no_neighbor_attr_unchanged, |
5097 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5098 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5099 | NO_STR |
718e3744 | 5100 | NEIGHBOR_STR |
5101 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5102 | "BGP attribute is propagated unchanged to this neighbor\n" |
5103 | "As-path attribute\n" | |
40e718b5 | 5104 | "Nexthop attribute\n" |
a8206004 | 5105 | "Med attribute\n") |
718e3744 | 5106 | { |
d62a17ae | 5107 | int idx = 0; |
5108 | char *peer = argv[2]->arg; | |
d7c0a89a | 5109 | uint16_t flags = 0; |
d62a17ae | 5110 | |
5111 | if (argv_find(argv, argc, "as-path", &idx)) | |
5112 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5113 | idx = 0; | |
5114 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5115 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5116 | idx = 0; | |
5117 | if (argv_find(argv, argc, "med", &idx)) | |
5118 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5119 | ||
5120 | if (!flags) // no flags means all of them! | |
5121 | { | |
5122 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5123 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5124 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5125 | } | |
5126 | ||
5127 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
5128 | bgp_node_safi(vty), flags); | |
5129 | } | |
5130 | ||
5131 | ALIAS_HIDDEN( | |
5132 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5133 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5134 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5135 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5136 | "As-path attribute\n" | |
5137 | "Nexthop attribute\n" | |
5138 | "Med attribute\n") | |
718e3744 | 5139 | |
718e3744 | 5140 | /* EBGP multihop configuration. */ |
d62a17ae | 5141 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5142 | const char *ttl_str) | |
718e3744 | 5143 | { |
d62a17ae | 5144 | struct peer *peer; |
5145 | unsigned int ttl; | |
718e3744 | 5146 | |
d62a17ae | 5147 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5148 | if (!peer) | |
5149 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5150 | |
d62a17ae | 5151 | if (peer->conf_if) |
5152 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5153 | |
d62a17ae | 5154 | if (!ttl_str) |
5155 | ttl = MAXTTL; | |
5156 | else | |
5157 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5158 | |
d62a17ae | 5159 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5160 | } |
5161 | ||
d62a17ae | 5162 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5163 | { |
d62a17ae | 5164 | struct peer *peer; |
718e3744 | 5165 | |
d62a17ae | 5166 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5167 | if (!peer) | |
5168 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5169 | |
d62a17ae | 5170 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5171 | } |
5172 | ||
5173 | /* neighbor ebgp-multihop. */ | |
5174 | DEFUN (neighbor_ebgp_multihop, | |
5175 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5176 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5177 | NEIGHBOR_STR |
5178 | NEIGHBOR_ADDR_STR2 | |
5179 | "Allow EBGP neighbors not on directly connected networks\n") | |
5180 | { | |
d62a17ae | 5181 | int idx_peer = 1; |
5182 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5183 | } |
5184 | ||
5185 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5186 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5187 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5188 | NEIGHBOR_STR |
5189 | NEIGHBOR_ADDR_STR2 | |
5190 | "Allow EBGP neighbors not on directly connected networks\n" | |
5191 | "maximum hop count\n") | |
5192 | { | |
d62a17ae | 5193 | int idx_peer = 1; |
5194 | int idx_number = 3; | |
5195 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5196 | argv[idx_number]->arg); | |
718e3744 | 5197 | } |
5198 | ||
5199 | DEFUN (no_neighbor_ebgp_multihop, | |
5200 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5201 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5202 | NO_STR |
5203 | NEIGHBOR_STR | |
5204 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5205 | "Allow EBGP neighbors not on directly connected networks\n" |
5206 | "maximum hop count\n") | |
718e3744 | 5207 | { |
d62a17ae | 5208 | int idx_peer = 2; |
5209 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5210 | } |
5211 | ||
6b0655a2 | 5212 | |
6ffd2079 | 5213 | /* disable-connected-check */ |
5214 | DEFUN (neighbor_disable_connected_check, | |
5215 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5216 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5217 | NEIGHBOR_STR |
7ebe625c | 5218 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5219 | "one-hop away EBGP peer using loopback address\n" |
5220 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5221 | { |
d62a17ae | 5222 | int idx_peer = 1; |
5223 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5224 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5225 | } |
5226 | ||
5227 | DEFUN (no_neighbor_disable_connected_check, | |
5228 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5229 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5230 | NO_STR |
5231 | NEIGHBOR_STR | |
7ebe625c | 5232 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5233 | "one-hop away EBGP peer using loopback address\n" |
5234 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5235 | { |
d62a17ae | 5236 | int idx_peer = 2; |
5237 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5238 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5239 | } |
5240 | ||
47cbc09b PM |
5241 | |
5242 | /* enforce-first-as */ | |
5243 | DEFUN (neighbor_enforce_first_as, | |
5244 | neighbor_enforce_first_as_cmd, | |
5245 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5246 | NEIGHBOR_STR | |
5247 | NEIGHBOR_ADDR_STR2 | |
5248 | "Enforce the first AS for EBGP routes\n") | |
5249 | { | |
5250 | int idx_peer = 1; | |
5251 | ||
5252 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5253 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5254 | } | |
5255 | ||
5256 | DEFUN (no_neighbor_enforce_first_as, | |
5257 | no_neighbor_enforce_first_as_cmd, | |
5258 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5259 | NO_STR | |
5260 | NEIGHBOR_STR | |
5261 | NEIGHBOR_ADDR_STR2 | |
5262 | "Enforce the first AS for EBGP routes\n") | |
5263 | { | |
5264 | int idx_peer = 2; | |
5265 | ||
5266 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5267 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5268 | } | |
5269 | ||
5270 | ||
718e3744 | 5271 | DEFUN (neighbor_description, |
5272 | neighbor_description_cmd, | |
e961923c | 5273 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5274 | NEIGHBOR_STR |
5275 | NEIGHBOR_ADDR_STR2 | |
5276 | "Neighbor specific description\n" | |
5277 | "Up to 80 characters describing this neighbor\n") | |
5278 | { | |
d62a17ae | 5279 | int idx_peer = 1; |
5280 | int idx_line = 3; | |
5281 | struct peer *peer; | |
5282 | char *str; | |
718e3744 | 5283 | |
d62a17ae | 5284 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5285 | if (!peer) | |
5286 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5287 | |
d62a17ae | 5288 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5289 | |
d62a17ae | 5290 | peer_description_set(peer, str); |
718e3744 | 5291 | |
d62a17ae | 5292 | XFREE(MTYPE_TMP, str); |
718e3744 | 5293 | |
d62a17ae | 5294 | return CMD_SUCCESS; |
718e3744 | 5295 | } |
5296 | ||
5297 | DEFUN (no_neighbor_description, | |
5298 | no_neighbor_description_cmd, | |
a14810f4 | 5299 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5300 | NO_STR |
5301 | NEIGHBOR_STR | |
5302 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5303 | "Neighbor specific description\n") |
718e3744 | 5304 | { |
d62a17ae | 5305 | int idx_peer = 2; |
5306 | struct peer *peer; | |
718e3744 | 5307 | |
d62a17ae | 5308 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5309 | if (!peer) | |
5310 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5311 | |
d62a17ae | 5312 | peer_description_unset(peer); |
718e3744 | 5313 | |
d62a17ae | 5314 | return CMD_SUCCESS; |
718e3744 | 5315 | } |
5316 | ||
a14810f4 PM |
5317 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5318 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5319 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5320 | "Neighbor specific description\n" | |
5321 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5322 | |
718e3744 | 5323 | /* Neighbor update-source. */ |
d62a17ae | 5324 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5325 | const char *source_str) | |
5326 | { | |
5327 | struct peer *peer; | |
5328 | struct prefix p; | |
a14810f4 | 5329 | union sockunion su; |
d62a17ae | 5330 | |
5331 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5332 | if (!peer) | |
5333 | return CMD_WARNING_CONFIG_FAILED; | |
5334 | ||
5335 | if (peer->conf_if) | |
5336 | return CMD_WARNING; | |
5337 | ||
5338 | if (source_str) { | |
a14810f4 | 5339 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5340 | peer_update_source_addr_set(peer, &su); |
5341 | else { | |
5342 | if (str2prefix(source_str, &p)) { | |
5343 | vty_out(vty, | |
5344 | "%% Invalid update-source, remove prefix length \n"); | |
5345 | return CMD_WARNING_CONFIG_FAILED; | |
5346 | } else | |
5347 | peer_update_source_if_set(peer, source_str); | |
5348 | } | |
5349 | } else | |
5350 | peer_update_source_unset(peer); | |
5351 | ||
5352 | return CMD_SUCCESS; | |
5353 | } | |
5354 | ||
5355 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5356 | "IPv4 address\n" \ | |
5357 | "IPv6 address\n" \ | |
5358 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5359 | |
718e3744 | 5360 | DEFUN (neighbor_update_source, |
5361 | neighbor_update_source_cmd, | |
9ccf14f7 | 5362 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5363 | NEIGHBOR_STR |
5364 | NEIGHBOR_ADDR_STR2 | |
5365 | "Source of routing updates\n" | |
369688c0 | 5366 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5367 | { |
d62a17ae | 5368 | int idx_peer = 1; |
5369 | int idx_peer_2 = 3; | |
5370 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5371 | argv[idx_peer_2]->arg); | |
718e3744 | 5372 | } |
5373 | ||
5374 | DEFUN (no_neighbor_update_source, | |
5375 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5376 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5377 | NO_STR |
5378 | NEIGHBOR_STR | |
5379 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5380 | "Source of routing updates\n" |
5381 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5382 | { |
d62a17ae | 5383 | int idx_peer = 2; |
5384 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5385 | } |
6b0655a2 | 5386 | |
d62a17ae | 5387 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5388 | afi_t afi, safi_t safi, | |
5389 | const char *rmap, int set) | |
718e3744 | 5390 | { |
d62a17ae | 5391 | int ret; |
5392 | struct peer *peer; | |
80912664 | 5393 | struct route_map *route_map = NULL; |
718e3744 | 5394 | |
d62a17ae | 5395 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5396 | if (!peer) | |
5397 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5398 | |
1de27621 | 5399 | if (set) { |
80912664 DS |
5400 | if (rmap) |
5401 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5402 | ret = peer_default_originate_set(peer, afi, safi, |
5403 | rmap, route_map); | |
5404 | } else | |
d62a17ae | 5405 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5406 | |
d62a17ae | 5407 | return bgp_vty_return(vty, ret); |
718e3744 | 5408 | } |
5409 | ||
5410 | /* neighbor default-originate. */ | |
5411 | DEFUN (neighbor_default_originate, | |
5412 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5413 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5414 | NEIGHBOR_STR |
5415 | NEIGHBOR_ADDR_STR2 | |
5416 | "Originate default route to this neighbor\n") | |
5417 | { | |
d62a17ae | 5418 | int idx_peer = 1; |
5419 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5420 | bgp_node_afi(vty), | |
5421 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5422 | } |
5423 | ||
d62a17ae | 5424 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5425 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5426 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5427 | "Originate default route to this neighbor\n") | |
596c17ba | 5428 | |
718e3744 | 5429 | DEFUN (neighbor_default_originate_rmap, |
5430 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5431 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5432 | NEIGHBOR_STR |
5433 | NEIGHBOR_ADDR_STR2 | |
5434 | "Originate default route to this neighbor\n" | |
5435 | "Route-map to specify criteria to originate default\n" | |
5436 | "route-map name\n") | |
5437 | { | |
d62a17ae | 5438 | int idx_peer = 1; |
5439 | int idx_word = 4; | |
5440 | return peer_default_originate_set_vty( | |
5441 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5442 | argv[idx_word]->arg, 1); | |
718e3744 | 5443 | } |
5444 | ||
d62a17ae | 5445 | ALIAS_HIDDEN( |
5446 | neighbor_default_originate_rmap, | |
5447 | neighbor_default_originate_rmap_hidden_cmd, | |
5448 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5449 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5450 | "Originate default route to this neighbor\n" | |
5451 | "Route-map to specify criteria to originate default\n" | |
5452 | "route-map name\n") | |
596c17ba | 5453 | |
718e3744 | 5454 | DEFUN (no_neighbor_default_originate, |
5455 | no_neighbor_default_originate_cmd, | |
a636c635 | 5456 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5457 | NO_STR |
5458 | NEIGHBOR_STR | |
5459 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5460 | "Originate default route to this neighbor\n" |
5461 | "Route-map to specify criteria to originate default\n" | |
5462 | "route-map name\n") | |
718e3744 | 5463 | { |
d62a17ae | 5464 | int idx_peer = 2; |
5465 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5466 | bgp_node_afi(vty), | |
5467 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5468 | } |
5469 | ||
d62a17ae | 5470 | ALIAS_HIDDEN( |
5471 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5472 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5473 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5474 | "Originate default route to this neighbor\n" | |
5475 | "Route-map to specify criteria to originate default\n" | |
5476 | "route-map name\n") | |
596c17ba | 5477 | |
6b0655a2 | 5478 | |
718e3744 | 5479 | /* Set neighbor's BGP port. */ |
d62a17ae | 5480 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5481 | const char *port_str) | |
5482 | { | |
5483 | struct peer *peer; | |
d7c0a89a | 5484 | uint16_t port; |
d62a17ae | 5485 | struct servent *sp; |
5486 | ||
5487 | peer = peer_lookup_vty(vty, ip_str); | |
5488 | if (!peer) | |
5489 | return CMD_WARNING_CONFIG_FAILED; | |
5490 | ||
5491 | if (!port_str) { | |
5492 | sp = getservbyname("bgp", "tcp"); | |
5493 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5494 | } else { | |
5495 | port = strtoul(port_str, NULL, 10); | |
5496 | } | |
718e3744 | 5497 | |
d62a17ae | 5498 | peer_port_set(peer, port); |
718e3744 | 5499 | |
d62a17ae | 5500 | return CMD_SUCCESS; |
718e3744 | 5501 | } |
5502 | ||
f418446b | 5503 | /* Set specified peer's BGP port. */ |
718e3744 | 5504 | DEFUN (neighbor_port, |
5505 | neighbor_port_cmd, | |
9ccf14f7 | 5506 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5507 | NEIGHBOR_STR |
5508 | NEIGHBOR_ADDR_STR | |
5509 | "Neighbor's BGP port\n" | |
5510 | "TCP port number\n") | |
5511 | { | |
d62a17ae | 5512 | int idx_ip = 1; |
5513 | int idx_number = 3; | |
5514 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5515 | argv[idx_number]->arg); | |
718e3744 | 5516 | } |
5517 | ||
5518 | DEFUN (no_neighbor_port, | |
5519 | no_neighbor_port_cmd, | |
9ccf14f7 | 5520 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5521 | NO_STR |
5522 | NEIGHBOR_STR | |
5523 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5524 | "Neighbor's BGP port\n" |
5525 | "TCP port number\n") | |
718e3744 | 5526 | { |
d62a17ae | 5527 | int idx_ip = 2; |
5528 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5529 | } |
5530 | ||
6b0655a2 | 5531 | |
718e3744 | 5532 | /* neighbor weight. */ |
d62a17ae | 5533 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5534 | safi_t safi, const char *weight_str) | |
718e3744 | 5535 | { |
d62a17ae | 5536 | int ret; |
5537 | struct peer *peer; | |
5538 | unsigned long weight; | |
718e3744 | 5539 | |
d62a17ae | 5540 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5541 | if (!peer) | |
5542 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5543 | |
d62a17ae | 5544 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5545 | |
d62a17ae | 5546 | ret = peer_weight_set(peer, afi, safi, weight); |
5547 | return bgp_vty_return(vty, ret); | |
718e3744 | 5548 | } |
5549 | ||
d62a17ae | 5550 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5551 | safi_t safi) | |
718e3744 | 5552 | { |
d62a17ae | 5553 | int ret; |
5554 | struct peer *peer; | |
718e3744 | 5555 | |
d62a17ae | 5556 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5557 | if (!peer) | |
5558 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5559 | |
d62a17ae | 5560 | ret = peer_weight_unset(peer, afi, safi); |
5561 | return bgp_vty_return(vty, ret); | |
718e3744 | 5562 | } |
5563 | ||
5564 | DEFUN (neighbor_weight, | |
5565 | neighbor_weight_cmd, | |
9ccf14f7 | 5566 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5567 | NEIGHBOR_STR |
5568 | NEIGHBOR_ADDR_STR2 | |
5569 | "Set default weight for routes from this neighbor\n" | |
5570 | "default weight\n") | |
5571 | { | |
d62a17ae | 5572 | int idx_peer = 1; |
5573 | int idx_number = 3; | |
5574 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5575 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5576 | } |
5577 | ||
d62a17ae | 5578 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5579 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5580 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5581 | "Set default weight for routes from this neighbor\n" | |
5582 | "default weight\n") | |
596c17ba | 5583 | |
718e3744 | 5584 | DEFUN (no_neighbor_weight, |
5585 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5586 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5587 | NO_STR |
5588 | NEIGHBOR_STR | |
5589 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5590 | "Set default weight for routes from this neighbor\n" |
5591 | "default weight\n") | |
718e3744 | 5592 | { |
d62a17ae | 5593 | int idx_peer = 2; |
5594 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5595 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5596 | } |
5597 | ||
d62a17ae | 5598 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5599 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5600 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5601 | "Set default weight for routes from this neighbor\n" | |
5602 | "default weight\n") | |
596c17ba | 5603 | |
6b0655a2 | 5604 | |
718e3744 | 5605 | /* Override capability negotiation. */ |
5606 | DEFUN (neighbor_override_capability, | |
5607 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5608 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5609 | NEIGHBOR_STR |
5610 | NEIGHBOR_ADDR_STR2 | |
5611 | "Override capability negotiation result\n") | |
5612 | { | |
d62a17ae | 5613 | int idx_peer = 1; |
5614 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5615 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5616 | } |
5617 | ||
5618 | DEFUN (no_neighbor_override_capability, | |
5619 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5620 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5621 | NO_STR |
5622 | NEIGHBOR_STR | |
5623 | NEIGHBOR_ADDR_STR2 | |
5624 | "Override capability negotiation result\n") | |
5625 | { | |
d62a17ae | 5626 | int idx_peer = 2; |
5627 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5628 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5629 | } |
6b0655a2 | 5630 | |
718e3744 | 5631 | DEFUN (neighbor_strict_capability, |
5632 | neighbor_strict_capability_cmd, | |
9fb964de | 5633 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5634 | NEIGHBOR_STR |
9fb964de | 5635 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5636 | "Strict capability negotiation match\n") |
5637 | { | |
9fb964de PM |
5638 | int idx_peer = 1; |
5639 | ||
5640 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5641 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5642 | } |
5643 | ||
5644 | DEFUN (no_neighbor_strict_capability, | |
5645 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5646 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5647 | NO_STR |
5648 | NEIGHBOR_STR | |
9fb964de | 5649 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5650 | "Strict capability negotiation match\n") |
5651 | { | |
9fb964de PM |
5652 | int idx_peer = 2; |
5653 | ||
5654 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5655 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5656 | } |
6b0655a2 | 5657 | |
d62a17ae | 5658 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5659 | const char *keep_str, const char *hold_str) | |
718e3744 | 5660 | { |
d62a17ae | 5661 | int ret; |
5662 | struct peer *peer; | |
d7c0a89a QY |
5663 | uint32_t keepalive; |
5664 | uint32_t holdtime; | |
718e3744 | 5665 | |
d62a17ae | 5666 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5667 | if (!peer) | |
5668 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5669 | |
d62a17ae | 5670 | keepalive = strtoul(keep_str, NULL, 10); |
5671 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5672 | |
d62a17ae | 5673 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5674 | |
d62a17ae | 5675 | return bgp_vty_return(vty, ret); |
718e3744 | 5676 | } |
6b0655a2 | 5677 | |
d62a17ae | 5678 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5679 | { |
d62a17ae | 5680 | int ret; |
5681 | struct peer *peer; | |
718e3744 | 5682 | |
d62a17ae | 5683 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5684 | if (!peer) | |
5685 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5686 | |
d62a17ae | 5687 | ret = peer_timers_unset(peer); |
718e3744 | 5688 | |
d62a17ae | 5689 | return bgp_vty_return(vty, ret); |
718e3744 | 5690 | } |
5691 | ||
5692 | DEFUN (neighbor_timers, | |
5693 | neighbor_timers_cmd, | |
9ccf14f7 | 5694 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5695 | NEIGHBOR_STR |
5696 | NEIGHBOR_ADDR_STR2 | |
5697 | "BGP per neighbor timers\n" | |
5698 | "Keepalive interval\n" | |
5699 | "Holdtime\n") | |
5700 | { | |
d62a17ae | 5701 | int idx_peer = 1; |
5702 | int idx_number = 3; | |
5703 | int idx_number_2 = 4; | |
5704 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5705 | argv[idx_number]->arg, | |
5706 | argv[idx_number_2]->arg); | |
718e3744 | 5707 | } |
5708 | ||
5709 | DEFUN (no_neighbor_timers, | |
5710 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5711 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5712 | NO_STR |
5713 | NEIGHBOR_STR | |
5714 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5715 | "BGP per neighbor timers\n" |
5716 | "Keepalive interval\n" | |
5717 | "Holdtime\n") | |
718e3744 | 5718 | { |
d62a17ae | 5719 | int idx_peer = 2; |
5720 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5721 | } |
6b0655a2 | 5722 | |
813d4307 | 5723 | |
d62a17ae | 5724 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5725 | const char *time_str) | |
718e3744 | 5726 | { |
d62a17ae | 5727 | int ret; |
5728 | struct peer *peer; | |
d7c0a89a | 5729 | uint32_t connect; |
718e3744 | 5730 | |
d62a17ae | 5731 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5732 | if (!peer) | |
5733 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5734 | |
d62a17ae | 5735 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5736 | |
d62a17ae | 5737 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5738 | |
d62a17ae | 5739 | return bgp_vty_return(vty, ret); |
718e3744 | 5740 | } |
5741 | ||
d62a17ae | 5742 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5743 | { |
d62a17ae | 5744 | int ret; |
5745 | struct peer *peer; | |
718e3744 | 5746 | |
d62a17ae | 5747 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5748 | if (!peer) | |
5749 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5750 | |
d62a17ae | 5751 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5752 | |
d62a17ae | 5753 | return bgp_vty_return(vty, ret); |
718e3744 | 5754 | } |
5755 | ||
5756 | DEFUN (neighbor_timers_connect, | |
5757 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5758 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5759 | NEIGHBOR_STR |
966f821c | 5760 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5761 | "BGP per neighbor timers\n" |
5762 | "BGP connect timer\n" | |
5763 | "Connect timer\n") | |
5764 | { | |
d62a17ae | 5765 | int idx_peer = 1; |
5766 | int idx_number = 4; | |
5767 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5768 | argv[idx_number]->arg); | |
718e3744 | 5769 | } |
5770 | ||
5771 | DEFUN (no_neighbor_timers_connect, | |
5772 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5773 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5774 | NO_STR |
5775 | NEIGHBOR_STR | |
966f821c | 5776 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5777 | "BGP per neighbor timers\n" |
8334fd5a DW |
5778 | "BGP connect timer\n" |
5779 | "Connect timer\n") | |
718e3744 | 5780 | { |
d62a17ae | 5781 | int idx_peer = 2; |
5782 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5783 | } |
5784 | ||
6b0655a2 | 5785 | |
d62a17ae | 5786 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5787 | const char *time_str, int set) | |
718e3744 | 5788 | { |
d62a17ae | 5789 | int ret; |
5790 | struct peer *peer; | |
d7c0a89a | 5791 | uint32_t routeadv = 0; |
718e3744 | 5792 | |
d62a17ae | 5793 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5794 | if (!peer) | |
5795 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5796 | |
d62a17ae | 5797 | if (time_str) |
5798 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5799 | |
d62a17ae | 5800 | if (set) |
5801 | ret = peer_advertise_interval_set(peer, routeadv); | |
5802 | else | |
5803 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5804 | |
d62a17ae | 5805 | return bgp_vty_return(vty, ret); |
718e3744 | 5806 | } |
5807 | ||
5808 | DEFUN (neighbor_advertise_interval, | |
5809 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5810 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5811 | NEIGHBOR_STR |
966f821c | 5812 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5813 | "Minimum interval between sending BGP routing updates\n" |
5814 | "time in seconds\n") | |
5815 | { | |
d62a17ae | 5816 | int idx_peer = 1; |
5817 | int idx_number = 3; | |
5818 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5819 | argv[idx_number]->arg, 1); | |
718e3744 | 5820 | } |
5821 | ||
5822 | DEFUN (no_neighbor_advertise_interval, | |
5823 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5824 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5825 | NO_STR |
5826 | NEIGHBOR_STR | |
966f821c | 5827 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5828 | "Minimum interval between sending BGP routing updates\n" |
5829 | "time in seconds\n") | |
718e3744 | 5830 | { |
d62a17ae | 5831 | int idx_peer = 2; |
5832 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5833 | } |
5834 | ||
6b0655a2 | 5835 | |
518f0eb1 DS |
5836 | /* Time to wait before processing route-map updates */ |
5837 | DEFUN (bgp_set_route_map_delay_timer, | |
5838 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5839 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5840 | SET_STR |
5841 | "BGP route-map delay timer\n" | |
5842 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5843 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5844 | { |
d62a17ae | 5845 | int idx_number = 3; |
d7c0a89a | 5846 | uint32_t rmap_delay_timer; |
d62a17ae | 5847 | |
5848 | if (argv[idx_number]->arg) { | |
5849 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5850 | bm->rmap_update_timer = rmap_delay_timer; | |
5851 | ||
5852 | /* if the dynamic update handling is being disabled, and a timer | |
5853 | * is | |
5854 | * running, stop the timer and act as if the timer has already | |
5855 | * fired. | |
5856 | */ | |
5857 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5858 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5859 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5860 | NULL, 0); | |
5861 | } | |
5862 | return CMD_SUCCESS; | |
5863 | } else { | |
5864 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5865 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5866 | } |
518f0eb1 DS |
5867 | } |
5868 | ||
5869 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5870 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5871 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5872 | NO_STR |
3a2d747c | 5873 | BGP_STR |
518f0eb1 | 5874 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5875 | "Reset to default time to wait for processing route-map changes\n" |
5876 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5877 | { |
518f0eb1 | 5878 | |
d62a17ae | 5879 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5880 | |
d62a17ae | 5881 | return CMD_SUCCESS; |
518f0eb1 DS |
5882 | } |
5883 | ||
f414725f | 5884 | |
718e3744 | 5885 | /* neighbor interface */ |
d62a17ae | 5886 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5887 | const char *str) | |
718e3744 | 5888 | { |
d62a17ae | 5889 | struct peer *peer; |
718e3744 | 5890 | |
d62a17ae | 5891 | peer = peer_lookup_vty(vty, ip_str); |
5892 | if (!peer || peer->conf_if) { | |
5893 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5894 | return CMD_WARNING_CONFIG_FAILED; | |
5895 | } | |
718e3744 | 5896 | |
d62a17ae | 5897 | if (str) |
5898 | peer_interface_set(peer, str); | |
5899 | else | |
5900 | peer_interface_unset(peer); | |
718e3744 | 5901 | |
d62a17ae | 5902 | return CMD_SUCCESS; |
718e3744 | 5903 | } |
5904 | ||
5905 | DEFUN (neighbor_interface, | |
5906 | neighbor_interface_cmd, | |
9ccf14f7 | 5907 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5908 | NEIGHBOR_STR |
5909 | NEIGHBOR_ADDR_STR | |
5910 | "Interface\n" | |
5911 | "Interface name\n") | |
5912 | { | |
d62a17ae | 5913 | int idx_ip = 1; |
5914 | int idx_word = 3; | |
5915 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5916 | } |
5917 | ||
5918 | DEFUN (no_neighbor_interface, | |
5919 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5920 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5921 | NO_STR |
5922 | NEIGHBOR_STR | |
16cedbb0 | 5923 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5924 | "Interface\n" |
5925 | "Interface name\n") | |
5926 | { | |
d62a17ae | 5927 | int idx_peer = 2; |
5928 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5929 | } |
6b0655a2 | 5930 | |
718e3744 | 5931 | DEFUN (neighbor_distribute_list, |
5932 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5933 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5934 | NEIGHBOR_STR |
5935 | NEIGHBOR_ADDR_STR2 | |
5936 | "Filter updates to/from this neighbor\n" | |
5937 | "IP access-list number\n" | |
5938 | "IP access-list number (expanded range)\n" | |
5939 | "IP Access-list name\n" | |
5940 | "Filter incoming updates\n" | |
5941 | "Filter outgoing updates\n") | |
5942 | { | |
d62a17ae | 5943 | int idx_peer = 1; |
5944 | int idx_acl = 3; | |
5945 | int direct, ret; | |
5946 | struct peer *peer; | |
a8206004 | 5947 | |
d62a17ae | 5948 | const char *pstr = argv[idx_peer]->arg; |
5949 | const char *acl = argv[idx_acl]->arg; | |
5950 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5951 | |
d62a17ae | 5952 | peer = peer_and_group_lookup_vty(vty, pstr); |
5953 | if (!peer) | |
5954 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5955 | |
d62a17ae | 5956 | /* Check filter direction. */ |
5957 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5958 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5959 | direct, acl); | |
a8206004 | 5960 | |
d62a17ae | 5961 | return bgp_vty_return(vty, ret); |
718e3744 | 5962 | } |
5963 | ||
d62a17ae | 5964 | ALIAS_HIDDEN( |
5965 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5966 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5967 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5968 | "Filter updates to/from this neighbor\n" | |
5969 | "IP access-list number\n" | |
5970 | "IP access-list number (expanded range)\n" | |
5971 | "IP Access-list name\n" | |
5972 | "Filter incoming updates\n" | |
5973 | "Filter outgoing updates\n") | |
596c17ba | 5974 | |
718e3744 | 5975 | DEFUN (no_neighbor_distribute_list, |
5976 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5977 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5978 | NO_STR |
5979 | NEIGHBOR_STR | |
5980 | NEIGHBOR_ADDR_STR2 | |
5981 | "Filter updates to/from this neighbor\n" | |
5982 | "IP access-list number\n" | |
5983 | "IP access-list number (expanded range)\n" | |
5984 | "IP Access-list name\n" | |
5985 | "Filter incoming updates\n" | |
5986 | "Filter outgoing updates\n") | |
5987 | { | |
d62a17ae | 5988 | int idx_peer = 2; |
5989 | int direct, ret; | |
5990 | struct peer *peer; | |
a8206004 | 5991 | |
d62a17ae | 5992 | const char *pstr = argv[idx_peer]->arg; |
5993 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5994 | |
d62a17ae | 5995 | peer = peer_and_group_lookup_vty(vty, pstr); |
5996 | if (!peer) | |
5997 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5998 | |
d62a17ae | 5999 | /* Check filter direction. */ |
6000 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6001 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6002 | direct); | |
a8206004 | 6003 | |
d62a17ae | 6004 | return bgp_vty_return(vty, ret); |
718e3744 | 6005 | } |
6b0655a2 | 6006 | |
d62a17ae | 6007 | ALIAS_HIDDEN( |
6008 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6009 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6010 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6011 | "Filter updates to/from this neighbor\n" | |
6012 | "IP access-list number\n" | |
6013 | "IP access-list number (expanded range)\n" | |
6014 | "IP Access-list name\n" | |
6015 | "Filter incoming updates\n" | |
6016 | "Filter outgoing updates\n") | |
596c17ba | 6017 | |
718e3744 | 6018 | /* Set prefix list to the peer. */ |
d62a17ae | 6019 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6020 | afi_t afi, safi_t safi, | |
6021 | const char *name_str, | |
6022 | const char *direct_str) | |
718e3744 | 6023 | { |
d62a17ae | 6024 | int ret; |
d62a17ae | 6025 | int direct = FILTER_IN; |
cf9ac8bf | 6026 | struct peer *peer; |
718e3744 | 6027 | |
d62a17ae | 6028 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6029 | if (!peer) | |
6030 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6031 | |
d62a17ae | 6032 | /* Check filter direction. */ |
6033 | if (strncmp(direct_str, "i", 1) == 0) | |
6034 | direct = FILTER_IN; | |
6035 | else if (strncmp(direct_str, "o", 1) == 0) | |
6036 | direct = FILTER_OUT; | |
718e3744 | 6037 | |
d62a17ae | 6038 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6039 | |
d62a17ae | 6040 | return bgp_vty_return(vty, ret); |
718e3744 | 6041 | } |
6042 | ||
d62a17ae | 6043 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6044 | afi_t afi, safi_t safi, | |
6045 | const char *direct_str) | |
718e3744 | 6046 | { |
d62a17ae | 6047 | int ret; |
6048 | struct peer *peer; | |
6049 | int direct = FILTER_IN; | |
718e3744 | 6050 | |
d62a17ae | 6051 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6052 | if (!peer) | |
6053 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6054 | |
d62a17ae | 6055 | /* Check filter direction. */ |
6056 | if (strncmp(direct_str, "i", 1) == 0) | |
6057 | direct = FILTER_IN; | |
6058 | else if (strncmp(direct_str, "o", 1) == 0) | |
6059 | direct = FILTER_OUT; | |
718e3744 | 6060 | |
d62a17ae | 6061 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6062 | |
d62a17ae | 6063 | return bgp_vty_return(vty, ret); |
718e3744 | 6064 | } |
6065 | ||
6066 | DEFUN (neighbor_prefix_list, | |
6067 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6068 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6069 | NEIGHBOR_STR |
6070 | NEIGHBOR_ADDR_STR2 | |
6071 | "Filter updates to/from this neighbor\n" | |
6072 | "Name of a prefix list\n" | |
6073 | "Filter incoming updates\n" | |
6074 | "Filter outgoing updates\n") | |
6075 | { | |
d62a17ae | 6076 | int idx_peer = 1; |
6077 | int idx_word = 3; | |
6078 | int idx_in_out = 4; | |
6079 | return peer_prefix_list_set_vty( | |
6080 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6081 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6082 | } |
6083 | ||
d62a17ae | 6084 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6085 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6086 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6087 | "Filter updates to/from this neighbor\n" | |
6088 | "Name of a prefix list\n" | |
6089 | "Filter incoming updates\n" | |
6090 | "Filter outgoing updates\n") | |
596c17ba | 6091 | |
718e3744 | 6092 | DEFUN (no_neighbor_prefix_list, |
6093 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6095 | NO_STR |
6096 | NEIGHBOR_STR | |
6097 | NEIGHBOR_ADDR_STR2 | |
6098 | "Filter updates to/from this neighbor\n" | |
6099 | "Name of a prefix list\n" | |
6100 | "Filter incoming updates\n" | |
6101 | "Filter outgoing updates\n") | |
6102 | { | |
d62a17ae | 6103 | int idx_peer = 2; |
6104 | int idx_in_out = 5; | |
6105 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6106 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6107 | argv[idx_in_out]->arg); | |
718e3744 | 6108 | } |
6b0655a2 | 6109 | |
d62a17ae | 6110 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6112 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6113 | "Filter updates to/from this neighbor\n" | |
6114 | "Name of a prefix list\n" | |
6115 | "Filter incoming updates\n" | |
6116 | "Filter outgoing updates\n") | |
596c17ba | 6117 | |
d62a17ae | 6118 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6119 | safi_t safi, const char *name_str, | |
6120 | const char *direct_str) | |
718e3744 | 6121 | { |
d62a17ae | 6122 | int ret; |
6123 | struct peer *peer; | |
6124 | int direct = FILTER_IN; | |
718e3744 | 6125 | |
d62a17ae | 6126 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6127 | if (!peer) | |
6128 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6129 | |
d62a17ae | 6130 | /* Check filter direction. */ |
6131 | if (strncmp(direct_str, "i", 1) == 0) | |
6132 | direct = FILTER_IN; | |
6133 | else if (strncmp(direct_str, "o", 1) == 0) | |
6134 | direct = FILTER_OUT; | |
718e3744 | 6135 | |
d62a17ae | 6136 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6137 | |
d62a17ae | 6138 | return bgp_vty_return(vty, ret); |
718e3744 | 6139 | } |
6140 | ||
d62a17ae | 6141 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6142 | safi_t safi, const char *direct_str) | |
718e3744 | 6143 | { |
d62a17ae | 6144 | int ret; |
6145 | struct peer *peer; | |
6146 | int direct = FILTER_IN; | |
718e3744 | 6147 | |
d62a17ae | 6148 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6149 | if (!peer) | |
6150 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6151 | |
d62a17ae | 6152 | /* Check filter direction. */ |
6153 | if (strncmp(direct_str, "i", 1) == 0) | |
6154 | direct = FILTER_IN; | |
6155 | else if (strncmp(direct_str, "o", 1) == 0) | |
6156 | direct = FILTER_OUT; | |
718e3744 | 6157 | |
d62a17ae | 6158 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6159 | |
d62a17ae | 6160 | return bgp_vty_return(vty, ret); |
718e3744 | 6161 | } |
6162 | ||
6163 | DEFUN (neighbor_filter_list, | |
6164 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6165 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6166 | NEIGHBOR_STR |
6167 | NEIGHBOR_ADDR_STR2 | |
6168 | "Establish BGP filters\n" | |
6169 | "AS path access-list name\n" | |
6170 | "Filter incoming routes\n" | |
6171 | "Filter outgoing routes\n") | |
6172 | { | |
d62a17ae | 6173 | int idx_peer = 1; |
6174 | int idx_word = 3; | |
6175 | int idx_in_out = 4; | |
6176 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6177 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6178 | argv[idx_in_out]->arg); | |
718e3744 | 6179 | } |
6180 | ||
d62a17ae | 6181 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6182 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6183 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6184 | "Establish BGP filters\n" | |
6185 | "AS path access-list name\n" | |
6186 | "Filter incoming routes\n" | |
6187 | "Filter outgoing routes\n") | |
596c17ba | 6188 | |
718e3744 | 6189 | DEFUN (no_neighbor_filter_list, |
6190 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6191 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6192 | NO_STR |
6193 | NEIGHBOR_STR | |
6194 | NEIGHBOR_ADDR_STR2 | |
6195 | "Establish BGP filters\n" | |
6196 | "AS path access-list name\n" | |
6197 | "Filter incoming routes\n" | |
6198 | "Filter outgoing routes\n") | |
6199 | { | |
d62a17ae | 6200 | int idx_peer = 2; |
6201 | int idx_in_out = 5; | |
6202 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6203 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6204 | argv[idx_in_out]->arg); | |
718e3744 | 6205 | } |
6b0655a2 | 6206 | |
d62a17ae | 6207 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6208 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6209 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6210 | "Establish BGP filters\n" | |
6211 | "AS path access-list name\n" | |
6212 | "Filter incoming routes\n" | |
6213 | "Filter outgoing routes\n") | |
596c17ba | 6214 | |
718e3744 | 6215 | /* Set route-map to the peer. */ |
d62a17ae | 6216 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6217 | afi_t afi, safi_t safi, const char *name_str, | |
6218 | const char *direct_str) | |
718e3744 | 6219 | { |
d62a17ae | 6220 | int ret; |
6221 | struct peer *peer; | |
6222 | int direct = RMAP_IN; | |
1de27621 | 6223 | struct route_map *route_map; |
718e3744 | 6224 | |
d62a17ae | 6225 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6226 | if (!peer) | |
6227 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6228 | |
d62a17ae | 6229 | /* Check filter direction. */ |
6230 | if (strncmp(direct_str, "in", 2) == 0) | |
6231 | direct = RMAP_IN; | |
6232 | else if (strncmp(direct_str, "o", 1) == 0) | |
6233 | direct = RMAP_OUT; | |
718e3744 | 6234 | |
1de27621 DA |
6235 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6236 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6237 | |
d62a17ae | 6238 | return bgp_vty_return(vty, ret); |
718e3744 | 6239 | } |
6240 | ||
d62a17ae | 6241 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6242 | afi_t afi, safi_t safi, | |
6243 | const char *direct_str) | |
718e3744 | 6244 | { |
d62a17ae | 6245 | int ret; |
6246 | struct peer *peer; | |
6247 | int direct = RMAP_IN; | |
718e3744 | 6248 | |
d62a17ae | 6249 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6250 | if (!peer) | |
6251 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6252 | |
d62a17ae | 6253 | /* Check filter direction. */ |
6254 | if (strncmp(direct_str, "in", 2) == 0) | |
6255 | direct = RMAP_IN; | |
6256 | else if (strncmp(direct_str, "o", 1) == 0) | |
6257 | direct = RMAP_OUT; | |
718e3744 | 6258 | |
d62a17ae | 6259 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6260 | |
d62a17ae | 6261 | return bgp_vty_return(vty, ret); |
718e3744 | 6262 | } |
6263 | ||
6264 | DEFUN (neighbor_route_map, | |
6265 | neighbor_route_map_cmd, | |
9ccf14f7 | 6266 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6267 | NEIGHBOR_STR |
6268 | NEIGHBOR_ADDR_STR2 | |
6269 | "Apply route map to neighbor\n" | |
6270 | "Name of route map\n" | |
6271 | "Apply map to incoming routes\n" | |
2a3d5731 | 6272 | "Apply map to outbound routes\n") |
718e3744 | 6273 | { |
d62a17ae | 6274 | int idx_peer = 1; |
6275 | int idx_word = 3; | |
6276 | int idx_in_out = 4; | |
6277 | return peer_route_map_set_vty( | |
6278 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6279 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6280 | } |
6281 | ||
d62a17ae | 6282 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6283 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6284 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6285 | "Apply route map to neighbor\n" | |
6286 | "Name of route map\n" | |
6287 | "Apply map to incoming routes\n" | |
6288 | "Apply map to outbound routes\n") | |
596c17ba | 6289 | |
718e3744 | 6290 | DEFUN (no_neighbor_route_map, |
6291 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6292 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6293 | NO_STR |
6294 | NEIGHBOR_STR | |
6295 | NEIGHBOR_ADDR_STR2 | |
6296 | "Apply route map to neighbor\n" | |
6297 | "Name of route map\n" | |
6298 | "Apply map to incoming routes\n" | |
2a3d5731 | 6299 | "Apply map to outbound routes\n") |
718e3744 | 6300 | { |
d62a17ae | 6301 | int idx_peer = 2; |
6302 | int idx_in_out = 5; | |
6303 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6304 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6305 | argv[idx_in_out]->arg); | |
718e3744 | 6306 | } |
6b0655a2 | 6307 | |
d62a17ae | 6308 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6309 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6310 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6311 | "Apply route map to neighbor\n" | |
6312 | "Name of route map\n" | |
6313 | "Apply map to incoming routes\n" | |
6314 | "Apply map to outbound routes\n") | |
596c17ba | 6315 | |
718e3744 | 6316 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6317 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6318 | afi_t afi, safi_t safi, | |
6319 | const char *name_str) | |
718e3744 | 6320 | { |
d62a17ae | 6321 | int ret; |
6322 | struct peer *peer; | |
1de27621 | 6323 | struct route_map *route_map; |
718e3744 | 6324 | |
d62a17ae | 6325 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6326 | if (!peer) | |
6327 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6328 | |
1de27621 DA |
6329 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6330 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6331 | |
d62a17ae | 6332 | return bgp_vty_return(vty, ret); |
718e3744 | 6333 | } |
6334 | ||
6335 | /* Unset route-map from the peer. */ | |
d62a17ae | 6336 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6337 | afi_t afi, safi_t safi) | |
718e3744 | 6338 | { |
d62a17ae | 6339 | int ret; |
6340 | struct peer *peer; | |
718e3744 | 6341 | |
d62a17ae | 6342 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6343 | if (!peer) | |
6344 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6345 | |
d62a17ae | 6346 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6347 | |
d62a17ae | 6348 | return bgp_vty_return(vty, ret); |
718e3744 | 6349 | } |
6350 | ||
6351 | DEFUN (neighbor_unsuppress_map, | |
6352 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6353 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6354 | NEIGHBOR_STR |
6355 | NEIGHBOR_ADDR_STR2 | |
6356 | "Route-map to selectively unsuppress suppressed routes\n" | |
6357 | "Name of route map\n") | |
6358 | { | |
d62a17ae | 6359 | int idx_peer = 1; |
6360 | int idx_word = 3; | |
6361 | return peer_unsuppress_map_set_vty( | |
6362 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6363 | argv[idx_word]->arg); | |
718e3744 | 6364 | } |
6365 | ||
d62a17ae | 6366 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6367 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6368 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6369 | "Route-map to selectively unsuppress suppressed routes\n" | |
6370 | "Name of route map\n") | |
596c17ba | 6371 | |
718e3744 | 6372 | DEFUN (no_neighbor_unsuppress_map, |
6373 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6374 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6375 | NO_STR |
6376 | NEIGHBOR_STR | |
6377 | NEIGHBOR_ADDR_STR2 | |
6378 | "Route-map to selectively unsuppress suppressed routes\n" | |
6379 | "Name of route map\n") | |
6380 | { | |
d62a17ae | 6381 | int idx_peer = 2; |
6382 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6383 | bgp_node_afi(vty), | |
6384 | bgp_node_safi(vty)); | |
718e3744 | 6385 | } |
6b0655a2 | 6386 | |
d62a17ae | 6387 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6389 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6390 | "Route-map to selectively unsuppress suppressed routes\n" | |
6391 | "Name of route map\n") | |
596c17ba | 6392 | |
d62a17ae | 6393 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6394 | afi_t afi, safi_t safi, | |
6395 | const char *num_str, | |
6396 | const char *threshold_str, int warning, | |
6397 | const char *restart_str) | |
718e3744 | 6398 | { |
d62a17ae | 6399 | int ret; |
6400 | struct peer *peer; | |
d7c0a89a QY |
6401 | uint32_t max; |
6402 | uint8_t threshold; | |
6403 | uint16_t restart; | |
718e3744 | 6404 | |
d62a17ae | 6405 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6406 | if (!peer) | |
6407 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6408 | |
d62a17ae | 6409 | max = strtoul(num_str, NULL, 10); |
6410 | if (threshold_str) | |
6411 | threshold = atoi(threshold_str); | |
6412 | else | |
6413 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6414 | |
d62a17ae | 6415 | if (restart_str) |
6416 | restart = atoi(restart_str); | |
6417 | else | |
6418 | restart = 0; | |
0a486e5f | 6419 | |
d62a17ae | 6420 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6421 | restart); | |
718e3744 | 6422 | |
d62a17ae | 6423 | return bgp_vty_return(vty, ret); |
718e3744 | 6424 | } |
6425 | ||
d62a17ae | 6426 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6427 | afi_t afi, safi_t safi) | |
718e3744 | 6428 | { |
d62a17ae | 6429 | int ret; |
6430 | struct peer *peer; | |
718e3744 | 6431 | |
d62a17ae | 6432 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6433 | if (!peer) | |
6434 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6435 | |
d62a17ae | 6436 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6437 | |
d62a17ae | 6438 | return bgp_vty_return(vty, ret); |
718e3744 | 6439 | } |
6440 | ||
fde246e8 DA |
6441 | /* Maximum number of prefix to be sent to the neighbor. */ |
6442 | DEFUN(neighbor_maximum_prefix_out, | |
6443 | neighbor_maximum_prefix_out_cmd, | |
6444 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6445 | NEIGHBOR_STR | |
6446 | NEIGHBOR_ADDR_STR2 | |
6447 | "Maximum number of prefixes to be sent to this peer\n" | |
6448 | "Maximum no. of prefix limit\n") | |
6449 | { | |
6450 | int idx_peer = 1; | |
6451 | int idx_number = 3; | |
6452 | struct peer *peer; | |
6453 | uint32_t max; | |
6454 | afi_t afi = bgp_node_afi(vty); | |
6455 | safi_t safi = bgp_node_safi(vty); | |
6456 | ||
6457 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6458 | if (!peer) | |
6459 | return CMD_WARNING_CONFIG_FAILED; | |
6460 | ||
6461 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6462 | ||
6463 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6464 | peer->pmax_out[afi][safi] = max; | |
6465 | ||
6466 | return CMD_SUCCESS; | |
6467 | } | |
6468 | ||
6469 | DEFUN(no_neighbor_maximum_prefix_out, | |
6470 | no_neighbor_maximum_prefix_out_cmd, | |
6471 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6472 | NO_STR | |
6473 | NEIGHBOR_STR | |
6474 | NEIGHBOR_ADDR_STR2 | |
6475 | "Maximum number of prefixes to be sent to this peer\n") | |
6476 | { | |
6477 | int idx_peer = 2; | |
6478 | struct peer *peer; | |
6479 | afi_t afi = bgp_node_afi(vty); | |
6480 | safi_t safi = bgp_node_safi(vty); | |
6481 | ||
6482 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6483 | if (!peer) | |
6484 | return CMD_WARNING_CONFIG_FAILED; | |
6485 | ||
6486 | peer->pmax_out[afi][safi] = 0; | |
6487 | ||
6488 | return CMD_SUCCESS; | |
6489 | } | |
6490 | ||
718e3744 | 6491 | /* Maximum number of prefix configuration. prefix count is different |
6492 | for each peer configuration. So this configuration can be set for | |
6493 | each peer configuration. */ | |
6494 | DEFUN (neighbor_maximum_prefix, | |
6495 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6496 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6497 | NEIGHBOR_STR |
6498 | NEIGHBOR_ADDR_STR2 | |
6499 | "Maximum number of prefix accept from this peer\n" | |
6500 | "maximum no. of prefix limit\n") | |
6501 | { | |
d62a17ae | 6502 | int idx_peer = 1; |
6503 | int idx_number = 3; | |
6504 | return peer_maximum_prefix_set_vty( | |
6505 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6506 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6507 | } |
6508 | ||
d62a17ae | 6509 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6510 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6511 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6512 | "Maximum number of prefix accept from this peer\n" | |
6513 | "maximum no. of prefix limit\n") | |
596c17ba | 6514 | |
e0701b79 | 6515 | DEFUN (neighbor_maximum_prefix_threshold, |
6516 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6517 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6518 | NEIGHBOR_STR |
6519 | NEIGHBOR_ADDR_STR2 | |
6520 | "Maximum number of prefix accept from this peer\n" | |
6521 | "maximum no. of prefix limit\n" | |
6522 | "Threshold value (%) at which to generate a warning msg\n") | |
6523 | { | |
d62a17ae | 6524 | int idx_peer = 1; |
6525 | int idx_number = 3; | |
6526 | int idx_number_2 = 4; | |
6527 | return peer_maximum_prefix_set_vty( | |
6528 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6529 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6530 | } |
e0701b79 | 6531 | |
d62a17ae | 6532 | ALIAS_HIDDEN( |
6533 | neighbor_maximum_prefix_threshold, | |
6534 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6535 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6536 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6537 | "Maximum number of prefix accept from this peer\n" | |
6538 | "maximum no. of prefix limit\n" | |
6539 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6540 | |
718e3744 | 6541 | DEFUN (neighbor_maximum_prefix_warning, |
6542 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6543 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6544 | NEIGHBOR_STR |
6545 | NEIGHBOR_ADDR_STR2 | |
6546 | "Maximum number of prefix accept from this peer\n" | |
6547 | "maximum no. of prefix limit\n" | |
6548 | "Only give warning message when limit is exceeded\n") | |
6549 | { | |
d62a17ae | 6550 | int idx_peer = 1; |
6551 | int idx_number = 3; | |
6552 | return peer_maximum_prefix_set_vty( | |
6553 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6554 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6555 | } |
6556 | ||
d62a17ae | 6557 | ALIAS_HIDDEN( |
6558 | neighbor_maximum_prefix_warning, | |
6559 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6560 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6561 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6562 | "Maximum number of prefix accept from this peer\n" | |
6563 | "maximum no. of prefix limit\n" | |
6564 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6565 | |
e0701b79 | 6566 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6567 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6568 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6569 | NEIGHBOR_STR |
6570 | NEIGHBOR_ADDR_STR2 | |
6571 | "Maximum number of prefix accept from this peer\n" | |
6572 | "maximum no. of prefix limit\n" | |
6573 | "Threshold value (%) at which to generate a warning msg\n" | |
6574 | "Only give warning message when limit is exceeded\n") | |
6575 | { | |
d62a17ae | 6576 | int idx_peer = 1; |
6577 | int idx_number = 3; | |
6578 | int idx_number_2 = 4; | |
6579 | return peer_maximum_prefix_set_vty( | |
6580 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6581 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6582 | } |
6583 | ||
d62a17ae | 6584 | ALIAS_HIDDEN( |
6585 | neighbor_maximum_prefix_threshold_warning, | |
6586 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6587 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6588 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6589 | "Maximum number of prefix accept from this peer\n" | |
6590 | "maximum no. of prefix limit\n" | |
6591 | "Threshold value (%) at which to generate a warning msg\n" | |
6592 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6593 | |
0a486e5f | 6594 | DEFUN (neighbor_maximum_prefix_restart, |
6595 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6596 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6597 | NEIGHBOR_STR |
6598 | NEIGHBOR_ADDR_STR2 | |
6599 | "Maximum number of prefix accept from this peer\n" | |
6600 | "maximum no. of prefix limit\n" | |
6601 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6602 | "Restart interval in minutes\n") |
0a486e5f | 6603 | { |
d62a17ae | 6604 | int idx_peer = 1; |
6605 | int idx_number = 3; | |
6606 | int idx_number_2 = 5; | |
6607 | return peer_maximum_prefix_set_vty( | |
6608 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6609 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6610 | } |
6611 | ||
d62a17ae | 6612 | ALIAS_HIDDEN( |
6613 | neighbor_maximum_prefix_restart, | |
6614 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6615 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6616 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6617 | "Maximum number of prefix accept from this peer\n" | |
6618 | "maximum no. of prefix limit\n" | |
6619 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6620 | "Restart interval in minutes\n") |
596c17ba | 6621 | |
0a486e5f | 6622 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6623 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6624 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6625 | NEIGHBOR_STR |
6626 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6627 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6628 | "maximum no. of prefix limit\n" |
6629 | "Threshold value (%) at which to generate a warning msg\n" | |
6630 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6631 | "Restart interval in minutes\n") |
0a486e5f | 6632 | { |
d62a17ae | 6633 | int idx_peer = 1; |
6634 | int idx_number = 3; | |
6635 | int idx_number_2 = 4; | |
6636 | int idx_number_3 = 6; | |
6637 | return peer_maximum_prefix_set_vty( | |
6638 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6639 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6640 | argv[idx_number_3]->arg); | |
6641 | } | |
6642 | ||
6643 | ALIAS_HIDDEN( | |
6644 | neighbor_maximum_prefix_threshold_restart, | |
6645 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6646 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6647 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6648 | "Maximum number of prefixes to accept from this peer\n" | |
6649 | "maximum no. of prefix limit\n" | |
6650 | "Threshold value (%) at which to generate a warning msg\n" | |
6651 | "Restart bgp connection after limit is exceeded\n" | |
6652 | "Restart interval in minutes\n") | |
596c17ba | 6653 | |
718e3744 | 6654 | DEFUN (no_neighbor_maximum_prefix, |
6655 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6657 | NO_STR |
6658 | NEIGHBOR_STR | |
6659 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6660 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6661 | "maximum no. of prefix limit\n" |
6662 | "Threshold value (%) at which to generate a warning msg\n" | |
6663 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6664 | "Restart interval in minutes\n" |
31500417 | 6665 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6666 | { |
d62a17ae | 6667 | int idx_peer = 2; |
6668 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6669 | bgp_node_afi(vty), | |
6670 | bgp_node_safi(vty)); | |
718e3744 | 6671 | } |
e52702f2 | 6672 | |
d62a17ae | 6673 | ALIAS_HIDDEN( |
6674 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6675 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6676 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6677 | "Maximum number of prefixes to accept from this peer\n" | |
6678 | "maximum no. of prefix limit\n" | |
6679 | "Threshold value (%) at which to generate a warning msg\n" | |
6680 | "Restart bgp connection after limit is exceeded\n" | |
6681 | "Restart interval in minutes\n" | |
6682 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6683 | |
718e3744 | 6684 | |
718e3744 | 6685 | /* "neighbor allowas-in" */ |
6686 | DEFUN (neighbor_allowas_in, | |
6687 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6688 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6689 | NEIGHBOR_STR |
6690 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6691 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6692 | "Number of occurrences of AS number\n" |
fd8503f5 | 6693 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6694 | { |
d62a17ae | 6695 | int idx_peer = 1; |
6696 | int idx_number_origin = 3; | |
6697 | int ret; | |
6698 | int origin = 0; | |
6699 | struct peer *peer; | |
6700 | int allow_num = 0; | |
6701 | ||
6702 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6703 | if (!peer) | |
6704 | return CMD_WARNING_CONFIG_FAILED; | |
6705 | ||
6706 | if (argc <= idx_number_origin) | |
6707 | allow_num = 3; | |
6708 | else { | |
6709 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6710 | origin = 1; | |
6711 | else | |
6712 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6713 | } | |
6714 | ||
6715 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6716 | allow_num, origin); | |
6717 | ||
6718 | return bgp_vty_return(vty, ret); | |
6719 | } | |
6720 | ||
6721 | ALIAS_HIDDEN( | |
6722 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6723 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6724 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6725 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6726 | "Number of occurrences of AS number\n" |
d62a17ae | 6727 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6728 | |
718e3744 | 6729 | DEFUN (no_neighbor_allowas_in, |
6730 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6731 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6732 | NO_STR |
6733 | NEIGHBOR_STR | |
6734 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6735 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6736 | "Number of occurrences of AS number\n" |
fd8503f5 | 6737 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6738 | { |
d62a17ae | 6739 | int idx_peer = 2; |
6740 | int ret; | |
6741 | struct peer *peer; | |
718e3744 | 6742 | |
d62a17ae | 6743 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6744 | if (!peer) | |
6745 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6746 | |
d62a17ae | 6747 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6748 | bgp_node_safi(vty)); | |
718e3744 | 6749 | |
d62a17ae | 6750 | return bgp_vty_return(vty, ret); |
718e3744 | 6751 | } |
6b0655a2 | 6752 | |
d62a17ae | 6753 | ALIAS_HIDDEN( |
6754 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6755 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6756 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6757 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6758 | "Number of occurrences of AS number\n" |
d62a17ae | 6759 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6760 | |
fa411a21 NH |
6761 | DEFUN (neighbor_ttl_security, |
6762 | neighbor_ttl_security_cmd, | |
7ebe625c | 6763 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6764 | NEIGHBOR_STR |
7ebe625c | 6765 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6766 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6767 | "Specify the maximum number of hops to the BGP peer\n" |
6768 | "Number of hops to BGP peer\n") | |
fa411a21 | 6769 | { |
d62a17ae | 6770 | int idx_peer = 1; |
6771 | int idx_number = 4; | |
6772 | struct peer *peer; | |
6773 | int gtsm_hops; | |
6774 | ||
6775 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6776 | if (!peer) | |
6777 | return CMD_WARNING_CONFIG_FAILED; | |
6778 | ||
6779 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6780 | ||
7ebe625c QY |
6781 | /* |
6782 | * If 'neighbor swpX', then this is for directly connected peers, | |
6783 | * we should not accept a ttl-security hops value greater than 1. | |
6784 | */ | |
6785 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6786 | vty_out(vty, | |
6787 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6788 | argv[idx_peer]->arg); | |
6789 | return CMD_WARNING_CONFIG_FAILED; | |
6790 | } | |
6791 | ||
d62a17ae | 6792 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6793 | } |
6794 | ||
6795 | DEFUN (no_neighbor_ttl_security, | |
6796 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6797 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6798 | NO_STR |
6799 | NEIGHBOR_STR | |
7ebe625c | 6800 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6801 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6802 | "Specify the maximum number of hops to the BGP peer\n" |
6803 | "Number of hops to BGP peer\n") | |
fa411a21 | 6804 | { |
d62a17ae | 6805 | int idx_peer = 2; |
6806 | struct peer *peer; | |
fa411a21 | 6807 | |
d62a17ae | 6808 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6809 | if (!peer) | |
6810 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6811 | |
d62a17ae | 6812 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6813 | } |
6b0655a2 | 6814 | |
adbac85e DW |
6815 | DEFUN (neighbor_addpath_tx_all_paths, |
6816 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6817 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6818 | NEIGHBOR_STR |
6819 | NEIGHBOR_ADDR_STR2 | |
6820 | "Use addpath to advertise all paths to a neighbor\n") | |
6821 | { | |
d62a17ae | 6822 | int idx_peer = 1; |
6823 | struct peer *peer; | |
adbac85e | 6824 | |
d62a17ae | 6825 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6826 | if (!peer) | |
6827 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6828 | |
dcc68b5e MS |
6829 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6830 | BGP_ADDPATH_ALL); | |
6831 | return CMD_SUCCESS; | |
adbac85e DW |
6832 | } |
6833 | ||
d62a17ae | 6834 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6835 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6836 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6837 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6838 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6839 | |
adbac85e DW |
6840 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6841 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6842 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6843 | NO_STR |
6844 | NEIGHBOR_STR | |
6845 | NEIGHBOR_ADDR_STR2 | |
6846 | "Use addpath to advertise all paths to a neighbor\n") | |
6847 | { | |
d62a17ae | 6848 | int idx_peer = 2; |
dcc68b5e MS |
6849 | struct peer *peer; |
6850 | ||
6851 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6852 | if (!peer) | |
6853 | return CMD_WARNING_CONFIG_FAILED; | |
6854 | ||
6855 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6856 | != BGP_ADDPATH_ALL) { | |
6857 | vty_out(vty, | |
6858 | "%% Peer not currently configured to transmit all paths."); | |
6859 | return CMD_WARNING_CONFIG_FAILED; | |
6860 | } | |
6861 | ||
6862 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6863 | BGP_ADDPATH_NONE); | |
6864 | ||
6865 | return CMD_SUCCESS; | |
adbac85e DW |
6866 | } |
6867 | ||
d62a17ae | 6868 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6869 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6870 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6871 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6872 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6873 | |
06370dac DW |
6874 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6875 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6876 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6877 | NEIGHBOR_STR |
6878 | NEIGHBOR_ADDR_STR2 | |
6879 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6880 | { | |
d62a17ae | 6881 | int idx_peer = 1; |
6882 | struct peer *peer; | |
06370dac | 6883 | |
d62a17ae | 6884 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6885 | if (!peer) | |
6886 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6887 | |
dcc68b5e MS |
6888 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6889 | BGP_ADDPATH_BEST_PER_AS); | |
6890 | ||
6891 | return CMD_SUCCESS; | |
06370dac DW |
6892 | } |
6893 | ||
d62a17ae | 6894 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6895 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6896 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6897 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6898 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6899 | |
06370dac DW |
6900 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6901 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6902 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6903 | NO_STR |
6904 | NEIGHBOR_STR | |
6905 | NEIGHBOR_ADDR_STR2 | |
6906 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6907 | { | |
d62a17ae | 6908 | int idx_peer = 2; |
dcc68b5e MS |
6909 | struct peer *peer; |
6910 | ||
6911 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6912 | if (!peer) | |
6913 | return CMD_WARNING_CONFIG_FAILED; | |
6914 | ||
6915 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6916 | != BGP_ADDPATH_BEST_PER_AS) { | |
6917 | vty_out(vty, | |
6918 | "%% Peer not currently configured to transmit all best path per as."); | |
6919 | return CMD_WARNING_CONFIG_FAILED; | |
6920 | } | |
6921 | ||
6922 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6923 | BGP_ADDPATH_NONE); | |
6924 | ||
6925 | return CMD_SUCCESS; | |
06370dac DW |
6926 | } |
6927 | ||
d62a17ae | 6928 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6929 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6930 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6931 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6932 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6933 | |
2b31007c RZ |
6934 | DEFPY( |
6935 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
6936 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
6937 | NEIGHBOR_STR | |
6938 | NEIGHBOR_ADDR_STR2 | |
6939 | "Detect AS loops before sending to neighbor\n") | |
6940 | { | |
6941 | struct peer *peer; | |
6942 | ||
6943 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6944 | if (!peer) | |
6945 | return CMD_WARNING_CONFIG_FAILED; | |
6946 | ||
6947 | peer->as_path_loop_detection = true; | |
6948 | ||
6949 | return CMD_SUCCESS; | |
6950 | } | |
6951 | ||
6952 | DEFPY( | |
6953 | no_neighbor_aspath_loop_detection, | |
6954 | no_neighbor_aspath_loop_detection_cmd, | |
6955 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
6956 | NO_STR | |
6957 | NEIGHBOR_STR | |
6958 | NEIGHBOR_ADDR_STR2 | |
6959 | "Detect AS loops before sending to neighbor\n") | |
6960 | { | |
6961 | struct peer *peer; | |
6962 | ||
6963 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6964 | if (!peer) | |
6965 | return CMD_WARNING_CONFIG_FAILED; | |
6966 | ||
6967 | peer->as_path_loop_detection = false; | |
6968 | ||
6969 | return CMD_SUCCESS; | |
6970 | } | |
6971 | ||
b9c7bc5a PZ |
6972 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6973 | struct ecommunity **list) | |
ddb5b488 | 6974 | { |
b9c7bc5a PZ |
6975 | struct ecommunity *ecom = NULL; |
6976 | struct ecommunity *ecomadd; | |
ddb5b488 | 6977 | |
b9c7bc5a | 6978 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6979 | |
b9c7bc5a PZ |
6980 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6981 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6982 | if (!ecomadd) { | |
6983 | vty_out(vty, "Malformed community-list value\n"); | |
6984 | if (ecom) | |
6985 | ecommunity_free(&ecom); | |
6986 | return CMD_WARNING_CONFIG_FAILED; | |
6987 | } | |
ddb5b488 | 6988 | |
b9c7bc5a PZ |
6989 | if (ecom) { |
6990 | ecommunity_merge(ecom, ecomadd); | |
6991 | ecommunity_free(&ecomadd); | |
6992 | } else { | |
6993 | ecom = ecomadd; | |
6994 | } | |
6995 | } | |
6996 | ||
6997 | if (*list) { | |
6998 | ecommunity_free(&*list); | |
ddb5b488 | 6999 | } |
b9c7bc5a PZ |
7000 | *list = ecom; |
7001 | ||
7002 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7003 | } |
7004 | ||
0ca70ba5 DS |
7005 | /* |
7006 | * v2vimport is true if we are handling a `import vrf ...` command | |
7007 | */ | |
7008 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7009 | { |
0ca70ba5 DS |
7010 | afi_t afi; |
7011 | ||
ddb5b488 | 7012 | switch (vty->node) { |
b9c7bc5a | 7013 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7014 | afi = AFI_IP; |
7015 | break; | |
b9c7bc5a | 7016 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7017 | afi = AFI_IP6; |
7018 | break; | |
ddb5b488 PZ |
7019 | default: |
7020 | vty_out(vty, | |
b9c7bc5a | 7021 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7022 | return AFI_MAX; |
ddb5b488 | 7023 | } |
69b07479 | 7024 | |
0ca70ba5 DS |
7025 | if (!v2vimport) { |
7026 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7027 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7028 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7029 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7030 | vty_out(vty, | |
7031 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7032 | return AFI_MAX; | |
7033 | } | |
7034 | } else { | |
7035 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7036 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7037 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7038 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7039 | vty_out(vty, | |
7040 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7041 | return AFI_MAX; | |
7042 | } | |
7043 | } | |
7044 | return afi; | |
ddb5b488 PZ |
7045 | } |
7046 | ||
b9c7bc5a PZ |
7047 | DEFPY (af_rd_vpn_export, |
7048 | af_rd_vpn_export_cmd, | |
7049 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7050 | NO_STR | |
ddb5b488 | 7051 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7052 | "Between current address-family and vpn\n" |
7053 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7054 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7055 | { | |
7056 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7057 | struct prefix_rd prd; | |
7058 | int ret; | |
ddb5b488 | 7059 | afi_t afi; |
b9c7bc5a PZ |
7060 | int idx = 0; |
7061 | int yes = 1; | |
ddb5b488 | 7062 | |
b9c7bc5a | 7063 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7064 | yes = 0; |
b9c7bc5a PZ |
7065 | |
7066 | if (yes) { | |
7067 | ret = str2prefix_rd(rd_str, &prd); | |
7068 | if (!ret) { | |
7069 | vty_out(vty, "%% Malformed rd\n"); | |
7070 | return CMD_WARNING_CONFIG_FAILED; | |
7071 | } | |
ddb5b488 PZ |
7072 | } |
7073 | ||
0ca70ba5 | 7074 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7075 | if (afi == AFI_MAX) |
7076 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7077 | |
69b07479 DS |
7078 | /* |
7079 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7080 | */ | |
7081 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7082 | bgp_get_default(), bgp); | |
ddb5b488 | 7083 | |
69b07479 DS |
7084 | if (yes) { |
7085 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7086 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7087 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7088 | } else { | |
7089 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7090 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7091 | } |
7092 | ||
69b07479 DS |
7093 | /* post-change: re-export vpn routes */ |
7094 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7095 | bgp_get_default(), bgp); | |
7096 | ||
ddb5b488 PZ |
7097 | return CMD_SUCCESS; |
7098 | } | |
7099 | ||
b9c7bc5a PZ |
7100 | ALIAS (af_rd_vpn_export, |
7101 | af_no_rd_vpn_export_cmd, | |
7102 | "no rd vpn export", | |
ddb5b488 | 7103 | NO_STR |
b9c7bc5a PZ |
7104 | "Specify route distinguisher\n" |
7105 | "Between current address-family and vpn\n" | |
7106 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7107 | |
b9c7bc5a PZ |
7108 | DEFPY (af_label_vpn_export, |
7109 | af_label_vpn_export_cmd, | |
e70e9f8e | 7110 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7111 | NO_STR |
ddb5b488 | 7112 | "label value for VRF\n" |
b9c7bc5a PZ |
7113 | "Between current address-family and vpn\n" |
7114 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7115 | "Label Value <0-1048575>\n" |
7116 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7117 | { |
7118 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7119 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7120 | afi_t afi; |
b9c7bc5a PZ |
7121 | int idx = 0; |
7122 | int yes = 1; | |
7123 | ||
7124 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7125 | yes = 0; |
ddb5b488 | 7126 | |
21a16cc2 PZ |
7127 | /* If "no ...", squash trailing parameter */ |
7128 | if (!yes) | |
7129 | label_auto = NULL; | |
7130 | ||
e70e9f8e PZ |
7131 | if (yes) { |
7132 | if (!label_auto) | |
7133 | label = label_val; /* parser should force unsigned */ | |
7134 | } | |
ddb5b488 | 7135 | |
0ca70ba5 | 7136 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7137 | if (afi == AFI_MAX) |
7138 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7139 | |
e70e9f8e | 7140 | |
69b07479 DS |
7141 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7142 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7143 | /* no change */ | |
7144 | return CMD_SUCCESS; | |
e70e9f8e | 7145 | |
69b07479 DS |
7146 | /* |
7147 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7148 | */ | |
7149 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7150 | bgp_get_default(), bgp); | |
7151 | ||
7152 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7153 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7154 | ||
7155 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7156 | ||
7157 | /* | |
7158 | * label has previously been automatically | |
7159 | * assigned by labelpool: release it | |
7160 | * | |
7161 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7162 | * means the automatic assignment is in flight | |
7163 | * and therefore the labelpool callback must | |
7164 | * detect that the auto label is not needed. | |
7165 | */ | |
7166 | ||
7167 | bgp_lp_release(LP_TYPE_VRF, | |
7168 | &bgp->vpn_policy[afi], | |
7169 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7170 | } |
69b07479 DS |
7171 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7172 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7173 | } | |
ddb5b488 | 7174 | |
69b07479 DS |
7175 | bgp->vpn_policy[afi].tovpn_label = label; |
7176 | if (label_auto) { | |
7177 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7178 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7179 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7180 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7181 | } |
7182 | ||
69b07479 DS |
7183 | /* post-change: re-export vpn routes */ |
7184 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7185 | bgp_get_default(), bgp); | |
7186 | ||
ddb5b488 PZ |
7187 | return CMD_SUCCESS; |
7188 | } | |
7189 | ||
b9c7bc5a PZ |
7190 | ALIAS (af_label_vpn_export, |
7191 | af_no_label_vpn_export_cmd, | |
7192 | "no label vpn export", | |
7193 | NO_STR | |
7194 | "label value for VRF\n" | |
7195 | "Between current address-family and vpn\n" | |
7196 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7197 | |
b9c7bc5a PZ |
7198 | DEFPY (af_nexthop_vpn_export, |
7199 | af_nexthop_vpn_export_cmd, | |
7200 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
7201 | NO_STR | |
ddb5b488 | 7202 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7203 | "Between current address-family and vpn\n" |
7204 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7205 | "IPv4 prefix\n" |
7206 | "IPv6 prefix\n") | |
7207 | { | |
7208 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7209 | afi_t afi; |
ddb5b488 | 7210 | struct prefix p; |
b9c7bc5a PZ |
7211 | int idx = 0; |
7212 | int yes = 1; | |
ddb5b488 | 7213 | |
b9c7bc5a | 7214 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7215 | yes = 0; |
b9c7bc5a PZ |
7216 | |
7217 | if (yes) { | |
7218 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
7219 | return CMD_WARNING_CONFIG_FAILED; | |
7220 | } | |
ddb5b488 | 7221 | |
0ca70ba5 | 7222 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7223 | if (afi == AFI_MAX) |
7224 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7225 | |
69b07479 DS |
7226 | /* |
7227 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7228 | */ | |
7229 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7230 | bgp_get_default(), bgp); | |
ddb5b488 | 7231 | |
69b07479 DS |
7232 | if (yes) { |
7233 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
7234 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7235 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7236 | } else { | |
7237 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7238 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7239 | } |
7240 | ||
69b07479 DS |
7241 | /* post-change: re-export vpn routes */ |
7242 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7243 | bgp_get_default(), bgp); | |
7244 | ||
ddb5b488 PZ |
7245 | return CMD_SUCCESS; |
7246 | } | |
7247 | ||
b9c7bc5a PZ |
7248 | ALIAS (af_nexthop_vpn_export, |
7249 | af_no_nexthop_vpn_export_cmd, | |
7250 | "no nexthop vpn export", | |
ddb5b488 | 7251 | NO_STR |
b9c7bc5a PZ |
7252 | "Specify next hop to use for VRF advertised prefixes\n" |
7253 | "Between current address-family and vpn\n" | |
7254 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7255 | |
b9c7bc5a | 7256 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7257 | { |
b9c7bc5a PZ |
7258 | if (!strcmp(dstr, "import")) { |
7259 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7260 | } else if (!strcmp(dstr, "export")) { | |
7261 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7262 | } else if (!strcmp(dstr, "both")) { | |
7263 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7264 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7265 | } else { | |
7266 | vty_out(vty, "%% direction parse error\n"); | |
7267 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7268 | } |
ddb5b488 PZ |
7269 | return CMD_SUCCESS; |
7270 | } | |
7271 | ||
b9c7bc5a PZ |
7272 | DEFPY (af_rt_vpn_imexport, |
7273 | af_rt_vpn_imexport_cmd, | |
7274 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7275 | NO_STR | |
7276 | "Specify route target list\n" | |
ddb5b488 | 7277 | "Specify route target list\n" |
b9c7bc5a PZ |
7278 | "Between current address-family and vpn\n" |
7279 | "For routes leaked from vpn to current address-family: match any\n" | |
7280 | "For routes leaked from current address-family to vpn: set\n" | |
7281 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7282 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7283 | { | |
7284 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7285 | int ret; | |
7286 | struct ecommunity *ecom = NULL; | |
7287 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7288 | vpn_policy_direction_t dir; |
7289 | afi_t afi; | |
7290 | int idx = 0; | |
b9c7bc5a | 7291 | int yes = 1; |
ddb5b488 | 7292 | |
b9c7bc5a | 7293 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7294 | yes = 0; |
b9c7bc5a | 7295 | |
0ca70ba5 | 7296 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7297 | if (afi == AFI_MAX) |
7298 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7299 | |
b9c7bc5a | 7300 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7301 | if (ret != CMD_SUCCESS) |
7302 | return ret; | |
7303 | ||
b9c7bc5a PZ |
7304 | if (yes) { |
7305 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7306 | vty_out(vty, "%% Missing RTLIST\n"); | |
7307 | return CMD_WARNING_CONFIG_FAILED; | |
7308 | } | |
7309 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7310 | if (ret != CMD_SUCCESS) { | |
7311 | return ret; | |
7312 | } | |
ddb5b488 PZ |
7313 | } |
7314 | ||
69b07479 DS |
7315 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7316 | if (!dodir[dir]) | |
ddb5b488 | 7317 | continue; |
ddb5b488 | 7318 | |
69b07479 | 7319 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7320 | |
69b07479 DS |
7321 | if (yes) { |
7322 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7323 | ecommunity_free( | |
7324 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7325 | bgp->vpn_policy[afi].rtlist[dir] = | |
7326 | ecommunity_dup(ecom); | |
7327 | } else { | |
7328 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7329 | ecommunity_free( | |
7330 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7331 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7332 | } |
69b07479 DS |
7333 | |
7334 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7335 | } |
69b07479 | 7336 | |
d555f3e9 PZ |
7337 | if (ecom) |
7338 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7339 | |
7340 | return CMD_SUCCESS; | |
7341 | } | |
7342 | ||
b9c7bc5a PZ |
7343 | ALIAS (af_rt_vpn_imexport, |
7344 | af_no_rt_vpn_imexport_cmd, | |
7345 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7346 | NO_STR |
7347 | "Specify route target list\n" | |
b9c7bc5a PZ |
7348 | "Specify route target list\n" |
7349 | "Between current address-family and vpn\n" | |
7350 | "For routes leaked from vpn to current address-family\n" | |
7351 | "For routes leaked from current address-family to vpn\n" | |
7352 | "both import and export\n") | |
7353 | ||
7354 | DEFPY (af_route_map_vpn_imexport, | |
7355 | af_route_map_vpn_imexport_cmd, | |
7356 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7357 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7358 | NO_STR | |
ddb5b488 | 7359 | "Specify route map\n" |
b9c7bc5a PZ |
7360 | "Between current address-family and vpn\n" |
7361 | "For routes leaked from vpn to current address-family\n" | |
7362 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7363 | "name of route-map\n") |
7364 | { | |
7365 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7366 | int ret; | |
7367 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7368 | vpn_policy_direction_t dir; |
7369 | afi_t afi; | |
ddb5b488 | 7370 | int idx = 0; |
b9c7bc5a | 7371 | int yes = 1; |
ddb5b488 | 7372 | |
b9c7bc5a | 7373 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7374 | yes = 0; |
b9c7bc5a | 7375 | |
0ca70ba5 | 7376 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7377 | if (afi == AFI_MAX) |
7378 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7379 | |
b9c7bc5a | 7380 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7381 | if (ret != CMD_SUCCESS) |
7382 | return ret; | |
7383 | ||
69b07479 DS |
7384 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7385 | if (!dodir[dir]) | |
ddb5b488 | 7386 | continue; |
ddb5b488 | 7387 | |
69b07479 | 7388 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7389 | |
69b07479 DS |
7390 | if (yes) { |
7391 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7392 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7393 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7394 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7395 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7396 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7397 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7398 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7399 | return CMD_SUCCESS; | |
7400 | } else { | |
7401 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7402 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7403 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7404 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7405 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7406 | } |
69b07479 DS |
7407 | |
7408 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7409 | } |
7410 | ||
7411 | return CMD_SUCCESS; | |
7412 | } | |
7413 | ||
b9c7bc5a PZ |
7414 | ALIAS (af_route_map_vpn_imexport, |
7415 | af_no_route_map_vpn_imexport_cmd, | |
7416 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7417 | NO_STR |
7418 | "Specify route map\n" | |
b9c7bc5a PZ |
7419 | "Between current address-family and vpn\n" |
7420 | "For routes leaked from vpn to current address-family\n" | |
7421 | "For routes leaked from current address-family to vpn\n") | |
7422 | ||
bb4f6190 DS |
7423 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
7424 | "[no] import vrf route-map RMAP$rmap_str", | |
7425 | NO_STR | |
7426 | "Import routes from another VRF\n" | |
7427 | "Vrf routes being filtered\n" | |
7428 | "Specify route map\n" | |
7429 | "name of route-map\n") | |
7430 | { | |
7431 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7432 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7433 | afi_t afi; | |
7434 | int idx = 0; | |
7435 | int yes = 1; | |
7436 | struct bgp *bgp_default; | |
7437 | ||
7438 | if (argv_find(argv, argc, "no", &idx)) | |
7439 | yes = 0; | |
7440 | ||
0ca70ba5 | 7441 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7442 | if (afi == AFI_MAX) |
7443 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7444 | |
7445 | bgp_default = bgp_get_default(); | |
7446 | if (!bgp_default) { | |
7447 | int32_t ret; | |
7448 | as_t as = bgp->as; | |
7449 | ||
7450 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7451 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7452 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7453 | |
7454 | if (ret) { | |
7455 | vty_out(vty, | |
7456 | "VRF default is not configured as a bgp instance\n"); | |
7457 | return CMD_WARNING; | |
7458 | } | |
7459 | } | |
7460 | ||
69b07479 | 7461 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7462 | |
69b07479 DS |
7463 | if (yes) { |
7464 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7465 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7466 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7467 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7468 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7469 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7470 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7471 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7472 | return CMD_SUCCESS; | |
7473 | } else { | |
7474 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7475 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7476 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7477 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7478 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
7479 | } |
7480 | ||
69b07479 DS |
7481 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7482 | ||
bb4f6190 DS |
7483 | return CMD_SUCCESS; |
7484 | } | |
7485 | ||
7486 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
7487 | "no import vrf route-map", | |
7488 | NO_STR | |
7489 | "Import routes from another VRF\n" | |
7490 | "Vrf routes being filtered\n" | |
7491 | "Specify route map\n") | |
7492 | ||
4d1b335c DA |
7493 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7494 | "[no] import vrf VIEWVRFNAME$import_name", | |
7495 | NO_STR | |
7496 | "Import routes from another VRF\n" | |
7497 | "VRF to import from\n" | |
7498 | "The name of the VRF\n") | |
12a844a5 DS |
7499 | { |
7500 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7501 | struct listnode *node; | |
79ef8664 DS |
7502 | struct bgp *vrf_bgp, *bgp_default; |
7503 | int32_t ret = 0; | |
7504 | as_t as = bgp->as; | |
12a844a5 DS |
7505 | bool remove = false; |
7506 | int32_t idx = 0; | |
7507 | char *vname; | |
a8dadcf6 | 7508 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7509 | safi_t safi; |
7510 | afi_t afi; | |
7511 | ||
867f0cca | 7512 | if (import_name == NULL) { |
7513 | vty_out(vty, "%% Missing import name\n"); | |
7514 | return CMD_WARNING; | |
7515 | } | |
7516 | ||
12a844a5 DS |
7517 | if (argv_find(argv, argc, "no", &idx)) |
7518 | remove = true; | |
7519 | ||
0ca70ba5 DS |
7520 | afi = vpn_policy_getafi(vty, bgp, true); |
7521 | if (afi == AFI_MAX) | |
7522 | return CMD_WARNING_CONFIG_FAILED; | |
7523 | ||
12a844a5 DS |
7524 | safi = bgp_node_safi(vty); |
7525 | ||
25679caa | 7526 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7527 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7528 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7529 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7530 | remove ? "unimport" : "import", import_name); | |
7531 | return CMD_WARNING; | |
7532 | } | |
7533 | ||
79ef8664 DS |
7534 | bgp_default = bgp_get_default(); |
7535 | if (!bgp_default) { | |
7536 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7537 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7538 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7539 | |
7540 | if (ret) { | |
7541 | vty_out(vty, | |
7542 | "VRF default is not configured as a bgp instance\n"); | |
7543 | return CMD_WARNING; | |
7544 | } | |
7545 | } | |
7546 | ||
12a844a5 DS |
7547 | vrf_bgp = bgp_lookup_by_name(import_name); |
7548 | if (!vrf_bgp) { | |
5742e42b | 7549 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7550 | vrf_bgp = bgp_default; |
7551 | else | |
0fb8d6e6 | 7552 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7553 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7554 | |
6e2c7fe6 | 7555 | if (ret) { |
020a3f60 DS |
7556 | vty_out(vty, |
7557 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7558 | import_name); |
7559 | return CMD_WARNING; | |
7560 | } | |
12a844a5 DS |
7561 | } |
7562 | ||
12a844a5 | 7563 | if (remove) { |
44338987 | 7564 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7565 | } else { |
44338987 | 7566 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7567 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7568 | vname)) { | |
7569 | if (strcmp(vname, import_name) == 0) | |
7570 | return CMD_WARNING; | |
7571 | } | |
7572 | ||
44338987 | 7573 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7574 | } |
7575 | ||
7576 | return CMD_SUCCESS; | |
7577 | } | |
7578 | ||
b9c7bc5a PZ |
7579 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7580 | DEFPY (bgp_imexport_vpn, | |
7581 | bgp_imexport_vpn_cmd, | |
7582 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7583 | NO_STR |
7584 | "Import routes to this address-family\n" | |
7585 | "Export routes from this address-family\n" | |
7586 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7587 | { |
7588 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7589 | int previous_state; |
ddb5b488 | 7590 | afi_t afi; |
b9c7bc5a | 7591 | safi_t safi; |
ddb5b488 | 7592 | int idx = 0; |
b9c7bc5a PZ |
7593 | int yes = 1; |
7594 | int flag; | |
7595 | vpn_policy_direction_t dir; | |
ddb5b488 | 7596 | |
b9c7bc5a | 7597 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7598 | yes = 0; |
ddb5b488 | 7599 | |
b9c7bc5a PZ |
7600 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7601 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7602 | |
b9c7bc5a PZ |
7603 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7604 | return CMD_WARNING_CONFIG_FAILED; | |
7605 | } | |
ddb5b488 | 7606 | |
b9c7bc5a PZ |
7607 | afi = bgp_node_afi(vty); |
7608 | safi = bgp_node_safi(vty); | |
7609 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7610 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7611 | return CMD_WARNING_CONFIG_FAILED; | |
7612 | } | |
ddb5b488 | 7613 | |
b9c7bc5a PZ |
7614 | if (!strcmp(direction_str, "import")) { |
7615 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7616 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7617 | } else if (!strcmp(direction_str, "export")) { | |
7618 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7619 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7620 | } else { | |
7621 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7622 | return CMD_WARNING_CONFIG_FAILED; | |
7623 | } | |
7624 | ||
7625 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7626 | |
b9c7bc5a PZ |
7627 | if (yes) { |
7628 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7629 | if (!previous_state) { | |
7630 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7631 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7632 | } | |
b9c7bc5a PZ |
7633 | } else { |
7634 | if (previous_state) { | |
7635 | /* trigger un-export current vrf */ | |
7636 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7637 | } | |
7638 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7639 | } |
7640 | ||
7641 | return CMD_SUCCESS; | |
7642 | } | |
7643 | ||
301ad80a PG |
7644 | DEFPY (af_routetarget_import, |
7645 | af_routetarget_import_cmd, | |
7646 | "[no] <rt|route-target> redirect import RTLIST...", | |
7647 | NO_STR | |
7648 | "Specify route target list\n" | |
7649 | "Specify route target list\n" | |
7650 | "Flow-spec redirect type route target\n" | |
7651 | "Import routes to this address-family\n" | |
7652 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7653 | { | |
7654 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7655 | int ret; | |
7656 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7657 | afi_t afi; |
7658 | int idx = 0; | |
7659 | int yes = 1; | |
7660 | ||
7661 | if (argv_find(argv, argc, "no", &idx)) | |
7662 | yes = 0; | |
7663 | ||
0ca70ba5 | 7664 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7665 | if (afi == AFI_MAX) |
7666 | return CMD_WARNING_CONFIG_FAILED; | |
7667 | ||
301ad80a PG |
7668 | if (yes) { |
7669 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7670 | vty_out(vty, "%% Missing RTLIST\n"); | |
7671 | return CMD_WARNING_CONFIG_FAILED; | |
7672 | } | |
7673 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7674 | if (ret != CMD_SUCCESS) | |
7675 | return ret; | |
7676 | } | |
69b07479 DS |
7677 | |
7678 | if (yes) { | |
7679 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7680 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7681 | .import_redirect_rtlist); |
69b07479 DS |
7682 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7683 | ecommunity_dup(ecom); | |
7684 | } else { | |
7685 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7686 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7687 | .import_redirect_rtlist); |
69b07479 | 7688 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7689 | } |
69b07479 | 7690 | |
301ad80a PG |
7691 | if (ecom) |
7692 | ecommunity_free(&ecom); | |
7693 | ||
7694 | return CMD_SUCCESS; | |
7695 | } | |
7696 | ||
505e5056 | 7697 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7698 | address_family_ipv4_safi_cmd, |
7699 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7700 | "Enter Address Family command mode\n" | |
7701 | "Address Family\n" | |
7702 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7703 | { |
f51bae9c | 7704 | |
d62a17ae | 7705 | if (argc == 3) { |
2131d5cf | 7706 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7707 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7708 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7709 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7710 | && safi != SAFI_EVPN) { |
31947174 MK |
7711 | vty_out(vty, |
7712 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7713 | return CMD_WARNING_CONFIG_FAILED; |
7714 | } | |
d62a17ae | 7715 | vty->node = bgp_node_type(AFI_IP, safi); |
7716 | } else | |
7717 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7718 | |
d62a17ae | 7719 | return CMD_SUCCESS; |
718e3744 | 7720 | } |
7721 | ||
505e5056 | 7722 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7723 | address_family_ipv6_safi_cmd, |
7724 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7725 | "Enter Address Family command mode\n" | |
7726 | "Address Family\n" | |
7727 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7728 | { |
d62a17ae | 7729 | if (argc == 3) { |
2131d5cf | 7730 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7731 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7732 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7733 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7734 | && safi != SAFI_EVPN) { |
31947174 MK |
7735 | vty_out(vty, |
7736 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7737 | return CMD_WARNING_CONFIG_FAILED; |
7738 | } | |
d62a17ae | 7739 | vty->node = bgp_node_type(AFI_IP6, safi); |
7740 | } else | |
7741 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7742 | |
d62a17ae | 7743 | return CMD_SUCCESS; |
25ffbdc1 | 7744 | } |
718e3744 | 7745 | |
d6902373 | 7746 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7747 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7748 | address_family_vpnv4_cmd, |
8334fd5a | 7749 | "address-family vpnv4 [unicast]", |
718e3744 | 7750 | "Enter Address Family command mode\n" |
8c3deaae | 7751 | "Address Family\n" |
3a2d747c | 7752 | "Address Family modifier\n") |
718e3744 | 7753 | { |
d62a17ae | 7754 | vty->node = BGP_VPNV4_NODE; |
7755 | return CMD_SUCCESS; | |
718e3744 | 7756 | } |
7757 | ||
505e5056 | 7758 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7759 | address_family_vpnv6_cmd, |
8334fd5a | 7760 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7761 | "Enter Address Family command mode\n" |
8c3deaae | 7762 | "Address Family\n" |
3a2d747c | 7763 | "Address Family modifier\n") |
8ecd3266 | 7764 | { |
d62a17ae | 7765 | vty->node = BGP_VPNV6_NODE; |
7766 | return CMD_SUCCESS; | |
8ecd3266 | 7767 | } |
64e4a6c5 | 7768 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7769 | |
505e5056 | 7770 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7771 | address_family_evpn_cmd, |
7111c1a0 | 7772 | "address-family l2vpn evpn", |
4e0b7b6d | 7773 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7774 | "Address Family\n" |
7775 | "Address Family modifier\n") | |
4e0b7b6d | 7776 | { |
2131d5cf | 7777 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7778 | vty->node = BGP_EVPN_NODE; |
7779 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7780 | } |
7781 | ||
505e5056 | 7782 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7783 | exit_address_family_cmd, |
7784 | "exit-address-family", | |
7785 | "Exit from Address Family configuration mode\n") | |
7786 | { | |
d62a17ae | 7787 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7788 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7789 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7790 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7791 | || vty->node == BGP_EVPN_NODE |
7792 | || vty->node == BGP_FLOWSPECV4_NODE | |
7793 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7794 | vty->node = BGP_NODE; |
7795 | return CMD_SUCCESS; | |
718e3744 | 7796 | } |
6b0655a2 | 7797 | |
8ad7271d | 7798 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7799 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7800 | const char *ip_str, afi_t afi, safi_t safi, | |
7801 | struct prefix_rd *prd) | |
7802 | { | |
7803 | int ret; | |
7804 | struct prefix match; | |
7805 | struct bgp_node *rn; | |
7806 | struct bgp_node *rm; | |
7807 | struct bgp *bgp; | |
7808 | struct bgp_table *table; | |
7809 | struct bgp_table *rib; | |
7810 | ||
7811 | /* BGP structure lookup. */ | |
7812 | if (view_name) { | |
7813 | bgp = bgp_lookup_by_name(view_name); | |
7814 | if (bgp == NULL) { | |
7815 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7816 | view_name); | |
7817 | return CMD_WARNING; | |
7818 | } | |
7819 | } else { | |
7820 | bgp = bgp_get_default(); | |
7821 | if (bgp == NULL) { | |
7822 | vty_out(vty, "%% No BGP process is configured\n"); | |
7823 | return CMD_WARNING; | |
7824 | } | |
7825 | } | |
7826 | ||
7827 | /* Check IP address argument. */ | |
7828 | ret = str2prefix(ip_str, &match); | |
7829 | if (!ret) { | |
7830 | vty_out(vty, "%% address is malformed\n"); | |
7831 | return CMD_WARNING; | |
7832 | } | |
7833 | ||
7834 | match.family = afi2family(afi); | |
7835 | rib = bgp->rib[afi][safi]; | |
7836 | ||
7837 | if (safi == SAFI_MPLS_VPN) { | |
7838 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7839 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7840 | continue; | |
7841 | ||
67009e22 DS |
7842 | table = bgp_node_get_bgp_table_info(rn); |
7843 | if (table != NULL) { | |
7844 | ||
d62a17ae | 7845 | if ((rm = bgp_node_match(table, &match)) |
7846 | != NULL) { | |
7847 | if (rm->p.prefixlen | |
7848 | == match.prefixlen) { | |
343cdb61 | 7849 | SET_FLAG(rm->flags, |
d62a17ae | 7850 | BGP_NODE_USER_CLEAR); |
7851 | bgp_process(bgp, rm, afi, safi); | |
7852 | } | |
7853 | bgp_unlock_node(rm); | |
7854 | } | |
7855 | } | |
7856 | } | |
7857 | } else { | |
7858 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7859 | if (rn->p.prefixlen == match.prefixlen) { | |
7860 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7861 | bgp_process(bgp, rn, afi, safi); | |
7862 | } | |
7863 | bgp_unlock_node(rn); | |
7864 | } | |
7865 | } | |
7866 | ||
7867 | return CMD_SUCCESS; | |
8ad7271d DS |
7868 | } |
7869 | ||
b09b5ae0 | 7870 | /* one clear bgp command to rule them all */ |
718e3744 | 7871 | DEFUN (clear_ip_bgp_all, |
7872 | clear_ip_bgp_all_cmd, | |
453c92f6 | 7873 | "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 | 7874 | CLEAR_STR |
7875 | IP_STR | |
7876 | BGP_STR | |
838758ac | 7877 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7878 | BGP_AFI_HELP_STR |
fd5e7b70 | 7879 | "Address Family\n" |
510afcd6 | 7880 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7881 | "Address Family modifier\n" |
b09b5ae0 | 7882 | "Clear all peers\n" |
453c92f6 | 7883 | "BGP IPv4 neighbor to clear\n" |
a80beece | 7884 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7885 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7886 | "Clear peers with the AS number\n" |
7887 | "Clear all external peers\n" | |
718e3744 | 7888 | "Clear all members of peer-group\n" |
b09b5ae0 | 7889 | "BGP peer-group name\n" |
b09b5ae0 DW |
7890 | BGP_SOFT_STR |
7891 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7892 | BGP_SOFT_OUT_STR |
7893 | BGP_SOFT_IN_STR | |
7894 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7895 | BGP_SOFT_OUT_STR) |
718e3744 | 7896 | { |
d62a17ae | 7897 | char *vrf = NULL; |
7898 | ||
dc912615 DS |
7899 | afi_t afi = AFI_UNSPEC; |
7900 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 7901 | enum clear_sort clr_sort = clear_peer; |
7902 | enum bgp_clear_type clr_type; | |
7903 | char *clr_arg = NULL; | |
7904 | ||
7905 | int idx = 0; | |
7906 | ||
7907 | /* clear [ip] bgp */ | |
7908 | if (argv_find(argv, argc, "ip", &idx)) | |
7909 | afi = AFI_IP; | |
7910 | ||
9a8bdf1c PG |
7911 | /* [<vrf> VIEWVRFNAME] */ |
7912 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7913 | vrf = argv[idx + 1]->arg; | |
7914 | idx += 2; | |
7915 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7916 | vrf = NULL; | |
7917 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7918 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7919 | vrf = argv[idx + 1]->arg; |
7920 | idx += 2; | |
7921 | } | |
d62a17ae | 7922 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7923 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7924 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7925 | ||
d7b9898c | 7926 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7927 | if (argv_find(argv, argc, "*", &idx)) { |
7928 | clr_sort = clear_all; | |
7929 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7930 | clr_sort = clear_peer; | |
7931 | clr_arg = argv[idx]->arg; | |
7932 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7933 | clr_sort = clear_peer; | |
7934 | clr_arg = argv[idx]->arg; | |
7935 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7936 | clr_sort = clear_group; | |
7937 | idx++; | |
7938 | clr_arg = argv[idx]->arg; | |
d7b9898c | 7939 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7940 | clr_sort = clear_peer; |
7941 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
7942 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
7943 | clr_sort = clear_peer; | |
7944 | clr_arg = argv[idx]->arg; | |
d62a17ae | 7945 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
7946 | clr_sort = clear_as; | |
7947 | clr_arg = argv[idx]->arg; | |
7948 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7949 | clr_sort = clear_external; | |
7950 | } | |
7951 | ||
7952 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7953 | if (argv_find(argv, argc, "soft", &idx)) { | |
7954 | if (argv_find(argv, argc, "in", &idx) | |
7955 | || argv_find(argv, argc, "out", &idx)) | |
7956 | clr_type = strmatch(argv[idx]->text, "in") | |
7957 | ? BGP_CLEAR_SOFT_IN | |
7958 | : BGP_CLEAR_SOFT_OUT; | |
7959 | else | |
7960 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7961 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7962 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7963 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7964 | : BGP_CLEAR_SOFT_IN; | |
7965 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7966 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7967 | } else | |
7968 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7969 | ||
7970 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7971 | } |
01080f7c | 7972 | |
8ad7271d DS |
7973 | DEFUN (clear_ip_bgp_prefix, |
7974 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7975 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7976 | CLEAR_STR |
7977 | IP_STR | |
7978 | BGP_STR | |
838758ac | 7979 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7980 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7981 | "IPv4 prefix\n") |
8ad7271d | 7982 | { |
d62a17ae | 7983 | char *vrf = NULL; |
7984 | char *prefix = NULL; | |
8ad7271d | 7985 | |
d62a17ae | 7986 | int idx = 0; |
01080f7c | 7987 | |
d62a17ae | 7988 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7989 | if (argv_find(argv, argc, "vrf", &idx)) { |
7990 | vrf = argv[idx + 1]->arg; | |
7991 | idx += 2; | |
7992 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7993 | vrf = NULL; | |
7994 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7995 | /* [<view> VIEWVRFNAME] */ | |
7996 | vrf = argv[idx + 1]->arg; | |
7997 | idx += 2; | |
7998 | } | |
0c7b1b01 | 7999 | |
d62a17ae | 8000 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8001 | |
d62a17ae | 8002 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8003 | } |
8ad7271d | 8004 | |
b09b5ae0 DW |
8005 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8006 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8007 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8008 | CLEAR_STR |
3a2d747c | 8009 | IP_STR |
718e3744 | 8010 | BGP_STR |
8c3deaae | 8011 | "Address Family\n" |
46f296b4 | 8012 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8013 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8014 | "IPv6 prefix\n") |
718e3744 | 8015 | { |
9b475e76 PG |
8016 | int idx_safi = 0; |
8017 | int idx_ipv6_prefix = 0; | |
8018 | safi_t safi = SAFI_UNICAST; | |
8019 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8020 | argv[idx_ipv6_prefix]->arg : NULL; | |
8021 | ||
8022 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8023 | return bgp_clear_prefix( |
9b475e76 PG |
8024 | vty, NULL, prefix, AFI_IP6, |
8025 | safi, NULL); | |
838758ac | 8026 | } |
01080f7c | 8027 | |
b09b5ae0 DW |
8028 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8029 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8030 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8031 | CLEAR_STR |
3a2d747c | 8032 | IP_STR |
718e3744 | 8033 | BGP_STR |
838758ac | 8034 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8035 | "Address Family\n" |
46f296b4 | 8036 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8037 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8038 | "IPv6 prefix\n") |
718e3744 | 8039 | { |
9b475e76 | 8040 | int idx_safi = 0; |
9a8bdf1c | 8041 | int idx_vrfview = 0; |
9b475e76 PG |
8042 | int idx_ipv6_prefix = 0; |
8043 | safi_t safi = SAFI_UNICAST; | |
8044 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8045 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8046 | char *vrfview = NULL; |
9b475e76 | 8047 | |
9a8bdf1c PG |
8048 | /* [<view|vrf> VIEWVRFNAME] */ |
8049 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8050 | vrfview = argv[idx_vrfview + 1]->arg; | |
8051 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8052 | vrfview = NULL; | |
8053 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8054 | /* [<view> VIEWVRFNAME] */ | |
8055 | vrfview = argv[idx_vrfview + 1]->arg; | |
8056 | } | |
9b475e76 PG |
8057 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8058 | ||
d62a17ae | 8059 | return bgp_clear_prefix( |
9b475e76 PG |
8060 | vty, vrfview, prefix, |
8061 | AFI_IP6, safi, NULL); | |
718e3744 | 8062 | } |
8063 | ||
b09b5ae0 DW |
8064 | DEFUN (show_bgp_views, |
8065 | show_bgp_views_cmd, | |
d6e3c605 | 8066 | "show [ip] bgp views", |
b09b5ae0 | 8067 | SHOW_STR |
d6e3c605 | 8068 | IP_STR |
01080f7c | 8069 | BGP_STR |
b09b5ae0 | 8070 | "Show the defined BGP views\n") |
01080f7c | 8071 | { |
d62a17ae | 8072 | struct list *inst = bm->bgp; |
8073 | struct listnode *node; | |
8074 | struct bgp *bgp; | |
01080f7c | 8075 | |
d62a17ae | 8076 | vty_out(vty, "Defined BGP views:\n"); |
8077 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8078 | /* Skip VRFs. */ | |
8079 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8080 | continue; | |
8081 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8082 | bgp->as); | |
8083 | } | |
e52702f2 | 8084 | |
d62a17ae | 8085 | return CMD_SUCCESS; |
e0081f70 ML |
8086 | } |
8087 | ||
8386ac43 | 8088 | DEFUN (show_bgp_vrfs, |
8089 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8090 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8091 | SHOW_STR |
d6e3c605 | 8092 | IP_STR |
8386ac43 | 8093 | BGP_STR |
8094 | "Show BGP VRFs\n" | |
9973d184 | 8095 | JSON_STR) |
8386ac43 | 8096 | { |
fe1dc5a3 | 8097 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8098 | struct list *inst = bm->bgp; |
8099 | struct listnode *node; | |
8100 | struct bgp *bgp; | |
9f049418 | 8101 | bool uj = use_json(argc, argv); |
d62a17ae | 8102 | json_object *json = NULL; |
8103 | json_object *json_vrfs = NULL; | |
8104 | int count = 0; | |
d62a17ae | 8105 | |
d62a17ae | 8106 | if (uj) { |
8107 | json = json_object_new_object(); | |
8108 | json_vrfs = json_object_new_object(); | |
8109 | } | |
8110 | ||
8111 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8112 | const char *name, *type; | |
8113 | struct peer *peer; | |
7fe96307 | 8114 | struct listnode *node2, *nnode2; |
d62a17ae | 8115 | int peers_cfg, peers_estb; |
8116 | json_object *json_vrf = NULL; | |
d62a17ae | 8117 | |
8118 | /* Skip Views. */ | |
8119 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8120 | continue; | |
8121 | ||
8122 | count++; | |
efb4077a | 8123 | if (!uj && count == 1) { |
fe1dc5a3 | 8124 | vty_out(vty, |
efb4077a | 8125 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8126 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8127 | "#PeersEstb", "Name"); |
8128 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8129 | "L3-VNI", "RouterMAC", "Interface"); | |
8130 | } | |
d62a17ae | 8131 | |
8132 | peers_cfg = peers_estb = 0; | |
8133 | if (uj) | |
8134 | json_vrf = json_object_new_object(); | |
8135 | ||
8136 | ||
7fe96307 | 8137 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8138 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8139 | continue; | |
8140 | peers_cfg++; | |
8141 | if (peer->status == Established) | |
8142 | peers_estb++; | |
8143 | } | |
8144 | ||
8145 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8146 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8147 | type = "DFLT"; |
8148 | } else { | |
8149 | name = bgp->name; | |
8150 | type = "VRF"; | |
8151 | } | |
8152 | ||
a8bf7d9c | 8153 | |
d62a17ae | 8154 | if (uj) { |
a4d82a8a PZ |
8155 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8156 | ? -1 | |
8157 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8158 | json_object_string_add(json_vrf, "type", type); |
8159 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8160 | json_object_string_add(json_vrf, "routerId", | |
8161 | inet_ntoa(bgp->router_id)); | |
8162 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8163 | peers_cfg); | |
8164 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8165 | peers_estb); | |
8166 | ||
fe1dc5a3 | 8167 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8168 | json_object_string_add( |
8169 | json_vrf, "rmac", | |
8170 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8171 | json_object_string_add(json_vrf, "interface", |
8172 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8173 | bgp->vrf_id)); | |
d62a17ae | 8174 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8175 | } else { |
fe1dc5a3 | 8176 | vty_out(vty, |
efb4077a | 8177 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8178 | type, |
8179 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8180 | : (int)bgp->vrf_id, | |
8181 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8182 | peers_estb, name); |
8183 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8184 | bgp->l3vni, | |
8185 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8186 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8187 | bgp->vrf_id)); | |
8188 | } | |
d62a17ae | 8189 | } |
8190 | ||
8191 | if (uj) { | |
8192 | json_object_object_add(json, "vrfs", json_vrfs); | |
8193 | ||
8194 | json_object_int_add(json, "totalVrfs", count); | |
8195 | ||
996c9314 LB |
8196 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8197 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8198 | json_object_free(json); |
8199 | } else { | |
8200 | if (count) | |
8201 | vty_out(vty, | |
8202 | "\nTotal number of VRFs (including default): %d\n", | |
8203 | count); | |
8204 | } | |
8205 | ||
8206 | return CMD_SUCCESS; | |
8386ac43 | 8207 | } |
8208 | ||
48ecf8f5 DS |
8209 | DEFUN (show_bgp_mac_hash, |
8210 | show_bgp_mac_hash_cmd, | |
8211 | "show bgp mac hash", | |
8212 | SHOW_STR | |
8213 | BGP_STR | |
8214 | "Mac Address\n" | |
8215 | "Mac Address database\n") | |
8216 | { | |
8217 | bgp_mac_dump_table(vty); | |
8218 | ||
8219 | return CMD_SUCCESS; | |
8220 | } | |
acf71666 | 8221 | |
e3b78da8 | 8222 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8223 | { |
0291c246 | 8224 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8225 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8226 | |
60466a63 | 8227 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8228 | tip->refcnt); |
8229 | } | |
8230 | ||
8231 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8232 | { | |
8233 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8234 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8235 | |
8236 | vty_out(vty, "Tunnel-ip database:\n"); | |
8237 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8238 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8239 | vty); |
8240 | } | |
8241 | ||
15c81ca4 DS |
8242 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8243 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8244 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8245 | "martian next-hops\n" |
8246 | "martian next-hop database\n") | |
acf71666 | 8247 | { |
0291c246 | 8248 | struct bgp *bgp = NULL; |
15c81ca4 | 8249 | int idx = 0; |
9a8bdf1c PG |
8250 | char *name = NULL; |
8251 | ||
8252 | /* [<vrf> VIEWVRFNAME] */ | |
8253 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8254 | name = argv[idx + 1]->arg; | |
8255 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8256 | name = NULL; | |
8257 | } else if (argv_find(argv, argc, "view", &idx)) | |
8258 | /* [<view> VIEWVRFNAME] */ | |
8259 | name = argv[idx + 1]->arg; | |
8260 | if (name) | |
8261 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8262 | else |
8263 | bgp = bgp_get_default(); | |
acf71666 | 8264 | |
acf71666 MK |
8265 | if (!bgp) { |
8266 | vty_out(vty, "%% No BGP process is configured\n"); | |
8267 | return CMD_WARNING; | |
8268 | } | |
8269 | bgp_show_martian_nexthops(vty, bgp); | |
8270 | ||
8271 | return CMD_SUCCESS; | |
8272 | } | |
8273 | ||
f412b39a | 8274 | DEFUN (show_bgp_memory, |
4bf6a362 | 8275 | show_bgp_memory_cmd, |
7fa12b13 | 8276 | "show [ip] bgp memory", |
4bf6a362 | 8277 | SHOW_STR |
3a2d747c | 8278 | IP_STR |
4bf6a362 PJ |
8279 | BGP_STR |
8280 | "Global BGP memory statistics\n") | |
8281 | { | |
d62a17ae | 8282 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8283 | unsigned long count; | |
8284 | ||
8285 | /* RIB related usage stats */ | |
8286 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8287 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8288 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8289 | count * sizeof(struct bgp_node))); | |
8290 | ||
8291 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8292 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8293 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8294 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8295 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8296 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8297 | count, | |
4b7e6066 DS |
8298 | mtype_memstr( |
8299 | memstrbuf, sizeof(memstrbuf), | |
8300 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8301 | |
8302 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8303 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8304 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8305 | count * sizeof(struct bgp_static))); | |
8306 | ||
8307 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8308 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8309 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8310 | count * sizeof(struct bpacket))); | |
8311 | ||
8312 | /* Adj-In/Out */ | |
8313 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8314 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8315 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8316 | count * sizeof(struct bgp_adj_in))); | |
8317 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8318 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8319 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8320 | count * sizeof(struct bgp_adj_out))); | |
8321 | ||
8322 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8323 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8324 | count, | |
8325 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8326 | count * sizeof(struct bgp_nexthop_cache))); | |
8327 | ||
8328 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8329 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8330 | count, | |
8331 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8332 | count * sizeof(struct bgp_damp_info))); | |
8333 | ||
8334 | /* Attributes */ | |
8335 | count = attr_count(); | |
8336 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8337 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8338 | count * sizeof(struct attr))); | |
8339 | ||
8340 | if ((count = attr_unknown_count())) | |
8341 | vty_out(vty, "%ld unknown attributes\n", count); | |
8342 | ||
8343 | /* AS_PATH attributes */ | |
8344 | count = aspath_count(); | |
8345 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8346 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8347 | count * sizeof(struct aspath))); | |
8348 | ||
8349 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8350 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8351 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8352 | count * sizeof(struct assegment))); | |
8353 | ||
8354 | /* Other attributes */ | |
8355 | if ((count = community_count())) | |
8356 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8357 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8358 | count * sizeof(struct community))); | |
d62a17ae | 8359 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8360 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8361 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8362 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8363 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8364 | vty_out(vty, | |
8365 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8366 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8367 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8368 | |
8369 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8370 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8371 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8372 | count * sizeof(struct cluster_list))); | |
8373 | ||
8374 | /* Peer related usage */ | |
8375 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8376 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8377 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8378 | count * sizeof(struct peer))); | |
8379 | ||
8380 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8381 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8382 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8383 | count * sizeof(struct peer_group))); | |
8384 | ||
8385 | /* Other */ | |
d62a17ae | 8386 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8387 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8388 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8389 | count * sizeof(regex_t))); | |
d62a17ae | 8390 | return CMD_SUCCESS; |
4bf6a362 | 8391 | } |
fee0f4c6 | 8392 | |
57a9c8a8 DS |
8393 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8394 | { | |
8395 | json_object *bestpath = json_object_new_object(); | |
8396 | ||
8397 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
8398 | json_object_string_add(bestpath, "asPath", "ignore"); | |
8399 | ||
8400 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
8401 | json_object_string_add(bestpath, "asPath", "confed"); | |
8402 | ||
8403 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
8404 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
8405 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
8406 | "as-set"); |
8407 | else | |
a4d82a8a | 8408 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8409 | "true"); |
8410 | } else | |
a4d82a8a | 8411 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
8412 | |
8413 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
8414 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
8415 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
8416 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8417 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8418 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
8419 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
8420 | json_object_string_add(bestpath, "med", | |
8421 | "missing-as-worst"); | |
8422 | else | |
8423 | json_object_string_add(bestpath, "med", "true"); | |
8424 | } | |
8425 | ||
8426 | json_object_object_add(json, "bestPath", bestpath); | |
8427 | } | |
8428 | ||
3577f1c5 DD |
8429 | /* Print the error code/subcode for why the peer is down */ |
8430 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8431 | json_object *json_peer, bool use_json) | |
8432 | { | |
8433 | const char *code_str; | |
8434 | const char *subcode_str; | |
8435 | ||
8436 | if (use_json) { | |
8437 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8438 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8439 | char errorcodesubcode_hexstr[5]; | |
8440 | char errorcodesubcode_str[256]; | |
8441 | ||
8442 | code_str = bgp_notify_code_str(peer->notify.code); | |
8443 | subcode_str = bgp_notify_subcode_str( | |
8444 | peer->notify.code, | |
8445 | peer->notify.subcode); | |
8446 | ||
8447 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
8448 | peer->notify.code, peer->notify.subcode); | |
8449 | json_object_string_add(json_peer, | |
8450 | "lastErrorCodeSubcode", | |
8451 | errorcodesubcode_hexstr); | |
8452 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8453 | code_str, subcode_str); | |
8454 | json_object_string_add(json_peer, | |
8455 | "lastNotificationReason", | |
8456 | errorcodesubcode_str); | |
8457 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8458 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8459 | && (peer->notify.subcode | |
8460 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8461 | || peer->notify.subcode | |
8462 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8463 | && peer->notify.length) { | |
8464 | char msgbuf[1024]; | |
8465 | const char *msg_str; | |
8466 | ||
8467 | msg_str = bgp_notify_admin_message( | |
8468 | msgbuf, sizeof(msgbuf), | |
8469 | (uint8_t *)peer->notify.data, | |
8470 | peer->notify.length); | |
8471 | if (msg_str) | |
8472 | json_object_string_add( | |
8473 | json_peer, | |
8474 | "lastShutdownDescription", | |
8475 | msg_str); | |
8476 | } | |
8477 | ||
c258527b | 8478 | } |
3577f1c5 DD |
8479 | json_object_string_add(json_peer, "lastResetDueTo", |
8480 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8481 | json_object_int_add(json_peer, "lastResetCode", |
8482 | peer->last_reset); | |
3577f1c5 DD |
8483 | } else { |
8484 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8485 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8486 | code_str = bgp_notify_code_str(peer->notify.code); | |
8487 | subcode_str = | |
8488 | bgp_notify_subcode_str(peer->notify.code, | |
8489 | peer->notify.subcode); | |
8490 | vty_out(vty, " Notification %s (%s%s)\n", | |
8491 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8492 | ? "sent" | |
8493 | : "received", | |
8494 | code_str, subcode_str); | |
8495 | } else { | |
8496 | vty_out(vty, " %s\n", | |
8497 | peer_down_str[(int)peer->last_reset]); | |
8498 | } | |
8499 | } | |
8500 | } | |
8501 | ||
8502 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8503 | safi_t safi) | |
8504 | { | |
8505 | return ((peer->status != Established) || | |
8506 | !peer->afc_recv[afi][safi]); | |
8507 | } | |
8508 | ||
8509 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8510 | struct peer *peer, json_object *json_peer, | |
8511 | int max_neighbor_width, bool use_json) | |
8512 | { | |
8513 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8514 | int len; | |
8515 | ||
8516 | if (use_json) { | |
8517 | if (peer_dynamic_neighbor(peer)) | |
8518 | json_object_boolean_true_add(json_peer, | |
8519 | "dynamicPeer"); | |
8520 | if (peer->hostname) | |
8521 | json_object_string_add(json_peer, "hostname", | |
8522 | peer->hostname); | |
8523 | ||
8524 | if (peer->domainname) | |
8525 | json_object_string_add(json_peer, "domainname", | |
8526 | peer->domainname); | |
8527 | json_object_int_add(json_peer, "connectionsEstablished", | |
8528 | peer->established); | |
8529 | json_object_int_add(json_peer, "connectionsDropped", | |
8530 | peer->dropped); | |
8531 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8532 | use_json, json_peer); | |
8533 | if (peer->status == Established) | |
8534 | json_object_string_add(json_peer, "lastResetDueTo", | |
8535 | "AFI/SAFI Not Negotiated"); | |
8536 | else | |
8537 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8538 | } else { | |
8539 | dn_flag[1] = '\0'; | |
8540 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8541 | if (peer->hostname | |
8542 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8543 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8544 | peer->hostname, peer->host); | |
8545 | else | |
8546 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8547 | ||
8548 | /* pad the neighbor column with spaces */ | |
8549 | if (len < max_neighbor_width) | |
8550 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8551 | " "); | |
8552 | vty_out(vty, "%7d %7d %8s", peer->established, | |
8553 | peer->dropped, | |
8554 | peer_uptime(peer->uptime, timebuf, | |
8555 | BGP_UPTIME_LEN, 0, NULL)); | |
8556 | if (peer->status == Established) | |
8557 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8558 | else | |
8559 | bgp_show_peer_reset(vty, peer, NULL, | |
8560 | false); | |
8561 | } | |
8562 | } | |
c258527b | 8563 | |
3577f1c5 | 8564 | |
718e3744 | 8565 | /* Show BGP peer's summary information. */ |
d62a17ae | 8566 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8567 | bool show_failed, bool use_json) |
d62a17ae | 8568 | { |
8569 | struct peer *peer; | |
8570 | struct listnode *node, *nnode; | |
8571 | unsigned int count = 0, dn_count = 0; | |
8572 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8573 | char neighbor_buf[VTY_BUFSIZ]; | |
8574 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8575 | int len, failed_count = 0; |
d62a17ae | 8576 | int max_neighbor_width = 0; |
8577 | int pfx_rcd_safi; | |
3c13337d | 8578 | json_object *json = NULL; |
d62a17ae | 8579 | json_object *json_peer = NULL; |
8580 | json_object *json_peers = NULL; | |
50e05855 | 8581 | struct peer_af *paf; |
d62a17ae | 8582 | |
8583 | /* labeled-unicast routes are installed in the unicast table so in order | |
8584 | * to | |
8585 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8586 | */ | |
3577f1c5 | 8587 | |
d62a17ae | 8588 | if (safi == SAFI_LABELED_UNICAST) |
8589 | pfx_rcd_safi = SAFI_UNICAST; | |
8590 | else | |
8591 | pfx_rcd_safi = safi; | |
8592 | ||
8593 | if (use_json) { | |
3c13337d | 8594 | json = json_object_new_object(); |
d62a17ae | 8595 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8596 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8597 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8598 | continue; | |
8599 | ||
8600 | if (peer->afc[afi][safi]) { | |
8601 | /* See if we have at least a single failed peer */ | |
8602 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8603 | failed_count++; | |
8604 | count++; | |
8605 | } | |
8606 | if (peer_dynamic_neighbor(peer)) | |
8607 | dn_count++; | |
8608 | } | |
c258527b | 8609 | |
d62a17ae | 8610 | } else { |
8611 | /* Loop over all neighbors that will be displayed to determine | |
8612 | * how many | |
8613 | * characters are needed for the Neighbor column | |
8614 | */ | |
8615 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8616 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8617 | continue; | |
8618 | ||
8619 | if (peer->afc[afi][safi]) { | |
8620 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8621 | if (peer_dynamic_neighbor(peer)) | |
8622 | dn_flag[0] = '*'; | |
8623 | ||
8624 | if (peer->hostname | |
8625 | && bgp_flag_check(bgp, | |
8626 | BGP_FLAG_SHOW_HOSTNAME)) | |
8627 | sprintf(neighbor_buf, "%s%s(%s) ", | |
8628 | dn_flag, peer->hostname, | |
8629 | peer->host); | |
8630 | else | |
8631 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8632 | peer->host); | |
8633 | ||
8634 | len = strlen(neighbor_buf); | |
8635 | ||
8636 | if (len > max_neighbor_width) | |
8637 | max_neighbor_width = len; | |
c258527b | 8638 | |
3577f1c5 DD |
8639 | /* See if we have at least a single failed peer */ |
8640 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8641 | failed_count++; | |
8642 | count++; | |
d62a17ae | 8643 | } |
8644 | } | |
f933309e | 8645 | |
d62a17ae | 8646 | /* Originally we displayed the Neighbor column as 16 |
8647 | * characters wide so make that the default | |
8648 | */ | |
8649 | if (max_neighbor_width < neighbor_col_default_width) | |
8650 | max_neighbor_width = neighbor_col_default_width; | |
8651 | } | |
f933309e | 8652 | |
3577f1c5 DD |
8653 | if (show_failed && !failed_count) { |
8654 | if (use_json) { | |
8655 | json_object_int_add(json, "failedPeersCount", 0); | |
8656 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8657 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8658 | |
8659 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8660 | json, JSON_C_TO_STRING_PRETTY)); | |
8661 | json_object_free(json); | |
8662 | } else { | |
8663 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8664 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8665 | } | |
8666 | return CMD_SUCCESS; | |
8667 | } | |
c258527b | 8668 | |
3577f1c5 | 8669 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8670 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8671 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8672 | continue; | |
8673 | ||
ea47320b DL |
8674 | if (!peer->afc[afi][safi]) |
8675 | continue; | |
d62a17ae | 8676 | |
ea47320b DL |
8677 | if (!count) { |
8678 | unsigned long ents; | |
8679 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8680 | int64_t vrf_id_ui; |
d62a17ae | 8681 | |
a4d82a8a PZ |
8682 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8683 | ? -1 | |
8684 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8685 | |
8686 | /* Usage summary and header */ | |
8687 | if (use_json) { | |
8688 | json_object_string_add( | |
8689 | json, "routerId", | |
8690 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8691 | json_object_int_add(json, "as", bgp->as); |
8692 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8693 | json_object_string_add( |
8694 | json, "vrfName", | |
8695 | (bgp->inst_type | |
8696 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8697 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8698 | : bgp->name); |
8699 | } else { | |
8700 | vty_out(vty, | |
8701 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8702 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8703 | bgp->vrf_id == VRF_UNKNOWN |
8704 | ? -1 | |
8705 | : (int)bgp->vrf_id); | |
ea47320b DL |
8706 | vty_out(vty, "\n"); |
8707 | } | |
d62a17ae | 8708 | |
ea47320b | 8709 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8710 | if (use_json) { |
ea47320b | 8711 | json_object_int_add( |
60466a63 | 8712 | json, "updateDelayLimit", |
ea47320b | 8713 | bgp->v_update_delay); |
d62a17ae | 8714 | |
ea47320b DL |
8715 | if (bgp->v_update_delay |
8716 | != bgp->v_establish_wait) | |
d62a17ae | 8717 | json_object_int_add( |
8718 | json, | |
ea47320b DL |
8719 | "updateDelayEstablishWait", |
8720 | bgp->v_establish_wait); | |
d62a17ae | 8721 | |
60466a63 | 8722 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8723 | json_object_string_add( |
8724 | json, | |
8725 | "updateDelayFirstNeighbor", | |
8726 | bgp->update_delay_begin_time); | |
8727 | json_object_boolean_true_add( | |
8728 | json, | |
8729 | "updateDelayInProgress"); | |
8730 | } else { | |
8731 | if (bgp->update_delay_over) { | |
d62a17ae | 8732 | json_object_string_add( |
8733 | json, | |
8734 | "updateDelayFirstNeighbor", | |
8735 | bgp->update_delay_begin_time); | |
ea47320b | 8736 | json_object_string_add( |
d62a17ae | 8737 | json, |
ea47320b DL |
8738 | "updateDelayBestpathResumed", |
8739 | bgp->update_delay_end_time); | |
8740 | json_object_string_add( | |
d62a17ae | 8741 | json, |
ea47320b DL |
8742 | "updateDelayZebraUpdateResume", |
8743 | bgp->update_delay_zebra_resume_time); | |
8744 | json_object_string_add( | |
8745 | json, | |
8746 | "updateDelayPeerUpdateResume", | |
8747 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8748 | } |
ea47320b DL |
8749 | } |
8750 | } else { | |
8751 | vty_out(vty, | |
8752 | "Read-only mode update-delay limit: %d seconds\n", | |
8753 | bgp->v_update_delay); | |
8754 | if (bgp->v_update_delay | |
8755 | != bgp->v_establish_wait) | |
d62a17ae | 8756 | vty_out(vty, |
ea47320b DL |
8757 | " Establish wait: %d seconds\n", |
8758 | bgp->v_establish_wait); | |
d62a17ae | 8759 | |
60466a63 | 8760 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8761 | vty_out(vty, |
8762 | " First neighbor established: %s\n", | |
8763 | bgp->update_delay_begin_time); | |
8764 | vty_out(vty, | |
8765 | " Delay in progress\n"); | |
8766 | } else { | |
8767 | if (bgp->update_delay_over) { | |
d62a17ae | 8768 | vty_out(vty, |
8769 | " First neighbor established: %s\n", | |
8770 | bgp->update_delay_begin_time); | |
8771 | vty_out(vty, | |
ea47320b DL |
8772 | " Best-paths resumed: %s\n", |
8773 | bgp->update_delay_end_time); | |
8774 | vty_out(vty, | |
8775 | " zebra update resumed: %s\n", | |
8776 | bgp->update_delay_zebra_resume_time); | |
8777 | vty_out(vty, | |
8778 | " peers update resumed: %s\n", | |
8779 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8780 | } |
8781 | } | |
8782 | } | |
ea47320b | 8783 | } |
d62a17ae | 8784 | |
ea47320b DL |
8785 | if (use_json) { |
8786 | if (bgp_maxmed_onstartup_configured(bgp) | |
8787 | && bgp->maxmed_active) | |
8788 | json_object_boolean_true_add( | |
60466a63 | 8789 | json, "maxMedOnStartup"); |
ea47320b DL |
8790 | if (bgp->v_maxmed_admin) |
8791 | json_object_boolean_true_add( | |
60466a63 | 8792 | json, "maxMedAdministrative"); |
d62a17ae | 8793 | |
ea47320b DL |
8794 | json_object_int_add( |
8795 | json, "tableVersion", | |
60466a63 | 8796 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8797 | |
60466a63 QY |
8798 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8799 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8800 | json_object_int_add( |
8801 | json, "ribMemory", | |
8802 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8803 | |
210ec2a0 | 8804 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8805 | json_object_int_add(json, "peerCount", ents); |
8806 | json_object_int_add(json, "peerMemory", | |
8807 | ents * sizeof(struct peer)); | |
d62a17ae | 8808 | |
ea47320b DL |
8809 | if ((ents = listcount(bgp->group))) { |
8810 | json_object_int_add( | |
60466a63 | 8811 | json, "peerGroupCount", ents); |
ea47320b DL |
8812 | json_object_int_add( |
8813 | json, "peerGroupMemory", | |
996c9314 LB |
8814 | ents * sizeof(struct |
8815 | peer_group)); | |
ea47320b | 8816 | } |
d62a17ae | 8817 | |
ea47320b DL |
8818 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8819 | BGP_CONFIG_DAMPENING)) | |
8820 | json_object_boolean_true_add( | |
60466a63 | 8821 | json, "dampeningEnabled"); |
ea47320b DL |
8822 | } else { |
8823 | if (bgp_maxmed_onstartup_configured(bgp) | |
8824 | && bgp->maxmed_active) | |
d62a17ae | 8825 | vty_out(vty, |
ea47320b DL |
8826 | "Max-med on-startup active\n"); |
8827 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8828 | vty_out(vty, |
ea47320b | 8829 | "Max-med administrative active\n"); |
d62a17ae | 8830 | |
60466a63 QY |
8831 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8832 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8833 | |
60466a63 | 8834 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8835 | vty_out(vty, |
8836 | "RIB entries %ld, using %s of memory\n", | |
8837 | ents, | |
996c9314 LB |
8838 | mtype_memstr(memstrbuf, |
8839 | sizeof(memstrbuf), | |
8840 | ents * sizeof(struct | |
8841 | bgp_node))); | |
ea47320b DL |
8842 | |
8843 | /* Peer related usage */ | |
210ec2a0 | 8844 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8845 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8846 | ents, |
8847 | mtype_memstr( | |
60466a63 QY |
8848 | memstrbuf, sizeof(memstrbuf), |
8849 | ents * sizeof(struct peer))); | |
ea47320b DL |
8850 | |
8851 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8852 | vty_out(vty, |
ea47320b | 8853 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8854 | ents, |
8855 | mtype_memstr( | |
8856 | memstrbuf, | |
8857 | sizeof(memstrbuf), | |
996c9314 LB |
8858 | ents * sizeof(struct |
8859 | peer_group))); | |
d62a17ae | 8860 | |
ea47320b DL |
8861 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8862 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8863 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8864 | vty_out(vty, "\n"); |
d62a17ae | 8865 | |
ea47320b DL |
8866 | /* Subtract 8 here because 'Neighbor' is |
8867 | * 8 characters */ | |
8868 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8869 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8870 | " "); | |
3577f1c5 DD |
8871 | if (show_failed) |
8872 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8873 | else | |
8874 | vty_out(vty, | |
ea47320b | 8875 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 8876 | } |
ea47320b | 8877 | } |
d62a17ae | 8878 | |
ea47320b | 8879 | count++; |
3577f1c5 DD |
8880 | /* Works for both failed & successful cases */ |
8881 | if (peer_dynamic_neighbor(peer)) | |
8882 | dn_count++; | |
d62a17ae | 8883 | |
ea47320b | 8884 | if (use_json) { |
3577f1c5 DD |
8885 | json_peer = NULL; |
8886 | ||
8887 | if (show_failed && | |
8888 | bgp_has_peer_failed(peer, afi, safi)) { | |
8889 | json_peer = json_object_new_object(); | |
8890 | bgp_show_failed_summary(vty, bgp, peer, | |
8891 | json_peer, 0, use_json); | |
8892 | } else if (!show_failed) { | |
8893 | json_peer = json_object_new_object(); | |
8894 | if (peer_dynamic_neighbor(peer)) { | |
8895 | json_object_boolean_true_add(json_peer, | |
8896 | "dynamicPeer"); | |
8897 | } | |
d62a17ae | 8898 | |
3577f1c5 DD |
8899 | if (peer->hostname) |
8900 | json_object_string_add(json_peer, "hostname", | |
8901 | peer->hostname); | |
8902 | ||
8903 | if (peer->domainname) | |
8904 | json_object_string_add(json_peer, "domainname", | |
8905 | peer->domainname); | |
8906 | ||
8907 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
8908 | json_object_int_add(json_peer, "version", 4); | |
8909 | json_object_int_add(json_peer, "msgRcvd", | |
8910 | PEER_TOTAL_RX(peer)); | |
8911 | json_object_int_add(json_peer, "msgSent", | |
8912 | PEER_TOTAL_TX(peer)); | |
8913 | ||
8914 | json_object_int_add(json_peer, "tableVersion", | |
8915 | peer->version[afi][safi]); | |
8916 | json_object_int_add(json_peer, "outq", | |
8917 | peer->obuf->count); | |
8918 | json_object_int_add(json_peer, "inq", 0); | |
8919 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8920 | use_json, json_peer); | |
8921 | ||
8922 | /* | |
8923 | * Adding "pfxRcd" field to match with the corresponding | |
8924 | * CLI. "prefixReceivedCount" will be deprecated in | |
8925 | * future. | |
8926 | */ | |
8927 | json_object_int_add(json_peer, "prefixReceivedCount", | |
8928 | peer->pcount[afi][pfx_rcd_safi]); | |
8929 | json_object_int_add(json_peer, "pfxRcd", | |
8930 | peer->pcount[afi][pfx_rcd_safi]); | |
8931 | ||
8932 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8933 | if (paf && PAF_SUBGRP(paf)) | |
8934 | json_object_int_add(json_peer, | |
8935 | "pfxSnt", | |
8936 | (PAF_SUBGRP(paf))->scount); | |
8937 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
8938 | json_object_string_add(json_peer, "state", | |
8939 | "Idle (Admin)"); | |
8940 | else if (peer->afc_recv[afi][safi]) | |
8941 | json_object_string_add( | |
8942 | json_peer, "state", | |
8943 | lookup_msg(bgp_status_msg, peer->status, | |
8944 | NULL)); | |
8945 | else if (CHECK_FLAG(peer->sflags, | |
8946 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8947 | json_object_string_add(json_peer, "state", | |
8948 | "Idle (PfxCt)"); | |
8949 | else | |
8950 | json_object_string_add( | |
8951 | json_peer, "state", | |
8952 | lookup_msg(bgp_status_msg, peer->status, | |
8953 | NULL)); | |
200116db DD |
8954 | json_object_int_add(json_peer, "connectionsEstablished", |
8955 | peer->established); | |
8956 | json_object_int_add(json_peer, "connectionsDropped", | |
8957 | peer->dropped); | |
b4e9dcba | 8958 | } |
3577f1c5 DD |
8959 | /* Avoid creating empty peer dicts in JSON */ |
8960 | if (json_peer == NULL) | |
8961 | continue; | |
ea47320b DL |
8962 | |
8963 | if (peer->conf_if) | |
60466a63 | 8964 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8965 | "interface"); |
8966 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8967 | json_object_string_add(json_peer, "idType", |
8968 | "ipv4"); | |
ea47320b | 8969 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8970 | json_object_string_add(json_peer, "idType", |
8971 | "ipv6"); | |
ea47320b DL |
8972 | json_object_object_add(json_peers, peer->host, |
8973 | json_peer); | |
8974 | } else { | |
3577f1c5 DD |
8975 | if (show_failed && |
8976 | bgp_has_peer_failed(peer, afi, safi)) { | |
8977 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
8978 | max_neighbor_width, | |
8979 | use_json); | |
8980 | } else if (!show_failed) { | |
8981 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8982 | if (peer_dynamic_neighbor(peer)) { | |
8983 | dn_flag[0] = '*'; | |
8984 | } | |
d62a17ae | 8985 | |
3577f1c5 DD |
8986 | if (peer->hostname |
8987 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) | |
8988 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
8989 | peer->hostname, peer->host); | |
d62a17ae | 8990 | else |
3577f1c5 DD |
8991 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
8992 | ||
8993 | /* pad the neighbor column with spaces */ | |
8994 | if (len < max_neighbor_width) | |
8995 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8996 | " "); | |
8997 | ||
8998 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", | |
8999 | peer->as, PEER_TOTAL_RX(peer), | |
9000 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
9001 | 0, peer->obuf->count, | |
9002 | peer_uptime(peer->uptime, timebuf, | |
9003 | BGP_UPTIME_LEN, 0, NULL)); | |
9004 | ||
9005 | if (peer->status == Established) | |
9006 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
9007 | vty_out(vty, " %12" PRIu32, |
9008 | peer->pcount | |
9009 | [afi] | |
9010 | [pfx_rcd_safi]); | |
3577f1c5 DD |
9011 | else |
9012 | vty_out(vty, " NoNeg"); | |
9013 | else { | |
9014 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9015 | vty_out(vty, " Idle (Admin)"); | |
9016 | else if (CHECK_FLAG( | |
9017 | peer->sflags, | |
9018 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9019 | vty_out(vty, " Idle (PfxCt)"); | |
9020 | else | |
9021 | vty_out(vty, " %12s", | |
9022 | lookup_msg(bgp_status_msg, | |
9023 | peer->status, NULL)); | |
9024 | } | |
9025 | vty_out(vty, "\n"); | |
d62a17ae | 9026 | } |
3577f1c5 | 9027 | |
d62a17ae | 9028 | } |
9029 | } | |
f933309e | 9030 | |
d62a17ae | 9031 | if (use_json) { |
9032 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9033 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9034 | json_object_int_add(json, "totalPeers", count); |
9035 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9036 | ||
3577f1c5 DD |
9037 | if (!show_failed) |
9038 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9039 | |
996c9314 LB |
9040 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9041 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9042 | json_object_free(json); |
9043 | } else { | |
9044 | if (count) | |
9045 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9046 | else { | |
d6ceaca3 | 9047 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9048 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9049 | } |
b05a1c8b | 9050 | |
d6ceaca3 | 9051 | if (dn_count) { |
d62a17ae | 9052 | vty_out(vty, "* - dynamic neighbor\n"); |
9053 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9054 | dn_count, bgp->dynamic_neighbors_limit); | |
9055 | } | |
9056 | } | |
1ff9a340 | 9057 | |
d62a17ae | 9058 | return CMD_SUCCESS; |
718e3744 | 9059 | } |
9060 | ||
d62a17ae | 9061 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9062 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9063 | { |
9064 | int is_first = 1; | |
9065 | int afi_wildcard = (afi == AFI_MAX); | |
9066 | int safi_wildcard = (safi == SAFI_MAX); | |
9067 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9068 | bool nbr_output = false; |
d62a17ae | 9069 | |
9070 | if (use_json && is_wildcard) | |
9071 | vty_out(vty, "{\n"); | |
9072 | if (afi_wildcard) | |
9073 | afi = 1; /* AFI_IP */ | |
9074 | while (afi < AFI_MAX) { | |
9075 | if (safi_wildcard) | |
9076 | safi = 1; /* SAFI_UNICAST */ | |
9077 | while (safi < SAFI_MAX) { | |
318cac96 | 9078 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9079 | nbr_output = true; |
f86897b9 | 9080 | |
d62a17ae | 9081 | if (is_wildcard) { |
9082 | /* | |
9083 | * So limit output to those afi/safi | |
9084 | * pairs that | |
9085 | * actualy have something interesting in | |
9086 | * them | |
9087 | */ | |
9088 | if (use_json) { | |
d62a17ae | 9089 | if (!is_first) |
9090 | vty_out(vty, ",\n"); | |
9091 | else | |
9092 | is_first = 0; | |
9093 | ||
9094 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9095 | get_afi_safi_str(afi, |
9096 | safi, | |
9097 | true)); | |
d62a17ae | 9098 | } else { |
9099 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9100 | get_afi_safi_str(afi, |
9101 | safi, | |
9102 | false)); | |
d62a17ae | 9103 | } |
9104 | } | |
3577f1c5 DD |
9105 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9106 | use_json); | |
d62a17ae | 9107 | } |
9108 | safi++; | |
d62a17ae | 9109 | if (!safi_wildcard) |
9110 | safi = SAFI_MAX; | |
9111 | } | |
9112 | afi++; | |
ee851c8c | 9113 | if (!afi_wildcard) |
d62a17ae | 9114 | afi = AFI_MAX; |
9115 | } | |
9116 | ||
9117 | if (use_json && is_wildcard) | |
9118 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9119 | else if (!nbr_output) { |
9120 | if (use_json) | |
9121 | vty_out(vty, "{}\n"); | |
9122 | else | |
9123 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9124 | } | |
d62a17ae | 9125 | } |
9126 | ||
9127 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9128 | safi_t safi, bool show_failed, |
9129 | bool use_json) | |
d62a17ae | 9130 | { |
9131 | struct listnode *node, *nnode; | |
9132 | struct bgp *bgp; | |
d62a17ae | 9133 | int is_first = 1; |
9f049418 | 9134 | bool nbr_output = false; |
d62a17ae | 9135 | |
9136 | if (use_json) | |
9137 | vty_out(vty, "{\n"); | |
9138 | ||
9139 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9140 | nbr_output = true; |
d62a17ae | 9141 | if (use_json) { |
d62a17ae | 9142 | if (!is_first) |
9143 | vty_out(vty, ",\n"); | |
9144 | else | |
9145 | is_first = 0; | |
9146 | ||
9147 | vty_out(vty, "\"%s\":", | |
9148 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9149 | ? VRF_DEFAULT_NAME |
d62a17ae | 9150 | : bgp->name); |
9151 | } else { | |
9152 | vty_out(vty, "\nInstance %s:\n", | |
9153 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9154 | ? VRF_DEFAULT_NAME |
d62a17ae | 9155 | : bgp->name); |
9156 | } | |
3577f1c5 DD |
9157 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9158 | use_json); | |
d62a17ae | 9159 | } |
9160 | ||
9161 | if (use_json) | |
9162 | vty_out(vty, "}\n"); | |
9f049418 DS |
9163 | else if (!nbr_output) |
9164 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9165 | } |
9166 | ||
9167 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9168 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9169 | { |
9170 | struct bgp *bgp; | |
9171 | ||
9172 | if (name) { | |
9173 | if (strmatch(name, "all")) { | |
9174 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9175 | show_failed, |
d62a17ae | 9176 | use_json); |
9177 | return CMD_SUCCESS; | |
9178 | } else { | |
9179 | bgp = bgp_lookup_by_name(name); | |
9180 | ||
9181 | if (!bgp) { | |
9182 | if (use_json) | |
9183 | vty_out(vty, "{}\n"); | |
9184 | else | |
9185 | vty_out(vty, | |
ca61fd25 | 9186 | "%% BGP instance not found\n"); |
d62a17ae | 9187 | return CMD_WARNING; |
9188 | } | |
9189 | ||
f86897b9 | 9190 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9191 | show_failed, use_json); |
d62a17ae | 9192 | return CMD_SUCCESS; |
9193 | } | |
9194 | } | |
9195 | ||
9196 | bgp = bgp_get_default(); | |
9197 | ||
9198 | if (bgp) | |
3577f1c5 DD |
9199 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9200 | use_json); | |
9f049418 | 9201 | else { |
ca61fd25 DS |
9202 | if (use_json) |
9203 | vty_out(vty, "{}\n"); | |
9204 | else | |
9205 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9206 | return CMD_WARNING; |
9207 | } | |
d62a17ae | 9208 | |
9209 | return CMD_SUCCESS; | |
4fb25c53 DW |
9210 | } |
9211 | ||
716b2d8a | 9212 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9213 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9214 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9215 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9216 | SHOW_STR |
9217 | IP_STR | |
9218 | BGP_STR | |
8386ac43 | 9219 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9220 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9221 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9222 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9223 | "Show only sessions not in Established state\n" |
9973d184 | 9224 | JSON_STR) |
718e3744 | 9225 | { |
d62a17ae | 9226 | char *vrf = NULL; |
9227 | afi_t afi = AFI_MAX; | |
9228 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9229 | bool show_failed = false; |
d62a17ae | 9230 | |
9231 | int idx = 0; | |
9232 | ||
9233 | /* show [ip] bgp */ | |
9234 | if (argv_find(argv, argc, "ip", &idx)) | |
9235 | afi = AFI_IP; | |
9a8bdf1c PG |
9236 | /* [<vrf> VIEWVRFNAME] */ |
9237 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9238 | vrf = argv[idx + 1]->arg; | |
9239 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9240 | vrf = NULL; | |
9241 | } else if (argv_find(argv, argc, "view", &idx)) | |
9242 | /* [<view> VIEWVRFNAME] */ | |
9243 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9244 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9245 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9246 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9247 | } | |
9248 | ||
3577f1c5 DD |
9249 | if (argv_find(argv, argc, "failed", &idx)) |
9250 | show_failed = true; | |
9251 | ||
9f049418 | 9252 | bool uj = use_json(argc, argv); |
d62a17ae | 9253 | |
3577f1c5 | 9254 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9255 | } |
9256 | ||
5cb5f4d0 | 9257 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9258 | { |
5cb5f4d0 DD |
9259 | if (for_json) |
9260 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9261 | else |
5cb5f4d0 | 9262 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9263 | } |
9264 | ||
d62a17ae | 9265 | |
9266 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9267 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9268 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9269 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9270 | bool use_json, json_object *json_pref) |
d62a17ae | 9271 | { |
9272 | /* Send-Mode */ | |
9273 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9274 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9275 | if (use_json) { | |
9276 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9277 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9278 | json_object_string_add(json_pref, "sendMode", | |
9279 | "advertisedAndReceived"); | |
9280 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9281 | json_object_string_add(json_pref, "sendMode", | |
9282 | "advertised"); | |
9283 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9284 | json_object_string_add(json_pref, "sendMode", | |
9285 | "received"); | |
9286 | } else { | |
9287 | vty_out(vty, " Send-mode: "); | |
9288 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9289 | vty_out(vty, "advertised"); | |
9290 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9291 | vty_out(vty, "%sreceived", | |
9292 | CHECK_FLAG(p->af_cap[afi][safi], | |
9293 | adv_smcap) | |
9294 | ? ", " | |
9295 | : ""); | |
9296 | vty_out(vty, "\n"); | |
9297 | } | |
9298 | } | |
9299 | ||
9300 | /* Receive-Mode */ | |
9301 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9302 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9303 | if (use_json) { | |
9304 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9305 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9306 | json_object_string_add(json_pref, "recvMode", | |
9307 | "advertisedAndReceived"); | |
9308 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9309 | json_object_string_add(json_pref, "recvMode", | |
9310 | "advertised"); | |
9311 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9312 | json_object_string_add(json_pref, "recvMode", | |
9313 | "received"); | |
9314 | } else { | |
9315 | vty_out(vty, " Receive-mode: "); | |
9316 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9317 | vty_out(vty, "advertised"); | |
9318 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9319 | vty_out(vty, "%sreceived", | |
9320 | CHECK_FLAG(p->af_cap[afi][safi], | |
9321 | adv_rmcap) | |
9322 | ? ", " | |
9323 | : ""); | |
9324 | vty_out(vty, "\n"); | |
9325 | } | |
9326 | } | |
9327 | } | |
9328 | ||
2986cac2 | 9329 | static void bgp_show_neighnor_graceful_restart_rbit( |
9330 | struct vty *vty, | |
9331 | struct peer *p, | |
9332 | bool use_json, | |
9333 | json_object *json) | |
9334 | { | |
9335 | bool rbit_status = 0; | |
9336 | ||
9337 | if (!use_json) | |
9338 | vty_out(vty, "\n R bit : "); | |
9339 | ||
9340 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
9341 | (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) && | |
9342 | (p->status == Established)) { | |
9343 | ||
9344 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
9345 | rbit_status = 1; | |
9346 | else | |
9347 | rbit_status = 0; | |
9348 | } | |
9349 | ||
9350 | if (rbit_status) { | |
9351 | if (use_json) | |
9352 | json_object_boolean_true_add( | |
9353 | json, "rBit"); | |
9354 | else | |
9355 | vty_out(vty, "True\n"); | |
9356 | } else { | |
9357 | if (use_json) | |
9358 | json_object_boolean_false_add( | |
9359 | json, "rBit"); | |
9360 | else | |
9361 | vty_out(vty, "False\n"); | |
9362 | } | |
9363 | } | |
9364 | ||
9365 | static void bgp_show_neighbor_graceful_restart_remote_mode( | |
9366 | struct vty *vty, | |
9367 | struct peer *peer, | |
9368 | bool use_json, | |
9369 | json_object *json) | |
9370 | { | |
2bb5d39b | 9371 | const char *mode = "NotApplicable"; |
2986cac2 | 9372 | |
9373 | if (!use_json) | |
9374 | vty_out(vty, "\n Remote GR Mode : "); | |
9375 | ||
9376 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) && | |
2986cac2 | 9377 | (peer->status == Established)) { |
9378 | ||
9379 | if ((peer->nsf_af_count == 0) && | |
9380 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
9381 | ||
9382 | /*Gr disabled case*/ | |
9383 | mode = "Disable"; | |
9384 | ||
2bb5d39b | 9385 | } else if (peer->nsf_af_count == 0 && |
9386 | CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9387 | |
9388 | /* Helper */ | |
9389 | mode = "Helper"; | |
9390 | ||
2bb5d39b | 9391 | } else if (peer->nsf_af_count != 0 && |
9392 | CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9393 | |
9394 | /* Restart */ | |
9395 | mode = "Restart"; | |
9396 | ||
9397 | } | |
9398 | } | |
9399 | ||
9400 | if (use_json) { | |
9401 | json_object_string_add(json, | |
9402 | "remoteGrMode", mode); | |
9403 | } else | |
9404 | vty_out(vty, mode, "\n"); | |
9405 | } | |
9406 | ||
9407 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, | |
9408 | struct peer *p, | |
9409 | bool use_json, | |
9410 | json_object *json) | |
9411 | { | |
9412 | const char *mode = "Invalid"; | |
9413 | ||
9414 | if (!use_json) | |
9415 | vty_out(vty, " Local GR Mode : "); | |
9416 | ||
9417 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9418 | mode = "Helper"; | |
9419 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9420 | mode = "Restart"; | |
9421 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9422 | mode = "Disable"; | |
9423 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) | |
9424 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) | |
9425 | mode = "Helper*"; | |
9426 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9427 | mode = "Restart*"; | |
9428 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9429 | mode = "Disable*"; | |
9430 | else | |
9431 | mode = "Invalid*"; | |
9432 | else | |
9433 | mode = "Invalid"; | |
9434 | ||
9435 | if (use_json) { | |
9436 | json_object_string_add(json, | |
9437 | "localGrMode", mode); | |
9438 | } else { | |
9439 | vty_out(vty, mode, "\n"); | |
9440 | } | |
9441 | } | |
9442 | ||
9443 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( | |
9444 | struct vty *vty, struct peer *peer, | |
9445 | bool use_json, json_object *json) | |
9446 | { | |
9447 | afi_t afi = AFI_MAX; | |
9448 | safi_t safi = SAFI_MAX; | |
9449 | json_object *json_afi_safi = NULL; | |
9450 | json_object *json_timer = NULL; | |
9451 | json_object *json_endofrib_status = NULL; | |
9452 | ||
9453 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9454 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
3a75afa4 | 9455 | if (peer->afc[afi][safi] |
2986cac2 | 9456 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
3a75afa4 | 9457 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV) |
9458 | ) { | |
2986cac2 | 9459 | if (use_json) { |
9460 | json_afi_safi = | |
9461 | json_object_new_object(); | |
9462 | json_endofrib_status = | |
9463 | json_object_new_object(); | |
9464 | json_timer = | |
9465 | json_object_new_object(); | |
9466 | } | |
9467 | ||
9468 | if (!use_json) { | |
9469 | vty_out(vty, " %s :\n", | |
9470 | get_afi_safi_str(afi, safi, false)); | |
9471 | ||
9472 | vty_out(vty, | |
9473 | " F bit : "); | |
9474 | } else | |
9475 | get_afi_safi_str(afi, safi, true); | |
9476 | ||
9477 | if (peer->nsf[afi][safi] | |
9478 | && CHECK_FLAG( | |
9479 | peer->af_cap[afi][safi], | |
9480 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
9481 | ||
9482 | if (use_json) { | |
9483 | json_object_boolean_true_add( | |
9484 | json_afi_safi, "fBit"); | |
9485 | } else { | |
9486 | vty_out(vty, | |
9487 | "True\n"); | |
9488 | } | |
9489 | ||
9490 | } else { | |
9491 | ||
9492 | if (use_json) { | |
9493 | json_object_boolean_false_add( | |
9494 | json_afi_safi, "fBit"); | |
9495 | } else { | |
9496 | vty_out(vty, | |
9497 | "False\n"); | |
9498 | } | |
9499 | ||
9500 | } | |
9501 | ||
9502 | if (!use_json) | |
9503 | vty_out(vty, | |
9504 | " End-of-RIB Received : "); | |
9505 | ||
9506 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9507 | PEER_STATUS_EOR_RECEIVED)) { | |
9508 | ||
9509 | if (use_json) { | |
9510 | json_object_boolean_true_add( | |
9511 | json_endofrib_status, | |
9512 | "endOfRibRecv"); | |
9513 | } else { | |
9514 | vty_out(vty, "Yes\n"); | |
9515 | } | |
9516 | ||
9517 | } else { | |
9518 | if (use_json) { | |
9519 | json_object_boolean_false_add( | |
9520 | json_endofrib_status, | |
9521 | "endOfRibRecv"); | |
9522 | } else { | |
9523 | vty_out(vty, "No\n"); | |
9524 | } | |
9525 | } | |
9526 | ||
9527 | if (!use_json) | |
9528 | vty_out(vty, | |
9529 | " End-of-RIB Send : "); | |
9530 | ||
9531 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9532 | PEER_STATUS_EOR_SEND)) { | |
9533 | ||
9534 | if (use_json) { | |
9535 | json_object_boolean_true_add( | |
9536 | json_endofrib_status, | |
9537 | "endOfRibSend"); | |
9538 | } else { | |
9539 | vty_out(vty, "Yes\n"); | |
9540 | } | |
9541 | ||
9542 | } else { | |
9543 | if (use_json) { | |
9544 | json_object_boolean_false_add( | |
9545 | json_endofrib_status, | |
9546 | "endOfRibSend"); | |
9547 | } else { | |
9548 | vty_out(vty, "No\n"); | |
9549 | } | |
9550 | } | |
9551 | ||
9552 | if (use_json) { | |
9553 | ||
9554 | json_object_int_add(json_timer, | |
9555 | "stalePathTimer", | |
9556 | peer->bgp->stalepath_time); | |
9557 | ||
9558 | if (peer->t_gr_stale != NULL) { | |
9559 | ||
9560 | json_object_int_add( | |
9561 | json_timer, | |
9562 | "stalePathTimerRemaining", | |
9563 | thread_timer_remain_second( | |
9564 | peer->t_gr_stale)); | |
9565 | } | |
9566 | ||
3a75afa4 | 9567 | /* Display Configured Selection |
9568 | * Deferral only when when | |
9569 | * Gr mode is enabled. | |
9570 | */ | |
9571 | if (CHECK_FLAG(peer->flags, | |
9572 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9573 | ||
9574 | json_object_int_add( | |
9575 | json_timer, | |
2986cac2 | 9576 | "selectionDeferralTimer", |
9577 | peer->bgp->stalepath_time); | |
3a75afa4 | 9578 | } |
2986cac2 | 9579 | |
9580 | if (peer->bgp | |
9581 | ->gr_info[afi][safi] | |
9582 | .t_select_deferral != NULL) { | |
9583 | ||
9584 | json_object_int_add( | |
9585 | json_timer, | |
9586 | "selectionDeferralTimerRemaining", | |
9587 | thread_timer_remain_second( | |
9588 | peer->bgp | |
9589 | ->gr_info[afi][safi] | |
9590 | .t_select_deferral)); | |
9591 | } | |
9592 | ||
9593 | } else { | |
9594 | ||
9595 | vty_out(vty, " Timers:\n"); | |
9596 | ||
9597 | vty_out(vty, "%*s", 6, ""); | |
9598 | vty_out(vty, | |
3a75afa4 | 9599 | "Configured Stale Path Time(sec)%*s: %u\n", |
9600 | 8, "", | |
2986cac2 | 9601 | peer->bgp->stalepath_time); |
9602 | ||
9603 | if (peer->t_gr_stale != NULL) { | |
9604 | vty_out(vty, "%*s", 6, ""); | |
9605 | vty_out(vty, | |
9606 | "Stale Path Remaining(sec)%*s: %ld\n", | |
9607 | 14, "", | |
9608 | thread_timer_remain_second( | |
9609 | peer->t_gr_stale)); | |
9610 | } | |
3a75afa4 | 9611 | /* Display Configured Selection |
9612 | * Deferral only when when | |
9613 | * Gr mode is enabled. | |
9614 | */ | |
9615 | if (CHECK_FLAG(peer->flags, | |
9616 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9617 | vty_out(vty, "%*s", 6, ""); | |
9618 | vty_out(vty, | |
9619 | "Configured Selection Deferral Time(sec): %u\n", | |
9620 | peer->bgp->select_defer_time); | |
9621 | } | |
2986cac2 | 9622 | |
9623 | if (peer->bgp | |
9624 | ->gr_info[afi][safi] | |
9625 | .t_select_deferral != NULL) { | |
9626 | ||
9627 | vty_out(vty, "%*s", 6, ""); | |
9628 | vty_out(vty, | |
9629 | "Selection Deferral Time Remaining(sec) : %ld\n", | |
9630 | thread_timer_remain_second( | |
9631 | peer->bgp | |
9632 | ->gr_info[afi][safi] | |
9633 | .t_select_deferral)); | |
9634 | } | |
9635 | ||
9636 | } | |
9637 | if (use_json) { | |
9638 | json_object_object_add(json_afi_safi, | |
9639 | "endOfRibStatus", | |
9640 | json_endofrib_status); | |
9641 | json_object_object_add(json_afi_safi, | |
9642 | "timers", | |
9643 | json_timer); | |
9644 | json_object_object_add(json, | |
9645 | get_afi_safi_str(afi, safi, true), | |
9646 | json_afi_safi); | |
9647 | } | |
9648 | } | |
9649 | } | |
9650 | } | |
9651 | } | |
9652 | ||
9653 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, | |
9654 | struct peer *p, | |
9655 | bool use_json, | |
9656 | json_object *json) | |
9657 | { | |
9658 | if (use_json) { | |
9659 | json_object *json_timer = NULL; | |
9660 | ||
9661 | json_timer = json_object_new_object(); | |
9662 | ||
9663 | json_object_int_add(json_timer, | |
9664 | "configuredRestartTimer", | |
9665 | p->bgp->restart_time); | |
9666 | ||
9667 | json_object_int_add(json_timer, | |
9668 | "recivedRestartTimer", | |
9669 | p->v_gr_restart); | |
9670 | ||
9671 | if (p->t_gr_restart != NULL) { | |
9672 | json_object_int_add(json_timer, | |
9673 | "restartTimerRemaining", | |
9674 | thread_timer_remain_second( | |
9675 | p->t_gr_restart) | |
9676 | ); | |
9677 | } | |
9678 | ||
9679 | json_object_object_add(json, "timers", json_timer); | |
9680 | } else { | |
9681 | ||
9682 | vty_out(vty, " Timers :\n"); | |
9683 | vty_out(vty, | |
9684 | " Configured Restart Time(sec) : %u\n", | |
9685 | p->bgp->restart_time); | |
9686 | ||
9687 | vty_out(vty, | |
9688 | " Received Restart Time(sec) : %u\n", | |
9689 | p->v_gr_restart); | |
9690 | if (p->t_gr_restart != NULL) { | |
9691 | vty_out(vty, | |
9692 | " Restart Time Remaining(sec) : %ld\n", | |
9693 | thread_timer_remain_second( | |
9694 | p->t_gr_restart)); | |
9695 | } | |
9696 | } | |
9697 | } | |
9698 | ||
9699 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
9700 | bool use_json, | |
9701 | json_object *json) | |
9702 | { | |
9703 | char buf[SU_ADDRSTRLEN] = {0}; | |
9704 | char dn_flag[2] = {0}; | |
9705 | char neighborAddr[INET6_ADDRSTRLEN] = {0}; | |
9706 | ||
9707 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9708 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9709 | dn_flag[0] = '*'; | |
9710 | ||
9711 | if (p->conf_if) { | |
9712 | if (use_json) | |
9713 | json_object_string_add(json, "neighborAddr", | |
9714 | BGP_PEER_SU_UNSPEC(p) | |
9715 | ? "none" | |
9716 | : sockunion2str(&p->su, buf, | |
9717 | SU_ADDRSTRLEN)); | |
9718 | else | |
9719 | vty_out(vty, "BGP neighbor on %s: %s\n", | |
9720 | p->conf_if, | |
9721 | BGP_PEER_SU_UNSPEC(p) | |
9722 | ? "none" | |
9723 | : sockunion2str(&p->su, buf, | |
9724 | SU_ADDRSTRLEN)); | |
9725 | } else { | |
9726 | sprintf(neighborAddr, "%s%s", dn_flag, p->host); | |
9727 | ||
9728 | if (use_json) | |
9729 | json_object_string_add( | |
9730 | json, "neighborAddr", | |
9731 | neighborAddr); | |
9732 | else | |
9733 | vty_out(vty, "BGP neighbor is %s\n", | |
9734 | neighborAddr); | |
9735 | } | |
9736 | ||
9737 | /* more gr info in new format */ | |
9738 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9739 | } | |
9740 | ||
d62a17ae | 9741 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9742 | safi_t safi, bool use_json, |
d62a17ae | 9743 | json_object *json_neigh) |
9744 | { | |
0291c246 MK |
9745 | struct bgp_filter *filter; |
9746 | struct peer_af *paf; | |
9747 | char orf_pfx_name[BUFSIZ]; | |
9748 | int orf_pfx_count; | |
9749 | json_object *json_af = NULL; | |
9750 | json_object *json_prefA = NULL; | |
9751 | json_object *json_prefB = NULL; | |
9752 | json_object *json_addr = NULL; | |
d62a17ae | 9753 | |
9754 | if (use_json) { | |
9755 | json_addr = json_object_new_object(); | |
9756 | json_af = json_object_new_object(); | |
9757 | filter = &p->filter[afi][safi]; | |
9758 | ||
9759 | if (peer_group_active(p)) | |
9760 | json_object_string_add(json_addr, "peerGroupMember", | |
9761 | p->group->name); | |
9762 | ||
9763 | paf = peer_af_find(p, afi, safi); | |
9764 | if (paf && PAF_SUBGRP(paf)) { | |
9765 | json_object_int_add(json_addr, "updateGroupId", | |
9766 | PAF_UPDGRP(paf)->id); | |
9767 | json_object_int_add(json_addr, "subGroupId", | |
9768 | PAF_SUBGRP(paf)->id); | |
9769 | json_object_int_add(json_addr, "packetQueueLength", | |
9770 | bpacket_queue_virtual_length(paf)); | |
9771 | } | |
9772 | ||
9773 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9774 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9775 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9776 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9777 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9778 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9779 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9780 | json_object_int_add(json_af, "orfType", | |
9781 | ORF_TYPE_PREFIX); | |
9782 | json_prefA = json_object_new_object(); | |
9783 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
9784 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
9785 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9786 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9787 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
9788 | use_json, json_prefA); | |
9789 | json_object_object_add(json_af, "orfPrefixList", | |
9790 | json_prefA); | |
9791 | } | |
9792 | ||
9793 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9794 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9795 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9796 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9797 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9798 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9799 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9800 | json_object_int_add(json_af, "orfOldType", | |
9801 | ORF_TYPE_PREFIX_OLD); | |
9802 | json_prefB = json_object_new_object(); | |
9803 | bgp_show_peer_afi_orf_cap( | |
9804 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9805 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9806 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9807 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9808 | json_prefB); | |
9809 | json_object_object_add(json_af, "orfOldPrefixList", | |
9810 | json_prefB); | |
9811 | } | |
9812 | ||
9813 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9814 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9815 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9816 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9817 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9818 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9819 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9820 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9821 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9822 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9823 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9824 | json_object_object_add(json_addr, "afDependentCap", | |
9825 | json_af); | |
9826 | else | |
9827 | json_object_free(json_af); | |
9828 | ||
9829 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9830 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9831 | NULL, afi, orf_pfx_name, use_json); | |
9832 | ||
9833 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9834 | PEER_STATUS_ORF_PREFIX_SEND) | |
9835 | || orf_pfx_count) { | |
9836 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9837 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9838 | json_object_boolean_true_add(json_neigh, | |
9839 | "orfSent"); | |
9840 | if (orf_pfx_count) | |
9841 | json_object_int_add(json_addr, "orfRecvCounter", | |
9842 | orf_pfx_count); | |
9843 | } | |
9844 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9845 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9846 | json_object_string_add( | |
9847 | json_addr, "orfFirstUpdate", | |
9848 | "deferredUntilORFOrRouteRefreshRecvd"); | |
9849 | ||
9850 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9851 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9852 | json_object_boolean_true_add(json_addr, | |
9853 | "routeReflectorClient"); | |
9854 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9855 | PEER_FLAG_RSERVER_CLIENT)) | |
9856 | json_object_boolean_true_add(json_addr, | |
9857 | "routeServerClient"); | |
9858 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9859 | json_object_boolean_true_add(json_addr, | |
9860 | "inboundSoftConfigPermit"); | |
9861 | ||
9862 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9863 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9864 | json_object_boolean_true_add( | |
9865 | json_addr, | |
9866 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
9867 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9868 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9869 | json_object_boolean_true_add( | |
9870 | json_addr, | |
9871 | "privateAsNumsReplacedInUpdatesToNbr"); | |
9872 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9873 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9874 | json_object_boolean_true_add( | |
9875 | json_addr, | |
9876 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
9877 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9878 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9879 | json_object_boolean_true_add( | |
9880 | json_addr, | |
9881 | "privateAsNumsRemovedInUpdatesToNbr"); | |
9882 | ||
dcc68b5e MS |
9883 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9884 | json_object_boolean_true_add( | |
9885 | json_addr, | |
9886 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9887 | ->type_json_name); | |
d62a17ae | 9888 | |
9889 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9890 | json_object_string_add(json_addr, | |
9891 | "overrideASNsInOutboundUpdates", | |
9892 | "ifAspathEqualRemoteAs"); | |
9893 | ||
9894 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9895 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9896 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9897 | json_object_boolean_true_add(json_addr, | |
9898 | "routerAlwaysNextHop"); | |
9899 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9900 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9901 | json_object_boolean_true_add( | |
9902 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
9903 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9904 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9905 | json_object_boolean_true_add( | |
9906 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
9907 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9908 | json_object_boolean_true_add( | |
9909 | json_addr, "unchangedMedPropogatedToNbr"); | |
9910 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9911 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9912 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
9913 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9914 | PEER_FLAG_SEND_COMMUNITY) | |
9915 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9916 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9917 | json_object_string_add(json_addr, | |
9918 | "commAttriSentToNbr", | |
9919 | "extendedAndStandard"); | |
9920 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9921 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9922 | json_object_string_add(json_addr, | |
9923 | "commAttriSentToNbr", | |
9924 | "extended"); | |
9925 | else | |
9926 | json_object_string_add(json_addr, | |
9927 | "commAttriSentToNbr", | |
9928 | "standard"); | |
9929 | } | |
9930 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9931 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9932 | if (p->default_rmap[afi][safi].name) | |
9933 | json_object_string_add( | |
9934 | json_addr, "defaultRouteMap", | |
9935 | p->default_rmap[afi][safi].name); | |
9936 | ||
9937 | if (paf && PAF_SUBGRP(paf) | |
9938 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9939 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9940 | json_object_boolean_true_add(json_addr, | |
9941 | "defaultSent"); | |
9942 | else | |
9943 | json_object_boolean_true_add(json_addr, | |
9944 | "defaultNotSent"); | |
9945 | } | |
9946 | ||
dff8f48d | 9947 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 9948 | if (is_evpn_enabled()) |
60466a63 QY |
9949 | json_object_boolean_true_add( |
9950 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
9951 | } |
9952 | ||
d62a17ae | 9953 | if (filter->plist[FILTER_IN].name |
9954 | || filter->dlist[FILTER_IN].name | |
9955 | || filter->aslist[FILTER_IN].name | |
9956 | || filter->map[RMAP_IN].name) | |
9957 | json_object_boolean_true_add(json_addr, | |
9958 | "inboundPathPolicyConfig"); | |
9959 | if (filter->plist[FILTER_OUT].name | |
9960 | || filter->dlist[FILTER_OUT].name | |
9961 | || filter->aslist[FILTER_OUT].name | |
9962 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9963 | json_object_boolean_true_add( | |
9964 | json_addr, "outboundPathPolicyConfig"); | |
9965 | ||
9966 | /* prefix-list */ | |
9967 | if (filter->plist[FILTER_IN].name) | |
9968 | json_object_string_add(json_addr, | |
9969 | "incomingUpdatePrefixFilterList", | |
9970 | filter->plist[FILTER_IN].name); | |
9971 | if (filter->plist[FILTER_OUT].name) | |
9972 | json_object_string_add(json_addr, | |
9973 | "outgoingUpdatePrefixFilterList", | |
9974 | filter->plist[FILTER_OUT].name); | |
9975 | ||
9976 | /* distribute-list */ | |
9977 | if (filter->dlist[FILTER_IN].name) | |
9978 | json_object_string_add( | |
9979 | json_addr, "incomingUpdateNetworkFilterList", | |
9980 | filter->dlist[FILTER_IN].name); | |
9981 | if (filter->dlist[FILTER_OUT].name) | |
9982 | json_object_string_add( | |
9983 | json_addr, "outgoingUpdateNetworkFilterList", | |
9984 | filter->dlist[FILTER_OUT].name); | |
9985 | ||
9986 | /* filter-list. */ | |
9987 | if (filter->aslist[FILTER_IN].name) | |
9988 | json_object_string_add(json_addr, | |
9989 | "incomingUpdateAsPathFilterList", | |
9990 | filter->aslist[FILTER_IN].name); | |
9991 | if (filter->aslist[FILTER_OUT].name) | |
9992 | json_object_string_add(json_addr, | |
9993 | "outgoingUpdateAsPathFilterList", | |
9994 | filter->aslist[FILTER_OUT].name); | |
9995 | ||
9996 | /* route-map. */ | |
9997 | if (filter->map[RMAP_IN].name) | |
9998 | json_object_string_add( | |
9999 | json_addr, "routeMapForIncomingAdvertisements", | |
10000 | filter->map[RMAP_IN].name); | |
10001 | if (filter->map[RMAP_OUT].name) | |
10002 | json_object_string_add( | |
10003 | json_addr, "routeMapForOutgoingAdvertisements", | |
10004 | filter->map[RMAP_OUT].name); | |
10005 | ||
9dac9fc8 DA |
10006 | /* ebgp-requires-policy (inbound) */ |
10007 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10008 | && !bgp_inbound_policy_exists(p, filter)) | |
10009 | json_object_string_add( | |
10010 | json_addr, "inboundEbgpRequiresPolicy", | |
10011 | "Inbound updates discarded due to missing policy"); | |
10012 | ||
10013 | /* ebgp-requires-policy (outbound) */ | |
10014 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10015 | && (!bgp_outbound_policy_exists(p, filter))) | |
10016 | json_object_string_add( | |
10017 | json_addr, "outboundEbgpRequiresPolicy", | |
10018 | "Outbound updates discarded due to missing policy"); | |
10019 | ||
d62a17ae | 10020 | /* unsuppress-map */ |
10021 | if (filter->usmap.name) | |
10022 | json_object_string_add(json_addr, | |
10023 | "selectiveUnsuppressRouteMap", | |
10024 | filter->usmap.name); | |
10025 | ||
10026 | /* Receive prefix count */ | |
10027 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10028 | p->pcount[afi][safi]); | |
50e05855 AD |
10029 | if (paf && PAF_SUBGRP(paf)) |
10030 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10031 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10032 | |
fde246e8 DA |
10033 | /* Maximum prefix */ |
10034 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10035 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10036 | p->pmax_out[afi][safi]); | |
10037 | ||
d62a17ae | 10038 | /* Maximum prefix */ |
10039 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10040 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10041 | p->pmax[afi][safi]); | |
10042 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10043 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10044 | json_object_boolean_true_add( | |
10045 | json_addr, "prefixAllowedMaxWarning"); | |
10046 | json_object_int_add(json_addr, | |
10047 | "prefixAllowedWarningThresh", | |
10048 | p->pmax_threshold[afi][safi]); | |
10049 | if (p->pmax_restart[afi][safi]) | |
10050 | json_object_int_add( | |
10051 | json_addr, | |
10052 | "prefixAllowedRestartIntervalMsecs", | |
10053 | p->pmax_restart[afi][safi] * 60000); | |
10054 | } | |
2986cac2 | 10055 | json_object_object_add(json_neigh, |
10056 | get_afi_safi_str(afi, | |
10057 | safi, true), | |
d62a17ae | 10058 | json_addr); |
10059 | ||
10060 | } else { | |
10061 | filter = &p->filter[afi][safi]; | |
10062 | ||
10063 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10064 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10065 | |
10066 | if (peer_group_active(p)) | |
10067 | vty_out(vty, " %s peer-group member\n", | |
10068 | p->group->name); | |
10069 | ||
10070 | paf = peer_af_find(p, afi, safi); | |
10071 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10072 | vty_out(vty, " Update group %" PRIu64 |
10073 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10074 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10075 | vty_out(vty, " Packet Queue length %d\n", | |
10076 | bpacket_queue_virtual_length(paf)); | |
10077 | } else { | |
10078 | vty_out(vty, " Not part of any update group\n"); | |
10079 | } | |
10080 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10081 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10082 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10083 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10084 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10085 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10086 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10087 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10088 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10089 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10090 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10091 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10092 | ||
10093 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10094 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10095 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10096 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10097 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10098 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10099 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10100 | vty_out(vty, | |
10101 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10102 | ORF_TYPE_PREFIX); | |
10103 | bgp_show_peer_afi_orf_cap( | |
10104 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10105 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10106 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10107 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10108 | } | |
10109 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10110 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10111 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10112 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10113 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10114 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10115 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10116 | vty_out(vty, | |
10117 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10118 | ORF_TYPE_PREFIX_OLD); | |
10119 | bgp_show_peer_afi_orf_cap( | |
10120 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10121 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10122 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10123 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10124 | } | |
10125 | ||
10126 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
10127 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
10128 | NULL, afi, orf_pfx_name, use_json); | |
10129 | ||
10130 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10131 | PEER_STATUS_ORF_PREFIX_SEND) | |
10132 | || orf_pfx_count) { | |
10133 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10134 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10135 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10136 | vty_out(vty, " sent;"); | |
10137 | if (orf_pfx_count) | |
10138 | vty_out(vty, " received (%d entries)", | |
10139 | orf_pfx_count); | |
10140 | vty_out(vty, "\n"); | |
10141 | } | |
10142 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10143 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10144 | vty_out(vty, | |
10145 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10146 | ||
10147 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10148 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10149 | vty_out(vty, " Route-Reflector Client\n"); | |
10150 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10151 | PEER_FLAG_RSERVER_CLIENT)) | |
10152 | vty_out(vty, " Route-Server Client\n"); | |
10153 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10154 | vty_out(vty, | |
10155 | " Inbound soft reconfiguration allowed\n"); | |
10156 | ||
10157 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10158 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10159 | vty_out(vty, | |
10160 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10161 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10162 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10163 | vty_out(vty, | |
10164 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10165 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10166 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10167 | vty_out(vty, | |
10168 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10169 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10170 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10171 | vty_out(vty, | |
10172 | " Private AS numbers removed in updates to this neighbor\n"); | |
10173 | ||
dcc68b5e MS |
10174 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10175 | vty_out(vty, " %s\n", | |
10176 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10177 | ->human_description); | |
d62a17ae | 10178 | |
10179 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10180 | vty_out(vty, | |
10181 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10182 | ||
10183 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10184 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10185 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10186 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10187 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10188 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10189 | vty_out(vty, | |
10190 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10191 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10192 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10193 | vty_out(vty, | |
10194 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10195 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10196 | vty_out(vty, | |
10197 | " MED is propagated unchanged to this neighbor\n"); | |
10198 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10199 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10200 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10201 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10202 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10203 | vty_out(vty, | |
10204 | " Community attribute sent to this neighbor"); | |
10205 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10206 | PEER_FLAG_SEND_COMMUNITY) | |
10207 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10208 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10209 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10210 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10211 | vty_out(vty, "(all)\n"); | |
10212 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10213 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10214 | vty_out(vty, "(large)\n"); | |
10215 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10216 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10217 | vty_out(vty, "(extended)\n"); | |
10218 | else | |
10219 | vty_out(vty, "(standard)\n"); | |
10220 | } | |
10221 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10222 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10223 | vty_out(vty, " Default information originate,"); | |
10224 | ||
10225 | if (p->default_rmap[afi][safi].name) | |
10226 | vty_out(vty, " default route-map %s%s,", | |
10227 | p->default_rmap[afi][safi].map ? "*" | |
10228 | : "", | |
10229 | p->default_rmap[afi][safi].name); | |
10230 | if (paf && PAF_SUBGRP(paf) | |
10231 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10232 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10233 | vty_out(vty, " default sent\n"); | |
10234 | else | |
10235 | vty_out(vty, " default not sent\n"); | |
10236 | } | |
10237 | ||
dff8f48d MK |
10238 | /* advertise-vni-all */ |
10239 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10240 | if (is_evpn_enabled()) |
dff8f48d MK |
10241 | vty_out(vty, " advertise-all-vni\n"); |
10242 | } | |
10243 | ||
d62a17ae | 10244 | if (filter->plist[FILTER_IN].name |
10245 | || filter->dlist[FILTER_IN].name | |
10246 | || filter->aslist[FILTER_IN].name | |
10247 | || filter->map[RMAP_IN].name) | |
10248 | vty_out(vty, " Inbound path policy configured\n"); | |
10249 | if (filter->plist[FILTER_OUT].name | |
10250 | || filter->dlist[FILTER_OUT].name | |
10251 | || filter->aslist[FILTER_OUT].name | |
10252 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10253 | vty_out(vty, " Outbound path policy configured\n"); | |
10254 | ||
10255 | /* prefix-list */ | |
10256 | if (filter->plist[FILTER_IN].name) | |
10257 | vty_out(vty, | |
10258 | " Incoming update prefix filter list is %s%s\n", | |
10259 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10260 | filter->plist[FILTER_IN].name); | |
10261 | if (filter->plist[FILTER_OUT].name) | |
10262 | vty_out(vty, | |
10263 | " Outgoing update prefix filter list is %s%s\n", | |
10264 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10265 | filter->plist[FILTER_OUT].name); | |
10266 | ||
10267 | /* distribute-list */ | |
10268 | if (filter->dlist[FILTER_IN].name) | |
10269 | vty_out(vty, | |
10270 | " Incoming update network filter list is %s%s\n", | |
10271 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10272 | filter->dlist[FILTER_IN].name); | |
10273 | if (filter->dlist[FILTER_OUT].name) | |
10274 | vty_out(vty, | |
10275 | " Outgoing update network filter list is %s%s\n", | |
10276 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10277 | filter->dlist[FILTER_OUT].name); | |
10278 | ||
10279 | /* filter-list. */ | |
10280 | if (filter->aslist[FILTER_IN].name) | |
10281 | vty_out(vty, | |
10282 | " Incoming update AS path filter list is %s%s\n", | |
10283 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10284 | filter->aslist[FILTER_IN].name); | |
10285 | if (filter->aslist[FILTER_OUT].name) | |
10286 | vty_out(vty, | |
10287 | " Outgoing update AS path filter list is %s%s\n", | |
10288 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10289 | filter->aslist[FILTER_OUT].name); | |
10290 | ||
10291 | /* route-map. */ | |
10292 | if (filter->map[RMAP_IN].name) | |
10293 | vty_out(vty, | |
10294 | " Route map for incoming advertisements is %s%s\n", | |
10295 | filter->map[RMAP_IN].map ? "*" : "", | |
10296 | filter->map[RMAP_IN].name); | |
10297 | if (filter->map[RMAP_OUT].name) | |
10298 | vty_out(vty, | |
10299 | " Route map for outgoing advertisements is %s%s\n", | |
10300 | filter->map[RMAP_OUT].map ? "*" : "", | |
10301 | filter->map[RMAP_OUT].name); | |
10302 | ||
9dac9fc8 DA |
10303 | /* ebgp-requires-policy (inbound) */ |
10304 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10305 | && !bgp_inbound_policy_exists(p, filter)) | |
10306 | vty_out(vty, | |
10307 | " Inbound updates discarded due to missing policy\n"); | |
10308 | ||
10309 | /* ebgp-requires-policy (outbound) */ | |
10310 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10311 | && !bgp_outbound_policy_exists(p, filter)) | |
10312 | vty_out(vty, | |
10313 | " Outbound updates discarded due to missing policy\n"); | |
10314 | ||
d62a17ae | 10315 | /* unsuppress-map */ |
10316 | if (filter->usmap.name) | |
10317 | vty_out(vty, | |
10318 | " Route map for selective unsuppress is %s%s\n", | |
10319 | filter->usmap.map ? "*" : "", | |
10320 | filter->usmap.name); | |
10321 | ||
10322 | /* Receive prefix count */ | |
a0a87037 DA |
10323 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10324 | p->pcount[afi][safi]); | |
d62a17ae | 10325 | |
fde246e8 DA |
10326 | /* maximum-prefix-out */ |
10327 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10328 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10329 | vty_out(vty, | |
10330 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10331 | p->pmax_out[afi][safi]); | |
10332 | ||
d62a17ae | 10333 | /* Maximum prefix */ |
10334 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10335 | vty_out(vty, |
10336 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10337 | p->pmax[afi][safi], |
10338 | CHECK_FLAG(p->af_flags[afi][safi], | |
10339 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10340 | ? " (warning-only)" | |
10341 | : ""); | |
10342 | vty_out(vty, " Threshold for warning message %d%%", | |
10343 | p->pmax_threshold[afi][safi]); | |
10344 | if (p->pmax_restart[afi][safi]) | |
10345 | vty_out(vty, ", restart interval %d min", | |
10346 | p->pmax_restart[afi][safi]); | |
10347 | vty_out(vty, "\n"); | |
10348 | } | |
10349 | ||
10350 | vty_out(vty, "\n"); | |
10351 | } | |
10352 | } | |
10353 | ||
9f049418 | 10354 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10355 | json_object *json) |
718e3744 | 10356 | { |
d62a17ae | 10357 | struct bgp *bgp; |
10358 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10359 | char timebuf[BGP_UPTIME_LEN]; | |
10360 | char dn_flag[2]; | |
d62a17ae | 10361 | afi_t afi; |
10362 | safi_t safi; | |
d7c0a89a QY |
10363 | uint16_t i; |
10364 | uint8_t *msg; | |
d62a17ae | 10365 | json_object *json_neigh = NULL; |
10366 | time_t epoch_tbuf; | |
718e3744 | 10367 | |
d62a17ae | 10368 | bgp = p->bgp; |
10369 | ||
10370 | if (use_json) | |
10371 | json_neigh = json_object_new_object(); | |
10372 | ||
10373 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10374 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10375 | dn_flag[0] = '*'; | |
10376 | ||
10377 | if (!use_json) { | |
10378 | if (p->conf_if) /* Configured interface name. */ | |
10379 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10380 | BGP_PEER_SU_UNSPEC(p) | |
10381 | ? "None" | |
10382 | : sockunion2str(&p->su, buf, | |
10383 | SU_ADDRSTRLEN)); | |
10384 | else /* Configured IP address. */ | |
10385 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10386 | p->host); | |
10387 | } | |
10388 | ||
10389 | if (use_json) { | |
10390 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10391 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10392 | "none"); | |
10393 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10394 | json_object_string_add( | |
10395 | json_neigh, "bgpNeighborAddr", | |
10396 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10397 | ||
10398 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10399 | ||
10400 | if (p->change_local_as) | |
10401 | json_object_int_add(json_neigh, "localAs", | |
10402 | p->change_local_as); | |
10403 | else | |
10404 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10405 | ||
10406 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10407 | json_object_boolean_true_add(json_neigh, | |
10408 | "localAsNoPrepend"); | |
10409 | ||
10410 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10411 | json_object_boolean_true_add(json_neigh, | |
10412 | "localAsReplaceAs"); | |
10413 | } else { | |
10414 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10415 | || (p->as_type == AS_INTERNAL)) | |
10416 | vty_out(vty, "remote AS %u, ", p->as); | |
10417 | else | |
10418 | vty_out(vty, "remote AS Unspecified, "); | |
10419 | vty_out(vty, "local AS %u%s%s, ", | |
10420 | p->change_local_as ? p->change_local_as : p->local_as, | |
10421 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10422 | ? " no-prepend" | |
10423 | : "", | |
10424 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10425 | ? " replace-as" | |
10426 | : ""); | |
10427 | } | |
faa16034 DS |
10428 | /* peer type internal or confed-internal */ |
10429 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10430 | if (use_json) { |
10431 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10432 | json_object_boolean_true_add( | |
10433 | json_neigh, "nbrConfedInternalLink"); | |
10434 | else | |
10435 | json_object_boolean_true_add(json_neigh, | |
10436 | "nbrInternalLink"); | |
10437 | } else { | |
10438 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10439 | vty_out(vty, "confed-internal link\n"); | |
10440 | else | |
10441 | vty_out(vty, "internal link\n"); | |
10442 | } | |
faa16034 DS |
10443 | /* peer type external or confed-external */ |
10444 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10445 | if (use_json) { |
10446 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10447 | json_object_boolean_true_add( | |
10448 | json_neigh, "nbrConfedExternalLink"); | |
10449 | else | |
10450 | json_object_boolean_true_add(json_neigh, | |
10451 | "nbrExternalLink"); | |
10452 | } else { | |
10453 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10454 | vty_out(vty, "confed-external link\n"); | |
10455 | else | |
10456 | vty_out(vty, "external link\n"); | |
10457 | } | |
faa16034 DS |
10458 | } else { |
10459 | if (use_json) | |
10460 | json_object_boolean_true_add(json_neigh, | |
10461 | "nbrUnspecifiedLink"); | |
10462 | else | |
10463 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10464 | } |
10465 | ||
10466 | /* Description. */ | |
10467 | if (p->desc) { | |
10468 | if (use_json) | |
10469 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10470 | else | |
10471 | vty_out(vty, " Description: %s\n", p->desc); | |
10472 | } | |
10473 | ||
10474 | if (p->hostname) { | |
10475 | if (use_json) { | |
10476 | if (p->hostname) | |
10477 | json_object_string_add(json_neigh, "hostname", | |
10478 | p->hostname); | |
10479 | ||
10480 | if (p->domainname) | |
10481 | json_object_string_add(json_neigh, "domainname", | |
10482 | p->domainname); | |
10483 | } else { | |
10484 | if (p->domainname && (p->domainname[0] != '\0')) | |
10485 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10486 | p->domainname); | |
10487 | else | |
10488 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10489 | } | |
10490 | } | |
10491 | ||
10492 | /* Peer-group */ | |
10493 | if (p->group) { | |
10494 | if (use_json) { | |
10495 | json_object_string_add(json_neigh, "peerGroup", | |
10496 | p->group->name); | |
10497 | ||
10498 | if (dn_flag[0]) { | |
10499 | struct prefix prefix, *range = NULL; | |
10500 | ||
10501 | sockunion2hostprefix(&(p->su), &prefix); | |
10502 | range = peer_group_lookup_dynamic_neighbor_range( | |
10503 | p->group, &prefix); | |
10504 | ||
10505 | if (range) { | |
10506 | prefix2str(range, buf1, sizeof(buf1)); | |
10507 | json_object_string_add( | |
10508 | json_neigh, | |
10509 | "peerSubnetRangeGroup", buf1); | |
10510 | } | |
10511 | } | |
10512 | } else { | |
10513 | vty_out(vty, | |
10514 | " Member of peer-group %s for session parameters\n", | |
10515 | p->group->name); | |
10516 | ||
10517 | if (dn_flag[0]) { | |
10518 | struct prefix prefix, *range = NULL; | |
10519 | ||
10520 | sockunion2hostprefix(&(p->su), &prefix); | |
10521 | range = peer_group_lookup_dynamic_neighbor_range( | |
10522 | p->group, &prefix); | |
10523 | ||
10524 | if (range) { | |
10525 | prefix2str(range, buf1, sizeof(buf1)); | |
10526 | vty_out(vty, | |
10527 | " Belongs to the subnet range group: %s\n", | |
10528 | buf1); | |
10529 | } | |
10530 | } | |
10531 | } | |
10532 | } | |
10533 | ||
10534 | if (use_json) { | |
10535 | /* Administrative shutdown. */ | |
10536 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10537 | json_object_boolean_true_add(json_neigh, | |
10538 | "adminShutDown"); | |
10539 | ||
10540 | /* BGP Version. */ | |
10541 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10542 | json_object_string_add( | |
10543 | json_neigh, "remoteRouterId", | |
10544 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10545 | json_object_string_add( |
10546 | json_neigh, "localRouterId", | |
10547 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10548 | sizeof(buf1))); | |
d62a17ae | 10549 | |
10550 | /* Confederation */ | |
10551 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10552 | && bgp_confederation_peers_check(bgp, p->as)) | |
10553 | json_object_boolean_true_add(json_neigh, | |
10554 | "nbrCommonAdmin"); | |
10555 | ||
10556 | /* Status. */ | |
10557 | json_object_string_add( | |
10558 | json_neigh, "bgpState", | |
10559 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10560 | ||
10561 | if (p->status == Established) { | |
10562 | time_t uptime; | |
d62a17ae | 10563 | |
10564 | uptime = bgp_clock(); | |
10565 | uptime -= p->uptime; | |
d62a17ae | 10566 | epoch_tbuf = time(NULL) - uptime; |
10567 | ||
d3c7efed DS |
10568 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10569 | uptime * 1000); | |
d62a17ae | 10570 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10571 | peer_uptime(p->uptime, timebuf, | |
10572 | BGP_UPTIME_LEN, 0, | |
10573 | NULL)); | |
10574 | json_object_int_add(json_neigh, | |
10575 | "bgpTimerUpEstablishedEpoch", | |
10576 | epoch_tbuf); | |
10577 | } | |
10578 | ||
10579 | else if (p->status == Active) { | |
10580 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10581 | json_object_string_add(json_neigh, "bgpStateIs", | |
10582 | "passive"); | |
10583 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10584 | json_object_string_add(json_neigh, "bgpStateIs", | |
10585 | "passiveNSF"); | |
10586 | } | |
10587 | ||
10588 | /* read timer */ | |
10589 | time_t uptime; | |
10590 | struct tm *tm; | |
10591 | ||
10592 | uptime = bgp_clock(); | |
10593 | uptime -= p->readtime; | |
10594 | tm = gmtime(&uptime); | |
10595 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
10596 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10597 | + (tm->tm_hour * 3600000)); | |
10598 | ||
10599 | uptime = bgp_clock(); | |
10600 | uptime -= p->last_write; | |
10601 | tm = gmtime(&uptime); | |
10602 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
10603 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10604 | + (tm->tm_hour * 3600000)); | |
10605 | ||
10606 | uptime = bgp_clock(); | |
10607 | uptime -= p->update_time; | |
10608 | tm = gmtime(&uptime); | |
10609 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
10610 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
10611 | + (tm->tm_hour * 3600000)); | |
10612 | ||
10613 | /* Configured timer values. */ | |
10614 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10615 | p->v_holdtime * 1000); | |
10616 | json_object_int_add(json_neigh, | |
10617 | "bgpTimerKeepAliveIntervalMsecs", | |
10618 | p->v_keepalive * 1000); | |
b90a8e13 | 10619 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10620 | json_object_int_add(json_neigh, |
10621 | "bgpTimerConfiguredHoldTimeMsecs", | |
10622 | p->holdtime * 1000); | |
10623 | json_object_int_add( | |
10624 | json_neigh, | |
10625 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10626 | p->keepalive * 1000); | |
5d5393b9 DL |
10627 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10628 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10629 | json_object_int_add(json_neigh, |
10630 | "bgpTimerConfiguredHoldTimeMsecs", | |
10631 | bgp->default_holdtime); | |
10632 | json_object_int_add( | |
10633 | json_neigh, | |
10634 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10635 | bgp->default_keepalive); | |
d62a17ae | 10636 | } |
10637 | } else { | |
10638 | /* Administrative shutdown. */ | |
10639 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10640 | vty_out(vty, " Administratively shut down\n"); | |
10641 | ||
10642 | /* BGP Version. */ | |
10643 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10644 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10645 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10646 | vty_out(vty, ", local router ID %s\n", |
10647 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10648 | sizeof(buf1))); | |
d62a17ae | 10649 | |
10650 | /* Confederation */ | |
10651 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10652 | && bgp_confederation_peers_check(bgp, p->as)) | |
10653 | vty_out(vty, | |
10654 | " Neighbor under common administration\n"); | |
10655 | ||
10656 | /* Status. */ | |
10657 | vty_out(vty, " BGP state = %s", | |
10658 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10659 | ||
10660 | if (p->status == Established) | |
10661 | vty_out(vty, ", up for %8s", | |
10662 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10663 | 0, NULL)); | |
10664 | ||
10665 | else if (p->status == Active) { | |
10666 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10667 | vty_out(vty, " (passive)"); | |
10668 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10669 | vty_out(vty, " (NSF passive)"); | |
10670 | } | |
10671 | vty_out(vty, "\n"); | |
10672 | ||
10673 | /* read timer */ | |
10674 | vty_out(vty, " Last read %s", | |
10675 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10676 | NULL)); | |
10677 | vty_out(vty, ", Last write %s\n", | |
10678 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10679 | NULL)); | |
10680 | ||
10681 | /* Configured timer values. */ | |
10682 | vty_out(vty, | |
10683 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10684 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10685 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10686 | vty_out(vty, " Configured hold time is %d", |
10687 | p->holdtime); | |
10688 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10689 | p->keepalive); | |
5d5393b9 DL |
10690 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10691 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10692 | vty_out(vty, " Configured hold time is %d", |
10693 | bgp->default_holdtime); | |
10694 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10695 | bgp->default_keepalive); | |
d62a17ae | 10696 | } |
10697 | } | |
10698 | /* Capability. */ | |
10699 | if (p->status == Established) { | |
10700 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10701 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10702 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10703 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10704 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10705 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10706 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10707 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10708 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10709 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10710 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10711 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10712 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10713 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10714 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10715 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10716 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10717 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10718 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10719 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10720 | if (use_json) { | |
10721 | json_object *json_cap = NULL; | |
10722 | ||
10723 | json_cap = json_object_new_object(); | |
10724 | ||
10725 | /* AS4 */ | |
10726 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10727 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10728 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10729 | && CHECK_FLAG(p->cap, | |
10730 | PEER_CAP_AS4_RCV)) | |
10731 | json_object_string_add( | |
10732 | json_cap, "4byteAs", | |
10733 | "advertisedAndReceived"); | |
10734 | else if (CHECK_FLAG(p->cap, | |
10735 | PEER_CAP_AS4_ADV)) | |
10736 | json_object_string_add( | |
10737 | json_cap, "4byteAs", | |
10738 | "advertised"); | |
10739 | else if (CHECK_FLAG(p->cap, | |
10740 | PEER_CAP_AS4_RCV)) | |
10741 | json_object_string_add( | |
10742 | json_cap, "4byteAs", | |
10743 | "received"); | |
10744 | } | |
10745 | ||
10746 | /* AddPath */ | |
10747 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10748 | || CHECK_FLAG(p->cap, | |
10749 | PEER_CAP_ADDPATH_ADV)) { | |
10750 | json_object *json_add = NULL; | |
10751 | const char *print_store; | |
10752 | ||
10753 | json_add = json_object_new_object(); | |
10754 | ||
05c7a1cc QY |
10755 | FOREACH_AFI_SAFI (afi, safi) { |
10756 | json_object *json_sub = NULL; | |
10757 | json_sub = | |
10758 | json_object_new_object(); | |
5cb5f4d0 DD |
10759 | print_store = get_afi_safi_str( |
10760 | afi, safi, true); | |
d62a17ae | 10761 | |
05c7a1cc QY |
10762 | if (CHECK_FLAG( |
10763 | p->af_cap[afi] | |
10764 | [safi], | |
10765 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10766 | || CHECK_FLAG( | |
10767 | p->af_cap[afi] | |
10768 | [safi], | |
10769 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10770 | if (CHECK_FLAG( |
10771 | p->af_cap | |
10772 | [afi] | |
10773 | [safi], | |
10774 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10775 | && CHECK_FLAG( |
d62a17ae | 10776 | p->af_cap |
10777 | [afi] | |
10778 | [safi], | |
05c7a1cc QY |
10779 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
10780 | json_object_boolean_true_add( | |
10781 | json_sub, | |
10782 | "txAdvertisedAndReceived"); | |
10783 | else if ( | |
10784 | CHECK_FLAG( | |
10785 | p->af_cap | |
10786 | [afi] | |
10787 | [safi], | |
10788 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
10789 | json_object_boolean_true_add( | |
10790 | json_sub, | |
10791 | "txAdvertised"); | |
10792 | else if ( | |
10793 | CHECK_FLAG( | |
10794 | p->af_cap | |
10795 | [afi] | |
10796 | [safi], | |
10797 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10798 | json_object_boolean_true_add( | |
10799 | json_sub, | |
10800 | "txReceived"); | |
10801 | } | |
d62a17ae | 10802 | |
05c7a1cc QY |
10803 | if (CHECK_FLAG( |
10804 | p->af_cap[afi] | |
10805 | [safi], | |
10806 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10807 | || CHECK_FLAG( | |
10808 | p->af_cap[afi] | |
10809 | [safi], | |
10810 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10811 | if (CHECK_FLAG( |
10812 | p->af_cap | |
10813 | [afi] | |
10814 | [safi], | |
10815 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10816 | && CHECK_FLAG( |
d62a17ae | 10817 | p->af_cap |
10818 | [afi] | |
10819 | [safi], | |
10820 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10821 | json_object_boolean_true_add( |
10822 | json_sub, | |
10823 | "rxAdvertisedAndReceived"); | |
10824 | else if ( | |
10825 | CHECK_FLAG( | |
10826 | p->af_cap | |
10827 | [afi] | |
10828 | [safi], | |
10829 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10830 | json_object_boolean_true_add( | |
10831 | json_sub, | |
10832 | "rxAdvertised"); | |
10833 | else if ( | |
10834 | CHECK_FLAG( | |
10835 | p->af_cap | |
10836 | [afi] | |
10837 | [safi], | |
10838 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10839 | json_object_boolean_true_add( | |
10840 | json_sub, | |
10841 | "rxReceived"); | |
d62a17ae | 10842 | } |
10843 | ||
05c7a1cc QY |
10844 | if (CHECK_FLAG( |
10845 | p->af_cap[afi] | |
10846 | [safi], | |
10847 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10848 | || CHECK_FLAG( | |
10849 | p->af_cap[afi] | |
10850 | [safi], | |
10851 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
10852 | || CHECK_FLAG( | |
10853 | p->af_cap[afi] | |
10854 | [safi], | |
10855 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10856 | || CHECK_FLAG( | |
10857 | p->af_cap[afi] | |
10858 | [safi], | |
10859 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10860 | json_object_object_add( | |
10861 | json_add, | |
10862 | print_store, | |
10863 | json_sub); | |
10864 | else | |
10865 | json_object_free( | |
10866 | json_sub); | |
10867 | } | |
10868 | ||
d62a17ae | 10869 | json_object_object_add( |
10870 | json_cap, "addPath", json_add); | |
10871 | } | |
10872 | ||
10873 | /* Dynamic */ | |
10874 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10875 | || CHECK_FLAG(p->cap, | |
10876 | PEER_CAP_DYNAMIC_ADV)) { | |
10877 | if (CHECK_FLAG(p->cap, | |
10878 | PEER_CAP_DYNAMIC_ADV) | |
10879 | && CHECK_FLAG(p->cap, | |
10880 | PEER_CAP_DYNAMIC_RCV)) | |
10881 | json_object_string_add( | |
10882 | json_cap, "dynamic", | |
10883 | "advertisedAndReceived"); | |
10884 | else if (CHECK_FLAG( | |
10885 | p->cap, | |
10886 | PEER_CAP_DYNAMIC_ADV)) | |
10887 | json_object_string_add( | |
10888 | json_cap, "dynamic", | |
10889 | "advertised"); | |
10890 | else if (CHECK_FLAG( | |
10891 | p->cap, | |
10892 | PEER_CAP_DYNAMIC_RCV)) | |
10893 | json_object_string_add( | |
10894 | json_cap, "dynamic", | |
10895 | "received"); | |
10896 | } | |
10897 | ||
10898 | /* Extended nexthop */ | |
10899 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10900 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10901 | json_object *json_nxt = NULL; | |
10902 | const char *print_store; | |
10903 | ||
10904 | ||
10905 | if (CHECK_FLAG(p->cap, | |
10906 | PEER_CAP_ENHE_ADV) | |
10907 | && CHECK_FLAG(p->cap, | |
10908 | PEER_CAP_ENHE_RCV)) | |
10909 | json_object_string_add( | |
10910 | json_cap, | |
10911 | "extendedNexthop", | |
10912 | "advertisedAndReceived"); | |
10913 | else if (CHECK_FLAG(p->cap, | |
10914 | PEER_CAP_ENHE_ADV)) | |
10915 | json_object_string_add( | |
10916 | json_cap, | |
10917 | "extendedNexthop", | |
10918 | "advertised"); | |
10919 | else if (CHECK_FLAG(p->cap, | |
10920 | PEER_CAP_ENHE_RCV)) | |
10921 | json_object_string_add( | |
10922 | json_cap, | |
10923 | "extendedNexthop", | |
10924 | "received"); | |
10925 | ||
10926 | if (CHECK_FLAG(p->cap, | |
10927 | PEER_CAP_ENHE_RCV)) { | |
10928 | json_nxt = | |
10929 | json_object_new_object(); | |
10930 | ||
10931 | for (safi = SAFI_UNICAST; | |
10932 | safi < SAFI_MAX; safi++) { | |
10933 | if (CHECK_FLAG( | |
10934 | p->af_cap | |
10935 | [AFI_IP] | |
10936 | [safi], | |
10937 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 10938 | print_store = get_afi_safi_str( |
d62a17ae | 10939 | AFI_IP, |
5cb5f4d0 | 10940 | safi, true); |
d62a17ae | 10941 | json_object_string_add( |
10942 | json_nxt, | |
10943 | print_store, | |
54f29523 | 10944 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 10945 | } |
10946 | } | |
10947 | json_object_object_add( | |
10948 | json_cap, | |
10949 | "extendedNexthopFamililesByPeer", | |
10950 | json_nxt); | |
10951 | } | |
10952 | } | |
10953 | ||
10954 | /* Route Refresh */ | |
10955 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10956 | || CHECK_FLAG(p->cap, | |
10957 | PEER_CAP_REFRESH_NEW_RCV) | |
10958 | || CHECK_FLAG(p->cap, | |
10959 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10960 | if (CHECK_FLAG(p->cap, | |
10961 | PEER_CAP_REFRESH_ADV) | |
10962 | && (CHECK_FLAG( | |
10963 | p->cap, | |
10964 | PEER_CAP_REFRESH_NEW_RCV) | |
10965 | || CHECK_FLAG( | |
10966 | p->cap, | |
10967 | PEER_CAP_REFRESH_OLD_RCV))) { | |
10968 | if (CHECK_FLAG( | |
10969 | p->cap, | |
10970 | PEER_CAP_REFRESH_OLD_RCV) | |
10971 | && CHECK_FLAG( | |
10972 | p->cap, | |
10973 | PEER_CAP_REFRESH_NEW_RCV)) | |
10974 | json_object_string_add( | |
10975 | json_cap, | |
10976 | "routeRefresh", | |
10977 | "advertisedAndReceivedOldNew"); | |
10978 | else { | |
10979 | if (CHECK_FLAG( | |
10980 | p->cap, | |
10981 | PEER_CAP_REFRESH_OLD_RCV)) | |
10982 | json_object_string_add( | |
10983 | json_cap, | |
10984 | "routeRefresh", | |
10985 | "advertisedAndReceivedOld"); | |
10986 | else | |
10987 | json_object_string_add( | |
10988 | json_cap, | |
10989 | "routeRefresh", | |
10990 | "advertisedAndReceivedNew"); | |
10991 | } | |
10992 | } else if ( | |
10993 | CHECK_FLAG( | |
10994 | p->cap, | |
10995 | PEER_CAP_REFRESH_ADV)) | |
10996 | json_object_string_add( | |
10997 | json_cap, | |
10998 | "routeRefresh", | |
10999 | "advertised"); | |
11000 | else if ( | |
11001 | CHECK_FLAG( | |
11002 | p->cap, | |
11003 | PEER_CAP_REFRESH_NEW_RCV) | |
11004 | || CHECK_FLAG( | |
11005 | p->cap, | |
11006 | PEER_CAP_REFRESH_OLD_RCV)) | |
11007 | json_object_string_add( | |
11008 | json_cap, | |
11009 | "routeRefresh", | |
11010 | "received"); | |
11011 | } | |
11012 | ||
11013 | /* Multiprotocol Extensions */ | |
11014 | json_object *json_multi = NULL; | |
11015 | json_multi = json_object_new_object(); | |
11016 | ||
05c7a1cc QY |
11017 | FOREACH_AFI_SAFI (afi, safi) { |
11018 | if (p->afc_adv[afi][safi] | |
11019 | || p->afc_recv[afi][safi]) { | |
11020 | json_object *json_exten = NULL; | |
11021 | json_exten = | |
11022 | json_object_new_object(); | |
11023 | ||
d62a17ae | 11024 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11025 | && p->afc_recv[afi][safi]) |
11026 | json_object_boolean_true_add( | |
11027 | json_exten, | |
11028 | "advertisedAndReceived"); | |
11029 | else if (p->afc_adv[afi][safi]) | |
11030 | json_object_boolean_true_add( | |
11031 | json_exten, | |
11032 | "advertised"); | |
11033 | else if (p->afc_recv[afi][safi]) | |
11034 | json_object_boolean_true_add( | |
11035 | json_exten, | |
11036 | "received"); | |
d62a17ae | 11037 | |
05c7a1cc QY |
11038 | json_object_object_add( |
11039 | json_multi, | |
5cb5f4d0 DD |
11040 | get_afi_safi_str(afi, |
11041 | safi, | |
11042 | true), | |
05c7a1cc | 11043 | json_exten); |
d62a17ae | 11044 | } |
11045 | } | |
11046 | json_object_object_add( | |
11047 | json_cap, "multiprotocolExtensions", | |
11048 | json_multi); | |
11049 | ||
d77114b7 | 11050 | /* Hostname capabilities */ |
60466a63 | 11051 | json_object *json_hname = NULL; |
d77114b7 MK |
11052 | |
11053 | json_hname = json_object_new_object(); | |
11054 | ||
11055 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11056 | json_object_string_add( | |
60466a63 QY |
11057 | json_hname, "advHostName", |
11058 | bgp->peer_self->hostname | |
11059 | ? bgp->peer_self | |
11060 | ->hostname | |
d77114b7 MK |
11061 | : "n/a"); |
11062 | json_object_string_add( | |
60466a63 QY |
11063 | json_hname, "advDomainName", |
11064 | bgp->peer_self->domainname | |
11065 | ? bgp->peer_self | |
11066 | ->domainname | |
d77114b7 MK |
11067 | : "n/a"); |
11068 | } | |
11069 | ||
11070 | ||
11071 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11072 | json_object_string_add( | |
60466a63 QY |
11073 | json_hname, "rcvHostName", |
11074 | p->hostname ? p->hostname | |
11075 | : "n/a"); | |
d77114b7 | 11076 | json_object_string_add( |
60466a63 QY |
11077 | json_hname, "rcvDomainName", |
11078 | p->domainname ? p->domainname | |
11079 | : "n/a"); | |
d77114b7 MK |
11080 | } |
11081 | ||
60466a63 | 11082 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11083 | json_hname); |
11084 | ||
d62a17ae | 11085 | /* Gracefull Restart */ |
11086 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11087 | || CHECK_FLAG(p->cap, | |
11088 | PEER_CAP_RESTART_ADV)) { | |
11089 | if (CHECK_FLAG(p->cap, | |
11090 | PEER_CAP_RESTART_ADV) | |
11091 | && CHECK_FLAG(p->cap, | |
11092 | PEER_CAP_RESTART_RCV)) | |
11093 | json_object_string_add( | |
11094 | json_cap, | |
11095 | "gracefulRestart", | |
11096 | "advertisedAndReceived"); | |
11097 | else if (CHECK_FLAG( | |
11098 | p->cap, | |
11099 | PEER_CAP_RESTART_ADV)) | |
11100 | json_object_string_add( | |
11101 | json_cap, | |
11102 | "gracefulRestartCapability", | |
11103 | "advertised"); | |
11104 | else if (CHECK_FLAG( | |
11105 | p->cap, | |
11106 | PEER_CAP_RESTART_RCV)) | |
11107 | json_object_string_add( | |
11108 | json_cap, | |
11109 | "gracefulRestartCapability", | |
11110 | "received"); | |
11111 | ||
11112 | if (CHECK_FLAG(p->cap, | |
11113 | PEER_CAP_RESTART_RCV)) { | |
11114 | int restart_af_count = 0; | |
11115 | json_object *json_restart = | |
11116 | NULL; | |
11117 | json_restart = | |
11118 | json_object_new_object(); | |
11119 | ||
11120 | json_object_int_add( | |
11121 | json_cap, | |
11122 | "gracefulRestartRemoteTimerMsecs", | |
11123 | p->v_gr_restart * 1000); | |
11124 | ||
05c7a1cc QY |
11125 | FOREACH_AFI_SAFI (afi, safi) { |
11126 | if (CHECK_FLAG( | |
11127 | p->af_cap | |
11128 | [afi] | |
11129 | [safi], | |
11130 | PEER_CAP_RESTART_AF_RCV)) { | |
11131 | json_object * | |
11132 | json_sub = | |
11133 | NULL; | |
11134 | json_sub = | |
11135 | json_object_new_object(); | |
11136 | ||
d62a17ae | 11137 | if (CHECK_FLAG( |
11138 | p->af_cap | |
11139 | [afi] | |
11140 | [safi], | |
05c7a1cc QY |
11141 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11142 | json_object_boolean_true_add( | |
11143 | json_sub, | |
11144 | "preserved"); | |
11145 | restart_af_count++; | |
11146 | json_object_object_add( | |
11147 | json_restart, | |
5cb5f4d0 | 11148 | get_afi_safi_str( |
05c7a1cc | 11149 | afi, |
5cb5f4d0 DD |
11150 | safi, |
11151 | true), | |
05c7a1cc | 11152 | json_sub); |
d62a17ae | 11153 | } |
11154 | } | |
11155 | if (!restart_af_count) { | |
11156 | json_object_string_add( | |
11157 | json_cap, | |
11158 | "addressFamiliesByPeer", | |
11159 | "none"); | |
11160 | json_object_free( | |
11161 | json_restart); | |
11162 | } else | |
11163 | json_object_object_add( | |
11164 | json_cap, | |
11165 | "addressFamiliesByPeer", | |
11166 | json_restart); | |
11167 | } | |
11168 | } | |
11169 | json_object_object_add(json_neigh, | |
11170 | "neighborCapabilities", | |
11171 | json_cap); | |
11172 | } else { | |
11173 | vty_out(vty, " Neighbor capabilities:\n"); | |
11174 | ||
11175 | /* AS4 */ | |
11176 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11177 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11178 | vty_out(vty, " 4 Byte AS:"); | |
11179 | if (CHECK_FLAG(p->cap, | |
11180 | PEER_CAP_AS4_ADV)) | |
11181 | vty_out(vty, " advertised"); | |
11182 | if (CHECK_FLAG(p->cap, | |
11183 | PEER_CAP_AS4_RCV)) | |
11184 | vty_out(vty, " %sreceived", | |
11185 | CHECK_FLAG( | |
11186 | p->cap, | |
11187 | PEER_CAP_AS4_ADV) | |
11188 | ? "and " | |
11189 | : ""); | |
11190 | vty_out(vty, "\n"); | |
11191 | } | |
11192 | ||
11193 | /* AddPath */ | |
11194 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11195 | || CHECK_FLAG(p->cap, | |
11196 | PEER_CAP_ADDPATH_ADV)) { | |
11197 | vty_out(vty, " AddPath:\n"); | |
11198 | ||
05c7a1cc QY |
11199 | FOREACH_AFI_SAFI (afi, safi) { |
11200 | if (CHECK_FLAG( | |
11201 | p->af_cap[afi] | |
11202 | [safi], | |
11203 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11204 | || CHECK_FLAG( | |
11205 | p->af_cap[afi] | |
11206 | [safi], | |
11207 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11208 | vty_out(vty, | |
11209 | " %s: TX ", | |
5cb5f4d0 | 11210 | get_afi_safi_str( |
05c7a1cc | 11211 | afi, |
5cb5f4d0 DD |
11212 | safi, |
11213 | false)); | |
05c7a1cc | 11214 | |
d62a17ae | 11215 | if (CHECK_FLAG( |
11216 | p->af_cap | |
11217 | [afi] | |
11218 | [safi], | |
05c7a1cc | 11219 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11220 | vty_out(vty, |
05c7a1cc | 11221 | "advertised %s", |
5cb5f4d0 | 11222 | get_afi_safi_str( |
d62a17ae | 11223 | afi, |
5cb5f4d0 DD |
11224 | safi, |
11225 | false)); | |
d62a17ae | 11226 | |
05c7a1cc QY |
11227 | if (CHECK_FLAG( |
11228 | p->af_cap | |
11229 | [afi] | |
11230 | [safi], | |
11231 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11232 | vty_out(vty, | |
11233 | "%sreceived", | |
11234 | CHECK_FLAG( | |
11235 | p->af_cap | |
11236 | [afi] | |
11237 | [safi], | |
11238 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11239 | ? " and " | |
11240 | : ""); | |
d62a17ae | 11241 | |
05c7a1cc QY |
11242 | vty_out(vty, "\n"); |
11243 | } | |
d62a17ae | 11244 | |
05c7a1cc QY |
11245 | if (CHECK_FLAG( |
11246 | p->af_cap[afi] | |
11247 | [safi], | |
11248 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11249 | || CHECK_FLAG( | |
11250 | p->af_cap[afi] | |
11251 | [safi], | |
11252 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11253 | vty_out(vty, | |
11254 | " %s: RX ", | |
5cb5f4d0 | 11255 | get_afi_safi_str( |
05c7a1cc | 11256 | afi, |
5cb5f4d0 DD |
11257 | safi, |
11258 | false)); | |
d62a17ae | 11259 | |
11260 | if (CHECK_FLAG( | |
11261 | p->af_cap | |
11262 | [afi] | |
11263 | [safi], | |
05c7a1cc | 11264 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11265 | vty_out(vty, |
05c7a1cc | 11266 | "advertised %s", |
5cb5f4d0 | 11267 | get_afi_safi_str( |
d62a17ae | 11268 | afi, |
5cb5f4d0 DD |
11269 | safi, |
11270 | false)); | |
d62a17ae | 11271 | |
05c7a1cc QY |
11272 | if (CHECK_FLAG( |
11273 | p->af_cap | |
11274 | [afi] | |
11275 | [safi], | |
11276 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11277 | vty_out(vty, |
05c7a1cc QY |
11278 | "%sreceived", |
11279 | CHECK_FLAG( | |
11280 | p->af_cap | |
11281 | [afi] | |
11282 | [safi], | |
11283 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11284 | ? " and " | |
11285 | : ""); | |
11286 | ||
11287 | vty_out(vty, "\n"); | |
d62a17ae | 11288 | } |
05c7a1cc | 11289 | } |
d62a17ae | 11290 | } |
11291 | ||
11292 | /* Dynamic */ | |
11293 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11294 | || CHECK_FLAG(p->cap, | |
11295 | PEER_CAP_DYNAMIC_ADV)) { | |
11296 | vty_out(vty, " Dynamic:"); | |
11297 | if (CHECK_FLAG(p->cap, | |
11298 | PEER_CAP_DYNAMIC_ADV)) | |
11299 | vty_out(vty, " advertised"); | |
11300 | if (CHECK_FLAG(p->cap, | |
11301 | PEER_CAP_DYNAMIC_RCV)) | |
11302 | vty_out(vty, " %sreceived", | |
11303 | CHECK_FLAG( | |
11304 | p->cap, | |
11305 | PEER_CAP_DYNAMIC_ADV) | |
11306 | ? "and " | |
11307 | : ""); | |
11308 | vty_out(vty, "\n"); | |
11309 | } | |
11310 | ||
11311 | /* Extended nexthop */ | |
11312 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11313 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11314 | vty_out(vty, " Extended nexthop:"); | |
11315 | if (CHECK_FLAG(p->cap, | |
11316 | PEER_CAP_ENHE_ADV)) | |
11317 | vty_out(vty, " advertised"); | |
11318 | if (CHECK_FLAG(p->cap, | |
11319 | PEER_CAP_ENHE_RCV)) | |
11320 | vty_out(vty, " %sreceived", | |
11321 | CHECK_FLAG( | |
11322 | p->cap, | |
11323 | PEER_CAP_ENHE_ADV) | |
11324 | ? "and " | |
11325 | : ""); | |
11326 | vty_out(vty, "\n"); | |
11327 | ||
11328 | if (CHECK_FLAG(p->cap, | |
11329 | PEER_CAP_ENHE_RCV)) { | |
11330 | vty_out(vty, | |
11331 | " Address families by peer:\n "); | |
11332 | for (safi = SAFI_UNICAST; | |
11333 | safi < SAFI_MAX; safi++) | |
11334 | if (CHECK_FLAG( | |
11335 | p->af_cap | |
11336 | [AFI_IP] | |
11337 | [safi], | |
11338 | PEER_CAP_ENHE_AF_RCV)) | |
11339 | vty_out(vty, | |
11340 | " %s\n", | |
5cb5f4d0 | 11341 | get_afi_safi_str( |
d62a17ae | 11342 | AFI_IP, |
5cb5f4d0 DD |
11343 | safi, |
11344 | false)); | |
d62a17ae | 11345 | } |
11346 | } | |
11347 | ||
11348 | /* Route Refresh */ | |
11349 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11350 | || CHECK_FLAG(p->cap, | |
11351 | PEER_CAP_REFRESH_NEW_RCV) | |
11352 | || CHECK_FLAG(p->cap, | |
11353 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11354 | vty_out(vty, " Route refresh:"); | |
11355 | if (CHECK_FLAG(p->cap, | |
11356 | PEER_CAP_REFRESH_ADV)) | |
11357 | vty_out(vty, " advertised"); | |
11358 | if (CHECK_FLAG(p->cap, | |
11359 | PEER_CAP_REFRESH_NEW_RCV) | |
11360 | || CHECK_FLAG( | |
11361 | p->cap, | |
11362 | PEER_CAP_REFRESH_OLD_RCV)) | |
11363 | vty_out(vty, " %sreceived(%s)", | |
11364 | CHECK_FLAG( | |
11365 | p->cap, | |
11366 | PEER_CAP_REFRESH_ADV) | |
11367 | ? "and " | |
11368 | : "", | |
11369 | (CHECK_FLAG( | |
11370 | p->cap, | |
11371 | PEER_CAP_REFRESH_OLD_RCV) | |
11372 | && CHECK_FLAG( | |
11373 | p->cap, | |
11374 | PEER_CAP_REFRESH_NEW_RCV)) | |
11375 | ? "old & new" | |
11376 | : CHECK_FLAG( | |
11377 | p->cap, | |
11378 | PEER_CAP_REFRESH_OLD_RCV) | |
11379 | ? "old" | |
11380 | : "new"); | |
11381 | ||
11382 | vty_out(vty, "\n"); | |
11383 | } | |
11384 | ||
11385 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11386 | FOREACH_AFI_SAFI (afi, safi) |
11387 | if (p->afc_adv[afi][safi] | |
11388 | || p->afc_recv[afi][safi]) { | |
11389 | vty_out(vty, | |
11390 | " Address Family %s:", | |
5cb5f4d0 DD |
11391 | get_afi_safi_str( |
11392 | afi, | |
11393 | safi, | |
11394 | false)); | |
05c7a1cc | 11395 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11396 | vty_out(vty, |
05c7a1cc QY |
11397 | " advertised"); |
11398 | if (p->afc_recv[afi][safi]) | |
11399 | vty_out(vty, | |
11400 | " %sreceived", | |
11401 | p->afc_adv[afi] | |
11402 | [safi] | |
11403 | ? "and " | |
11404 | : ""); | |
11405 | vty_out(vty, "\n"); | |
11406 | } | |
d62a17ae | 11407 | |
11408 | /* Hostname capability */ | |
60466a63 | 11409 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11410 | |
11411 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11412 | vty_out(vty, |
11413 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11414 | bgp->peer_self->hostname |
11415 | ? bgp->peer_self | |
11416 | ->hostname | |
d77114b7 | 11417 | : "n/a", |
60466a63 QY |
11418 | bgp->peer_self->domainname |
11419 | ? bgp->peer_self | |
11420 | ->domainname | |
d77114b7 MK |
11421 | : "n/a"); |
11422 | } else { | |
11423 | vty_out(vty, " not advertised"); | |
d62a17ae | 11424 | } |
11425 | ||
d77114b7 | 11426 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11427 | vty_out(vty, |
11428 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11429 | p->hostname ? p->hostname |
11430 | : "n/a", | |
11431 | p->domainname ? p->domainname | |
11432 | : "n/a"); | |
d77114b7 MK |
11433 | } else { |
11434 | vty_out(vty, " not received"); | |
11435 | } | |
11436 | ||
11437 | vty_out(vty, "\n"); | |
11438 | ||
d62a17ae | 11439 | /* Gracefull Restart */ |
11440 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11441 | || CHECK_FLAG(p->cap, | |
11442 | PEER_CAP_RESTART_ADV)) { | |
11443 | vty_out(vty, | |
11444 | " Graceful Restart Capabilty:"); | |
11445 | if (CHECK_FLAG(p->cap, | |
11446 | PEER_CAP_RESTART_ADV)) | |
11447 | vty_out(vty, " advertised"); | |
11448 | if (CHECK_FLAG(p->cap, | |
11449 | PEER_CAP_RESTART_RCV)) | |
11450 | vty_out(vty, " %sreceived", | |
11451 | CHECK_FLAG( | |
11452 | p->cap, | |
11453 | PEER_CAP_RESTART_ADV) | |
11454 | ? "and " | |
11455 | : ""); | |
11456 | vty_out(vty, "\n"); | |
11457 | ||
11458 | if (CHECK_FLAG(p->cap, | |
11459 | PEER_CAP_RESTART_RCV)) { | |
11460 | int restart_af_count = 0; | |
11461 | ||
11462 | vty_out(vty, | |
11463 | " Remote Restart timer is %d seconds\n", | |
11464 | p->v_gr_restart); | |
11465 | vty_out(vty, | |
11466 | " Address families by peer:\n "); | |
11467 | ||
05c7a1cc QY |
11468 | FOREACH_AFI_SAFI (afi, safi) |
11469 | if (CHECK_FLAG( | |
11470 | p->af_cap | |
11471 | [afi] | |
11472 | [safi], | |
11473 | PEER_CAP_RESTART_AF_RCV)) { | |
11474 | vty_out(vty, | |
11475 | "%s%s(%s)", | |
11476 | restart_af_count | |
11477 | ? ", " | |
11478 | : "", | |
5cb5f4d0 | 11479 | get_afi_safi_str( |
05c7a1cc | 11480 | afi, |
5cb5f4d0 DD |
11481 | safi, |
11482 | false), | |
05c7a1cc QY |
11483 | CHECK_FLAG( |
11484 | p->af_cap | |
11485 | [afi] | |
11486 | [safi], | |
11487 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11488 | ? "preserved" | |
11489 | : "not preserved"); | |
11490 | restart_af_count++; | |
11491 | } | |
d62a17ae | 11492 | if (!restart_af_count) |
11493 | vty_out(vty, "none"); | |
11494 | vty_out(vty, "\n"); | |
11495 | } | |
2986cac2 | 11496 | } /* Gracefull Restart */ |
d62a17ae | 11497 | } |
11498 | } | |
11499 | } | |
11500 | ||
11501 | /* graceful restart information */ | |
d62a17ae | 11502 | json_object *json_grace = NULL; |
11503 | json_object *json_grace_send = NULL; | |
11504 | json_object *json_grace_recv = NULL; | |
11505 | int eor_send_af_count = 0; | |
11506 | int eor_receive_af_count = 0; | |
11507 | ||
11508 | if (use_json) { | |
11509 | json_grace = json_object_new_object(); | |
11510 | json_grace_send = json_object_new_object(); | |
11511 | json_grace_recv = json_object_new_object(); | |
11512 | ||
2986cac2 | 11513 | if ((p->status == Established) && |
11514 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11515 | FOREACH_AFI_SAFI (afi, safi) { |
11516 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
2986cac2 | 11517 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11518 | json_object_boolean_true_add( |
11519 | json_grace_send, | |
5cb5f4d0 DD |
11520 | get_afi_safi_str(afi, |
11521 | safi, | |
11522 | true)); | |
05c7a1cc | 11523 | eor_send_af_count++; |
d62a17ae | 11524 | } |
11525 | } | |
05c7a1cc QY |
11526 | FOREACH_AFI_SAFI (afi, safi) { |
11527 | if (CHECK_FLAG( | |
2986cac2 | 11528 | p->af_sflags[afi][safi], |
11529 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11530 | json_object_boolean_true_add( |
11531 | json_grace_recv, | |
5cb5f4d0 DD |
11532 | get_afi_safi_str(afi, |
11533 | safi, | |
11534 | true)); | |
05c7a1cc | 11535 | eor_receive_af_count++; |
d62a17ae | 11536 | } |
11537 | } | |
11538 | } | |
2986cac2 | 11539 | json_object_object_add(json_grace, |
11540 | "endOfRibSend", | |
11541 | json_grace_send); | |
11542 | json_object_object_add(json_grace, | |
11543 | "endOfRibRecv", | |
11544 | json_grace_recv); | |
d62a17ae | 11545 | |
d62a17ae | 11546 | |
11547 | if (p->t_gr_restart) | |
11548 | json_object_int_add(json_grace, | |
11549 | "gracefulRestartTimerMsecs", | |
11550 | thread_timer_remain_second( | |
11551 | p->t_gr_restart) | |
11552 | * 1000); | |
11553 | ||
11554 | if (p->t_gr_stale) | |
11555 | json_object_int_add( | |
11556 | json_grace, | |
11557 | "gracefulStalepathTimerMsecs", | |
11558 | thread_timer_remain_second( | |
11559 | p->t_gr_stale) | |
11560 | * 1000); | |
2986cac2 | 11561 | /* more gr info in new format */ |
11562 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
11563 | json_grace); | |
d62a17ae | 11564 | json_object_object_add( |
11565 | json_neigh, "gracefulRestartInfo", json_grace); | |
11566 | } else { | |
2986cac2 | 11567 | vty_out(vty, " Graceful restart informations:\n"); |
11568 | if ((p->status == Established) && | |
11569 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
11570 | ||
d62a17ae | 11571 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11572 | FOREACH_AFI_SAFI (afi, safi) { |
11573 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11574 | PEER_STATUS_EOR_SEND)) { | |
11575 | vty_out(vty, "%s%s", | |
11576 | eor_send_af_count ? ", " | |
11577 | : "", | |
5cb5f4d0 | 11578 | get_afi_safi_str(afi, |
2986cac2 | 11579 | safi, |
11580 | false)); | |
05c7a1cc | 11581 | eor_send_af_count++; |
d62a17ae | 11582 | } |
11583 | } | |
11584 | vty_out(vty, "\n"); | |
11585 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11586 | FOREACH_AFI_SAFI (afi, safi) { |
11587 | if (CHECK_FLAG( | |
11588 | p->af_sflags[afi][safi], | |
11589 | PEER_STATUS_EOR_RECEIVED)) { | |
11590 | vty_out(vty, "%s%s", | |
11591 | eor_receive_af_count | |
11592 | ? ", " | |
11593 | : "", | |
5cb5f4d0 DD |
11594 | get_afi_safi_str(afi, |
11595 | safi, | |
11596 | false)); | |
05c7a1cc | 11597 | eor_receive_af_count++; |
d62a17ae | 11598 | } |
11599 | } | |
11600 | vty_out(vty, "\n"); | |
11601 | } | |
11602 | ||
11603 | if (p->t_gr_restart) | |
11604 | vty_out(vty, | |
11605 | " The remaining time of restart timer is %ld\n", | |
11606 | thread_timer_remain_second( | |
11607 | p->t_gr_restart)); | |
11608 | ||
11609 | if (p->t_gr_stale) | |
11610 | vty_out(vty, | |
11611 | " The remaining time of stalepath timer is %ld\n", | |
11612 | thread_timer_remain_second( | |
11613 | p->t_gr_stale)); | |
2986cac2 | 11614 | |
11615 | /* more gr info in new format */ | |
11616 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11617 | } |
2986cac2 | 11618 | |
d62a17ae | 11619 | if (use_json) { |
11620 | json_object *json_stat = NULL; | |
11621 | json_stat = json_object_new_object(); | |
11622 | /* Packet counts. */ | |
11623 | json_object_int_add(json_stat, "depthInq", 0); | |
11624 | json_object_int_add(json_stat, "depthOutq", | |
11625 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
11626 | json_object_int_add(json_stat, "opensSent", |
11627 | atomic_load_explicit(&p->open_out, | |
11628 | memory_order_relaxed)); | |
11629 | json_object_int_add(json_stat, "opensRecv", | |
11630 | atomic_load_explicit(&p->open_in, | |
11631 | memory_order_relaxed)); | |
d62a17ae | 11632 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11633 | atomic_load_explicit(&p->notify_out, |
11634 | memory_order_relaxed)); | |
d62a17ae | 11635 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11636 | atomic_load_explicit(&p->notify_in, |
11637 | memory_order_relaxed)); | |
11638 | json_object_int_add(json_stat, "updatesSent", | |
11639 | atomic_load_explicit(&p->update_out, | |
11640 | memory_order_relaxed)); | |
11641 | json_object_int_add(json_stat, "updatesRecv", | |
11642 | atomic_load_explicit(&p->update_in, | |
11643 | memory_order_relaxed)); | |
d62a17ae | 11644 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11645 | atomic_load_explicit(&p->keepalive_out, |
11646 | memory_order_relaxed)); | |
d62a17ae | 11647 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11648 | atomic_load_explicit(&p->keepalive_in, |
11649 | memory_order_relaxed)); | |
d62a17ae | 11650 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11651 | atomic_load_explicit(&p->refresh_out, |
11652 | memory_order_relaxed)); | |
d62a17ae | 11653 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11654 | atomic_load_explicit(&p->refresh_in, |
11655 | memory_order_relaxed)); | |
d62a17ae | 11656 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11657 | atomic_load_explicit(&p->dynamic_cap_out, |
11658 | memory_order_relaxed)); | |
d62a17ae | 11659 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11660 | atomic_load_explicit(&p->dynamic_cap_in, |
11661 | memory_order_relaxed)); | |
11662 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11663 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11664 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11665 | } else { | |
11666 | /* Packet counts. */ | |
11667 | vty_out(vty, " Message statistics:\n"); | |
11668 | vty_out(vty, " Inq depth is 0\n"); | |
11669 | vty_out(vty, " Outq depth is %lu\n", | |
11670 | (unsigned long)p->obuf->count); | |
11671 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
11672 | vty_out(vty, " Opens: %10d %10d\n", |
11673 | atomic_load_explicit(&p->open_out, | |
11674 | memory_order_relaxed), | |
11675 | atomic_load_explicit(&p->open_in, | |
11676 | memory_order_relaxed)); | |
11677 | vty_out(vty, " Notifications: %10d %10d\n", | |
11678 | atomic_load_explicit(&p->notify_out, | |
11679 | memory_order_relaxed), | |
11680 | atomic_load_explicit(&p->notify_in, | |
11681 | memory_order_relaxed)); | |
11682 | vty_out(vty, " Updates: %10d %10d\n", | |
11683 | atomic_load_explicit(&p->update_out, | |
11684 | memory_order_relaxed), | |
11685 | atomic_load_explicit(&p->update_in, | |
11686 | memory_order_relaxed)); | |
11687 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11688 | atomic_load_explicit(&p->keepalive_out, | |
11689 | memory_order_relaxed), | |
11690 | atomic_load_explicit(&p->keepalive_in, | |
11691 | memory_order_relaxed)); | |
11692 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11693 | atomic_load_explicit(&p->refresh_out, | |
11694 | memory_order_relaxed), | |
11695 | atomic_load_explicit(&p->refresh_in, | |
11696 | memory_order_relaxed)); | |
d62a17ae | 11697 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11698 | atomic_load_explicit(&p->dynamic_cap_out, |
11699 | memory_order_relaxed), | |
11700 | atomic_load_explicit(&p->dynamic_cap_in, | |
11701 | memory_order_relaxed)); | |
11702 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11703 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11704 | } |
11705 | ||
11706 | if (use_json) { | |
11707 | /* advertisement-interval */ | |
11708 | json_object_int_add(json_neigh, | |
11709 | "minBtwnAdvertisementRunsTimerMsecs", | |
11710 | p->v_routeadv * 1000); | |
11711 | ||
11712 | /* Update-source. */ | |
11713 | if (p->update_if || p->update_source) { | |
11714 | if (p->update_if) | |
11715 | json_object_string_add(json_neigh, | |
11716 | "updateSource", | |
11717 | p->update_if); | |
11718 | else if (p->update_source) | |
11719 | json_object_string_add( | |
11720 | json_neigh, "updateSource", | |
11721 | sockunion2str(p->update_source, buf1, | |
11722 | SU_ADDRSTRLEN)); | |
11723 | } | |
11724 | } else { | |
11725 | /* advertisement-interval */ | |
11726 | vty_out(vty, | |
11727 | " Minimum time between advertisement runs is %d seconds\n", | |
11728 | p->v_routeadv); | |
11729 | ||
11730 | /* Update-source. */ | |
11731 | if (p->update_if || p->update_source) { | |
11732 | vty_out(vty, " Update source is "); | |
11733 | if (p->update_if) | |
11734 | vty_out(vty, "%s", p->update_if); | |
11735 | else if (p->update_source) | |
11736 | vty_out(vty, "%s", | |
11737 | sockunion2str(p->update_source, buf1, | |
11738 | SU_ADDRSTRLEN)); | |
11739 | vty_out(vty, "\n"); | |
11740 | } | |
11741 | ||
11742 | vty_out(vty, "\n"); | |
11743 | } | |
11744 | ||
11745 | /* Address Family Information */ | |
11746 | json_object *json_hold = NULL; | |
11747 | ||
11748 | if (use_json) | |
11749 | json_hold = json_object_new_object(); | |
11750 | ||
05c7a1cc QY |
11751 | FOREACH_AFI_SAFI (afi, safi) |
11752 | if (p->afc[afi][safi]) | |
11753 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11754 | json_hold); | |
d62a17ae | 11755 | |
11756 | if (use_json) { | |
11757 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11758 | json_hold); | |
11759 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11760 | p->established); | |
11761 | json_object_int_add(json_neigh, "connectionsDropped", | |
11762 | p->dropped); | |
11763 | } else | |
11764 | vty_out(vty, " Connections established %d; dropped %d\n", | |
11765 | p->established, p->dropped); | |
11766 | ||
11767 | if (!p->last_reset) { | |
11768 | if (use_json) | |
11769 | json_object_string_add(json_neigh, "lastReset", | |
11770 | "never"); | |
11771 | else | |
11772 | vty_out(vty, " Last reset never\n"); | |
11773 | } else { | |
11774 | if (use_json) { | |
11775 | time_t uptime; | |
11776 | struct tm *tm; | |
11777 | ||
11778 | uptime = bgp_clock(); | |
11779 | uptime -= p->resettime; | |
11780 | tm = gmtime(&uptime); | |
11781 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
11782 | (tm->tm_sec * 1000) | |
11783 | + (tm->tm_min * 60000) | |
11784 | + (tm->tm_hour * 3600000)); | |
3577f1c5 | 11785 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 11786 | } else { |
11787 | vty_out(vty, " Last reset %s, ", | |
11788 | peer_uptime(p->resettime, timebuf, | |
11789 | BGP_UPTIME_LEN, 0, NULL)); | |
11790 | ||
3577f1c5 | 11791 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 11792 | if (p->last_reset_cause_size) { |
11793 | msg = p->last_reset_cause; | |
11794 | vty_out(vty, | |
11795 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
11796 | for (i = 1; i <= p->last_reset_cause_size; | |
11797 | i++) { | |
11798 | vty_out(vty, "%02X", *msg++); | |
11799 | ||
11800 | if (i != p->last_reset_cause_size) { | |
11801 | if (i % 16 == 0) { | |
11802 | vty_out(vty, "\n "); | |
11803 | } else if (i % 4 == 0) { | |
11804 | vty_out(vty, " "); | |
11805 | } | |
11806 | } | |
11807 | } | |
11808 | vty_out(vty, "\n"); | |
11809 | } | |
11810 | } | |
11811 | } | |
11812 | ||
11813 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11814 | if (use_json) | |
11815 | json_object_boolean_true_add(json_neigh, | |
11816 | "prefixesConfigExceedMax"); | |
11817 | else | |
11818 | vty_out(vty, | |
11819 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11820 | ||
11821 | if (p->t_pmax_restart) { | |
11822 | if (use_json) { | |
11823 | json_object_boolean_true_add( | |
11824 | json_neigh, "reducePrefixNumFrom"); | |
11825 | json_object_int_add(json_neigh, | |
11826 | "restartInTimerMsec", | |
11827 | thread_timer_remain_second( | |
11828 | p->t_pmax_restart) | |
11829 | * 1000); | |
11830 | } else | |
11831 | vty_out(vty, | |
11832 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
11833 | p->host, thread_timer_remain_second( |
11834 | p->t_pmax_restart)); | |
d62a17ae | 11835 | } else { |
11836 | if (use_json) | |
11837 | json_object_boolean_true_add( | |
11838 | json_neigh, | |
11839 | "reducePrefixNumAndClearIpBgp"); | |
11840 | else | |
11841 | vty_out(vty, | |
11842 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
11843 | p->host); | |
11844 | } | |
11845 | } | |
11846 | ||
11847 | /* EBGP Multihop and GTSM */ | |
11848 | if (p->sort != BGP_PEER_IBGP) { | |
11849 | if (use_json) { | |
11850 | if (p->gtsm_hops > 0) | |
11851 | json_object_int_add(json_neigh, | |
11852 | "externalBgpNbrMaxHopsAway", | |
11853 | p->gtsm_hops); | |
c8d6f0d6 | 11854 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11855 | json_object_int_add(json_neigh, |
11856 | "externalBgpNbrMaxHopsAway", | |
11857 | p->ttl); | |
11858 | } else { | |
11859 | if (p->gtsm_hops > 0) | |
11860 | vty_out(vty, | |
11861 | " External BGP neighbor may be up to %d hops away.\n", | |
11862 | p->gtsm_hops); | |
c8d6f0d6 | 11863 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11864 | vty_out(vty, |
11865 | " External BGP neighbor may be up to %d hops away.\n", | |
11866 | p->ttl); | |
11867 | } | |
11868 | } else { | |
11869 | if (p->gtsm_hops > 0) { | |
11870 | if (use_json) | |
11871 | json_object_int_add(json_neigh, | |
11872 | "internalBgpNbrMaxHopsAway", | |
11873 | p->gtsm_hops); | |
11874 | else | |
11875 | vty_out(vty, | |
11876 | " Internal BGP neighbor may be up to %d hops away.\n", | |
11877 | p->gtsm_hops); | |
11878 | } | |
11879 | } | |
11880 | ||
11881 | /* Local address. */ | |
11882 | if (p->su_local) { | |
11883 | if (use_json) { | |
11884 | json_object_string_add(json_neigh, "hostLocal", | |
11885 | sockunion2str(p->su_local, buf1, | |
11886 | SU_ADDRSTRLEN)); | |
11887 | json_object_int_add(json_neigh, "portLocal", | |
11888 | ntohs(p->su_local->sin.sin_port)); | |
11889 | } else | |
11890 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
11891 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
11892 | ntohs(p->su_local->sin.sin_port)); | |
11893 | } | |
11894 | ||
11895 | /* Remote address. */ | |
11896 | if (p->su_remote) { | |
11897 | if (use_json) { | |
11898 | json_object_string_add(json_neigh, "hostForeign", | |
11899 | sockunion2str(p->su_remote, buf1, | |
11900 | SU_ADDRSTRLEN)); | |
11901 | json_object_int_add(json_neigh, "portForeign", | |
11902 | ntohs(p->su_remote->sin.sin_port)); | |
11903 | } else | |
11904 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
11905 | sockunion2str(p->su_remote, buf1, | |
11906 | SU_ADDRSTRLEN), | |
11907 | ntohs(p->su_remote->sin.sin_port)); | |
11908 | } | |
11909 | ||
11910 | /* Nexthop display. */ | |
11911 | if (p->su_local) { | |
11912 | if (use_json) { | |
11913 | json_object_string_add(json_neigh, "nexthop", | |
11914 | inet_ntop(AF_INET, | |
11915 | &p->nexthop.v4, buf1, | |
11916 | sizeof(buf1))); | |
11917 | json_object_string_add(json_neigh, "nexthopGlobal", | |
11918 | inet_ntop(AF_INET6, | |
11919 | &p->nexthop.v6_global, | |
11920 | buf1, sizeof(buf1))); | |
11921 | json_object_string_add(json_neigh, "nexthopLocal", | |
11922 | inet_ntop(AF_INET6, | |
11923 | &p->nexthop.v6_local, | |
11924 | buf1, sizeof(buf1))); | |
11925 | if (p->shared_network) | |
11926 | json_object_string_add(json_neigh, | |
11927 | "bgpConnection", | |
11928 | "sharedNetwork"); | |
11929 | else | |
11930 | json_object_string_add(json_neigh, | |
11931 | "bgpConnection", | |
11932 | "nonSharedNetwork"); | |
11933 | } else { | |
11934 | vty_out(vty, "Nexthop: %s\n", | |
11935 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
11936 | sizeof(buf1))); | |
11937 | vty_out(vty, "Nexthop global: %s\n", | |
11938 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
11939 | sizeof(buf1))); | |
11940 | vty_out(vty, "Nexthop local: %s\n", | |
11941 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
11942 | sizeof(buf1))); | |
11943 | vty_out(vty, "BGP connection: %s\n", | |
11944 | p->shared_network ? "shared network" | |
11945 | : "non shared network"); | |
11946 | } | |
11947 | } | |
11948 | ||
11949 | /* Timer information. */ | |
11950 | if (use_json) { | |
11951 | json_object_int_add(json_neigh, "connectRetryTimer", | |
11952 | p->v_connect); | |
11953 | if (p->status == Established && p->rtt) | |
11954 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
11955 | p->rtt); | |
11956 | if (p->t_start) | |
11957 | json_object_int_add( | |
11958 | json_neigh, "nextStartTimerDueInMsecs", | |
11959 | thread_timer_remain_second(p->t_start) * 1000); | |
11960 | if (p->t_connect) | |
11961 | json_object_int_add( | |
11962 | json_neigh, "nextConnectTimerDueInMsecs", | |
11963 | thread_timer_remain_second(p->t_connect) | |
11964 | * 1000); | |
11965 | if (p->t_routeadv) { | |
11966 | json_object_int_add(json_neigh, "mraiInterval", | |
11967 | p->v_routeadv); | |
11968 | json_object_int_add( | |
11969 | json_neigh, "mraiTimerExpireInMsecs", | |
11970 | thread_timer_remain_second(p->t_routeadv) | |
11971 | * 1000); | |
11972 | } | |
11973 | if (p->password) | |
11974 | json_object_int_add(json_neigh, "authenticationEnabled", | |
11975 | 1); | |
11976 | ||
11977 | if (p->t_read) | |
11978 | json_object_string_add(json_neigh, "readThread", "on"); | |
11979 | else | |
11980 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
11981 | |
11982 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 11983 | json_object_string_add(json_neigh, "writeThread", "on"); |
11984 | else | |
11985 | json_object_string_add(json_neigh, "writeThread", | |
11986 | "off"); | |
11987 | } else { | |
11988 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
11989 | p->v_connect); | |
11990 | if (p->status == Established && p->rtt) | |
11991 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
11992 | p->rtt); | |
11993 | if (p->t_start) | |
11994 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
11995 | thread_timer_remain_second(p->t_start)); | |
11996 | if (p->t_connect) | |
11997 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
11998 | thread_timer_remain_second(p->t_connect)); | |
11999 | if (p->t_routeadv) | |
12000 | vty_out(vty, | |
12001 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12002 | p->v_routeadv, | |
12003 | thread_timer_remain_second(p->t_routeadv)); | |
12004 | if (p->password) | |
12005 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12006 | ||
cac9e917 | 12007 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12008 | p->t_read ? "on" : "off", |
12009 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12010 | ? "on" | |
cac9e917 | 12011 | : "off", p->fd); |
d62a17ae | 12012 | } |
12013 | ||
12014 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12015 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12016 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12017 | ||
12018 | if (!use_json) | |
12019 | vty_out(vty, "\n"); | |
12020 | ||
12021 | /* BFD information. */ | |
12022 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12023 | ||
12024 | if (use_json) { | |
12025 | if (p->conf_if) /* Configured interface name. */ | |
12026 | json_object_object_add(json, p->conf_if, json_neigh); | |
12027 | else /* Configured IP address. */ | |
12028 | json_object_object_add(json, p->host, json_neigh); | |
12029 | } | |
12030 | } | |
12031 | ||
2986cac2 | 12032 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, |
12033 | struct bgp *bgp, | |
12034 | enum show_type type, | |
12035 | union sockunion *su, | |
12036 | const char *conf_if, afi_t afi, | |
12037 | bool use_json, json_object *json) | |
12038 | { | |
12039 | struct listnode *node, *nnode; | |
12040 | struct peer *peer; | |
12041 | int find = 0; | |
12042 | safi_t safi = SAFI_UNICAST; | |
12043 | json_object *json_neighbor = NULL; | |
12044 | ||
12045 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12046 | ||
12047 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12048 | continue; | |
12049 | ||
12050 | if ((peer->afc[afi][safi]) == 0) | |
12051 | continue; | |
12052 | ||
12053 | if (use_json) | |
12054 | json_neighbor = json_object_new_object(); | |
12055 | ||
12056 | if (show_all == type) { | |
12057 | bgp_show_peer_gr_status(vty, peer, use_json, | |
12058 | json_neighbor); | |
12059 | ||
12060 | if (use_json) | |
12061 | json_object_object_add(json, | |
12062 | peer->host, json_neighbor); | |
12063 | ||
12064 | } else if (show_peer == type) { | |
12065 | if (conf_if) { | |
12066 | if ((peer->conf_if | |
12067 | && !strcmp(peer->conf_if, conf_if)) | |
12068 | || (peer->hostname | |
12069 | && !strcmp(peer->hostname, conf_if))) { | |
12070 | find = 1; | |
12071 | bgp_show_peer_gr_status(vty, | |
12072 | peer, use_json, | |
12073 | json_neighbor); | |
12074 | } | |
12075 | } else { | |
12076 | if (sockunion_same(&peer->su, su)) { | |
12077 | find = 1; | |
12078 | bgp_show_peer_gr_status(vty, | |
12079 | peer, use_json, | |
12080 | json_neighbor); | |
12081 | } | |
12082 | } | |
12083 | if (use_json && find) { | |
12084 | json_object_object_add(json, | |
12085 | peer->host, json_neighbor); | |
12086 | } | |
12087 | } | |
12088 | ||
12089 | if (find) | |
12090 | break; | |
12091 | } | |
12092 | ||
12093 | if (type == show_peer && !find) { | |
12094 | if (use_json) | |
12095 | json_object_boolean_true_add(json, | |
12096 | "bgpNoSuchNeighbor"); | |
12097 | else | |
12098 | vty_out(vty, "%% No such neighbor\n"); | |
12099 | } | |
12100 | if (use_json) { | |
12101 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
12102 | json, JSON_C_TO_STRING_PRETTY)); | |
12103 | } else { | |
12104 | vty_out(vty, "\n"); | |
12105 | } | |
12106 | ||
12107 | return CMD_SUCCESS; | |
12108 | } | |
12109 | ||
d62a17ae | 12110 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12111 | enum show_type type, union sockunion *su, | |
9f049418 | 12112 | const char *conf_if, bool use_json, |
d62a17ae | 12113 | json_object *json) |
12114 | { | |
12115 | struct listnode *node, *nnode; | |
12116 | struct peer *peer; | |
12117 | int find = 0; | |
9f049418 | 12118 | bool nbr_output = false; |
d1927ebe AS |
12119 | afi_t afi = AFI_MAX; |
12120 | safi_t safi = SAFI_MAX; | |
12121 | ||
12122 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12123 | afi = AFI_IP; | |
12124 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12125 | afi = AFI_IP6; | |
12126 | } | |
d62a17ae | 12127 | |
12128 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12129 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12130 | continue; | |
12131 | ||
12132 | switch (type) { | |
12133 | case show_all: | |
12134 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12135 | nbr_output = true; |
d62a17ae | 12136 | break; |
12137 | case show_peer: | |
12138 | if (conf_if) { | |
12139 | if ((peer->conf_if | |
12140 | && !strcmp(peer->conf_if, conf_if)) | |
12141 | || (peer->hostname | |
12142 | && !strcmp(peer->hostname, conf_if))) { | |
12143 | find = 1; | |
12144 | bgp_show_peer(vty, peer, use_json, | |
12145 | json); | |
12146 | } | |
12147 | } else { | |
12148 | if (sockunion_same(&peer->su, su)) { | |
12149 | find = 1; | |
12150 | bgp_show_peer(vty, peer, use_json, | |
12151 | json); | |
12152 | } | |
12153 | } | |
12154 | break; | |
d1927ebe AS |
12155 | case show_ipv4_peer: |
12156 | case show_ipv6_peer: | |
12157 | FOREACH_SAFI (safi) { | |
12158 | if (peer->afc[afi][safi]) { | |
12159 | if (conf_if) { | |
12160 | if ((peer->conf_if | |
12161 | && !strcmp(peer->conf_if, conf_if)) | |
12162 | || (peer->hostname | |
12163 | && !strcmp(peer->hostname, conf_if))) { | |
12164 | find = 1; | |
12165 | bgp_show_peer(vty, peer, use_json, | |
12166 | json); | |
12167 | break; | |
12168 | } | |
12169 | } else { | |
12170 | if (sockunion_same(&peer->su, su)) { | |
12171 | find = 1; | |
12172 | bgp_show_peer(vty, peer, use_json, | |
12173 | json); | |
12174 | break; | |
12175 | } | |
12176 | } | |
12177 | } | |
12178 | } | |
12179 | break; | |
12180 | case show_ipv4_all: | |
12181 | case show_ipv6_all: | |
12182 | FOREACH_SAFI (safi) { | |
12183 | if (peer->afc[afi][safi]) { | |
12184 | bgp_show_peer(vty, peer, use_json, json); | |
12185 | nbr_output = true; | |
12186 | break; | |
12187 | } | |
12188 | } | |
12189 | break; | |
d62a17ae | 12190 | } |
12191 | } | |
12192 | ||
d1927ebe AS |
12193 | if ((type == show_peer || type == show_ipv4_peer || |
12194 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12195 | if (use_json) |
12196 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12197 | else | |
88b7d255 | 12198 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12199 | } |
12200 | ||
d1927ebe AS |
12201 | if (type != show_peer && type != show_ipv4_peer && |
12202 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12203 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12204 | |
d62a17ae | 12205 | if (use_json) { |
996c9314 LB |
12206 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12207 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12208 | } else { |
12209 | vty_out(vty, "\n"); | |
12210 | } | |
12211 | ||
12212 | return CMD_SUCCESS; | |
12213 | } | |
12214 | ||
2986cac2 | 12215 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12216 | enum show_type type, const char *ip_str, | |
12217 | afi_t afi, bool use_json) | |
12218 | { | |
12219 | ||
12220 | int ret; | |
12221 | struct bgp *bgp; | |
12222 | union sockunion su; | |
12223 | json_object *json = NULL; | |
12224 | ||
12225 | bgp = bgp_get_default(); | |
12226 | ||
12227 | if (bgp) { | |
12228 | ||
12229 | if (!use_json) { | |
12230 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, | |
12231 | use_json, NULL); | |
12232 | } | |
12233 | ||
12234 | json = json_object_new_object(); | |
12235 | if (ip_str) { | |
12236 | ret = str2sockunion(ip_str, &su); | |
12237 | if (ret < 0) | |
12238 | bgp_show_neighbor_graceful_restart(vty, | |
12239 | bgp, type, NULL, ip_str, | |
12240 | afi, use_json, json); | |
12241 | else | |
12242 | bgp_show_neighbor_graceful_restart(vty, | |
12243 | bgp, type, &su, NULL, | |
12244 | afi, use_json, json); | |
12245 | } else { | |
12246 | bgp_show_neighbor_graceful_restart(vty, bgp, | |
12247 | type, NULL, NULL, afi, | |
12248 | use_json, json); | |
12249 | } | |
12250 | json_object_free(json); | |
12251 | } | |
12252 | ||
12253 | } | |
12254 | ||
d62a17ae | 12255 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12256 | enum show_type type, |
12257 | const char *ip_str, | |
9f049418 | 12258 | bool use_json) |
d62a17ae | 12259 | { |
0291c246 MK |
12260 | struct listnode *node, *nnode; |
12261 | struct bgp *bgp; | |
71aedaa3 | 12262 | union sockunion su; |
0291c246 | 12263 | json_object *json = NULL; |
71aedaa3 | 12264 | int ret, is_first = 1; |
9f049418 | 12265 | bool nbr_output = false; |
d62a17ae | 12266 | |
12267 | if (use_json) | |
12268 | vty_out(vty, "{\n"); | |
12269 | ||
12270 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12271 | nbr_output = true; |
d62a17ae | 12272 | if (use_json) { |
12273 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12274 | flog_err( |
e50f7cfd | 12275 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12276 | "Unable to allocate memory for JSON object"); |
12277 | vty_out(vty, | |
12278 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12279 | return; | |
12280 | } | |
12281 | ||
12282 | json_object_int_add(json, "vrfId", | |
12283 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12284 | ? -1 |
12285 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12286 | json_object_string_add( |
12287 | json, "vrfName", | |
12288 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12289 | ? VRF_DEFAULT_NAME |
d62a17ae | 12290 | : bgp->name); |
12291 | ||
12292 | if (!is_first) | |
12293 | vty_out(vty, ",\n"); | |
12294 | else | |
12295 | is_first = 0; | |
12296 | ||
12297 | vty_out(vty, "\"%s\":", | |
12298 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12299 | ? VRF_DEFAULT_NAME |
d62a17ae | 12300 | : bgp->name); |
12301 | } else { | |
12302 | vty_out(vty, "\nInstance %s:\n", | |
12303 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12304 | ? VRF_DEFAULT_NAME |
d62a17ae | 12305 | : bgp->name); |
12306 | } | |
71aedaa3 | 12307 | |
d1927ebe AS |
12308 | if (type == show_peer || type == show_ipv4_peer || |
12309 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12310 | ret = str2sockunion(ip_str, &su); |
12311 | if (ret < 0) | |
12312 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12313 | use_json, json); | |
12314 | else | |
12315 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12316 | use_json, json); | |
12317 | } else { | |
d1927ebe | 12318 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12319 | use_json, json); |
12320 | } | |
b77004d6 | 12321 | json_object_free(json); |
d62a17ae | 12322 | } |
12323 | ||
01cbfd04 | 12324 | if (use_json) { |
d62a17ae | 12325 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12326 | json_object_free(json); |
12327 | } | |
9f049418 DS |
12328 | else if (!nbr_output) |
12329 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12330 | } |
12331 | ||
12332 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12333 | enum show_type type, const char *ip_str, | |
9f049418 | 12334 | bool use_json) |
d62a17ae | 12335 | { |
12336 | int ret; | |
12337 | struct bgp *bgp; | |
12338 | union sockunion su; | |
12339 | json_object *json = NULL; | |
12340 | ||
12341 | if (name) { | |
12342 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12343 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12344 | use_json); | |
d62a17ae | 12345 | return CMD_SUCCESS; |
12346 | } else { | |
12347 | bgp = bgp_lookup_by_name(name); | |
12348 | if (!bgp) { | |
12349 | if (use_json) { | |
12350 | json = json_object_new_object(); | |
d62a17ae | 12351 | vty_out(vty, "%s\n", |
12352 | json_object_to_json_string_ext( | |
12353 | json, | |
12354 | JSON_C_TO_STRING_PRETTY)); | |
12355 | json_object_free(json); | |
12356 | } else | |
12357 | vty_out(vty, | |
9f049418 | 12358 | "%% BGP instance not found\n"); |
d62a17ae | 12359 | |
12360 | return CMD_WARNING; | |
12361 | } | |
12362 | } | |
12363 | } else { | |
12364 | bgp = bgp_get_default(); | |
12365 | } | |
12366 | ||
12367 | if (bgp) { | |
12368 | json = json_object_new_object(); | |
12369 | if (ip_str) { | |
12370 | ret = str2sockunion(ip_str, &su); | |
12371 | if (ret < 0) | |
12372 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12373 | use_json, json); | |
12374 | else | |
12375 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12376 | use_json, json); | |
12377 | } else { | |
12378 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12379 | json); | |
12380 | } | |
12381 | json_object_free(json); | |
ca61fd25 DS |
12382 | } else { |
12383 | if (use_json) | |
12384 | vty_out(vty, "{}\n"); | |
12385 | else | |
12386 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12387 | } |
12388 | ||
12389 | return CMD_SUCCESS; | |
4fb25c53 DW |
12390 | } |
12391 | ||
2986cac2 | 12392 | |
12393 | ||
12394 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12395 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12396 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12397 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12398 | SHOW_STR | |
12399 | BGP_STR | |
12400 | IP_STR | |
12401 | IPV6_STR | |
12402 | NEIGHBOR_STR | |
12403 | "Neighbor to display information about\n" | |
12404 | "Neighbor to display information about\n" | |
12405 | "Neighbor on BGP configured interface\n" | |
12406 | GR_SHOW | |
12407 | JSON_STR) | |
12408 | { | |
12409 | char *sh_arg = NULL; | |
12410 | enum show_type sh_type; | |
12411 | int idx = 0; | |
12412 | afi_t afi = AFI_MAX; | |
12413 | ||
12414 | bool uj = use_json(argc, argv); | |
12415 | ||
12416 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
12417 | afi = AFI_MAX; | |
12418 | ||
12419 | idx++; | |
12420 | ||
12421 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12422 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12423 | || argv_find(argv, argc, "WORD", &idx)) { | |
12424 | sh_type = show_peer; | |
12425 | sh_arg = argv[idx]->arg; | |
12426 | } else | |
12427 | sh_type = show_all; | |
12428 | ||
12429 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12430 | return CMD_SUCCESS; | |
12431 | ||
12432 | ||
12433 | return bgp_show_neighbor_graceful_restart_afi_all(vty, | |
12434 | sh_type, sh_arg, | |
12435 | afi, uj); | |
12436 | } | |
12437 | ||
716b2d8a | 12438 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12439 | DEFUN (show_ip_bgp_neighbors, |
12440 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12441 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12442 | SHOW_STR |
12443 | IP_STR | |
12444 | BGP_STR | |
f2a8972b | 12445 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12446 | "Address Family\n" |
12447 | "Address Family\n" | |
718e3744 | 12448 | "Detailed information on TCP and BGP neighbor connections\n" |
12449 | "Neighbor to display information about\n" | |
a80beece | 12450 | "Neighbor to display information about\n" |
91d37724 | 12451 | "Neighbor on BGP configured interface\n" |
9973d184 | 12452 | JSON_STR) |
718e3744 | 12453 | { |
d62a17ae | 12454 | char *vrf = NULL; |
12455 | char *sh_arg = NULL; | |
12456 | enum show_type sh_type; | |
d1927ebe | 12457 | afi_t afi = AFI_MAX; |
718e3744 | 12458 | |
9f049418 | 12459 | bool uj = use_json(argc, argv); |
718e3744 | 12460 | |
d62a17ae | 12461 | int idx = 0; |
718e3744 | 12462 | |
9a8bdf1c PG |
12463 | /* [<vrf> VIEWVRFNAME] */ |
12464 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12465 | vrf = argv[idx + 1]->arg; | |
12466 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12467 | vrf = NULL; | |
12468 | } else if (argv_find(argv, argc, "view", &idx)) | |
12469 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12470 | vrf = argv[idx + 1]->arg; |
718e3744 | 12471 | |
d62a17ae | 12472 | idx++; |
d1927ebe AS |
12473 | |
12474 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12475 | sh_type = show_ipv4_all; | |
12476 | afi = AFI_IP; | |
12477 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12478 | sh_type = show_ipv6_all; | |
12479 | afi = AFI_IP6; | |
12480 | } else { | |
12481 | sh_type = show_all; | |
12482 | } | |
12483 | ||
d62a17ae | 12484 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12485 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12486 | || argv_find(argv, argc, "WORD", &idx)) { | |
12487 | sh_type = show_peer; | |
12488 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12489 | } |
12490 | ||
12491 | if (sh_type == show_peer && afi == AFI_IP) { | |
12492 | sh_type = show_ipv4_peer; | |
12493 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12494 | sh_type = show_ipv6_peer; | |
12495 | } | |
856ca177 | 12496 | |
d62a17ae | 12497 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12498 | } |
12499 | ||
716b2d8a | 12500 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12501 | paths' and `show ip mbgp paths'. Those functions results are the |
12502 | same.*/ | |
f412b39a | 12503 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12504 | show_ip_bgp_paths_cmd, |
46f296b4 | 12505 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12506 | SHOW_STR |
12507 | IP_STR | |
12508 | BGP_STR | |
46f296b4 | 12509 | BGP_SAFI_HELP_STR |
718e3744 | 12510 | "Path information\n") |
12511 | { | |
d62a17ae | 12512 | vty_out(vty, "Address Refcnt Path\n"); |
12513 | aspath_print_all_vty(vty); | |
12514 | return CMD_SUCCESS; | |
718e3744 | 12515 | } |
12516 | ||
718e3744 | 12517 | #include "hash.h" |
12518 | ||
e3b78da8 | 12519 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12520 | struct vty *vty) |
718e3744 | 12521 | { |
d62a17ae | 12522 | struct community *com; |
718e3744 | 12523 | |
e3b78da8 | 12524 | com = (struct community *)bucket->data; |
3f65c5b1 | 12525 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12526 | community_str(com, false)); |
718e3744 | 12527 | } |
12528 | ||
12529 | /* Show BGP's community internal data. */ | |
f412b39a | 12530 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12531 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12532 | "show [ip] bgp community-info", |
718e3744 | 12533 | SHOW_STR |
12534 | IP_STR | |
12535 | BGP_STR | |
12536 | "List all bgp community information\n") | |
12537 | { | |
d62a17ae | 12538 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12539 | |
d62a17ae | 12540 | hash_iterate(community_hash(), |
e3b78da8 | 12541 | (void (*)(struct hash_bucket *, |
d62a17ae | 12542 | void *))community_show_all_iterator, |
12543 | vty); | |
718e3744 | 12544 | |
d62a17ae | 12545 | return CMD_SUCCESS; |
718e3744 | 12546 | } |
12547 | ||
e3b78da8 | 12548 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12549 | struct vty *vty) |
57d187bc | 12550 | { |
d62a17ae | 12551 | struct lcommunity *lcom; |
57d187bc | 12552 | |
e3b78da8 | 12553 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12554 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12555 | lcommunity_str(lcom, false)); |
57d187bc JS |
12556 | } |
12557 | ||
12558 | /* Show BGP's community internal data. */ | |
12559 | DEFUN (show_ip_bgp_lcommunity_info, | |
12560 | show_ip_bgp_lcommunity_info_cmd, | |
12561 | "show ip bgp large-community-info", | |
12562 | SHOW_STR | |
12563 | IP_STR | |
12564 | BGP_STR | |
12565 | "List all bgp large-community information\n") | |
12566 | { | |
d62a17ae | 12567 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12568 | |
d62a17ae | 12569 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12570 | (void (*)(struct hash_bucket *, |
d62a17ae | 12571 | void *))lcommunity_show_all_iterator, |
12572 | vty); | |
57d187bc | 12573 | |
d62a17ae | 12574 | return CMD_SUCCESS; |
57d187bc | 12575 | } |
2986cac2 | 12576 | /* Graceful Restart */ |
12577 | ||
12578 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
12579 | struct bgp *bgp, | |
12580 | bool use_json, | |
12581 | json_object *json) | |
12582 | { | |
57d187bc JS |
12583 | |
12584 | ||
2986cac2 | 12585 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12586 | ||
12587 | int bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); | |
12588 | ||
12589 | switch (bgp_global_gr_mode) { | |
12590 | ||
12591 | case GLOBAL_HELPER: | |
12592 | vty_out(vty, | |
12593 | "Global Bgp GR Mode : Helper\n"); | |
12594 | break; | |
12595 | ||
12596 | case GLOBAL_GR: | |
12597 | vty_out(vty, | |
12598 | "Global Bgp GR Mode : Restart\n"); | |
12599 | break; | |
12600 | ||
12601 | case GLOBAL_DISABLE: | |
12602 | vty_out(vty, | |
12603 | "Global Bgp GR Mode : Disable\n"); | |
12604 | break; | |
12605 | ||
12606 | case GLOBAL_INVALID: | |
12607 | default: | |
12608 | vty_out(vty, | |
12609 | "Global Bgp GR Mode Invalid\n"); | |
12610 | break; | |
12611 | } | |
12612 | vty_out(vty, "\n"); | |
12613 | } | |
12614 | ||
12615 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, | |
12616 | enum show_type type, | |
12617 | const char *ip_str, | |
12618 | afi_t afi, | |
12619 | bool use_json) | |
12620 | { | |
12621 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12622 | afi = AFI_IP; | |
12623 | ||
12624 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12625 | ||
12626 | bgp_show_neighbor_graceful_restart_vty(vty, | |
12627 | type, ip_str, | |
12628 | afi, use_json); | |
12629 | afi++; | |
12630 | } | |
12631 | } else if (afi != AFI_MAX) { | |
12632 | bgp_show_neighbor_graceful_restart_vty(vty, | |
12633 | type, ip_str, | |
12634 | afi, use_json); | |
12635 | } else { | |
12636 | return CMD_ERR_INCOMPLETE; | |
12637 | } | |
12638 | ||
12639 | return CMD_SUCCESS; | |
12640 | } | |
12641 | /* Graceful Restart */ | |
12642 | ||
f412b39a | 12643 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12644 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12645 | "show [ip] bgp attribute-info", |
718e3744 | 12646 | SHOW_STR |
12647 | IP_STR | |
12648 | BGP_STR | |
12649 | "List all bgp attribute information\n") | |
12650 | { | |
d62a17ae | 12651 | attr_show_all(vty); |
12652 | return CMD_SUCCESS; | |
718e3744 | 12653 | } |
6b0655a2 | 12654 | |
03915806 CS |
12655 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12656 | afi_t afi, safi_t safi, | |
12657 | bool use_json, json_object *json) | |
53089bec | 12658 | { |
12659 | struct bgp *bgp; | |
12660 | struct listnode *node; | |
12661 | char *vname; | |
12662 | char buf1[INET6_ADDRSTRLEN]; | |
12663 | char *ecom_str; | |
12664 | vpn_policy_direction_t dir; | |
12665 | ||
03915806 | 12666 | if (json) { |
b46dfd20 DS |
12667 | json_object *json_import_vrfs = NULL; |
12668 | json_object *json_export_vrfs = NULL; | |
12669 | ||
b46dfd20 DS |
12670 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12671 | ||
53089bec | 12672 | if (!bgp) { |
b46dfd20 DS |
12673 | vty_out(vty, "%s\n", |
12674 | json_object_to_json_string_ext( | |
12675 | json, | |
12676 | JSON_C_TO_STRING_PRETTY)); | |
12677 | json_object_free(json); | |
12678 | ||
53089bec | 12679 | return CMD_WARNING; |
12680 | } | |
b46dfd20 | 12681 | |
94d4c685 DS |
12682 | /* Provide context for the block */ |
12683 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12684 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12685 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12686 | |
b46dfd20 DS |
12687 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12688 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12689 | json_object_string_add(json, "importFromVrfs", "none"); | |
12690 | json_object_string_add(json, "importRts", "none"); | |
12691 | } else { | |
6ce24e52 DS |
12692 | json_import_vrfs = json_object_new_array(); |
12693 | ||
b46dfd20 DS |
12694 | for (ALL_LIST_ELEMENTS_RO( |
12695 | bgp->vpn_policy[afi].import_vrf, | |
12696 | node, vname)) | |
12697 | json_object_array_add(json_import_vrfs, | |
12698 | json_object_new_string(vname)); | |
12699 | ||
b20875ea CS |
12700 | json_object_object_add(json, "importFromVrfs", |
12701 | json_import_vrfs); | |
b46dfd20 | 12702 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12703 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12704 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12705 | bgp->vpn_policy[afi].rtlist[dir], |
12706 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12707 | json_object_string_add(json, "importRts", |
12708 | ecom_str); | |
12709 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12710 | } else | |
12711 | json_object_string_add(json, "importRts", | |
12712 | "none"); | |
b46dfd20 DS |
12713 | } |
12714 | ||
12715 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12716 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12717 | json_object_string_add(json, "exportToVrfs", "none"); | |
12718 | json_object_string_add(json, "routeDistinguisher", | |
12719 | "none"); | |
12720 | json_object_string_add(json, "exportRts", "none"); | |
12721 | } else { | |
6ce24e52 DS |
12722 | json_export_vrfs = json_object_new_array(); |
12723 | ||
b46dfd20 DS |
12724 | for (ALL_LIST_ELEMENTS_RO( |
12725 | bgp->vpn_policy[afi].export_vrf, | |
12726 | node, vname)) | |
12727 | json_object_array_add(json_export_vrfs, | |
12728 | json_object_new_string(vname)); | |
12729 | json_object_object_add(json, "exportToVrfs", | |
12730 | json_export_vrfs); | |
12731 | json_object_string_add(json, "routeDistinguisher", | |
12732 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12733 | buf1, RD_ADDRSTRLEN)); | |
12734 | ||
12735 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12736 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12737 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12738 | bgp->vpn_policy[afi].rtlist[dir], |
12739 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12740 | json_object_string_add(json, "exportRts", |
12741 | ecom_str); | |
12742 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12743 | } else | |
12744 | json_object_string_add(json, "exportRts", | |
12745 | "none"); | |
b46dfd20 DS |
12746 | } |
12747 | ||
03915806 CS |
12748 | if (use_json) { |
12749 | vty_out(vty, "%s\n", | |
12750 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12751 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12752 | json_object_free(json); |
12753 | } | |
53089bec | 12754 | } else { |
b46dfd20 DS |
12755 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12756 | ||
53089bec | 12757 | if (!bgp) { |
b46dfd20 | 12758 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12759 | return CMD_WARNING; |
12760 | } | |
53089bec | 12761 | |
b46dfd20 DS |
12762 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12763 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12764 | vty_out(vty, | |
12765 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12766 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12767 | else { |
12768 | vty_out(vty, | |
12769 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 12770 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12771 | |
12772 | for (ALL_LIST_ELEMENTS_RO( | |
12773 | bgp->vpn_policy[afi].import_vrf, | |
12774 | node, vname)) | |
12775 | vty_out(vty, " %s\n", vname); | |
12776 | ||
12777 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
12778 | ecom_str = NULL; |
12779 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
12780 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12781 | bgp->vpn_policy[afi].rtlist[dir], |
12782 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 12783 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 12784 | |
b20875ea CS |
12785 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
12786 | } else | |
12787 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12788 | } |
53089bec | 12789 | |
b46dfd20 DS |
12790 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12791 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12792 | vty_out(vty, | |
12793 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 12794 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12795 | else { |
12796 | vty_out(vty, | |
04c9077f | 12797 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 12798 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12799 | |
12800 | for (ALL_LIST_ELEMENTS_RO( | |
12801 | bgp->vpn_policy[afi].export_vrf, | |
12802 | node, vname)) | |
12803 | vty_out(vty, " %s\n", vname); | |
12804 | ||
12805 | vty_out(vty, "RD: %s\n", | |
12806 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12807 | buf1, RD_ADDRSTRLEN)); | |
12808 | ||
12809 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12810 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12811 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12812 | bgp->vpn_policy[afi].rtlist[dir], |
12813 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12814 | vty_out(vty, "Export RT: %s\n", ecom_str); |
12815 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12816 | } else | |
12817 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12818 | } |
53089bec | 12819 | } |
12820 | ||
12821 | return CMD_SUCCESS; | |
12822 | } | |
12823 | ||
03915806 CS |
12824 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
12825 | safi_t safi, bool use_json) | |
12826 | { | |
12827 | struct listnode *node, *nnode; | |
12828 | struct bgp *bgp; | |
12829 | char *vrf_name = NULL; | |
12830 | json_object *json = NULL; | |
12831 | json_object *json_vrf = NULL; | |
12832 | json_object *json_vrfs = NULL; | |
12833 | ||
12834 | if (use_json) { | |
12835 | json = json_object_new_object(); | |
12836 | json_vrfs = json_object_new_object(); | |
12837 | } | |
12838 | ||
12839 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
12840 | ||
12841 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
12842 | vrf_name = bgp->name; | |
12843 | ||
12844 | if (use_json) { | |
12845 | json_vrf = json_object_new_object(); | |
12846 | } else { | |
12847 | vty_out(vty, "\nInstance %s:\n", | |
12848 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12849 | ? VRF_DEFAULT_NAME : bgp->name); | |
12850 | } | |
12851 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
12852 | if (use_json) { | |
12853 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12854 | json_object_object_add(json_vrfs, | |
12855 | VRF_DEFAULT_NAME, json_vrf); | |
12856 | else | |
12857 | json_object_object_add(json_vrfs, vrf_name, | |
12858 | json_vrf); | |
12859 | } | |
12860 | } | |
12861 | ||
12862 | if (use_json) { | |
12863 | json_object_object_add(json, "vrfs", json_vrfs); | |
12864 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
12865 | JSON_C_TO_STRING_PRETTY)); | |
12866 | json_object_free(json); | |
12867 | } | |
12868 | ||
12869 | return CMD_SUCCESS; | |
12870 | } | |
12871 | ||
53089bec | 12872 | /* "show [ip] bgp route-leak" command. */ |
12873 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
12874 | show_ip_bgp_route_leak_cmd, |
12875 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
12876 | SHOW_STR |
12877 | IP_STR | |
12878 | BGP_STR | |
12879 | BGP_INSTANCE_HELP_STR | |
12880 | BGP_AFI_HELP_STR | |
12881 | BGP_SAFI_HELP_STR | |
12882 | "Route leaking information\n" | |
12883 | JSON_STR) | |
53089bec | 12884 | { |
12885 | char *vrf = NULL; | |
12886 | afi_t afi = AFI_MAX; | |
12887 | safi_t safi = SAFI_MAX; | |
12888 | ||
9f049418 | 12889 | bool uj = use_json(argc, argv); |
53089bec | 12890 | int idx = 0; |
03915806 | 12891 | json_object *json = NULL; |
53089bec | 12892 | |
12893 | /* show [ip] bgp */ | |
12894 | if (argv_find(argv, argc, "ip", &idx)) { | |
12895 | afi = AFI_IP; | |
12896 | safi = SAFI_UNICAST; | |
12897 | } | |
12898 | /* [vrf VIEWVRFNAME] */ | |
12899 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
12900 | vty_out(vty, |
12901 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 12902 | return CMD_WARNING; |
12903 | } | |
12904 | ||
9a8bdf1c PG |
12905 | if (argv_find(argv, argc, "vrf", &idx)) { |
12906 | vrf = argv[idx + 1]->arg; | |
12907 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12908 | vrf = NULL; | |
12909 | } | |
53089bec | 12910 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
12911 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
12912 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
12913 | } | |
12914 | ||
12915 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
12916 | vty_out(vty, |
12917 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 12918 | return CMD_WARNING; |
12919 | } | |
12920 | ||
03915806 CS |
12921 | if (vrf && strmatch(vrf, "all")) |
12922 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
12923 | ||
12924 | if (uj) | |
12925 | json = json_object_new_object(); | |
12926 | ||
12927 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 12928 | } |
12929 | ||
d62a17ae | 12930 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
12931 | safi_t safi) | |
f186de26 | 12932 | { |
d62a17ae | 12933 | struct listnode *node, *nnode; |
12934 | struct bgp *bgp; | |
f186de26 | 12935 | |
d62a17ae | 12936 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
12937 | vty_out(vty, "\nInstance %s:\n", | |
12938 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12939 | ? VRF_DEFAULT_NAME |
d62a17ae | 12940 | : bgp->name); |
12941 | update_group_show(bgp, afi, safi, vty, 0); | |
12942 | } | |
f186de26 | 12943 | } |
12944 | ||
d62a17ae | 12945 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
12946 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 12947 | { |
d62a17ae | 12948 | struct bgp *bgp; |
4fb25c53 | 12949 | |
d62a17ae | 12950 | if (name) { |
12951 | if (strmatch(name, "all")) { | |
12952 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
12953 | return CMD_SUCCESS; | |
12954 | } else { | |
12955 | bgp = bgp_lookup_by_name(name); | |
12956 | } | |
12957 | } else { | |
12958 | bgp = bgp_get_default(); | |
12959 | } | |
4fb25c53 | 12960 | |
d62a17ae | 12961 | if (bgp) |
12962 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
12963 | return CMD_SUCCESS; | |
4fb25c53 DW |
12964 | } |
12965 | ||
8fe8a7f6 DS |
12966 | DEFUN (show_ip_bgp_updgrps, |
12967 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 12968 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 12969 | SHOW_STR |
12970 | IP_STR | |
12971 | BGP_STR | |
12972 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 12973 | BGP_AFI_HELP_STR |
9bedbb1e | 12974 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
12975 | "Detailed info about dynamic update groups\n" |
12976 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 12977 | { |
d62a17ae | 12978 | char *vrf = NULL; |
12979 | afi_t afi = AFI_IP6; | |
12980 | safi_t safi = SAFI_UNICAST; | |
12981 | uint64_t subgrp_id = 0; | |
12982 | ||
12983 | int idx = 0; | |
12984 | ||
12985 | /* show [ip] bgp */ | |
12986 | if (argv_find(argv, argc, "ip", &idx)) | |
12987 | afi = AFI_IP; | |
9a8bdf1c PG |
12988 | /* [<vrf> VIEWVRFNAME] */ |
12989 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12990 | vrf = argv[idx + 1]->arg; | |
12991 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12992 | vrf = NULL; | |
12993 | } else if (argv_find(argv, argc, "view", &idx)) | |
12994 | /* [<view> VIEWVRFNAME] */ | |
12995 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 12996 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
12997 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
12998 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
12999 | } | |
5bf15956 | 13000 | |
d62a17ae | 13001 | /* get subgroup id, if provided */ |
13002 | idx = argc - 1; | |
13003 | if (argv[idx]->type == VARIABLE_TKN) | |
13004 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13005 | |
d62a17ae | 13006 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13007 | } |
13008 | ||
f186de26 | 13009 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13010 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13011 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13012 | SHOW_STR |
716b2d8a | 13013 | IP_STR |
f186de26 | 13014 | BGP_STR |
13015 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13016 | "Detailed info about dynamic update groups\n") |
f186de26 | 13017 | { |
d62a17ae | 13018 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13019 | return CMD_SUCCESS; | |
f186de26 | 13020 | } |
13021 | ||
43d3f4fc DS |
13022 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13023 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13024 | "show [ip] bgp l2vpn evpn update-groups", | |
13025 | SHOW_STR | |
13026 | IP_STR | |
13027 | BGP_STR | |
13028 | "l2vpn address family\n" | |
13029 | "evpn sub-address family\n" | |
13030 | "Detailed info about dynamic update groups\n") | |
13031 | { | |
13032 | char *vrf = NULL; | |
13033 | uint64_t subgrp_id = 0; | |
13034 | ||
13035 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13036 | return CMD_SUCCESS; | |
13037 | } | |
13038 | ||
5bf15956 DW |
13039 | DEFUN (show_bgp_updgrps_stats, |
13040 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13041 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13042 | SHOW_STR |
716b2d8a | 13043 | IP_STR |
3f9c7369 | 13044 | BGP_STR |
0c7b1b01 | 13045 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13046 | "Statistics\n") |
13047 | { | |
d62a17ae | 13048 | struct bgp *bgp; |
3f9c7369 | 13049 | |
d62a17ae | 13050 | bgp = bgp_get_default(); |
13051 | if (bgp) | |
13052 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13053 | |
d62a17ae | 13054 | return CMD_SUCCESS; |
3f9c7369 DS |
13055 | } |
13056 | ||
8386ac43 | 13057 | DEFUN (show_bgp_instance_updgrps_stats, |
13058 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13059 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13060 | SHOW_STR |
716b2d8a | 13061 | IP_STR |
8386ac43 | 13062 | BGP_STR |
13063 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13064 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13065 | "Statistics\n") |
13066 | { | |
d62a17ae | 13067 | int idx_word = 3; |
13068 | struct bgp *bgp; | |
8386ac43 | 13069 | |
d62a17ae | 13070 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13071 | if (bgp) | |
13072 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13073 | |
d62a17ae | 13074 | return CMD_SUCCESS; |
8386ac43 | 13075 | } |
13076 | ||
d62a17ae | 13077 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13078 | afi_t afi, safi_t safi, | |
13079 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13080 | { |
d62a17ae | 13081 | struct bgp *bgp; |
8386ac43 | 13082 | |
d62a17ae | 13083 | if (name) |
13084 | bgp = bgp_lookup_by_name(name); | |
13085 | else | |
13086 | bgp = bgp_get_default(); | |
8386ac43 | 13087 | |
d62a17ae | 13088 | if (bgp) { |
13089 | if (!strcmp(what, "advertise-queue")) | |
13090 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13091 | subgrp_id); | |
13092 | else if (!strcmp(what, "advertised-routes")) | |
13093 | update_group_show_advertised(bgp, afi, safi, vty, | |
13094 | subgrp_id); | |
13095 | else if (!strcmp(what, "packet-queue")) | |
13096 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13097 | subgrp_id); | |
13098 | } | |
3f9c7369 DS |
13099 | } |
13100 | ||
dc64bdec QY |
13101 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13102 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13103 | "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", | |
13104 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13105 | BGP_SAFI_HELP_STR | |
13106 | "Detailed info about dynamic update groups\n" | |
13107 | "Specific subgroup to display info for\n" | |
13108 | "Advertisement queue\n" | |
13109 | "Announced routes\n" | |
13110 | "Packet queue\n") | |
3f9c7369 | 13111 | { |
dc64bdec QY |
13112 | uint64_t subgrp_id = 0; |
13113 | afi_t afiz; | |
13114 | safi_t safiz; | |
13115 | if (sgid) | |
13116 | subgrp_id = strtoull(sgid, NULL, 10); | |
13117 | ||
13118 | if (!ip && !afi) | |
13119 | afiz = AFI_IP6; | |
13120 | if (!ip && afi) | |
13121 | afiz = bgp_vty_afi_from_str(afi); | |
13122 | if (ip && !afi) | |
13123 | afiz = AFI_IP; | |
13124 | if (ip && afi) { | |
13125 | afiz = bgp_vty_afi_from_str(afi); | |
13126 | if (afiz != AFI_IP) | |
13127 | vty_out(vty, | |
13128 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13129 | return CMD_WARNING; | |
13130 | } | |
d62a17ae | 13131 | |
dc64bdec | 13132 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13133 | |
dc64bdec | 13134 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13135 | return CMD_SUCCESS; |
13136 | } | |
13137 | ||
d62a17ae | 13138 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13139 | { | |
13140 | struct listnode *node, *nnode; | |
13141 | struct prefix *range; | |
13142 | struct peer *conf; | |
13143 | struct peer *peer; | |
13144 | char buf[PREFIX2STR_BUFFER]; | |
13145 | afi_t afi; | |
13146 | safi_t safi; | |
13147 | const char *peer_status; | |
13148 | const char *af_str; | |
13149 | int lr_count; | |
13150 | int dynamic; | |
13151 | int af_cfgd; | |
13152 | ||
13153 | conf = group->conf; | |
13154 | ||
13155 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13156 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13157 | group->name, conf->as); | |
d62a17ae | 13158 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13159 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13160 | group->name, group->bgp->as); | |
d62a17ae | 13161 | } else { |
13162 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13163 | } | |
f14e6fdb | 13164 | |
d62a17ae | 13165 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13166 | vty_out(vty, " Peer-group type is internal\n"); | |
13167 | else | |
13168 | vty_out(vty, " Peer-group type is external\n"); | |
13169 | ||
13170 | /* Display AFs configured. */ | |
13171 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13172 | FOREACH_AFI_SAFI (afi, safi) { |
13173 | if (conf->afc[afi][safi]) { | |
13174 | af_cfgd = 1; | |
5cb5f4d0 | 13175 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13176 | } |
05c7a1cc | 13177 | } |
d62a17ae | 13178 | if (!af_cfgd) |
13179 | vty_out(vty, " none\n"); | |
13180 | else | |
13181 | vty_out(vty, "\n"); | |
13182 | ||
13183 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13184 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13185 | if (afi == AFI_IP) | |
13186 | af_str = "IPv4"; | |
13187 | else if (afi == AFI_IP6) | |
13188 | af_str = "IPv6"; | |
13189 | else | |
13190 | af_str = "???"; | |
13191 | lr_count = listcount(group->listen_range[afi]); | |
13192 | if (lr_count) { | |
13193 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13194 | af_str); | |
13195 | ||
13196 | ||
13197 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13198 | nnode, range)) { | |
13199 | prefix2str(range, buf, sizeof(buf)); | |
13200 | vty_out(vty, " %s\n", buf); | |
13201 | } | |
13202 | } | |
13203 | } | |
f14e6fdb | 13204 | |
d62a17ae | 13205 | /* Display group members and their status */ |
13206 | if (listcount(group->peer)) { | |
13207 | vty_out(vty, " Peer-group members:\n"); | |
13208 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13209 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13210 | peer_status = "Idle (Admin)"; | |
13211 | else if (CHECK_FLAG(peer->sflags, | |
13212 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13213 | peer_status = "Idle (PfxCt)"; | |
13214 | else | |
13215 | peer_status = lookup_msg(bgp_status_msg, | |
13216 | peer->status, NULL); | |
13217 | ||
13218 | dynamic = peer_dynamic_neighbor(peer); | |
13219 | vty_out(vty, " %s %s %s \n", peer->host, | |
13220 | dynamic ? "(dynamic)" : "", peer_status); | |
13221 | } | |
13222 | } | |
f14e6fdb | 13223 | |
d62a17ae | 13224 | return CMD_SUCCESS; |
13225 | } | |
13226 | ||
ff9959b0 QY |
13227 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13228 | const char *group_name) | |
d62a17ae | 13229 | { |
ff9959b0 | 13230 | struct bgp *bgp; |
d62a17ae | 13231 | struct listnode *node, *nnode; |
13232 | struct peer_group *group; | |
ff9959b0 QY |
13233 | bool found = false; |
13234 | ||
13235 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13236 | ||
13237 | if (!bgp) { | |
9f049418 | 13238 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13239 | return CMD_WARNING; |
13240 | } | |
d62a17ae | 13241 | |
13242 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13243 | if (group_name) { |
13244 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13245 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13246 | found = true; |
13247 | break; | |
d62a17ae | 13248 | } |
ff9959b0 QY |
13249 | } else { |
13250 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13251 | } |
f14e6fdb | 13252 | } |
f14e6fdb | 13253 | |
ff9959b0 | 13254 | if (group_name && !found) |
d62a17ae | 13255 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13256 | |
d62a17ae | 13257 | return CMD_SUCCESS; |
f14e6fdb DS |
13258 | } |
13259 | ||
f14e6fdb DS |
13260 | DEFUN (show_ip_bgp_peer_groups, |
13261 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13262 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13263 | SHOW_STR |
13264 | IP_STR | |
13265 | BGP_STR | |
8386ac43 | 13266 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13267 | "Detailed information on BGP peer groups\n" |
13268 | "Peer group name\n") | |
f14e6fdb | 13269 | { |
d62a17ae | 13270 | char *vrf, *pg; |
d62a17ae | 13271 | int idx = 0; |
f14e6fdb | 13272 | |
a4d82a8a PZ |
13273 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13274 | : NULL; | |
d62a17ae | 13275 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13276 | |
ff9959b0 | 13277 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13278 | } |
3f9c7369 | 13279 | |
d6e3c605 | 13280 | |
718e3744 | 13281 | /* Redistribute VTY commands. */ |
13282 | ||
718e3744 | 13283 | DEFUN (bgp_redistribute_ipv4, |
13284 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13285 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13286 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13287 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13288 | { |
d62a17ae | 13289 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13290 | int idx_protocol = 1; | |
13291 | int type; | |
718e3744 | 13292 | |
d62a17ae | 13293 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13294 | if (type < 0) { | |
13295 | vty_out(vty, "%% Invalid route type\n"); | |
13296 | return CMD_WARNING_CONFIG_FAILED; | |
13297 | } | |
7f323236 | 13298 | |
d62a17ae | 13299 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13300 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13301 | } |
13302 | ||
d62a17ae | 13303 | ALIAS_HIDDEN( |
13304 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13305 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13306 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13307 | |
718e3744 | 13308 | DEFUN (bgp_redistribute_ipv4_rmap, |
13309 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13310 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13311 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13312 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13313 | "Route map reference\n" |
13314 | "Pointer to route-map entries\n") | |
13315 | { | |
d62a17ae | 13316 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13317 | int idx_protocol = 1; | |
13318 | int idx_word = 3; | |
13319 | int type; | |
13320 | struct bgp_redist *red; | |
e923dd62 | 13321 | bool changed; |
1de27621 DA |
13322 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13323 | vty, argv[idx_word]->arg); | |
718e3744 | 13324 | |
d62a17ae | 13325 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13326 | if (type < 0) { | |
13327 | vty_out(vty, "%% Invalid route type\n"); | |
13328 | return CMD_WARNING_CONFIG_FAILED; | |
13329 | } | |
718e3744 | 13330 | |
d62a17ae | 13331 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13332 | changed = |
13333 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13334 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13335 | } |
13336 | ||
d62a17ae | 13337 | ALIAS_HIDDEN( |
13338 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13339 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13340 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13341 | "Route map reference\n" | |
13342 | "Pointer to route-map entries\n") | |
596c17ba | 13343 | |
718e3744 | 13344 | DEFUN (bgp_redistribute_ipv4_metric, |
13345 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13346 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13347 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13348 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13349 | "Metric for redistributed routes\n" |
13350 | "Default metric\n") | |
13351 | { | |
d62a17ae | 13352 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13353 | int idx_protocol = 1; | |
13354 | int idx_number = 3; | |
13355 | int type; | |
d7c0a89a | 13356 | uint32_t metric; |
d62a17ae | 13357 | struct bgp_redist *red; |
e923dd62 | 13358 | bool changed; |
d62a17ae | 13359 | |
13360 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13361 | if (type < 0) { | |
13362 | vty_out(vty, "%% Invalid route type\n"); | |
13363 | return CMD_WARNING_CONFIG_FAILED; | |
13364 | } | |
13365 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13366 | ||
13367 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13368 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13369 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13370 | } |
13371 | ||
13372 | ALIAS_HIDDEN( | |
13373 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13374 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13375 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13376 | "Metric for redistributed routes\n" | |
13377 | "Default metric\n") | |
596c17ba | 13378 | |
718e3744 | 13379 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13380 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13381 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13382 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13383 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13384 | "Route map reference\n" |
13385 | "Pointer to route-map entries\n" | |
13386 | "Metric for redistributed routes\n" | |
13387 | "Default metric\n") | |
13388 | { | |
d62a17ae | 13389 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13390 | int idx_protocol = 1; | |
13391 | int idx_word = 3; | |
13392 | int idx_number = 5; | |
13393 | int type; | |
d7c0a89a | 13394 | uint32_t metric; |
d62a17ae | 13395 | struct bgp_redist *red; |
e923dd62 | 13396 | bool changed; |
1de27621 DA |
13397 | struct route_map *route_map = |
13398 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13399 | |
13400 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13401 | if (type < 0) { | |
13402 | vty_out(vty, "%% Invalid route type\n"); | |
13403 | return CMD_WARNING_CONFIG_FAILED; | |
13404 | } | |
13405 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13406 | ||
13407 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13408 | changed = |
13409 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13410 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13411 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13412 | } |
13413 | ||
13414 | ALIAS_HIDDEN( | |
13415 | bgp_redistribute_ipv4_rmap_metric, | |
13416 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13417 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13418 | " route-map WORD metric (0-4294967295)", | |
13419 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13420 | "Route map reference\n" | |
13421 | "Pointer to route-map entries\n" | |
13422 | "Metric for redistributed routes\n" | |
13423 | "Default metric\n") | |
596c17ba | 13424 | |
718e3744 | 13425 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13426 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13427 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13428 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13429 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13430 | "Metric for redistributed routes\n" |
13431 | "Default metric\n" | |
13432 | "Route map reference\n" | |
13433 | "Pointer to route-map entries\n") | |
13434 | { | |
d62a17ae | 13435 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13436 | int idx_protocol = 1; | |
13437 | int idx_number = 3; | |
13438 | int idx_word = 5; | |
13439 | int type; | |
d7c0a89a | 13440 | uint32_t metric; |
d62a17ae | 13441 | struct bgp_redist *red; |
e923dd62 | 13442 | bool changed; |
1de27621 DA |
13443 | struct route_map *route_map = |
13444 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13445 | |
13446 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13447 | if (type < 0) { | |
13448 | vty_out(vty, "%% Invalid route type\n"); | |
13449 | return CMD_WARNING_CONFIG_FAILED; | |
13450 | } | |
13451 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13452 | ||
13453 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13454 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13455 | changed |= |
13456 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13457 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13458 | } |
13459 | ||
13460 | ALIAS_HIDDEN( | |
13461 | bgp_redistribute_ipv4_metric_rmap, | |
13462 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13463 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13464 | " metric (0-4294967295) route-map WORD", | |
13465 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13466 | "Metric for redistributed routes\n" | |
13467 | "Default metric\n" | |
13468 | "Route map reference\n" | |
13469 | "Pointer to route-map entries\n") | |
596c17ba | 13470 | |
7c8ff89e DS |
13471 | DEFUN (bgp_redistribute_ipv4_ospf, |
13472 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13473 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13474 | "Redistribute information from another routing protocol\n" |
13475 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13476 | "Non-main Kernel Routing Table\n" |
13477 | "Instance ID/Table ID\n") | |
7c8ff89e | 13478 | { |
d62a17ae | 13479 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13480 | int idx_ospf_table = 1; | |
13481 | int idx_number = 2; | |
d7c0a89a QY |
13482 | unsigned short instance; |
13483 | unsigned short protocol; | |
7c8ff89e | 13484 | |
d62a17ae | 13485 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13486 | |
d62a17ae | 13487 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13488 | protocol = ZEBRA_ROUTE_OSPF; | |
13489 | else | |
13490 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13491 | |
d62a17ae | 13492 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13493 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13494 | } |
13495 | ||
d62a17ae | 13496 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13497 | "redistribute <ospf|table> (1-65535)", | |
13498 | "Redistribute information from another routing protocol\n" | |
13499 | "Open Shortest Path First (OSPFv2)\n" | |
13500 | "Non-main Kernel Routing Table\n" | |
13501 | "Instance ID/Table ID\n") | |
596c17ba | 13502 | |
7c8ff89e DS |
13503 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13504 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13505 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13506 | "Redistribute information from another routing protocol\n" |
13507 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13508 | "Non-main Kernel Routing Table\n" |
13509 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13510 | "Route map reference\n" |
13511 | "Pointer to route-map entries\n") | |
13512 | { | |
d62a17ae | 13513 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13514 | int idx_ospf_table = 1; | |
13515 | int idx_number = 2; | |
13516 | int idx_word = 4; | |
13517 | struct bgp_redist *red; | |
d7c0a89a | 13518 | unsigned short instance; |
d62a17ae | 13519 | int protocol; |
e923dd62 | 13520 | bool changed; |
1de27621 DA |
13521 | struct route_map *route_map = |
13522 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13523 | |
13524 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13525 | protocol = ZEBRA_ROUTE_OSPF; | |
13526 | else | |
13527 | protocol = ZEBRA_ROUTE_TABLE; | |
13528 | ||
13529 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13530 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13531 | changed = |
13532 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13533 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13534 | } |
13535 | ||
13536 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13537 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13538 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13539 | "Redistribute information from another routing protocol\n" | |
13540 | "Open Shortest Path First (OSPFv2)\n" | |
13541 | "Non-main Kernel Routing Table\n" | |
13542 | "Instance ID/Table ID\n" | |
13543 | "Route map reference\n" | |
13544 | "Pointer to route-map entries\n") | |
596c17ba | 13545 | |
7c8ff89e DS |
13546 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13547 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13548 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13549 | "Redistribute information from another routing protocol\n" |
13550 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13551 | "Non-main Kernel Routing Table\n" |
13552 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13553 | "Metric for redistributed routes\n" |
13554 | "Default metric\n") | |
13555 | { | |
d62a17ae | 13556 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13557 | int idx_ospf_table = 1; | |
13558 | int idx_number = 2; | |
13559 | int idx_number_2 = 4; | |
d7c0a89a | 13560 | uint32_t metric; |
d62a17ae | 13561 | struct bgp_redist *red; |
d7c0a89a | 13562 | unsigned short instance; |
d62a17ae | 13563 | int protocol; |
e923dd62 | 13564 | bool changed; |
d62a17ae | 13565 | |
13566 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13567 | protocol = ZEBRA_ROUTE_OSPF; | |
13568 | else | |
13569 | protocol = ZEBRA_ROUTE_TABLE; | |
13570 | ||
13571 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13572 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13573 | ||
13574 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13575 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13576 | metric); | |
13577 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13578 | } |
13579 | ||
13580 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13581 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13582 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13583 | "Redistribute information from another routing protocol\n" | |
13584 | "Open Shortest Path First (OSPFv2)\n" | |
13585 | "Non-main Kernel Routing Table\n" | |
13586 | "Instance ID/Table ID\n" | |
13587 | "Metric for redistributed routes\n" | |
13588 | "Default metric\n") | |
596c17ba | 13589 | |
7c8ff89e DS |
13590 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13591 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13592 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13593 | "Redistribute information from another routing protocol\n" |
13594 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13595 | "Non-main Kernel Routing Table\n" |
13596 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13597 | "Route map reference\n" |
13598 | "Pointer to route-map entries\n" | |
13599 | "Metric for redistributed routes\n" | |
13600 | "Default metric\n") | |
13601 | { | |
d62a17ae | 13602 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13603 | int idx_ospf_table = 1; | |
13604 | int idx_number = 2; | |
13605 | int idx_word = 4; | |
13606 | int idx_number_2 = 6; | |
d7c0a89a | 13607 | uint32_t metric; |
d62a17ae | 13608 | struct bgp_redist *red; |
d7c0a89a | 13609 | unsigned short instance; |
d62a17ae | 13610 | int protocol; |
e923dd62 | 13611 | bool changed; |
1de27621 DA |
13612 | struct route_map *route_map = |
13613 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13614 | |
13615 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13616 | protocol = ZEBRA_ROUTE_OSPF; | |
13617 | else | |
13618 | protocol = ZEBRA_ROUTE_TABLE; | |
13619 | ||
13620 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13621 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13622 | ||
13623 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13624 | changed = |
13625 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13626 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13627 | metric); | |
13628 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13629 | } |
13630 | ||
13631 | ALIAS_HIDDEN( | |
13632 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13633 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13634 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13635 | "Redistribute information from another routing protocol\n" | |
13636 | "Open Shortest Path First (OSPFv2)\n" | |
13637 | "Non-main Kernel Routing Table\n" | |
13638 | "Instance ID/Table ID\n" | |
13639 | "Route map reference\n" | |
13640 | "Pointer to route-map entries\n" | |
13641 | "Metric for redistributed routes\n" | |
13642 | "Default metric\n") | |
596c17ba | 13643 | |
7c8ff89e DS |
13644 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13645 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13646 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13647 | "Redistribute information from another routing protocol\n" |
13648 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13649 | "Non-main Kernel Routing Table\n" |
13650 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13651 | "Metric for redistributed routes\n" |
13652 | "Default metric\n" | |
13653 | "Route map reference\n" | |
13654 | "Pointer to route-map entries\n") | |
13655 | { | |
d62a17ae | 13656 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13657 | int idx_ospf_table = 1; | |
13658 | int idx_number = 2; | |
13659 | int idx_number_2 = 4; | |
13660 | int idx_word = 6; | |
d7c0a89a | 13661 | uint32_t metric; |
d62a17ae | 13662 | struct bgp_redist *red; |
d7c0a89a | 13663 | unsigned short instance; |
d62a17ae | 13664 | int protocol; |
e923dd62 | 13665 | bool changed; |
1de27621 DA |
13666 | struct route_map *route_map = |
13667 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13668 | |
13669 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13670 | protocol = ZEBRA_ROUTE_OSPF; | |
13671 | else | |
13672 | protocol = ZEBRA_ROUTE_TABLE; | |
13673 | ||
13674 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13675 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13676 | ||
13677 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13678 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13679 | metric); | |
1de27621 DA |
13680 | changed |= |
13681 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13682 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13683 | } |
13684 | ||
13685 | ALIAS_HIDDEN( | |
13686 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13687 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13688 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13689 | "Redistribute information from another routing protocol\n" | |
13690 | "Open Shortest Path First (OSPFv2)\n" | |
13691 | "Non-main Kernel Routing Table\n" | |
13692 | "Instance ID/Table ID\n" | |
13693 | "Metric for redistributed routes\n" | |
13694 | "Default metric\n" | |
13695 | "Route map reference\n" | |
13696 | "Pointer to route-map entries\n") | |
596c17ba | 13697 | |
7c8ff89e DS |
13698 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13699 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13700 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13701 | NO_STR |
13702 | "Redistribute information from another routing protocol\n" | |
13703 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13704 | "Non-main Kernel Routing Table\n" |
31500417 DW |
13705 | "Instance ID/Table ID\n" |
13706 | "Metric for redistributed routes\n" | |
13707 | "Default metric\n" | |
13708 | "Route map reference\n" | |
13709 | "Pointer to route-map entries\n") | |
7c8ff89e | 13710 | { |
d62a17ae | 13711 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13712 | int idx_ospf_table = 2; | |
13713 | int idx_number = 3; | |
d7c0a89a | 13714 | unsigned short instance; |
d62a17ae | 13715 | int protocol; |
13716 | ||
13717 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13718 | protocol = ZEBRA_ROUTE_OSPF; | |
13719 | else | |
13720 | protocol = ZEBRA_ROUTE_TABLE; | |
13721 | ||
13722 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13723 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13724 | } | |
13725 | ||
13726 | ALIAS_HIDDEN( | |
13727 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13728 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13729 | NO_STR |
13730 | "Redistribute information from another routing protocol\n" | |
13731 | "Open Shortest Path First (OSPFv2)\n" | |
13732 | "Non-main Kernel Routing Table\n" | |
13733 | "Instance ID/Table ID\n" | |
13734 | "Metric for redistributed routes\n" | |
13735 | "Default metric\n" | |
13736 | "Route map reference\n" | |
13737 | "Pointer to route-map entries\n") | |
596c17ba | 13738 | |
718e3744 | 13739 | DEFUN (no_bgp_redistribute_ipv4, |
13740 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13741 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13742 | NO_STR |
13743 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13744 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13745 | "Metric for redistributed routes\n" |
13746 | "Default metric\n" | |
13747 | "Route map reference\n" | |
13748 | "Pointer to route-map entries\n") | |
718e3744 | 13749 | { |
d62a17ae | 13750 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13751 | int idx_protocol = 2; | |
13752 | int type; | |
13753 | ||
13754 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13755 | if (type < 0) { | |
13756 | vty_out(vty, "%% Invalid route type\n"); | |
13757 | return CMD_WARNING_CONFIG_FAILED; | |
13758 | } | |
13759 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13760 | } | |
13761 | ||
13762 | ALIAS_HIDDEN( | |
13763 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13764 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13765 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13766 | NO_STR |
13767 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13768 | "Metric for redistributed routes\n" | |
13769 | "Default metric\n" | |
13770 | "Route map reference\n" | |
13771 | "Pointer to route-map entries\n") | |
596c17ba | 13772 | |
718e3744 | 13773 | DEFUN (bgp_redistribute_ipv6, |
13774 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 13775 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 13776 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13777 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 13778 | { |
d62a17ae | 13779 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13780 | int idx_protocol = 1; | |
13781 | int type; | |
718e3744 | 13782 | |
d62a17ae | 13783 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13784 | if (type < 0) { | |
13785 | vty_out(vty, "%% Invalid route type\n"); | |
13786 | return CMD_WARNING_CONFIG_FAILED; | |
13787 | } | |
718e3744 | 13788 | |
d62a17ae | 13789 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13790 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 13791 | } |
13792 | ||
13793 | DEFUN (bgp_redistribute_ipv6_rmap, | |
13794 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 13795 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13796 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13797 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13798 | "Route map reference\n" |
13799 | "Pointer to route-map entries\n") | |
13800 | { | |
d62a17ae | 13801 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13802 | int idx_protocol = 1; | |
13803 | int idx_word = 3; | |
13804 | int type; | |
13805 | struct bgp_redist *red; | |
e923dd62 | 13806 | bool changed; |
1de27621 DA |
13807 | struct route_map *route_map = |
13808 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 13809 | |
d62a17ae | 13810 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13811 | if (type < 0) { | |
13812 | vty_out(vty, "%% Invalid route type\n"); | |
13813 | return CMD_WARNING_CONFIG_FAILED; | |
13814 | } | |
718e3744 | 13815 | |
d62a17ae | 13816 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13817 | changed = |
13818 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13819 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13820 | } |
13821 | ||
13822 | DEFUN (bgp_redistribute_ipv6_metric, | |
13823 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 13824 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13825 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13826 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13827 | "Metric for redistributed routes\n" |
13828 | "Default metric\n") | |
13829 | { | |
d62a17ae | 13830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13831 | int idx_protocol = 1; | |
13832 | int idx_number = 3; | |
13833 | int type; | |
d7c0a89a | 13834 | uint32_t metric; |
d62a17ae | 13835 | struct bgp_redist *red; |
e923dd62 | 13836 | bool changed; |
d62a17ae | 13837 | |
13838 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13839 | if (type < 0) { | |
13840 | vty_out(vty, "%% Invalid route type\n"); | |
13841 | return CMD_WARNING_CONFIG_FAILED; | |
13842 | } | |
13843 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13844 | |
d62a17ae | 13845 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13846 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
13847 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13848 | } |
13849 | ||
13850 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
13851 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 13852 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13853 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13854 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13855 | "Route map reference\n" |
13856 | "Pointer to route-map entries\n" | |
13857 | "Metric for redistributed routes\n" | |
13858 | "Default metric\n") | |
13859 | { | |
d62a17ae | 13860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13861 | int idx_protocol = 1; | |
13862 | int idx_word = 3; | |
13863 | int idx_number = 5; | |
13864 | int type; | |
d7c0a89a | 13865 | uint32_t metric; |
d62a17ae | 13866 | struct bgp_redist *red; |
e923dd62 | 13867 | bool changed; |
1de27621 DA |
13868 | struct route_map *route_map = |
13869 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13870 | |
13871 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13872 | if (type < 0) { | |
13873 | vty_out(vty, "%% Invalid route type\n"); | |
13874 | return CMD_WARNING_CONFIG_FAILED; | |
13875 | } | |
13876 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13877 | |
d62a17ae | 13878 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13879 | changed = |
13880 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13881 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
13882 | metric); | |
13883 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13884 | } |
13885 | ||
13886 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
13887 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 13888 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13889 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13890 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13891 | "Metric for redistributed routes\n" |
13892 | "Default metric\n" | |
13893 | "Route map reference\n" | |
13894 | "Pointer to route-map entries\n") | |
13895 | { | |
d62a17ae | 13896 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13897 | int idx_protocol = 1; | |
13898 | int idx_number = 3; | |
13899 | int idx_word = 5; | |
13900 | int type; | |
d7c0a89a | 13901 | uint32_t metric; |
d62a17ae | 13902 | struct bgp_redist *red; |
e923dd62 | 13903 | bool changed; |
1de27621 DA |
13904 | struct route_map *route_map = |
13905 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13906 | |
13907 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13908 | if (type < 0) { | |
13909 | vty_out(vty, "%% Invalid route type\n"); | |
13910 | return CMD_WARNING_CONFIG_FAILED; | |
13911 | } | |
13912 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13913 | |
d62a17ae | 13914 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13915 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
13916 | metric); | |
1de27621 DA |
13917 | changed |= |
13918 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13919 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13920 | } |
13921 | ||
13922 | DEFUN (no_bgp_redistribute_ipv6, | |
13923 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 13924 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13925 | NO_STR |
13926 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13927 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
13928 | "Metric for redistributed routes\n" |
13929 | "Default metric\n" | |
13930 | "Route map reference\n" | |
13931 | "Pointer to route-map entries\n") | |
718e3744 | 13932 | { |
d62a17ae | 13933 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13934 | int idx_protocol = 2; | |
13935 | int type; | |
718e3744 | 13936 | |
d62a17ae | 13937 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13938 | if (type < 0) { | |
13939 | vty_out(vty, "%% Invalid route type\n"); | |
13940 | return CMD_WARNING_CONFIG_FAILED; | |
13941 | } | |
718e3744 | 13942 | |
d62a17ae | 13943 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
13944 | } | |
13945 | ||
dd65f45e DL |
13946 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
13947 | afi_t afi, safi_t safi) | |
d62a17ae | 13948 | { |
13949 | int i; | |
13950 | ||
13951 | /* Unicast redistribution only. */ | |
13952 | if (safi != SAFI_UNICAST) | |
2b791107 | 13953 | return; |
d62a17ae | 13954 | |
13955 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
13956 | /* Redistribute BGP does not make sense. */ | |
13957 | if (i != ZEBRA_ROUTE_BGP) { | |
13958 | struct list *red_list; | |
13959 | struct listnode *node; | |
13960 | struct bgp_redist *red; | |
13961 | ||
13962 | red_list = bgp->redist[afi][i]; | |
13963 | if (!red_list) | |
13964 | continue; | |
13965 | ||
13966 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 13967 | /* "redistribute" configuration. */ |
13968 | vty_out(vty, " redistribute %s", | |
13969 | zebra_route_string(i)); | |
13970 | if (red->instance) | |
13971 | vty_out(vty, " %d", red->instance); | |
13972 | if (red->redist_metric_flag) | |
13973 | vty_out(vty, " metric %u", | |
13974 | red->redist_metric); | |
13975 | if (red->rmap.name) | |
13976 | vty_out(vty, " route-map %s", | |
13977 | red->rmap.name); | |
13978 | vty_out(vty, "\n"); | |
13979 | } | |
13980 | } | |
13981 | } | |
718e3744 | 13982 | } |
6b0655a2 | 13983 | |
dd65f45e DL |
13984 | /* peer-group helpers for config-write */ |
13985 | ||
13986 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
13987 | { | |
13988 | if (!peer_group_active(peer)) { | |
13989 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
13990 | return !CHECK_FLAG(peer->flags, flag); | |
13991 | else | |
13992 | return !!CHECK_FLAG(peer->flags, flag); | |
13993 | } | |
13994 | ||
13995 | return !!CHECK_FLAG(peer->flags_override, flag); | |
13996 | } | |
13997 | ||
13998 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
13999 | uint32_t flag) | |
14000 | { | |
14001 | if (!peer_group_active(peer)) { | |
14002 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14003 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14004 | else | |
14005 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14006 | } | |
14007 | ||
14008 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14009 | } | |
14010 | ||
14011 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14012 | uint8_t type, int direct) | |
14013 | { | |
14014 | struct bgp_filter *filter; | |
14015 | ||
14016 | if (peer_group_active(peer)) | |
14017 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14018 | type); | |
14019 | ||
14020 | filter = &peer->filter[afi][safi]; | |
14021 | switch (type) { | |
14022 | case PEER_FT_DISTRIBUTE_LIST: | |
14023 | return !!(filter->dlist[direct].name); | |
14024 | case PEER_FT_FILTER_LIST: | |
14025 | return !!(filter->aslist[direct].name); | |
14026 | case PEER_FT_PREFIX_LIST: | |
14027 | return !!(filter->plist[direct].name); | |
14028 | case PEER_FT_ROUTE_MAP: | |
14029 | return !!(filter->map[direct].name); | |
14030 | case PEER_FT_UNSUPPRESS_MAP: | |
14031 | return !!(filter->usmap.name); | |
14032 | default: | |
14033 | return false; | |
14034 | } | |
14035 | } | |
14036 | ||
14037 | /* Return true if the addpath type is set for peer and different from | |
14038 | * peer-group. | |
14039 | */ | |
14040 | static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi) | |
14041 | { | |
14042 | enum bgp_addpath_strat type, g_type; | |
14043 | ||
14044 | type = peer->addpath_type[afi][safi]; | |
14045 | ||
14046 | if (type != BGP_ADDPATH_NONE) { | |
14047 | if (peer_group_active(peer)) { | |
14048 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14049 | ||
14050 | if (type != g_type) | |
14051 | return 1; | |
14052 | else | |
14053 | return 0; | |
14054 | } | |
14055 | ||
14056 | return 1; | |
14057 | } | |
14058 | ||
14059 | return 0; | |
14060 | } | |
14061 | ||
b9c7bc5a | 14062 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14063 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14064 | afi_t afi) |
14065 | { | |
b9c7bc5a | 14066 | int indent = 2; |
ddb5b488 | 14067 | |
8a066a70 PG |
14068 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
14069 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
14070 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
14071 | bgp->vpn_policy[afi] | |
bb4f6190 | 14072 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14073 | else |
14074 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14075 | bgp->vpn_policy[afi] | |
14076 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14077 | } | |
12a844a5 DS |
14078 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14079 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14080 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14081 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14082 | return; | |
14083 | ||
e70e9f8e PZ |
14084 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14085 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14086 | ||
14087 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14088 | ||
14089 | } else { | |
14090 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14091 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14092 | bgp->vpn_policy[afi].tovpn_label); | |
14093 | } | |
ddb5b488 PZ |
14094 | } |
14095 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14096 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14097 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14098 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14099 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14100 | sizeof(buf))); | |
14101 | } | |
14102 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14103 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14104 | ||
14105 | char buf[PREFIX_STRLEN]; | |
14106 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14107 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14108 | sizeof(buf))) { | |
14109 | ||
b9c7bc5a PZ |
14110 | vty_out(vty, "%*snexthop vpn export %s\n", |
14111 | indent, "", buf); | |
ddb5b488 PZ |
14112 | } |
14113 | } | |
14114 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14115 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14116 | && ecommunity_cmp( | |
14117 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14118 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14119 | ||
14120 | char *b = ecommunity_ecom2str( | |
14121 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14122 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14123 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14124 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14125 | } else { | |
14126 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14127 | char *b = ecommunity_ecom2str( | |
14128 | bgp->vpn_policy[afi] | |
14129 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14130 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14131 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14132 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14133 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14134 | } | |
14135 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14136 | char *b = ecommunity_ecom2str( | |
14137 | bgp->vpn_policy[afi] | |
14138 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14139 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14140 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14141 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14142 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14143 | } | |
14144 | } | |
bb4f6190 DS |
14145 | |
14146 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14147 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14148 | bgp->vpn_policy[afi] |
14149 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14150 | |
301ad80a PG |
14151 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14152 | char *b = ecommunity_ecom2str( | |
14153 | bgp->vpn_policy[afi] | |
14154 | .import_redirect_rtlist, | |
14155 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14156 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14157 | |
301ad80a PG |
14158 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14159 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14160 | } | |
ddb5b488 PZ |
14161 | } |
14162 | ||
dd65f45e DL |
14163 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14164 | afi_t afi, safi_t safi) | |
14165 | { | |
14166 | struct bgp_filter *filter; | |
14167 | char *addr; | |
14168 | ||
14169 | addr = peer->host; | |
14170 | filter = &peer->filter[afi][safi]; | |
14171 | ||
14172 | /* distribute-list. */ | |
14173 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14174 | FILTER_IN)) | |
14175 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14176 | filter->dlist[FILTER_IN].name); | |
14177 | ||
14178 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14179 | FILTER_OUT)) | |
14180 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14181 | filter->dlist[FILTER_OUT].name); | |
14182 | ||
14183 | /* prefix-list. */ | |
14184 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14185 | FILTER_IN)) | |
14186 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14187 | filter->plist[FILTER_IN].name); | |
14188 | ||
14189 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14190 | FILTER_OUT)) | |
14191 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14192 | filter->plist[FILTER_OUT].name); | |
14193 | ||
14194 | /* route-map. */ | |
14195 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14196 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14197 | filter->map[RMAP_IN].name); | |
14198 | ||
14199 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14200 | RMAP_OUT)) | |
14201 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14202 | filter->map[RMAP_OUT].name); | |
14203 | ||
14204 | /* unsuppress-map */ | |
14205 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14206 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14207 | filter->usmap.name); | |
14208 | ||
14209 | /* filter-list. */ | |
14210 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14211 | FILTER_IN)) | |
14212 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14213 | filter->aslist[FILTER_IN].name); | |
14214 | ||
14215 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14216 | FILTER_OUT)) | |
14217 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14218 | filter->aslist[FILTER_OUT].name); | |
14219 | } | |
14220 | ||
14221 | /* BGP peer configuration display function. */ | |
14222 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14223 | struct peer *peer) | |
14224 | { | |
14225 | struct peer *g_peer = NULL; | |
14226 | char buf[SU_ADDRSTRLEN]; | |
14227 | char *addr; | |
14228 | int if_pg_printed = false; | |
14229 | int if_ras_printed = false; | |
14230 | ||
14231 | /* Skip dynamic neighbors. */ | |
14232 | if (peer_dynamic_neighbor(peer)) | |
14233 | return; | |
14234 | ||
14235 | if (peer->conf_if) | |
14236 | addr = peer->conf_if; | |
14237 | else | |
14238 | addr = peer->host; | |
14239 | ||
14240 | /************************************ | |
14241 | ****** Global to the neighbor ****** | |
14242 | ************************************/ | |
14243 | if (peer->conf_if) { | |
14244 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14245 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14246 | else | |
14247 | vty_out(vty, " neighbor %s interface", addr); | |
14248 | ||
14249 | if (peer_group_active(peer)) { | |
14250 | vty_out(vty, " peer-group %s", peer->group->name); | |
14251 | if_pg_printed = true; | |
14252 | } else if (peer->as_type == AS_SPECIFIED) { | |
14253 | vty_out(vty, " remote-as %u", peer->as); | |
14254 | if_ras_printed = true; | |
14255 | } else if (peer->as_type == AS_INTERNAL) { | |
14256 | vty_out(vty, " remote-as internal"); | |
14257 | if_ras_printed = true; | |
14258 | } else if (peer->as_type == AS_EXTERNAL) { | |
14259 | vty_out(vty, " remote-as external"); | |
14260 | if_ras_printed = true; | |
14261 | } | |
14262 | ||
14263 | vty_out(vty, "\n"); | |
14264 | } | |
14265 | ||
14266 | /* remote-as and peer-group */ | |
14267 | /* peer is a member of a peer-group */ | |
14268 | if (peer_group_active(peer)) { | |
14269 | g_peer = peer->group->conf; | |
14270 | ||
14271 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14272 | if (peer->as_type == AS_SPECIFIED) { | |
14273 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14274 | addr, peer->as); | |
14275 | } else if (peer->as_type == AS_INTERNAL) { | |
14276 | vty_out(vty, | |
14277 | " neighbor %s remote-as internal\n", | |
14278 | addr); | |
14279 | } else if (peer->as_type == AS_EXTERNAL) { | |
14280 | vty_out(vty, | |
14281 | " neighbor %s remote-as external\n", | |
14282 | addr); | |
14283 | } | |
14284 | } | |
14285 | ||
14286 | /* For swpX peers we displayed the peer-group | |
14287 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14288 | if (!if_pg_printed) | |
14289 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14290 | peer->group->name); | |
14291 | } | |
14292 | ||
14293 | /* peer is NOT a member of a peer-group */ | |
14294 | else { | |
14295 | /* peer is a peer-group, declare the peer-group */ | |
14296 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14297 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14298 | } | |
14299 | ||
14300 | if (!if_ras_printed) { | |
14301 | if (peer->as_type == AS_SPECIFIED) { | |
14302 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14303 | addr, peer->as); | |
14304 | } else if (peer->as_type == AS_INTERNAL) { | |
14305 | vty_out(vty, | |
14306 | " neighbor %s remote-as internal\n", | |
14307 | addr); | |
14308 | } else if (peer->as_type == AS_EXTERNAL) { | |
14309 | vty_out(vty, | |
14310 | " neighbor %s remote-as external\n", | |
14311 | addr); | |
14312 | } | |
14313 | } | |
14314 | } | |
14315 | ||
14316 | /* local-as */ | |
14317 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14318 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14319 | peer->change_local_as); | |
14320 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14321 | vty_out(vty, " no-prepend"); | |
14322 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14323 | vty_out(vty, " replace-as"); | |
14324 | vty_out(vty, "\n"); | |
14325 | } | |
14326 | ||
14327 | /* description */ | |
14328 | if (peer->desc) { | |
14329 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14330 | } | |
14331 | ||
14332 | /* shutdown */ | |
14333 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14334 | if (peer->tx_shutdown_message) | |
14335 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14336 | peer->tx_shutdown_message); | |
14337 | else | |
14338 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14339 | } | |
14340 | ||
14341 | /* bfd */ | |
14342 | if (peer->bfd_info) { | |
14343 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14344 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14345 | } | |
14346 | } | |
14347 | ||
14348 | /* password */ | |
14349 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14350 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14351 | peer->password); | |
14352 | ||
14353 | /* neighbor solo */ | |
14354 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14355 | if (!peer_group_active(peer)) { | |
14356 | vty_out(vty, " neighbor %s solo\n", addr); | |
14357 | } | |
14358 | } | |
14359 | ||
14360 | /* BGP port */ | |
14361 | if (peer->port != BGP_PORT_DEFAULT) { | |
14362 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14363 | } | |
14364 | ||
14365 | /* Local interface name */ | |
14366 | if (peer->ifname) { | |
14367 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14368 | } | |
14369 | ||
14370 | /* passive */ | |
14371 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14372 | vty_out(vty, " neighbor %s passive\n", addr); | |
14373 | ||
14374 | /* ebgp-multihop */ | |
14375 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
14376 | && !(peer->gtsm_hops != 0 && peer->ttl == MAXTTL)) { | |
14377 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { | |
14378 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14379 | peer->ttl); | |
14380 | } | |
14381 | } | |
14382 | ||
14383 | /* ttl-security hops */ | |
14384 | if (peer->gtsm_hops != 0) { | |
14385 | if (!peer_group_active(peer) | |
14386 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14387 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14388 | addr, peer->gtsm_hops); | |
14389 | } | |
14390 | } | |
14391 | ||
14392 | /* disable-connected-check */ | |
14393 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14394 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14395 | ||
14396 | /* enforce-first-as */ | |
14397 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14398 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14399 | ||
14400 | /* update-source */ | |
14401 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14402 | if (peer->update_source) | |
14403 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14404 | sockunion2str(peer->update_source, buf, | |
14405 | SU_ADDRSTRLEN)); | |
14406 | else if (peer->update_if) | |
14407 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14408 | peer->update_if); | |
14409 | } | |
14410 | ||
14411 | /* advertisement-interval */ | |
14412 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14413 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14414 | peer->routeadv); | |
14415 | ||
14416 | /* timers */ | |
14417 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14418 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14419 | peer->keepalive, peer->holdtime); | |
14420 | ||
14421 | /* timers connect */ | |
14422 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14423 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14424 | peer->connect); | |
5d5393b9 DL |
14425 | /* need special-case handling for changed default values due to |
14426 | * config profile / version (because there is no "timers bgp connect" | |
14427 | * command, we need to save this per-peer :/) | |
14428 | */ | |
14429 | else if (!peer_group_active(peer) && !peer->connect && | |
14430 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14431 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14432 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14433 | |
14434 | /* capability dynamic */ | |
14435 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14436 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14437 | ||
14438 | /* capability extended-nexthop */ | |
14439 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14440 | if (!peer->conf_if) { | |
14441 | if (CHECK_FLAG(peer->flags_invert, | |
14442 | PEER_FLAG_CAPABILITY_ENHE)) | |
14443 | vty_out(vty, | |
14444 | " no neighbor %s capability extended-nexthop\n", | |
14445 | addr); | |
14446 | else | |
14447 | vty_out(vty, | |
14448 | " neighbor %s capability extended-nexthop\n", | |
14449 | addr); | |
14450 | } | |
14451 | } | |
14452 | ||
14453 | /* dont-capability-negotiation */ | |
14454 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14455 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14456 | ||
14457 | /* override-capability */ | |
14458 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14459 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14460 | ||
14461 | /* strict-capability-match */ | |
14462 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14463 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14464 | ||
14465 | /* Sender side AS path loop detection. */ | |
14466 | if (peer->as_path_loop_detection) | |
14467 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14468 | addr); | |
cfd47646 | 14469 | |
14470 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14471 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { | |
14472 | ||
14473 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14474 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { | |
14475 | vty_out(vty, | |
14476 | " neighbor %s graceful-restart-helper\n", addr); | |
14477 | } else if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14478 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
14479 | vty_out(vty, | |
14480 | " neighbor %s graceful-restart\n", addr); | |
14481 | } else if ((!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14482 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14483 | && !(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14484 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14485 | vty_out(vty, | |
14486 | " neighbor %s graceful-restart-disable\n", | |
14487 | addr); | |
14488 | } | |
14489 | } | |
dd65f45e DL |
14490 | } |
14491 | ||
14492 | /* BGP peer configuration display function. */ | |
14493 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14494 | struct peer *peer, afi_t afi, safi_t safi) | |
14495 | { | |
14496 | struct peer *g_peer = NULL; | |
14497 | char *addr; | |
14498 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14499 | ||
14500 | /* Skip dynamic neighbors. */ | |
14501 | if (peer_dynamic_neighbor(peer)) | |
14502 | return; | |
14503 | ||
14504 | if (peer->conf_if) | |
14505 | addr = peer->conf_if; | |
14506 | else | |
14507 | addr = peer->host; | |
14508 | ||
14509 | /************************************ | |
14510 | ****** Per AF to the neighbor ****** | |
14511 | ************************************/ | |
14512 | if (peer_group_active(peer)) { | |
14513 | g_peer = peer->group->conf; | |
14514 | ||
14515 | /* If the peer-group is active but peer is not, print a 'no | |
14516 | * activate' */ | |
14517 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14518 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14519 | } | |
14520 | ||
14521 | /* If the peer-group is not active but peer is, print an | |
14522 | 'activate' */ | |
14523 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14524 | vty_out(vty, " neighbor %s activate\n", addr); | |
14525 | } | |
14526 | } else { | |
14527 | if (peer->afc[afi][safi]) { | |
14528 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
14529 | if (bgp_flag_check(bgp, | |
14530 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
14531 | vty_out(vty, " neighbor %s activate\n", | |
14532 | addr); | |
14533 | } | |
14534 | } else | |
14535 | vty_out(vty, " neighbor %s activate\n", addr); | |
14536 | } else { | |
14537 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
14538 | if (!bgp_flag_check(bgp, | |
14539 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
14540 | vty_out(vty, | |
14541 | " no neighbor %s activate\n", | |
14542 | addr); | |
14543 | } | |
14544 | } | |
14545 | } | |
14546 | } | |
14547 | ||
14548 | /* addpath TX knobs */ | |
14549 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14550 | switch (peer->addpath_type[afi][safi]) { | |
14551 | case BGP_ADDPATH_ALL: | |
14552 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14553 | addr); | |
14554 | break; | |
14555 | case BGP_ADDPATH_BEST_PER_AS: | |
14556 | vty_out(vty, | |
14557 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14558 | addr); | |
14559 | break; | |
14560 | case BGP_ADDPATH_MAX: | |
14561 | case BGP_ADDPATH_NONE: | |
14562 | break; | |
14563 | } | |
14564 | } | |
14565 | ||
14566 | /* ORF capability. */ | |
14567 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14568 | || peergroup_af_flag_check(peer, afi, safi, | |
14569 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14570 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14571 | ||
14572 | if (peergroup_af_flag_check(peer, afi, safi, | |
14573 | PEER_FLAG_ORF_PREFIX_SM) | |
14574 | && peergroup_af_flag_check(peer, afi, safi, | |
14575 | PEER_FLAG_ORF_PREFIX_RM)) | |
14576 | vty_out(vty, " both"); | |
14577 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14578 | PEER_FLAG_ORF_PREFIX_SM)) | |
14579 | vty_out(vty, " send"); | |
14580 | else | |
14581 | vty_out(vty, " receive"); | |
14582 | vty_out(vty, "\n"); | |
14583 | } | |
14584 | ||
14585 | /* BGP flag dampening. */ | |
14586 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14587 | BGP_CONFIG_DAMPENING)) | |
14588 | bgp_config_write_damp(vty, afi, safi); | |
14589 | ||
14590 | /* Route reflector client. */ | |
14591 | if (peergroup_af_flag_check(peer, afi, safi, | |
14592 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14593 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14594 | } | |
14595 | ||
14596 | /* next-hop-self force */ | |
14597 | if (peergroup_af_flag_check(peer, afi, safi, | |
14598 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14599 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14600 | } | |
14601 | ||
14602 | /* next-hop-self */ | |
14603 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14604 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14605 | } | |
14606 | ||
14607 | /* remove-private-AS */ | |
14608 | if (peergroup_af_flag_check(peer, afi, safi, | |
14609 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14610 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14611 | addr); | |
14612 | } | |
14613 | ||
14614 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14615 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14616 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14617 | addr); | |
14618 | } | |
14619 | ||
14620 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14621 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14622 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14623 | } | |
14624 | ||
14625 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14626 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14627 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14628 | } | |
14629 | ||
14630 | /* as-override */ | |
14631 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14632 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14633 | } | |
14634 | ||
14635 | /* send-community print. */ | |
14636 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14637 | PEER_FLAG_SEND_COMMUNITY); | |
14638 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14639 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14640 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14641 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14642 | ||
14643 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14644 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14645 | } else { | |
14646 | if (flag_scomm) | |
14647 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14648 | if (flag_secomm) | |
14649 | vty_out(vty, | |
14650 | " no neighbor %s send-community extended\n", | |
14651 | addr); | |
14652 | ||
14653 | if (flag_slcomm) | |
14654 | vty_out(vty, " no neighbor %s send-community large\n", | |
14655 | addr); | |
14656 | } | |
14657 | ||
14658 | /* Default information */ | |
14659 | if (peergroup_af_flag_check(peer, afi, safi, | |
14660 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14661 | vty_out(vty, " neighbor %s default-originate", addr); | |
14662 | ||
14663 | if (peer->default_rmap[afi][safi].name) | |
14664 | vty_out(vty, " route-map %s", | |
14665 | peer->default_rmap[afi][safi].name); | |
14666 | ||
14667 | vty_out(vty, "\n"); | |
14668 | } | |
14669 | ||
14670 | /* Soft reconfiguration inbound. */ | |
14671 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14672 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14673 | addr); | |
14674 | } | |
14675 | ||
14676 | /* maximum-prefix. */ | |
14677 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14678 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14679 | peer->pmax[afi][safi]); | |
14680 | ||
14681 | if (peer->pmax_threshold[afi][safi] | |
14682 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14683 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14684 | if (peer_af_flag_check(peer, afi, safi, | |
14685 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14686 | vty_out(vty, " warning-only"); | |
14687 | if (peer->pmax_restart[afi][safi]) | |
14688 | vty_out(vty, " restart %u", | |
14689 | peer->pmax_restart[afi][safi]); | |
14690 | ||
14691 | vty_out(vty, "\n"); | |
14692 | } | |
14693 | ||
fde246e8 DA |
14694 | /* maximum-prefix-out */ |
14695 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14696 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14697 | addr, peer->pmax_out[afi][safi]); | |
14698 | ||
dd65f45e DL |
14699 | /* Route server client. */ |
14700 | if (peergroup_af_flag_check(peer, afi, safi, | |
14701 | PEER_FLAG_RSERVER_CLIENT)) { | |
14702 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14703 | } | |
14704 | ||
14705 | /* Nexthop-local unchanged. */ | |
14706 | if (peergroup_af_flag_check(peer, afi, safi, | |
14707 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14708 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14709 | } | |
14710 | ||
14711 | /* allowas-in <1-10> */ | |
14712 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14713 | if (peer_af_flag_check(peer, afi, safi, | |
14714 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14715 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14716 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14717 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14718 | } else { | |
14719 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14720 | peer->allowas_in[afi][safi]); | |
14721 | } | |
14722 | } | |
14723 | ||
14724 | /* weight */ | |
14725 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14726 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14727 | peer->weight[afi][safi]); | |
14728 | ||
14729 | /* Filter. */ | |
14730 | bgp_config_write_filter(vty, peer, afi, safi); | |
14731 | ||
14732 | /* atribute-unchanged. */ | |
14733 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14734 | || (safi != SAFI_EVPN | |
14735 | && peer_af_flag_check(peer, afi, safi, | |
14736 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14737 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14738 | ||
14739 | if (!peer_group_active(peer) | |
14740 | || peergroup_af_flag_check(peer, afi, safi, | |
14741 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14742 | || peergroup_af_flag_check(peer, afi, safi, | |
14743 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14744 | || peergroup_af_flag_check(peer, afi, safi, | |
14745 | PEER_FLAG_MED_UNCHANGED)) { | |
14746 | ||
14747 | vty_out(vty, | |
14748 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14749 | addr, | |
14750 | peer_af_flag_check(peer, afi, safi, | |
14751 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14752 | ? " as-path" | |
14753 | : "", | |
14754 | peer_af_flag_check(peer, afi, safi, | |
14755 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14756 | ? " next-hop" | |
14757 | : "", | |
14758 | peer_af_flag_check(peer, afi, safi, | |
14759 | PEER_FLAG_MED_UNCHANGED) | |
14760 | ? " med" | |
14761 | : ""); | |
14762 | } | |
14763 | } | |
14764 | } | |
14765 | ||
14766 | /* Address family based peer configuration display. */ | |
14767 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14768 | safi_t safi) | |
14769 | { | |
14770 | struct peer *peer; | |
14771 | struct peer_group *group; | |
14772 | struct listnode *node, *nnode; | |
14773 | ||
14774 | ||
14775 | vty_frame(vty, " !\n address-family "); | |
14776 | if (afi == AFI_IP) { | |
14777 | if (safi == SAFI_UNICAST) | |
14778 | vty_frame(vty, "ipv4 unicast"); | |
14779 | else if (safi == SAFI_LABELED_UNICAST) | |
14780 | vty_frame(vty, "ipv4 labeled-unicast"); | |
14781 | else if (safi == SAFI_MULTICAST) | |
14782 | vty_frame(vty, "ipv4 multicast"); | |
14783 | else if (safi == SAFI_MPLS_VPN) | |
14784 | vty_frame(vty, "ipv4 vpn"); | |
14785 | else if (safi == SAFI_ENCAP) | |
14786 | vty_frame(vty, "ipv4 encap"); | |
14787 | else if (safi == SAFI_FLOWSPEC) | |
14788 | vty_frame(vty, "ipv4 flowspec"); | |
14789 | } else if (afi == AFI_IP6) { | |
14790 | if (safi == SAFI_UNICAST) | |
14791 | vty_frame(vty, "ipv6 unicast"); | |
14792 | else if (safi == SAFI_LABELED_UNICAST) | |
14793 | vty_frame(vty, "ipv6 labeled-unicast"); | |
14794 | else if (safi == SAFI_MULTICAST) | |
14795 | vty_frame(vty, "ipv6 multicast"); | |
14796 | else if (safi == SAFI_MPLS_VPN) | |
14797 | vty_frame(vty, "ipv6 vpn"); | |
14798 | else if (safi == SAFI_ENCAP) | |
14799 | vty_frame(vty, "ipv6 encap"); | |
14800 | else if (safi == SAFI_FLOWSPEC) | |
14801 | vty_frame(vty, "ipv6 flowspec"); | |
14802 | } else if (afi == AFI_L2VPN) { | |
14803 | if (safi == SAFI_EVPN) | |
14804 | vty_frame(vty, "l2vpn evpn"); | |
14805 | } | |
14806 | vty_frame(vty, "\n"); | |
14807 | ||
14808 | bgp_config_write_distance(vty, bgp, afi, safi); | |
14809 | ||
14810 | bgp_config_write_network(vty, bgp, afi, safi); | |
14811 | ||
14812 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
14813 | ||
14814 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
14815 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
14816 | ||
14817 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14818 | /* Skip dynamic neighbors. */ | |
14819 | if (peer_dynamic_neighbor(peer)) | |
14820 | continue; | |
14821 | ||
14822 | /* Do not display doppelganger peers */ | |
14823 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14824 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
14825 | } | |
14826 | ||
14827 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
14828 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
14829 | ||
14830 | if (safi == SAFI_EVPN) | |
14831 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
14832 | ||
14833 | if (safi == SAFI_FLOWSPEC) | |
14834 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
14835 | ||
14836 | if (safi == SAFI_UNICAST) { | |
14837 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
14838 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14839 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
14840 | ||
14841 | vty_out(vty, " export vpn\n"); | |
14842 | } | |
14843 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14844 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
14845 | ||
14846 | vty_out(vty, " import vpn\n"); | |
14847 | } | |
14848 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14849 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14850 | char *name; | |
14851 | ||
14852 | for (ALL_LIST_ELEMENTS_RO( | |
14853 | bgp->vpn_policy[afi].import_vrf, node, | |
14854 | name)) | |
14855 | vty_out(vty, " import vrf %s\n", name); | |
14856 | } | |
14857 | } | |
14858 | ||
14859 | vty_endframe(vty, " exit-address-family\n"); | |
14860 | } | |
14861 | ||
14862 | int bgp_config_write(struct vty *vty) | |
14863 | { | |
14864 | struct bgp *bgp; | |
14865 | struct peer_group *group; | |
14866 | struct peer *peer; | |
14867 | struct listnode *node, *nnode; | |
14868 | struct listnode *mnode, *mnnode; | |
14869 | ||
14870 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
14871 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
14872 | bm->rmap_update_timer); | |
14873 | ||
14874 | /* BGP configuration. */ | |
14875 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
14876 | ||
14877 | /* skip all auto created vrf as they dont have user config */ | |
14878 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
14879 | continue; | |
14880 | ||
14881 | /* Router bgp ASN */ | |
14882 | vty_out(vty, "router bgp %u", bgp->as); | |
14883 | ||
14884 | if (bgp->name) | |
14885 | vty_out(vty, " %s %s", | |
14886 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
14887 | ? "view" : "vrf", bgp->name); | |
14888 | vty_out(vty, "\n"); | |
14889 | ||
14890 | /* BGP fast-external-failover. */ | |
14891 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
14892 | vty_out(vty, " no bgp fast-external-failover\n"); | |
14893 | ||
14894 | /* BGP router ID. */ | |
14895 | if (bgp->router_id_static.s_addr != 0) | |
14896 | vty_out(vty, " bgp router-id %s\n", | |
14897 | inet_ntoa(bgp->router_id_static)); | |
14898 | ||
14899 | /* BGP log-neighbor-changes. */ | |
14900 | if (!!bgp_flag_check(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
5d5393b9 | 14901 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e DL |
14902 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
14903 | bgp_flag_check(bgp, | |
14904 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
14905 | ? "" | |
14906 | : "no "); | |
14907 | ||
14908 | /* BGP configuration. */ | |
14909 | if (bgp_flag_check(bgp, BGP_FLAG_ALWAYS_COMPARE_MED)) | |
14910 | vty_out(vty, " bgp always-compare-med\n"); | |
14911 | ||
14912 | /* RFC8212 default eBGP policy. */ | |
14913 | if (bgp->ebgp_requires_policy | |
14914 | == DEFAULT_EBGP_POLICY_ENABLED) | |
14915 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
14916 | ||
14917 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
14918 | if (bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) | |
14919 | vty_out(vty, " bgp reject-as-sets\n"); | |
14920 | ||
14921 | /* BGP default ipv4-unicast. */ | |
14922 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4)) | |
14923 | vty_out(vty, " no bgp default ipv4-unicast\n"); | |
14924 | ||
14925 | /* BGP default local-preference. */ | |
14926 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
14927 | vty_out(vty, " bgp default local-preference %u\n", | |
14928 | bgp->default_local_pref); | |
14929 | ||
14930 | /* BGP default show-hostname */ | |
14931 | if (!!bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
5d5393b9 | 14932 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e DL |
14933 | vty_out(vty, " %sbgp default show-hostname\n", |
14934 | bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME) | |
14935 | ? "" | |
14936 | : "no "); | |
14937 | ||
14938 | /* BGP default subgroup-pkt-queue-max. */ | |
14939 | if (bgp->default_subgroup_pkt_queue_max | |
14940 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
14941 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
14942 | bgp->default_subgroup_pkt_queue_max); | |
14943 | ||
14944 | /* BGP client-to-client reflection. */ | |
14945 | if (bgp_flag_check(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT)) | |
14946 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
14947 | ||
14948 | /* BGP cluster ID. */ | |
14949 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
14950 | vty_out(vty, " bgp cluster-id %s\n", | |
14951 | inet_ntoa(bgp->cluster_id)); | |
14952 | ||
14953 | /* Disable ebgp connected nexthop check */ | |
14954 | if (bgp_flag_check(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) | |
14955 | vty_out(vty, | |
14956 | " bgp disable-ebgp-connected-route-check\n"); | |
14957 | ||
14958 | /* Confederation identifier*/ | |
14959 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
14960 | vty_out(vty, " bgp confederation identifier %u\n", | |
14961 | bgp->confed_id); | |
14962 | ||
14963 | /* Confederation peer */ | |
14964 | if (bgp->confed_peers_cnt > 0) { | |
14965 | int i; | |
14966 | ||
14967 | vty_out(vty, " bgp confederation peers"); | |
14968 | ||
14969 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
14970 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
14971 | ||
14972 | vty_out(vty, "\n"); | |
14973 | } | |
14974 | ||
14975 | /* BGP deterministic-med. */ | |
14976 | if (!!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
5d5393b9 | 14977 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e DL |
14978 | vty_out(vty, " %sbgp deterministic-med\n", |
14979 | bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED) | |
14980 | ? "" | |
14981 | : "no "); | |
14982 | ||
14983 | /* BGP update-delay. */ | |
14984 | bgp_config_write_update_delay(vty, bgp); | |
14985 | ||
14986 | if (bgp->v_maxmed_onstartup | |
14987 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
14988 | vty_out(vty, " bgp max-med on-startup %u", | |
14989 | bgp->v_maxmed_onstartup); | |
14990 | if (bgp->maxmed_onstartup_value | |
14991 | != BGP_MAXMED_VALUE_DEFAULT) | |
14992 | vty_out(vty, " %u", | |
14993 | bgp->maxmed_onstartup_value); | |
14994 | vty_out(vty, "\n"); | |
14995 | } | |
14996 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
14997 | vty_out(vty, " bgp max-med administrative"); | |
14998 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
14999 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15000 | vty_out(vty, "\n"); | |
15001 | } | |
15002 | ||
15003 | /* write quanta */ | |
15004 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15005 | /* read quanta */ | |
15006 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15007 | ||
15008 | /* coalesce time */ | |
15009 | bgp_config_write_coalesce_time(vty, bgp); | |
15010 | ||
15011 | /* BGP graceful-restart. */ | |
15012 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15013 | vty_out(vty, | |
15014 | " bgp graceful-restart stalepath-time %u\n", | |
15015 | bgp->stalepath_time); | |
cfd47646 | 15016 | |
dd65f45e DL |
15017 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15018 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15019 | bgp->restart_time); | |
cfd47646 | 15020 | |
15021 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15022 | vty_out(vty, | |
15023 | " bgp graceful-restart select-defer-time %u\n", | |
15024 | bgp->select_defer_time); | |
15025 | ||
15026 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15027 | vty_out(vty, " bgp graceful-restart\n"); |
15028 | ||
cfd47646 | 15029 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15030 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15031 | ||
dd65f45e DL |
15032 | /* BGP graceful-shutdown */ |
15033 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
15034 | vty_out(vty, " bgp graceful-shutdown\n"); | |
15035 | ||
15036 | /* BGP graceful-restart Preserve State F bit. */ | |
15037 | if (bgp_flag_check(bgp, BGP_FLAG_GR_PRESERVE_FWD)) | |
15038 | vty_out(vty, | |
15039 | " bgp graceful-restart preserve-fw-state\n"); | |
15040 | ||
15041 | /* BGP bestpath method. */ | |
15042 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
15043 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
15044 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
15045 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
15046 | ||
15047 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
15048 | if (bgp_flag_check(bgp, | |
15049 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
15050 | vty_out(vty, | |
15051 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15052 | } else { | |
15053 | vty_out(vty, | |
15054 | " bgp bestpath as-path multipath-relax\n"); | |
15055 | } | |
15056 | } | |
15057 | ||
15058 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { | |
15059 | vty_out(vty, | |
15060 | " bgp route-reflector allow-outbound-policy\n"); | |
15061 | } | |
15062 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
15063 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
15064 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
15065 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
15066 | vty_out(vty, " bgp bestpath med"); | |
15067 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
15068 | vty_out(vty, " confed"); | |
15069 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
15070 | vty_out(vty, " missing-as-worst"); | |
15071 | vty_out(vty, "\n"); | |
15072 | } | |
15073 | ||
15074 | /* BGP network import check. */ | |
15075 | if (!!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
5d5393b9 | 15076 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e DL |
15077 | vty_out(vty, " %sbgp network import-check\n", |
15078 | bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK) | |
15079 | ? "" | |
15080 | : "no "); | |
15081 | ||
15082 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15083 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15084 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15085 | vty_out(vty, " timers bgp %u %u\n", |
15086 | bgp->default_keepalive, bgp->default_holdtime); | |
15087 | ||
15088 | /* peer-group */ | |
15089 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15090 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15091 | } | |
15092 | ||
15093 | /* Normal neighbor configuration. */ | |
15094 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15095 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15096 | bgp_config_write_peer_global(vty, bgp, peer); | |
15097 | } | |
15098 | ||
15099 | /* listen range and limit for dynamic BGP neighbors */ | |
15100 | bgp_config_write_listen(vty, bgp); | |
15101 | ||
15102 | /* | |
15103 | * BGP default autoshutdown neighbors | |
15104 | * | |
15105 | * This must be placed after any peer and peer-group | |
15106 | * configuration, to avoid setting all peers to shutdown after | |
15107 | * a daemon restart, which is undesired behavior. (see #2286) | |
15108 | */ | |
15109 | if (bgp->autoshutdown) | |
15110 | vty_out(vty, " bgp default shutdown\n"); | |
15111 | ||
15112 | /* IPv4 unicast configuration. */ | |
15113 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15114 | ||
15115 | /* IPv4 multicast configuration. */ | |
15116 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15117 | ||
15118 | /* IPv4 labeled-unicast configuration. */ | |
15119 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15120 | ||
15121 | /* IPv4 VPN configuration. */ | |
15122 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15123 | ||
15124 | /* ENCAPv4 configuration. */ | |
15125 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15126 | ||
15127 | /* FLOWSPEC v4 configuration. */ | |
15128 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15129 | ||
15130 | /* IPv6 unicast configuration. */ | |
15131 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15132 | ||
15133 | /* IPv6 multicast configuration. */ | |
15134 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15135 | ||
15136 | /* IPv6 labeled-unicast configuration. */ | |
15137 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15138 | SAFI_LABELED_UNICAST); | |
15139 | ||
15140 | /* IPv6 VPN configuration. */ | |
15141 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15142 | ||
15143 | /* ENCAPv6 configuration. */ | |
15144 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15145 | ||
15146 | /* FLOWSPEC v6 configuration. */ | |
15147 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15148 | ||
15149 | /* EVPN configuration. */ | |
15150 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15151 | ||
15152 | hook_call(bgp_inst_config_write, bgp, vty); | |
15153 | ||
15154 | #if ENABLE_BGP_VNC | |
15155 | bgp_rfapi_cfg_write(vty, bgp); | |
15156 | #endif | |
15157 | ||
15158 | vty_out(vty, "!\n"); | |
15159 | } | |
15160 | return 0; | |
15161 | } | |
15162 | ||
ddb5b488 | 15163 | |
718e3744 | 15164 | /* BGP node structure. */ |
d62a17ae | 15165 | static struct cmd_node bgp_node = { |
9d303b37 | 15166 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 15167 | }; |
15168 | ||
d62a17ae | 15169 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 15170 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15171 | }; |
15172 | ||
d62a17ae | 15173 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 15174 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15175 | }; |
15176 | ||
d62a17ae | 15177 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 15178 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15179 | }; |
15180 | ||
d62a17ae | 15181 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 15182 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15183 | }; |
15184 | ||
d62a17ae | 15185 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 15186 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 15187 | }; |
15188 | ||
d62a17ae | 15189 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 15190 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15191 | }; |
15192 | ||
d62a17ae | 15193 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
15194 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 15195 | |
d62a17ae | 15196 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
15197 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 15198 | |
d62a17ae | 15199 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
15200 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 15201 | |
d62a17ae | 15202 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
15203 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 15204 | |
7c40bf39 | 15205 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
15206 | "%s(config-router-af)# ", 1}; | |
15207 | ||
15208 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
15209 | "%s(config-router-af-vpnv6)# ", 1}; | |
15210 | ||
d62a17ae | 15211 | static void community_list_vty(void); |
1f8ae70b | 15212 | |
d62a17ae | 15213 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15214 | { |
d62a17ae | 15215 | struct bgp *bgp; |
15216 | struct peer *peer; | |
d62a17ae | 15217 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15218 | |
d62a17ae | 15219 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15220 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15221 | /* only provide suggestions on the appropriate input | |
15222 | * token type, | |
15223 | * they'll otherwise show up multiple times */ | |
15224 | enum cmd_token_type match_type; | |
15225 | char *name = peer->host; | |
d48ed3e0 | 15226 | |
d62a17ae | 15227 | if (peer->conf_if) { |
15228 | match_type = VARIABLE_TKN; | |
15229 | name = peer->conf_if; | |
15230 | } else if (strchr(peer->host, ':')) | |
15231 | match_type = IPV6_TKN; | |
15232 | else | |
15233 | match_type = IPV4_TKN; | |
d48ed3e0 | 15234 | |
d62a17ae | 15235 | if (token->type != match_type) |
15236 | continue; | |
d48ed3e0 | 15237 | |
d62a17ae | 15238 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15239 | } | |
d62a17ae | 15240 | } |
b8a815e5 DL |
15241 | } |
15242 | ||
15243 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15244 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15245 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15246 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15247 | {.completions = NULL}}; |
15248 | ||
47a306a0 DS |
15249 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15250 | { | |
15251 | struct bgp *bgp; | |
15252 | struct peer_group *group; | |
15253 | struct listnode *lnbgp, *lnpeer; | |
15254 | ||
15255 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15256 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15257 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15258 | group->name)); | |
15259 | } | |
15260 | } | |
15261 | ||
15262 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15263 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15264 | {.completions = NULL} }; | |
15265 | ||
d62a17ae | 15266 | void bgp_vty_init(void) |
15267 | { | |
15268 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15269 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15270 | |
15271 | /* Install bgp top node. */ | |
15272 | install_node(&bgp_node, bgp_config_write); | |
15273 | install_node(&bgp_ipv4_unicast_node, NULL); | |
15274 | install_node(&bgp_ipv4_multicast_node, NULL); | |
15275 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
15276 | install_node(&bgp_ipv6_unicast_node, NULL); | |
15277 | install_node(&bgp_ipv6_multicast_node, NULL); | |
15278 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
15279 | install_node(&bgp_vpnv4_node, NULL); | |
15280 | install_node(&bgp_vpnv6_node, NULL); | |
15281 | install_node(&bgp_evpn_node, NULL); | |
15282 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 15283 | install_node(&bgp_flowspecv4_node, NULL); |
15284 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 15285 | |
15286 | /* Install default VTY commands to new nodes. */ | |
15287 | install_default(BGP_NODE); | |
15288 | install_default(BGP_IPV4_NODE); | |
15289 | install_default(BGP_IPV4M_NODE); | |
15290 | install_default(BGP_IPV4L_NODE); | |
15291 | install_default(BGP_IPV6_NODE); | |
15292 | install_default(BGP_IPV6M_NODE); | |
15293 | install_default(BGP_IPV6L_NODE); | |
15294 | install_default(BGP_VPNV4_NODE); | |
15295 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15296 | install_default(BGP_FLOWSPECV4_NODE); |
15297 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15298 | install_default(BGP_EVPN_NODE); |
15299 | install_default(BGP_EVPN_VNI_NODE); | |
15300 | ||
8029b216 AK |
15301 | /* "bgp local-mac" hidden commands. */ |
15302 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15303 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15304 | ||
d62a17ae | 15305 | /* bgp route-map delay-timer commands. */ |
15306 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15307 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15308 | ||
15309 | /* Dummy commands (Currently not supported) */ | |
15310 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15311 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15312 | ||
15313 | /* "router bgp" commands. */ | |
15314 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15315 | ||
15316 | /* "no router bgp" commands. */ | |
15317 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15318 | ||
15319 | /* "bgp router-id" commands. */ | |
15320 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15321 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15322 | ||
15323 | /* "bgp cluster-id" commands. */ | |
15324 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15325 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15326 | ||
15327 | /* "bgp confederation" commands. */ | |
15328 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15329 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15330 | ||
15331 | /* "bgp confederation peers" commands. */ | |
15332 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15333 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15334 | ||
15335 | /* bgp max-med command */ | |
15336 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15337 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15338 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15339 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15340 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15341 | ||
15342 | /* bgp disable-ebgp-connected-nh-check */ | |
15343 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15344 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15345 | ||
15346 | /* bgp update-delay command */ | |
15347 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15348 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15349 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15350 | ||
15351 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15352 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15353 | |
15354 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15355 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15356 | ||
15357 | /* "maximum-paths" commands. */ | |
15358 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15359 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15360 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15361 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15362 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15363 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15364 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15365 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15366 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15367 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15368 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15369 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15370 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15371 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15372 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15373 | ||
15374 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15375 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15376 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15377 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15378 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15379 | ||
15380 | /* "timers bgp" commands. */ | |
15381 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15382 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15383 | ||
15384 | /* route-map delay-timer commands - per instance for backwards compat. | |
15385 | */ | |
15386 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15387 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15388 | ||
15389 | /* "bgp client-to-client reflection" commands */ | |
15390 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15391 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15392 | ||
15393 | /* "bgp always-compare-med" commands */ | |
15394 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15395 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15396 | ||
9dac9fc8 DA |
15397 | /* bgp ebgp-requires-policy */ |
15398 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15399 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15400 | ||
fb29348a DA |
15401 | /* bgp reject-as-sets */ |
15402 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15403 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15404 | ||
d62a17ae | 15405 | /* "bgp deterministic-med" commands */ |
15406 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15407 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15408 | ||
055679e9 | 15409 | /* "bgp graceful-restart" command */ |
15410 | install_element(BGP_NODE, | |
15411 | &bgp_graceful_restart_cmd); | |
15412 | install_element(BGP_NODE, | |
15413 | &no_bgp_graceful_restart_cmd); | |
15414 | ||
15415 | /* "bgp graceful-restart-disable" command */ | |
15416 | install_element(BGP_NODE, | |
15417 | &bgp_graceful_restart_disable_cmd); | |
15418 | install_element(BGP_NODE, | |
15419 | &no_bgp_graceful_restart_disable_cmd); | |
15420 | ||
15421 | /* "neighbor a:b:c:d graceful-restart" command */ | |
15422 | install_element(BGP_NODE, | |
15423 | &bgp_neighbor_graceful_restart_set_cmd); | |
15424 | install_element(BGP_NODE, | |
15425 | &no_bgp_neighbor_graceful_restart_set_cmd); | |
15426 | ||
15427 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15428 | install_element(BGP_NODE, | |
15429 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15430 | install_element(BGP_NODE, | |
15431 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15432 | ||
15433 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15434 | install_element(BGP_NODE, | |
15435 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15436 | install_element(BGP_NODE, | |
15437 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15438 | ||
d62a17ae | 15439 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15440 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15441 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15442 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15443 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15444 | install_element(BGP_NODE, |
15445 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15446 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15447 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15448 | ||
7f323236 DW |
15449 | /* "bgp graceful-shutdown" commands */ |
15450 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15451 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15452 | ||
d62a17ae | 15453 | /* "bgp fast-external-failover" commands */ |
15454 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15455 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15456 | ||
d62a17ae | 15457 | /* "bgp bestpath compare-routerid" commands */ |
15458 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15459 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15460 | ||
15461 | /* "bgp bestpath as-path ignore" commands */ | |
15462 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15463 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15464 | ||
15465 | /* "bgp bestpath as-path confed" commands */ | |
15466 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15467 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15468 | ||
15469 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15470 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15471 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15472 | ||
15473 | /* "bgp log-neighbor-changes" commands */ | |
15474 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15475 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15476 | ||
15477 | /* "bgp bestpath med" commands */ | |
15478 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15479 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15480 | ||
15481 | /* "no bgp default ipv4-unicast" commands. */ | |
15482 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15483 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15484 | ||
15485 | /* "bgp network import-check" commands. */ | |
15486 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15487 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15488 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15489 | ||
15490 | /* "bgp default local-preference" commands. */ | |
15491 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15492 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15493 | ||
15494 | /* bgp default show-hostname */ | |
15495 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15496 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15497 | ||
15498 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15499 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15500 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15501 | ||
15502 | /* bgp ibgp-allow-policy-mods command */ | |
15503 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15504 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15505 | ||
15506 | /* "bgp listen limit" commands. */ | |
15507 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15508 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15509 | ||
15510 | /* "bgp listen range" commands. */ | |
15511 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15512 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15513 | ||
8175f54a | 15514 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15515 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15516 | ||
d62a17ae | 15517 | /* "neighbor remote-as" commands. */ |
15518 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15519 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15520 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15521 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15522 | install_element(BGP_NODE, | |
15523 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15524 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15525 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15526 | ||
15527 | /* "neighbor peer-group" commands. */ | |
15528 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15529 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15530 | install_element(BGP_NODE, | |
15531 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15532 | ||
15533 | /* "neighbor local-as" commands. */ | |
15534 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15535 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15536 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15537 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15538 | ||
15539 | /* "neighbor solo" commands. */ | |
15540 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15541 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15542 | ||
15543 | /* "neighbor password" commands. */ | |
15544 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15545 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15546 | ||
15547 | /* "neighbor activate" commands. */ | |
15548 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15549 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15550 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15551 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15552 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15553 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15554 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15555 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15556 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15557 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15558 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15559 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15560 | ||
15561 | /* "no neighbor activate" commands. */ | |
15562 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15563 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15564 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15565 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15566 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15567 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15568 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15569 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15570 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15571 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15572 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15573 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15574 | ||
15575 | /* "neighbor peer-group" set commands. */ | |
15576 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15577 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15578 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15579 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15580 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15581 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15582 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15583 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15584 | install_element(BGP_FLOWSPECV4_NODE, |
15585 | &neighbor_set_peer_group_hidden_cmd); | |
15586 | install_element(BGP_FLOWSPECV6_NODE, | |
15587 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15588 | |
15589 | /* "no neighbor peer-group unset" commands. */ | |
15590 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15591 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15592 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15593 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15594 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15595 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15596 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15597 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15598 | install_element(BGP_FLOWSPECV4_NODE, |
15599 | &no_neighbor_set_peer_group_hidden_cmd); | |
15600 | install_element(BGP_FLOWSPECV6_NODE, | |
15601 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15602 | |
15603 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15604 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15605 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15606 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15607 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15608 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15609 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15610 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15611 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15612 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15613 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15614 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15615 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15616 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15617 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15618 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15619 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15620 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15621 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15622 | install_element(BGP_FLOWSPECV4_NODE, |
15623 | &neighbor_soft_reconfiguration_cmd); | |
15624 | install_element(BGP_FLOWSPECV4_NODE, | |
15625 | &no_neighbor_soft_reconfiguration_cmd); | |
15626 | install_element(BGP_FLOWSPECV6_NODE, | |
15627 | &neighbor_soft_reconfiguration_cmd); | |
15628 | install_element(BGP_FLOWSPECV6_NODE, | |
15629 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15630 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15631 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15632 | |
15633 | /* "neighbor attribute-unchanged" commands. */ | |
15634 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15635 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15636 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15637 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15638 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15639 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15640 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15641 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15642 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15643 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15644 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15645 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15646 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15647 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15648 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15649 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15650 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15651 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15652 | ||
15653 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15654 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15655 | ||
15656 | /* "nexthop-local unchanged" commands */ | |
15657 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15658 | install_element(BGP_IPV6_NODE, | |
15659 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15660 | ||
15661 | /* "neighbor next-hop-self" commands. */ | |
15662 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15663 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15664 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15665 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15666 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15667 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15668 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15669 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15670 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15671 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15672 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15673 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15674 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15675 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15676 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15677 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15678 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15679 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15680 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15681 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15682 | |
15683 | /* "neighbor next-hop-self force" commands. */ | |
15684 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15685 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15686 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15687 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15688 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15689 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15690 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15691 | install_element(BGP_IPV4_NODE, | |
15692 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15693 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15694 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15695 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15696 | install_element(BGP_IPV4M_NODE, | |
15697 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15698 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
15699 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15700 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15701 | install_element(BGP_IPV4L_NODE, | |
15702 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15703 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
15704 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15705 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15706 | install_element(BGP_IPV6_NODE, | |
15707 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15708 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
15709 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15710 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15711 | install_element(BGP_IPV6M_NODE, | |
15712 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15713 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
15714 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15715 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15716 | install_element(BGP_IPV6L_NODE, | |
15717 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15718 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
15719 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15720 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15721 | install_element(BGP_VPNV4_NODE, | |
15722 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15723 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
15724 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15725 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15726 | install_element(BGP_VPNV6_NODE, | |
15727 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15728 | |
15729 | /* "neighbor as-override" commands. */ | |
15730 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
15731 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
15732 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
15733 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
15734 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
15735 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
15736 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
15737 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
15738 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
15739 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
15740 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
15741 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
15742 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
15743 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
15744 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
15745 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
15746 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
15747 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
15748 | ||
15749 | /* "neighbor remove-private-AS" commands. */ | |
15750 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
15751 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
15752 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
15753 | install_element(BGP_NODE, | |
15754 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
15755 | install_element(BGP_NODE, | |
15756 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
15757 | install_element(BGP_NODE, | |
15758 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
15759 | install_element(BGP_NODE, | |
15760 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15761 | install_element( | |
15762 | BGP_NODE, | |
15763 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15764 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
15765 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15766 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15767 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15768 | install_element(BGP_IPV4_NODE, | |
15769 | &neighbor_remove_private_as_replace_as_cmd); | |
15770 | install_element(BGP_IPV4_NODE, | |
15771 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15772 | install_element(BGP_IPV4_NODE, | |
15773 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15774 | install_element(BGP_IPV4_NODE, | |
15775 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15776 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
15777 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
15778 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
15779 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15780 | install_element(BGP_IPV4M_NODE, | |
15781 | &neighbor_remove_private_as_replace_as_cmd); | |
15782 | install_element(BGP_IPV4M_NODE, | |
15783 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15784 | install_element(BGP_IPV4M_NODE, | |
15785 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15786 | install_element(BGP_IPV4M_NODE, | |
15787 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15788 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
15789 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
15790 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
15791 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15792 | install_element(BGP_IPV4L_NODE, | |
15793 | &neighbor_remove_private_as_replace_as_cmd); | |
15794 | install_element(BGP_IPV4L_NODE, | |
15795 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15796 | install_element(BGP_IPV4L_NODE, | |
15797 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15798 | install_element(BGP_IPV4L_NODE, | |
15799 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15800 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
15801 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15802 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15803 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15804 | install_element(BGP_IPV6_NODE, | |
15805 | &neighbor_remove_private_as_replace_as_cmd); | |
15806 | install_element(BGP_IPV6_NODE, | |
15807 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15808 | install_element(BGP_IPV6_NODE, | |
15809 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15810 | install_element(BGP_IPV6_NODE, | |
15811 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15812 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
15813 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
15814 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
15815 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15816 | install_element(BGP_IPV6M_NODE, | |
15817 | &neighbor_remove_private_as_replace_as_cmd); | |
15818 | install_element(BGP_IPV6M_NODE, | |
15819 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15820 | install_element(BGP_IPV6M_NODE, | |
15821 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15822 | install_element(BGP_IPV6M_NODE, | |
15823 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15824 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
15825 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
15826 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
15827 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15828 | install_element(BGP_IPV6L_NODE, | |
15829 | &neighbor_remove_private_as_replace_as_cmd); | |
15830 | install_element(BGP_IPV6L_NODE, | |
15831 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15832 | install_element(BGP_IPV6L_NODE, | |
15833 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15834 | install_element(BGP_IPV6L_NODE, | |
15835 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15836 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
15837 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15838 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15839 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15840 | install_element(BGP_VPNV4_NODE, | |
15841 | &neighbor_remove_private_as_replace_as_cmd); | |
15842 | install_element(BGP_VPNV4_NODE, | |
15843 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15844 | install_element(BGP_VPNV4_NODE, | |
15845 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15846 | install_element(BGP_VPNV4_NODE, | |
15847 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15848 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
15849 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15850 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15851 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15852 | install_element(BGP_VPNV6_NODE, | |
15853 | &neighbor_remove_private_as_replace_as_cmd); | |
15854 | install_element(BGP_VPNV6_NODE, | |
15855 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15856 | install_element(BGP_VPNV6_NODE, | |
15857 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15858 | install_element(BGP_VPNV6_NODE, | |
15859 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15860 | ||
15861 | /* "neighbor send-community" commands.*/ | |
15862 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
15863 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
15864 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
15865 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
15866 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
15867 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
15868 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
15869 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
15870 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
15871 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
15872 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
15873 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
15874 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
15875 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
15876 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
15877 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
15878 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
15879 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
15880 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
15881 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
15882 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
15883 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
15884 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
15885 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
15886 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
15887 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
15888 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
15889 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
15890 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
15891 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
15892 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
15893 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
15894 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
15895 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
15896 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
15897 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
15898 | ||
15899 | /* "neighbor route-reflector" commands.*/ | |
15900 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
15901 | install_element(BGP_NODE, | |
15902 | &no_neighbor_route_reflector_client_hidden_cmd); | |
15903 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
15904 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
15905 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
15906 | install_element(BGP_IPV4M_NODE, | |
15907 | &no_neighbor_route_reflector_client_cmd); | |
15908 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
15909 | install_element(BGP_IPV4L_NODE, | |
15910 | &no_neighbor_route_reflector_client_cmd); | |
15911 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
15912 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
15913 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
15914 | install_element(BGP_IPV6M_NODE, | |
15915 | &no_neighbor_route_reflector_client_cmd); | |
15916 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
15917 | install_element(BGP_IPV6L_NODE, | |
15918 | &no_neighbor_route_reflector_client_cmd); | |
15919 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
15920 | install_element(BGP_VPNV4_NODE, | |
15921 | &no_neighbor_route_reflector_client_cmd); | |
15922 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
15923 | install_element(BGP_VPNV6_NODE, | |
15924 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 15925 | install_element(BGP_FLOWSPECV4_NODE, |
15926 | &neighbor_route_reflector_client_cmd); | |
15927 | install_element(BGP_FLOWSPECV4_NODE, | |
15928 | &no_neighbor_route_reflector_client_cmd); | |
15929 | install_element(BGP_FLOWSPECV6_NODE, | |
15930 | &neighbor_route_reflector_client_cmd); | |
15931 | install_element(BGP_FLOWSPECV6_NODE, | |
15932 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 15933 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
15934 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
15935 | ||
15936 | /* "neighbor route-server" commands.*/ | |
15937 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
15938 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
15939 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
15940 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
15941 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
15942 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
15943 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
15944 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
15945 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
15946 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
15947 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
15948 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
15949 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
15950 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
15951 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
15952 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
15953 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
15954 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
15955 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
15956 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 15957 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
15958 | install_element(BGP_FLOWSPECV4_NODE, | |
15959 | &no_neighbor_route_server_client_cmd); | |
15960 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
15961 | install_element(BGP_FLOWSPECV6_NODE, | |
15962 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 15963 | |
15964 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
15965 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
15966 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
15967 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15968 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15969 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15970 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15971 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15972 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15973 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15974 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15975 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15976 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15977 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15978 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15979 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15980 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15981 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
15982 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
15983 | ||
15984 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
15985 | install_element(BGP_NODE, | |
15986 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
15987 | install_element(BGP_NODE, | |
15988 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
15989 | install_element(BGP_IPV4_NODE, | |
15990 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
15991 | install_element(BGP_IPV4_NODE, | |
15992 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
15993 | install_element(BGP_IPV4M_NODE, | |
15994 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
15995 | install_element(BGP_IPV4M_NODE, | |
15996 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
15997 | install_element(BGP_IPV4L_NODE, | |
15998 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
15999 | install_element(BGP_IPV4L_NODE, | |
16000 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16001 | install_element(BGP_IPV6_NODE, | |
16002 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16003 | install_element(BGP_IPV6_NODE, | |
16004 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16005 | install_element(BGP_IPV6M_NODE, | |
16006 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16007 | install_element(BGP_IPV6M_NODE, | |
16008 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16009 | install_element(BGP_IPV6L_NODE, | |
16010 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16011 | install_element(BGP_IPV6L_NODE, | |
16012 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16013 | install_element(BGP_VPNV4_NODE, | |
16014 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16015 | install_element(BGP_VPNV4_NODE, | |
16016 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16017 | install_element(BGP_VPNV6_NODE, | |
16018 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16019 | install_element(BGP_VPNV6_NODE, | |
16020 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16021 | ||
2b31007c RZ |
16022 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16023 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16024 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16025 | ||
d62a17ae | 16026 | /* "neighbor passive" commands. */ |
16027 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16028 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16029 | ||
16030 | ||
16031 | /* "neighbor shutdown" commands. */ | |
16032 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16033 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16034 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16035 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16036 | ||
16037 | /* "neighbor capability extended-nexthop" commands.*/ | |
16038 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16039 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16040 | ||
16041 | /* "neighbor capability orf prefix-list" commands.*/ | |
16042 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16043 | install_element(BGP_NODE, | |
16044 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16045 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16046 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16047 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16048 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16049 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16050 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16051 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16052 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16053 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16054 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16055 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16056 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16057 | ||
16058 | /* "neighbor capability dynamic" commands.*/ | |
16059 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16060 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16061 | ||
16062 | /* "neighbor dont-capability-negotiate" commands. */ | |
16063 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16064 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16065 | ||
16066 | /* "neighbor ebgp-multihop" commands. */ | |
16067 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16068 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16069 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16070 | ||
16071 | /* "neighbor disable-connected-check" commands. */ | |
16072 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16073 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16074 | ||
47cbc09b PM |
16075 | /* "neighbor enforce-first-as" commands. */ |
16076 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16077 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16078 | ||
d62a17ae | 16079 | /* "neighbor description" commands. */ |
16080 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16081 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16082 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16083 | |
16084 | /* "neighbor update-source" commands. "*/ | |
16085 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16086 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16087 | ||
16088 | /* "neighbor default-originate" commands. */ | |
16089 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16090 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16091 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16092 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16093 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16094 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16095 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16096 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16097 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16098 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16099 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16100 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16101 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16102 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16103 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16104 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16105 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16106 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16107 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16108 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16109 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16110 | ||
16111 | /* "neighbor port" commands. */ | |
16112 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16113 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16114 | ||
16115 | /* "neighbor weight" commands. */ | |
16116 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16117 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16118 | ||
16119 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16120 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16121 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16122 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16123 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16124 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16125 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16126 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16127 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16128 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16129 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16130 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16131 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16132 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16133 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16134 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16135 | ||
16136 | /* "neighbor override-capability" commands. */ | |
16137 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16138 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16139 | ||
16140 | /* "neighbor strict-capability-match" commands. */ | |
16141 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16142 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16143 | ||
16144 | /* "neighbor timers" commands. */ | |
16145 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16146 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16147 | ||
16148 | /* "neighbor timers connect" commands. */ | |
16149 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16150 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16151 | ||
16152 | /* "neighbor advertisement-interval" commands. */ | |
16153 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16154 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16155 | ||
16156 | /* "neighbor interface" commands. */ | |
16157 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16158 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16159 | ||
16160 | /* "neighbor distribute" commands. */ | |
16161 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16162 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16163 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16164 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16165 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16166 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16167 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16168 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16169 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16170 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16171 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16172 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16173 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16174 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16175 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16176 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16177 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16178 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16179 | ||
16180 | /* "neighbor prefix-list" commands. */ | |
16181 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16182 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16183 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16184 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16185 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16186 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16187 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16188 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16189 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16190 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16191 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16192 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16193 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16194 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16195 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16196 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16197 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16198 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16199 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16200 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16201 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16202 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16203 | |
16204 | /* "neighbor filter-list" commands. */ | |
16205 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16206 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16207 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16208 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16209 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16210 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16211 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16212 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16213 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16214 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16215 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16216 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16217 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16218 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16219 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16220 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16221 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16222 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16223 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16224 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16225 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16226 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16227 | |
16228 | /* "neighbor route-map" commands. */ | |
16229 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16230 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16231 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16232 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16233 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16234 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16235 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16236 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16237 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16238 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16239 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16240 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16241 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16242 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16243 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16244 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16245 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16246 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16247 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16248 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16249 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16250 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16251 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16252 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16253 | |
16254 | /* "neighbor unsuppress-map" commands. */ | |
16255 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16256 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16257 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16258 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16259 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16260 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16261 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16262 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16263 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16264 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16265 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16266 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16267 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16268 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16269 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16270 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16271 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16272 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16273 | ||
fde246e8 DA |
16274 | /* neighbor maximum-prefix-out commands. */ |
16275 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16276 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16277 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16278 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16279 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16280 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16281 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16282 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16283 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16284 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16285 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16286 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16287 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16288 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16289 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16290 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16291 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16292 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16293 | ||
d62a17ae | 16294 | /* "neighbor maximum-prefix" commands. */ |
16295 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16296 | install_element(BGP_NODE, | |
16297 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16298 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16299 | install_element(BGP_NODE, | |
16300 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16301 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16302 | install_element(BGP_NODE, | |
16303 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16304 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16305 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16306 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16307 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16308 | install_element(BGP_IPV4_NODE, | |
16309 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16310 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16311 | install_element(BGP_IPV4_NODE, | |
16312 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16313 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16314 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16315 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16316 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16317 | install_element(BGP_IPV4M_NODE, | |
16318 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16319 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16320 | install_element(BGP_IPV4M_NODE, | |
16321 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16322 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16323 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16324 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16325 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16326 | install_element(BGP_IPV4L_NODE, | |
16327 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16328 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16329 | install_element(BGP_IPV4L_NODE, | |
16330 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16331 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16332 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16333 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16334 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16335 | install_element(BGP_IPV6_NODE, | |
16336 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16337 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16338 | install_element(BGP_IPV6_NODE, | |
16339 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16340 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16341 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16342 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16343 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16344 | install_element(BGP_IPV6M_NODE, | |
16345 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16346 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16347 | install_element(BGP_IPV6M_NODE, | |
16348 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16349 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16350 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16351 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16352 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16353 | install_element(BGP_IPV6L_NODE, | |
16354 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16355 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16356 | install_element(BGP_IPV6L_NODE, | |
16357 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16358 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16359 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16360 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16361 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16362 | install_element(BGP_VPNV4_NODE, | |
16363 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16364 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16365 | install_element(BGP_VPNV4_NODE, | |
16366 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16367 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16368 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16369 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16370 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16371 | install_element(BGP_VPNV6_NODE, | |
16372 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16373 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16374 | install_element(BGP_VPNV6_NODE, | |
16375 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16376 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16377 | ||
16378 | /* "neighbor allowas-in" */ | |
16379 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16380 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16381 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16382 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16383 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16384 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16385 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16386 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16387 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16388 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16389 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16390 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16391 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16392 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16393 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16394 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16395 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16396 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16397 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16398 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16399 | ||
16400 | /* address-family commands. */ | |
16401 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16402 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16403 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16404 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16405 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16406 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16407 | |
d62a17ae | 16408 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16409 | ||
16410 | /* "exit-address-family" command. */ | |
16411 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16412 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16413 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16414 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16415 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16416 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16417 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16418 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16419 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16420 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16421 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16422 | ||
16423 | /* "clear ip bgp commands" */ | |
16424 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16425 | ||
16426 | /* clear ip bgp prefix */ | |
16427 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16428 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16429 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16430 | ||
16431 | /* "show [ip] bgp summary" commands. */ | |
16432 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16433 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16434 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16435 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16436 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16437 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16438 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16439 | ||
16440 | /* "show [ip] bgp neighbors" commands. */ | |
16441 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16442 | ||
2986cac2 | 16443 | install_element(VIEW_NODE, |
16444 | &show_ip_bgp_neighbors_graceful_restart_cmd); | |
16445 | ||
d62a17ae | 16446 | /* "show [ip] bgp peer-group" commands. */ |
16447 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16448 | ||
16449 | /* "show [ip] bgp paths" commands. */ | |
16450 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16451 | ||
16452 | /* "show [ip] bgp community" commands. */ | |
16453 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16454 | ||
16455 | /* "show ip bgp large-community" commands. */ | |
16456 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16457 | /* "show [ip] bgp attribute-info" commands. */ | |
16458 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16459 | /* "show [ip] bgp route-leak" command */ |
16460 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16461 | |
16462 | /* "redistribute" commands. */ | |
16463 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16464 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16465 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16466 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16467 | install_element(BGP_NODE, | |
16468 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16469 | install_element(BGP_NODE, | |
16470 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16471 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16472 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16473 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16474 | install_element(BGP_NODE, | |
16475 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16476 | install_element(BGP_NODE, | |
16477 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16478 | install_element(BGP_NODE, | |
16479 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16480 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16481 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16482 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16483 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16484 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16485 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16486 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16487 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16488 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16489 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16490 | install_element(BGP_IPV4_NODE, | |
16491 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16492 | install_element(BGP_IPV4_NODE, | |
16493 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16494 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16495 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16496 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16497 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16498 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16499 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16500 | ||
b9c7bc5a PZ |
16501 | /* import|export vpn [route-map WORD] */ |
16502 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16503 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16504 | |
12a844a5 DS |
16505 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16506 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16507 | ||
d62a17ae | 16508 | /* ttl_security commands */ |
16509 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16510 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16511 | ||
16512 | /* "show [ip] bgp memory" commands. */ | |
16513 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16514 | ||
acf71666 MK |
16515 | /* "show bgp martian next-hop" */ |
16516 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16517 | ||
48ecf8f5 DS |
16518 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16519 | ||
d62a17ae | 16520 | /* "show [ip] bgp views" commands. */ |
16521 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16522 | ||
16523 | /* "show [ip] bgp vrfs" commands. */ | |
16524 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16525 | ||
16526 | /* Community-list. */ | |
16527 | community_list_vty(); | |
ddb5b488 PZ |
16528 | |
16529 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16530 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16531 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16532 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16533 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16534 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16535 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16536 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16537 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16538 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16539 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16540 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16541 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16542 | |
301ad80a PG |
16543 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16544 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16545 | ||
b9c7bc5a PZ |
16546 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16547 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16548 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16549 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
16550 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
16551 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
16552 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
16553 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16554 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16555 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16556 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16557 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16558 | } |
6b0655a2 | 16559 | |
718e3744 | 16560 | #include "memory.h" |
16561 | #include "bgp_regex.h" | |
16562 | #include "bgp_clist.h" | |
16563 | #include "bgp_ecommunity.h" | |
16564 | ||
16565 | /* VTY functions. */ | |
16566 | ||
16567 | /* Direction value to string conversion. */ | |
d62a17ae | 16568 | static const char *community_direct_str(int direct) |
16569 | { | |
16570 | switch (direct) { | |
16571 | case COMMUNITY_DENY: | |
16572 | return "deny"; | |
16573 | case COMMUNITY_PERMIT: | |
16574 | return "permit"; | |
16575 | default: | |
16576 | return "unknown"; | |
16577 | } | |
718e3744 | 16578 | } |
16579 | ||
16580 | /* Display error string. */ | |
d62a17ae | 16581 | static void community_list_perror(struct vty *vty, int ret) |
16582 | { | |
16583 | switch (ret) { | |
16584 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16585 | vty_out(vty, "%% Can't find community-list\n"); | |
16586 | break; | |
16587 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16588 | vty_out(vty, "%% Malformed community-list value\n"); | |
16589 | break; | |
16590 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16591 | vty_out(vty, | |
16592 | "%% Community name conflict, previously defined as standard community\n"); | |
16593 | break; | |
16594 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16595 | vty_out(vty, | |
16596 | "%% Community name conflict, previously defined as expanded community\n"); | |
16597 | break; | |
16598 | } | |
718e3744 | 16599 | } |
16600 | ||
5bf15956 DW |
16601 | /* "community-list" keyword help string. */ |
16602 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16603 | ||
7336e101 SP |
16604 | /*community-list standard */ |
16605 | DEFUN (community_list_standard, | |
16606 | bgp_community_list_standard_cmd, | |
16607 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
16608 | BGP_STR | |
718e3744 | 16609 | COMMUNITY_LIST_STR |
16610 | "Community list number (standard)\n" | |
5bf15956 | 16611 | "Add an standard community-list entry\n" |
718e3744 | 16612 | "Community list name\n" |
16613 | "Specify community to reject\n" | |
16614 | "Specify community to accept\n" | |
16615 | COMMUNITY_VAL_STR) | |
16616 | { | |
d62a17ae | 16617 | char *cl_name_or_number = NULL; |
16618 | int direct = 0; | |
16619 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16620 | int idx = 0; |
7336e101 | 16621 | |
d62a17ae | 16622 | argv_find(argv, argc, "(1-99)", &idx); |
16623 | argv_find(argv, argc, "WORD", &idx); | |
16624 | cl_name_or_number = argv[idx]->arg; | |
16625 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16626 | : COMMUNITY_DENY; | |
16627 | argv_find(argv, argc, "AA:NN", &idx); | |
16628 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16629 | |
d62a17ae | 16630 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
16631 | style); | |
42f914d4 | 16632 | |
d62a17ae | 16633 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16634 | |
d62a17ae | 16635 | if (ret < 0) { |
16636 | /* Display error string. */ | |
16637 | community_list_perror(vty, ret); | |
16638 | return CMD_WARNING_CONFIG_FAILED; | |
16639 | } | |
42f914d4 | 16640 | |
d62a17ae | 16641 | return CMD_SUCCESS; |
718e3744 | 16642 | } |
16643 | ||
7336e101 SP |
16644 | DEFUN (no_community_list_standard_all, |
16645 | no_bgp_community_list_standard_all_cmd, | |
16646 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
16647 | NO_STR | |
16648 | BGP_STR | |
16649 | COMMUNITY_LIST_STR | |
16650 | "Community list number (standard)\n" | |
16651 | "Add an standard community-list entry\n" | |
16652 | "Community list name\n" | |
16653 | "Specify community to reject\n" | |
16654 | "Specify community to accept\n" | |
16655 | COMMUNITY_VAL_STR) | |
718e3744 | 16656 | { |
d62a17ae | 16657 | char *cl_name_or_number = NULL; |
174b5cb9 | 16658 | char *str = NULL; |
d62a17ae | 16659 | int direct = 0; |
16660 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 16661 | |
d62a17ae | 16662 | int idx = 0; |
7336e101 | 16663 | |
174b5cb9 DA |
16664 | argv_find(argv, argc, "permit", &idx); |
16665 | argv_find(argv, argc, "deny", &idx); | |
16666 | ||
16667 | if (idx) { | |
16668 | direct = argv_find(argv, argc, "permit", &idx) | |
16669 | ? COMMUNITY_PERMIT | |
16670 | : COMMUNITY_DENY; | |
16671 | ||
16672 | idx = 0; | |
16673 | argv_find(argv, argc, "AA:NN", &idx); | |
16674 | str = argv_concat(argv, argc, idx); | |
16675 | } | |
16676 | ||
16677 | idx = 0; | |
d62a17ae | 16678 | argv_find(argv, argc, "(1-99)", &idx); |
16679 | argv_find(argv, argc, "WORD", &idx); | |
16680 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16681 | |
d62a17ae | 16682 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 16683 | direct, style); |
42f914d4 | 16684 | |
d62a17ae | 16685 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16686 | |
d62a17ae | 16687 | if (ret < 0) { |
16688 | community_list_perror(vty, ret); | |
16689 | return CMD_WARNING_CONFIG_FAILED; | |
16690 | } | |
42f914d4 | 16691 | |
d62a17ae | 16692 | return CMD_SUCCESS; |
718e3744 | 16693 | } |
7336e101 | 16694 | |
174b5cb9 DA |
16695 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
16696 | "no bgp community-list <(1-99)|standard WORD>", | |
16697 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
16698 | "Community list number (standard)\n" | |
16699 | "Add an standard community-list entry\n" | |
16700 | "Community list name\n") | |
16701 | ||
7336e101 SP |
16702 | /*community-list expanded */ |
16703 | DEFUN (community_list_expanded_all, | |
16704 | bgp_community_list_expanded_all_cmd, | |
16705 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
16706 | BGP_STR | |
16707 | COMMUNITY_LIST_STR | |
718e3744 | 16708 | "Community list number (expanded)\n" |
5bf15956 | 16709 | "Add an expanded community-list entry\n" |
718e3744 | 16710 | "Community list name\n" |
16711 | "Specify community to reject\n" | |
16712 | "Specify community to accept\n" | |
16713 | COMMUNITY_VAL_STR) | |
16714 | { | |
d62a17ae | 16715 | char *cl_name_or_number = NULL; |
16716 | int direct = 0; | |
16717 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 16718 | |
d62a17ae | 16719 | int idx = 0; |
7b9a4750 | 16720 | |
d62a17ae | 16721 | argv_find(argv, argc, "(100-500)", &idx); |
16722 | argv_find(argv, argc, "WORD", &idx); | |
16723 | cl_name_or_number = argv[idx]->arg; | |
16724 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16725 | : COMMUNITY_DENY; | |
16726 | argv_find(argv, argc, "AA:NN", &idx); | |
16727 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16728 | |
d62a17ae | 16729 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
16730 | style); | |
42f914d4 | 16731 | |
d62a17ae | 16732 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16733 | |
d62a17ae | 16734 | if (ret < 0) { |
16735 | /* Display error string. */ | |
16736 | community_list_perror(vty, ret); | |
16737 | return CMD_WARNING_CONFIG_FAILED; | |
16738 | } | |
42f914d4 | 16739 | |
d62a17ae | 16740 | return CMD_SUCCESS; |
718e3744 | 16741 | } |
16742 | ||
7336e101 SP |
16743 | DEFUN (no_community_list_expanded_all, |
16744 | no_bgp_community_list_expanded_all_cmd, | |
16745 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
16746 | NO_STR | |
16747 | BGP_STR | |
16748 | COMMUNITY_LIST_STR | |
16749 | "Community list number (expanded)\n" | |
16750 | "Add an expanded community-list entry\n" | |
16751 | "Community list name\n" | |
16752 | "Specify community to reject\n" | |
16753 | "Specify community to accept\n" | |
16754 | COMMUNITY_VAL_STR) | |
718e3744 | 16755 | { |
d62a17ae | 16756 | char *cl_name_or_number = NULL; |
174b5cb9 | 16757 | char *str = NULL; |
d62a17ae | 16758 | int direct = 0; |
16759 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 16760 | |
d62a17ae | 16761 | int idx = 0; |
174b5cb9 DA |
16762 | |
16763 | argv_find(argv, argc, "permit", &idx); | |
16764 | argv_find(argv, argc, "deny", &idx); | |
16765 | ||
16766 | if (idx) { | |
16767 | direct = argv_find(argv, argc, "permit", &idx) | |
16768 | ? COMMUNITY_PERMIT | |
16769 | : COMMUNITY_DENY; | |
16770 | ||
16771 | idx = 0; | |
16772 | argv_find(argv, argc, "AA:NN", &idx); | |
16773 | str = argv_concat(argv, argc, idx); | |
7336e101 | 16774 | } |
174b5cb9 DA |
16775 | |
16776 | idx = 0; | |
d62a17ae | 16777 | argv_find(argv, argc, "(100-500)", &idx); |
16778 | argv_find(argv, argc, "WORD", &idx); | |
16779 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16780 | |
d62a17ae | 16781 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 16782 | direct, style); |
42f914d4 | 16783 | |
d62a17ae | 16784 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16785 | |
d62a17ae | 16786 | if (ret < 0) { |
16787 | community_list_perror(vty, ret); | |
16788 | return CMD_WARNING_CONFIG_FAILED; | |
16789 | } | |
42f914d4 | 16790 | |
d62a17ae | 16791 | return CMD_SUCCESS; |
718e3744 | 16792 | } |
16793 | ||
174b5cb9 DA |
16794 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
16795 | "no bgp community-list <(100-500)|expanded WORD>", | |
16796 | NO_STR IP_STR COMMUNITY_LIST_STR | |
16797 | "Community list number (expanded)\n" | |
16798 | "Add an expanded community-list entry\n" | |
16799 | "Community list name\n") | |
16800 | ||
8d9b8ed9 PM |
16801 | /* Return configuration string of community-list entry. */ |
16802 | static const char *community_list_config_str(struct community_entry *entry) | |
16803 | { | |
16804 | const char *str; | |
16805 | ||
16806 | if (entry->any) | |
16807 | str = ""; | |
16808 | else { | |
16809 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
16810 | str = community_str(entry->u.com, false); | |
16811 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
16812 | str = lcommunity_str(entry->u.lcom, false); | |
16813 | else | |
16814 | str = entry->config; | |
16815 | } | |
16816 | return str; | |
16817 | } | |
16818 | ||
d62a17ae | 16819 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 16820 | { |
d62a17ae | 16821 | struct community_entry *entry; |
718e3744 | 16822 | |
d62a17ae | 16823 | for (entry = list->head; entry; entry = entry->next) { |
16824 | if (entry == list->head) { | |
16825 | if (all_digit(list->name)) | |
16826 | vty_out(vty, "Community %s list %s\n", | |
16827 | entry->style == COMMUNITY_LIST_STANDARD | |
16828 | ? "standard" | |
16829 | : "(expanded) access", | |
16830 | list->name); | |
16831 | else | |
16832 | vty_out(vty, "Named Community %s list %s\n", | |
16833 | entry->style == COMMUNITY_LIST_STANDARD | |
16834 | ? "standard" | |
16835 | : "expanded", | |
16836 | list->name); | |
16837 | } | |
16838 | if (entry->any) | |
16839 | vty_out(vty, " %s\n", | |
16840 | community_direct_str(entry->direct)); | |
16841 | else | |
16842 | vty_out(vty, " %s %s\n", | |
16843 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16844 | community_list_config_str(entry)); |
d62a17ae | 16845 | } |
718e3744 | 16846 | } |
16847 | ||
7336e101 SP |
16848 | DEFUN (show_community_list, |
16849 | show_bgp_community_list_cmd, | |
16850 | "show bgp community-list", | |
718e3744 | 16851 | SHOW_STR |
7336e101 | 16852 | BGP_STR |
718e3744 | 16853 | "List community-list\n") |
16854 | { | |
d62a17ae | 16855 | struct community_list *list; |
16856 | struct community_list_master *cm; | |
718e3744 | 16857 | |
d62a17ae | 16858 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
16859 | if (!cm) | |
16860 | return CMD_SUCCESS; | |
718e3744 | 16861 | |
d62a17ae | 16862 | for (list = cm->num.head; list; list = list->next) |
16863 | community_list_show(vty, list); | |
718e3744 | 16864 | |
d62a17ae | 16865 | for (list = cm->str.head; list; list = list->next) |
16866 | community_list_show(vty, list); | |
718e3744 | 16867 | |
d62a17ae | 16868 | return CMD_SUCCESS; |
718e3744 | 16869 | } |
16870 | ||
7336e101 SP |
16871 | DEFUN (show_community_list_arg, |
16872 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 16873 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
16874 | SHOW_STR |
16875 | BGP_STR | |
718e3744 | 16876 | "List community-list\n" |
16877 | "Community-list number\n" | |
960b69b9 | 16878 | "Community-list name\n" |
16879 | "Detailed information on community-list\n") | |
718e3744 | 16880 | { |
d62a17ae | 16881 | int idx_comm_list = 3; |
16882 | struct community_list *list; | |
718e3744 | 16883 | |
e237b0d2 | 16884 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 16885 | COMMUNITY_LIST_MASTER); |
16886 | if (!list) { | |
16887 | vty_out(vty, "%% Can't find community-list\n"); | |
16888 | return CMD_WARNING; | |
16889 | } | |
718e3744 | 16890 | |
d62a17ae | 16891 | community_list_show(vty, list); |
718e3744 | 16892 | |
d62a17ae | 16893 | return CMD_SUCCESS; |
718e3744 | 16894 | } |
6b0655a2 | 16895 | |
57d187bc JS |
16896 | /* |
16897 | * Large Community code. | |
16898 | */ | |
d62a17ae | 16899 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
16900 | struct cmd_token **argv, int style, | |
16901 | int reject_all_digit_name) | |
16902 | { | |
16903 | int ret; | |
16904 | int direct; | |
16905 | char *str; | |
16906 | int idx = 0; | |
16907 | char *cl_name; | |
16908 | ||
16909 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16910 | : COMMUNITY_DENY; | |
16911 | ||
16912 | /* All digit name check. */ | |
16913 | idx = 0; | |
16914 | argv_find(argv, argc, "WORD", &idx); | |
16915 | argv_find(argv, argc, "(1-99)", &idx); | |
16916 | argv_find(argv, argc, "(100-500)", &idx); | |
16917 | cl_name = argv[idx]->arg; | |
16918 | if (reject_all_digit_name && all_digit(cl_name)) { | |
16919 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
16920 | return CMD_WARNING_CONFIG_FAILED; | |
16921 | } | |
16922 | ||
16923 | idx = 0; | |
16924 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
16925 | argv_find(argv, argc, "LINE", &idx); | |
16926 | /* Concat community string argument. */ | |
16927 | if (idx) | |
16928 | str = argv_concat(argv, argc, idx); | |
16929 | else | |
16930 | str = NULL; | |
16931 | ||
16932 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
16933 | ||
16934 | /* Free temporary community list string allocated by | |
16935 | argv_concat(). */ | |
0a22ddfb | 16936 | XFREE(MTYPE_TMP, str); |
d62a17ae | 16937 | |
16938 | if (ret < 0) { | |
16939 | community_list_perror(vty, ret); | |
16940 | return CMD_WARNING_CONFIG_FAILED; | |
16941 | } | |
16942 | return CMD_SUCCESS; | |
16943 | } | |
16944 | ||
16945 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
16946 | struct cmd_token **argv, int style) | |
16947 | { | |
16948 | int ret; | |
16949 | int direct = 0; | |
16950 | char *str = NULL; | |
16951 | int idx = 0; | |
16952 | ||
16953 | argv_find(argv, argc, "permit", &idx); | |
16954 | argv_find(argv, argc, "deny", &idx); | |
16955 | ||
16956 | if (idx) { | |
16957 | /* Check the list direct. */ | |
16958 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
16959 | direct = COMMUNITY_PERMIT; | |
16960 | else | |
16961 | direct = COMMUNITY_DENY; | |
16962 | ||
16963 | idx = 0; | |
16964 | argv_find(argv, argc, "LINE", &idx); | |
16965 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
16966 | /* Concat community string argument. */ | |
16967 | str = argv_concat(argv, argc, idx); | |
16968 | } | |
16969 | ||
16970 | idx = 0; | |
16971 | argv_find(argv, argc, "(1-99)", &idx); | |
16972 | argv_find(argv, argc, "(100-500)", &idx); | |
16973 | argv_find(argv, argc, "WORD", &idx); | |
16974 | ||
16975 | /* Unset community list. */ | |
16976 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
16977 | style); | |
16978 | ||
16979 | /* Free temporary community list string allocated by | |
16980 | argv_concat(). */ | |
0a22ddfb | 16981 | XFREE(MTYPE_TMP, str); |
d62a17ae | 16982 | |
16983 | if (ret < 0) { | |
16984 | community_list_perror(vty, ret); | |
16985 | return CMD_WARNING_CONFIG_FAILED; | |
16986 | } | |
16987 | ||
16988 | return CMD_SUCCESS; | |
57d187bc JS |
16989 | } |
16990 | ||
16991 | /* "large-community-list" keyword help string. */ | |
16992 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
16993 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
16994 | ||
7336e101 SP |
16995 | DEFUN (lcommunity_list_standard, |
16996 | bgp_lcommunity_list_standard_cmd, | |
7336e101 SP |
16997 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", |
16998 | BGP_STR | |
16999 | LCOMMUNITY_LIST_STR | |
17000 | "Large Community list number (standard)\n" | |
17001 | "Specify large community to reject\n" | |
17002 | "Specify large community to accept\n" | |
17003 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17004 | { |
d62a17ae | 17005 | return lcommunity_list_set_vty(vty, argc, argv, |
17006 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17007 | } |
17008 | ||
7336e101 SP |
17009 | DEFUN (lcommunity_list_expanded, |
17010 | bgp_lcommunity_list_expanded_cmd, | |
17011 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
17012 | BGP_STR | |
17013 | LCOMMUNITY_LIST_STR | |
17014 | "Large Community list number (expanded)\n" | |
17015 | "Specify large community to reject\n" | |
17016 | "Specify large community to accept\n" | |
17017 | "An ordered list as a regular-expression\n") | |
57d187bc | 17018 | { |
d62a17ae | 17019 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17020 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17021 | } |
17022 | ||
7336e101 SP |
17023 | DEFUN (lcommunity_list_name_standard, |
17024 | bgp_lcommunity_list_name_standard_cmd, | |
7336e101 SP |
17025 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", |
17026 | BGP_STR | |
17027 | LCOMMUNITY_LIST_STR | |
17028 | "Specify standard large-community-list\n" | |
17029 | "Large Community list name\n" | |
17030 | "Specify large community to reject\n" | |
17031 | "Specify large community to accept\n" | |
17032 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17033 | { |
d62a17ae | 17034 | return lcommunity_list_set_vty(vty, argc, argv, |
17035 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17036 | } |
17037 | ||
7336e101 SP |
17038 | DEFUN (lcommunity_list_name_expanded, |
17039 | bgp_lcommunity_list_name_expanded_cmd, | |
17040 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
17041 | BGP_STR | |
17042 | LCOMMUNITY_LIST_STR | |
17043 | "Specify expanded large-community-list\n" | |
17044 | "Large Community list name\n" | |
17045 | "Specify large community to reject\n" | |
17046 | "Specify large community to accept\n" | |
17047 | "An ordered list as a regular-expression\n") | |
57d187bc | 17048 | { |
d62a17ae | 17049 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17050 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17051 | } |
17052 | ||
7336e101 SP |
17053 | DEFUN (no_lcommunity_list_standard_all, |
17054 | no_bgp_lcommunity_list_standard_all_cmd, | |
17055 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
17056 | NO_STR | |
17057 | BGP_STR | |
17058 | LCOMMUNITY_LIST_STR | |
17059 | "Large Community list number (standard)\n" | |
17060 | "Large Community list number (expanded)\n" | |
17061 | "Large Community list name\n") | |
57d187bc | 17062 | { |
7336e101 SP |
17063 | return lcommunity_list_unset_vty(vty, argc, argv, |
17064 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17065 | } |
17066 | ||
7336e101 SP |
17067 | DEFUN (no_lcommunity_list_name_expanded_all, |
17068 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17069 | "no bgp large-community-list expanded WORD", | |
17070 | NO_STR | |
17071 | BGP_STR | |
17072 | LCOMMUNITY_LIST_STR | |
17073 | "Specify expanded large-community-list\n" | |
17074 | "Large Community list name\n") | |
57d187bc | 17075 | { |
d62a17ae | 17076 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17077 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17078 | } |
17079 | ||
7336e101 SP |
17080 | DEFUN (no_lcommunity_list_standard, |
17081 | no_bgp_lcommunity_list_standard_cmd, | |
17082 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
17083 | NO_STR | |
17084 | BGP_STR | |
17085 | LCOMMUNITY_LIST_STR | |
17086 | "Large Community list number (standard)\n" | |
17087 | "Specify large community to reject\n" | |
17088 | "Specify large community to accept\n" | |
17089 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17090 | { |
d62a17ae | 17091 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17092 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17093 | } |
17094 | ||
7336e101 SP |
17095 | DEFUN (no_lcommunity_list_expanded, |
17096 | no_bgp_lcommunity_list_expanded_cmd, | |
17097 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
17098 | NO_STR | |
17099 | BGP_STR | |
17100 | LCOMMUNITY_LIST_STR | |
17101 | "Large Community list number (expanded)\n" | |
17102 | "Specify large community to reject\n" | |
17103 | "Specify large community to accept\n" | |
17104 | "An ordered list as a regular-expression\n") | |
57d187bc | 17105 | { |
d62a17ae | 17106 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17107 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17108 | } |
17109 | ||
7336e101 SP |
17110 | DEFUN (no_lcommunity_list_name_standard, |
17111 | no_bgp_lcommunity_list_name_standard_cmd, | |
17112 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
17113 | NO_STR | |
17114 | BGP_STR | |
17115 | LCOMMUNITY_LIST_STR | |
17116 | "Specify standard large-community-list\n" | |
17117 | "Large Community list name\n" | |
17118 | "Specify large community to reject\n" | |
17119 | "Specify large community to accept\n" | |
17120 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17121 | { |
d62a17ae | 17122 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17123 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17124 | } |
17125 | ||
7336e101 SP |
17126 | DEFUN (no_lcommunity_list_name_expanded, |
17127 | no_bgp_lcommunity_list_name_expanded_cmd, | |
17128 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
17129 | NO_STR | |
17130 | BGP_STR | |
17131 | LCOMMUNITY_LIST_STR | |
17132 | "Specify expanded large-community-list\n" | |
17133 | "Large community list name\n" | |
17134 | "Specify large community to reject\n" | |
17135 | "Specify large community to accept\n" | |
17136 | "An ordered list as a regular-expression\n") | |
57d187bc | 17137 | { |
d62a17ae | 17138 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17139 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17140 | } |
17141 | ||
d62a17ae | 17142 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17143 | { | |
17144 | struct community_entry *entry; | |
17145 | ||
17146 | for (entry = list->head; entry; entry = entry->next) { | |
17147 | if (entry == list->head) { | |
17148 | if (all_digit(list->name)) | |
17149 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17150 | entry->style == |
17151 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17152 | ? "standard" |
17153 | : "(expanded) access", | |
17154 | list->name); | |
17155 | else | |
17156 | vty_out(vty, | |
17157 | "Named large community %s list %s\n", | |
169b72c8 | 17158 | entry->style == |
17159 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17160 | ? "standard" |
17161 | : "expanded", | |
17162 | list->name); | |
17163 | } | |
17164 | if (entry->any) | |
17165 | vty_out(vty, " %s\n", | |
17166 | community_direct_str(entry->direct)); | |
17167 | else | |
17168 | vty_out(vty, " %s %s\n", | |
17169 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17170 | community_list_config_str(entry)); |
d62a17ae | 17171 | } |
57d187bc JS |
17172 | } |
17173 | ||
7336e101 SP |
17174 | DEFUN (show_lcommunity_list, |
17175 | show_bgp_lcommunity_list_cmd, | |
17176 | "show bgp large-community-list", | |
57d187bc | 17177 | SHOW_STR |
7336e101 | 17178 | BGP_STR |
57d187bc JS |
17179 | "List large-community list\n") |
17180 | { | |
d62a17ae | 17181 | struct community_list *list; |
17182 | struct community_list_master *cm; | |
57d187bc | 17183 | |
d62a17ae | 17184 | cm = community_list_master_lookup(bgp_clist, |
17185 | LARGE_COMMUNITY_LIST_MASTER); | |
17186 | if (!cm) | |
17187 | return CMD_SUCCESS; | |
57d187bc | 17188 | |
d62a17ae | 17189 | for (list = cm->num.head; list; list = list->next) |
17190 | lcommunity_list_show(vty, list); | |
57d187bc | 17191 | |
d62a17ae | 17192 | for (list = cm->str.head; list; list = list->next) |
17193 | lcommunity_list_show(vty, list); | |
57d187bc | 17194 | |
d62a17ae | 17195 | return CMD_SUCCESS; |
57d187bc JS |
17196 | } |
17197 | ||
7336e101 SP |
17198 | DEFUN (show_lcommunity_list_arg, |
17199 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17200 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17201 | SHOW_STR |
17202 | BGP_STR | |
57d187bc | 17203 | "List large-community list\n" |
960b69b9 | 17204 | "Large-community-list number\n" |
17205 | "Large-community-list name\n" | |
17206 | "Detailed information on large-community-list\n") | |
57d187bc | 17207 | { |
d62a17ae | 17208 | struct community_list *list; |
57d187bc | 17209 | |
e237b0d2 | 17210 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17211 | LARGE_COMMUNITY_LIST_MASTER); |
17212 | if (!list) { | |
960b69b9 | 17213 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17214 | return CMD_WARNING; |
17215 | } | |
57d187bc | 17216 | |
d62a17ae | 17217 | lcommunity_list_show(vty, list); |
57d187bc | 17218 | |
d62a17ae | 17219 | return CMD_SUCCESS; |
57d187bc JS |
17220 | } |
17221 | ||
718e3744 | 17222 | /* "extcommunity-list" keyword help string. */ |
17223 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17224 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17225 | ||
7336e101 SP |
17226 | DEFUN (extcommunity_list_standard, |
17227 | bgp_extcommunity_list_standard_cmd, | |
17228 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
17229 | BGP_STR | |
718e3744 | 17230 | EXTCOMMUNITY_LIST_STR |
17231 | "Extended Community list number (standard)\n" | |
718e3744 | 17232 | "Specify standard extcommunity-list\n" |
5bf15956 | 17233 | "Community list name\n" |
718e3744 | 17234 | "Specify community to reject\n" |
17235 | "Specify community to accept\n" | |
17236 | EXTCOMMUNITY_VAL_STR) | |
17237 | { | |
d62a17ae | 17238 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17239 | int direct = 0; | |
17240 | char *cl_number_or_name = NULL; | |
42f914d4 | 17241 | |
d62a17ae | 17242 | int idx = 0; |
7b9a4750 | 17243 | |
d62a17ae | 17244 | argv_find(argv, argc, "(1-99)", &idx); |
17245 | argv_find(argv, argc, "WORD", &idx); | |
17246 | cl_number_or_name = argv[idx]->arg; | |
17247 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17248 | : COMMUNITY_DENY; | |
17249 | argv_find(argv, argc, "AA:NN", &idx); | |
17250 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17251 | |
d62a17ae | 17252 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
17253 | direct, style); | |
42f914d4 | 17254 | |
d62a17ae | 17255 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17256 | |
d62a17ae | 17257 | if (ret < 0) { |
17258 | community_list_perror(vty, ret); | |
17259 | return CMD_WARNING_CONFIG_FAILED; | |
17260 | } | |
42f914d4 | 17261 | |
d62a17ae | 17262 | return CMD_SUCCESS; |
718e3744 | 17263 | } |
17264 | ||
7336e101 SP |
17265 | DEFUN (extcommunity_list_name_expanded, |
17266 | bgp_extcommunity_list_name_expanded_cmd, | |
17267 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
17268 | BGP_STR | |
17269 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17270 | "Extended Community list number (expanded)\n" |
718e3744 | 17271 | "Specify expanded extcommunity-list\n" |
17272 | "Extended Community list name\n" | |
17273 | "Specify community to reject\n" | |
17274 | "Specify community to accept\n" | |
17275 | "An ordered list as a regular-expression\n") | |
17276 | { | |
d62a17ae | 17277 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17278 | int direct = 0; | |
17279 | char *cl_number_or_name = NULL; | |
d62a17ae | 17280 | int idx = 0; |
7336e101 | 17281 | |
d62a17ae | 17282 | argv_find(argv, argc, "(100-500)", &idx); |
17283 | argv_find(argv, argc, "WORD", &idx); | |
17284 | cl_number_or_name = argv[idx]->arg; | |
17285 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17286 | : COMMUNITY_DENY; | |
17287 | argv_find(argv, argc, "LINE", &idx); | |
17288 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17289 | |
d62a17ae | 17290 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
17291 | direct, style); | |
42f914d4 | 17292 | |
d62a17ae | 17293 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17294 | |
d62a17ae | 17295 | if (ret < 0) { |
17296 | community_list_perror(vty, ret); | |
17297 | return CMD_WARNING_CONFIG_FAILED; | |
17298 | } | |
42f914d4 | 17299 | |
d62a17ae | 17300 | return CMD_SUCCESS; |
718e3744 | 17301 | } |
17302 | ||
7336e101 SP |
17303 | DEFUN (no_extcommunity_list_standard_all, |
17304 | no_bgp_extcommunity_list_standard_all_cmd, | |
17305 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
17306 | NO_STR | |
17307 | BGP_STR | |
17308 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17309 | "Extended Community list number (standard)\n" |
718e3744 | 17310 | "Specify standard extcommunity-list\n" |
5bf15956 | 17311 | "Community list name\n" |
718e3744 | 17312 | "Specify community to reject\n" |
17313 | "Specify community to accept\n" | |
17314 | EXTCOMMUNITY_VAL_STR) | |
17315 | { | |
d62a17ae | 17316 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17317 | int direct = 0; | |
17318 | char *cl_number_or_name = NULL; | |
d4455c89 | 17319 | char *str = NULL; |
d62a17ae | 17320 | int idx = 0; |
d4455c89 | 17321 | |
d4455c89 DA |
17322 | argv_find(argv, argc, "permit", &idx); |
17323 | argv_find(argv, argc, "deny", &idx); | |
17324 | ||
17325 | if (idx) { | |
17326 | direct = argv_find(argv, argc, "permit", &idx) | |
17327 | ? COMMUNITY_PERMIT | |
17328 | : COMMUNITY_DENY; | |
17329 | ||
17330 | idx = 0; | |
17331 | argv_find(argv, argc, "AA:NN", &idx); | |
17332 | str = argv_concat(argv, argc, idx); | |
17333 | } | |
17334 | ||
17335 | idx = 0; | |
d62a17ae | 17336 | argv_find(argv, argc, "(1-99)", &idx); |
17337 | argv_find(argv, argc, "WORD", &idx); | |
17338 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17339 | |
d62a17ae | 17340 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 17341 | direct, style); |
42f914d4 | 17342 | |
d62a17ae | 17343 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17344 | |
d62a17ae | 17345 | if (ret < 0) { |
17346 | community_list_perror(vty, ret); | |
17347 | return CMD_WARNING_CONFIG_FAILED; | |
17348 | } | |
42f914d4 | 17349 | |
d62a17ae | 17350 | return CMD_SUCCESS; |
718e3744 | 17351 | } |
17352 | ||
d4455c89 DA |
17353 | ALIAS(no_extcommunity_list_standard_all, |
17354 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17355 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17356 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17357 | "Extended Community list number (standard)\n" | |
17358 | "Specify standard extcommunity-list\n" | |
17359 | "Community list name\n") | |
17360 | ||
7336e101 SP |
17361 | DEFUN (no_extcommunity_list_expanded_all, |
17362 | no_bgp_extcommunity_list_expanded_all_cmd, | |
17363 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
17364 | NO_STR | |
17365 | BGP_STR | |
17366 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17367 | "Extended Community list number (expanded)\n" |
718e3744 | 17368 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17369 | "Extended Community list name\n" |
718e3744 | 17370 | "Specify community to reject\n" |
17371 | "Specify community to accept\n" | |
17372 | "An ordered list as a regular-expression\n") | |
17373 | { | |
d62a17ae | 17374 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17375 | int direct = 0; | |
17376 | char *cl_number_or_name = NULL; | |
d4455c89 | 17377 | char *str = NULL; |
d62a17ae | 17378 | int idx = 0; |
d4455c89 | 17379 | |
d4455c89 DA |
17380 | argv_find(argv, argc, "permit", &idx); |
17381 | argv_find(argv, argc, "deny", &idx); | |
17382 | ||
17383 | if (idx) { | |
17384 | direct = argv_find(argv, argc, "permit", &idx) | |
17385 | ? COMMUNITY_PERMIT | |
17386 | : COMMUNITY_DENY; | |
17387 | ||
17388 | idx = 0; | |
17389 | argv_find(argv, argc, "LINE", &idx); | |
17390 | str = argv_concat(argv, argc, idx); | |
17391 | } | |
17392 | ||
17393 | idx = 0; | |
d62a17ae | 17394 | argv_find(argv, argc, "(100-500)", &idx); |
17395 | argv_find(argv, argc, "WORD", &idx); | |
17396 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17397 | |
d62a17ae | 17398 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 17399 | direct, style); |
42f914d4 | 17400 | |
d62a17ae | 17401 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17402 | |
d62a17ae | 17403 | if (ret < 0) { |
17404 | community_list_perror(vty, ret); | |
17405 | return CMD_WARNING_CONFIG_FAILED; | |
17406 | } | |
42f914d4 | 17407 | |
d62a17ae | 17408 | return CMD_SUCCESS; |
718e3744 | 17409 | } |
17410 | ||
d4455c89 DA |
17411 | ALIAS(no_extcommunity_list_expanded_all, |
17412 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17413 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17414 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17415 | "Extended Community list number (expanded)\n" | |
17416 | "Specify expanded extcommunity-list\n" | |
17417 | "Extended Community list name\n") | |
17418 | ||
d62a17ae | 17419 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17420 | { |
d62a17ae | 17421 | struct community_entry *entry; |
718e3744 | 17422 | |
d62a17ae | 17423 | for (entry = list->head; entry; entry = entry->next) { |
17424 | if (entry == list->head) { | |
17425 | if (all_digit(list->name)) | |
17426 | vty_out(vty, "Extended community %s list %s\n", | |
17427 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17428 | ? "standard" | |
17429 | : "(expanded) access", | |
17430 | list->name); | |
17431 | else | |
17432 | vty_out(vty, | |
17433 | "Named extended community %s list %s\n", | |
17434 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17435 | ? "standard" | |
17436 | : "expanded", | |
17437 | list->name); | |
17438 | } | |
17439 | if (entry->any) | |
17440 | vty_out(vty, " %s\n", | |
17441 | community_direct_str(entry->direct)); | |
17442 | else | |
17443 | vty_out(vty, " %s %s\n", | |
17444 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17445 | community_list_config_str(entry)); |
d62a17ae | 17446 | } |
718e3744 | 17447 | } |
17448 | ||
7336e101 SP |
17449 | DEFUN (show_extcommunity_list, |
17450 | show_bgp_extcommunity_list_cmd, | |
17451 | "show bgp extcommunity-list", | |
718e3744 | 17452 | SHOW_STR |
7336e101 | 17453 | BGP_STR |
718e3744 | 17454 | "List extended-community list\n") |
17455 | { | |
d62a17ae | 17456 | struct community_list *list; |
17457 | struct community_list_master *cm; | |
718e3744 | 17458 | |
d62a17ae | 17459 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17460 | if (!cm) | |
17461 | return CMD_SUCCESS; | |
718e3744 | 17462 | |
d62a17ae | 17463 | for (list = cm->num.head; list; list = list->next) |
17464 | extcommunity_list_show(vty, list); | |
718e3744 | 17465 | |
d62a17ae | 17466 | for (list = cm->str.head; list; list = list->next) |
17467 | extcommunity_list_show(vty, list); | |
718e3744 | 17468 | |
d62a17ae | 17469 | return CMD_SUCCESS; |
718e3744 | 17470 | } |
17471 | ||
7336e101 SP |
17472 | DEFUN (show_extcommunity_list_arg, |
17473 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17474 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17475 | SHOW_STR |
17476 | BGP_STR | |
718e3744 | 17477 | "List extended-community list\n" |
17478 | "Extcommunity-list number\n" | |
960b69b9 | 17479 | "Extcommunity-list name\n" |
17480 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17481 | { |
d62a17ae | 17482 | int idx_comm_list = 3; |
17483 | struct community_list *list; | |
718e3744 | 17484 | |
e237b0d2 | 17485 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17486 | EXTCOMMUNITY_LIST_MASTER); |
17487 | if (!list) { | |
17488 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17489 | return CMD_WARNING; | |
17490 | } | |
718e3744 | 17491 | |
d62a17ae | 17492 | extcommunity_list_show(vty, list); |
718e3744 | 17493 | |
d62a17ae | 17494 | return CMD_SUCCESS; |
718e3744 | 17495 | } |
6b0655a2 | 17496 | |
718e3744 | 17497 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17498 | static int community_list_config_write(struct vty *vty) |
17499 | { | |
17500 | struct community_list *list; | |
17501 | struct community_entry *entry; | |
17502 | struct community_list_master *cm; | |
17503 | int write = 0; | |
17504 | ||
17505 | /* Community-list. */ | |
17506 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17507 | ||
17508 | for (list = cm->num.head; list; list = list->next) | |
17509 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17510 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 17511 | community_direct_str(entry->direct), |
17512 | community_list_config_str(entry)); | |
17513 | write++; | |
17514 | } | |
17515 | for (list = cm->str.head; list; list = list->next) | |
17516 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17517 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 17518 | entry->style == COMMUNITY_LIST_STANDARD |
17519 | ? "standard" | |
17520 | : "expanded", | |
17521 | list->name, community_direct_str(entry->direct), | |
17522 | community_list_config_str(entry)); | |
17523 | write++; | |
17524 | } | |
17525 | ||
17526 | /* Extcommunity-list. */ | |
17527 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17528 | ||
17529 | for (list = cm->num.head; list; list = list->next) | |
17530 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17531 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 17532 | list->name, community_direct_str(entry->direct), |
17533 | community_list_config_str(entry)); | |
17534 | write++; | |
17535 | } | |
17536 | for (list = cm->str.head; list; list = list->next) | |
17537 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17538 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 17539 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17540 | ? "standard" | |
17541 | : "expanded", | |
17542 | list->name, community_direct_str(entry->direct), | |
17543 | community_list_config_str(entry)); | |
17544 | write++; | |
17545 | } | |
17546 | ||
17547 | ||
17548 | /* lcommunity-list. */ | |
17549 | cm = community_list_master_lookup(bgp_clist, | |
17550 | LARGE_COMMUNITY_LIST_MASTER); | |
17551 | ||
17552 | for (list = cm->num.head; list; list = list->next) | |
17553 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17554 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 17555 | list->name, community_direct_str(entry->direct), |
17556 | community_list_config_str(entry)); | |
17557 | write++; | |
17558 | } | |
17559 | for (list = cm->str.head; list; list = list->next) | |
17560 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 17561 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 17562 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17563 | ? "standard" | |
17564 | : "expanded", | |
17565 | list->name, community_direct_str(entry->direct), | |
17566 | community_list_config_str(entry)); | |
17567 | write++; | |
17568 | } | |
17569 | ||
17570 | return write; | |
17571 | } | |
17572 | ||
17573 | static struct cmd_node community_list_node = { | |
17574 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 17575 | }; |
17576 | ||
d62a17ae | 17577 | static void community_list_vty(void) |
17578 | { | |
17579 | install_node(&community_list_node, community_list_config_write); | |
17580 | ||
17581 | /* Community-list. */ | |
7336e101 SP |
17582 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
17583 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
17584 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 17585 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 17586 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 17587 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
17588 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
17589 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 17590 | |
17591 | /* Extcommunity-list. */ | |
7336e101 SP |
17592 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
17593 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
17594 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
17595 | install_element(CONFIG_NODE, |
17596 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 17597 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
17598 | install_element(CONFIG_NODE, |
17599 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
17600 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
17601 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 17602 | |
17603 | /* Large Community List */ | |
7336e101 | 17604 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
17605 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
17606 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 SP |
17607 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
17608 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
17609 | install_element(CONFIG_NODE, | |
17610 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
17611 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
17612 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
17613 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
17614 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
17615 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
17616 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 17617 | } |