]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
5cb5f4d0 | 25 | #include "lib_errors.h" |
ec0ab544 | 26 | #include "lib/zclient.h" |
718e3744 | 27 | #include "prefix.h" |
28 | #include "plist.h" | |
29 | #include "buffer.h" | |
30 | #include "linklist.h" | |
31 | #include "stream.h" | |
32 | #include "thread.h" | |
33 | #include "log.h" | |
3b8b1855 | 34 | #include "memory.h" |
1c0d8808 | 35 | #include "lib_vty.h" |
4bf6a362 | 36 | #include "hash.h" |
3f9c7369 | 37 | #include "queue.h" |
039f3a34 | 38 | #include "filter.h" |
5d5ba018 | 39 | #include "frrstr.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 42 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 43 | #include "bgpd/bgp_advertise.h" |
718e3744 | 44 | #include "bgpd/bgp_attr.h" |
45 | #include "bgpd/bgp_aspath.h" | |
46 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 47 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 48 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 49 | #include "bgpd/bgp_damp.h" |
718e3744 | 50 | #include "bgpd/bgp_debug.h" |
14454c9f | 51 | #include "bgpd/bgp_errors.h" |
e0701b79 | 52 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 53 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 54 | #include "bgpd/bgp_open.h" |
4bf6a362 | 55 | #include "bgpd/bgp_regex.h" |
718e3744 | 56 | #include "bgpd/bgp_route.h" |
c016b6c7 | 57 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 58 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 59 | #include "bgpd/bgp_table.h" |
94f2b392 | 60 | #include "bgpd/bgp_vty.h" |
165b5fff | 61 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 62 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 63 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 64 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 65 | #include "bgpd/bgp_io.h" |
94c2f693 | 66 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 67 | #include "bgpd/bgp_evpn_vty.h" |
dcc68b5e | 68 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 69 | #include "bgpd/bgp_mac.h" |
dd65f45e DL |
70 | #include "bgpd/bgp_flowspec.h" |
71 | #if ENABLE_BGP_VNC | |
72 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" | |
73 | #endif | |
74 | ||
5d5393b9 DL |
75 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
76 | { .val_long = true, .match_profile = "datacenter", }, | |
77 | { .val_long = false }, | |
78 | ) | |
79 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
80 | { .val_long = true, .match_profile = "datacenter", }, | |
81 | { .val_long = false }, | |
82 | ) | |
83 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, | |
84 | { .val_long = true, .match_profile = "datacenter", }, | |
85 | { .val_long = false }, | |
86 | ) | |
87 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
88 | { .val_long = true, .match_profile = "datacenter", }, | |
89 | { .val_long = false }, | |
90 | ) | |
91 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
92 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
93 | { .val_ulong = 120 }, | |
94 | ) | |
95 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
96 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
97 | { .val_ulong = 180 }, | |
98 | ) | |
99 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
100 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
101 | { .val_ulong = 60 }, | |
102 | ) | |
103 | ||
dd65f45e DL |
104 | DEFINE_HOOK(bgp_inst_config_write, |
105 | (struct bgp *bgp, struct vty *vty), | |
106 | (bgp, vty)) | |
718e3744 | 107 | |
36235319 QY |
108 | #define GR_NO_OPER \ |
109 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
110 | #define GR_INVALID \ | |
111 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 112 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
113 | struct prefix *range, int exact); | |
114 | ||
055679e9 | 115 | /* Show BGP peer's information. */ |
116 | enum show_type { | |
117 | show_all, | |
118 | show_peer, | |
119 | show_ipv4_all, | |
120 | show_ipv6_all, | |
121 | show_ipv4_peer, | |
122 | show_ipv6_peer | |
123 | }; | |
124 | ||
36235319 QY |
125 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
126 | struct prefix *range, int exact); | |
2986cac2 | 127 | |
36235319 QY |
128 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
129 | struct bgp *bgp, | |
130 | bool use_json, | |
131 | json_object *json); | |
2986cac2 | 132 | |
36235319 QY |
133 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
134 | enum show_type type, | |
135 | const char *ip_str, | |
136 | afi_t afi, bool use_json); | |
2986cac2 | 137 | |
d62a17ae | 138 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
139 | { | |
140 | switch (afi) { | |
141 | case AFI_IP: | |
142 | switch (safi) { | |
143 | case SAFI_UNICAST: | |
144 | return BGP_IPV4_NODE; | |
d62a17ae | 145 | case SAFI_MULTICAST: |
146 | return BGP_IPV4M_NODE; | |
d62a17ae | 147 | case SAFI_LABELED_UNICAST: |
148 | return BGP_IPV4L_NODE; | |
d62a17ae | 149 | case SAFI_MPLS_VPN: |
150 | return BGP_VPNV4_NODE; | |
7c40bf39 | 151 | case SAFI_FLOWSPEC: |
152 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
153 | default: |
154 | /* not expected */ | |
155 | return BGP_IPV4_NODE; | |
d62a17ae | 156 | } |
157 | break; | |
158 | case AFI_IP6: | |
159 | switch (safi) { | |
160 | case SAFI_UNICAST: | |
161 | return BGP_IPV6_NODE; | |
d62a17ae | 162 | case SAFI_MULTICAST: |
163 | return BGP_IPV6M_NODE; | |
d62a17ae | 164 | case SAFI_LABELED_UNICAST: |
165 | return BGP_IPV6L_NODE; | |
d62a17ae | 166 | case SAFI_MPLS_VPN: |
167 | return BGP_VPNV6_NODE; | |
7c40bf39 | 168 | case SAFI_FLOWSPEC: |
169 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
170 | default: |
171 | /* not expected */ | |
172 | return BGP_IPV4_NODE; | |
d62a17ae | 173 | } |
174 | break; | |
175 | case AFI_L2VPN: | |
176 | return BGP_EVPN_NODE; | |
b26f891d | 177 | case AFI_UNSPEC: |
d62a17ae | 178 | case AFI_MAX: |
179 | // We should never be here but to clarify the switch statement.. | |
180 | return BGP_IPV4_NODE; | |
d62a17ae | 181 | } |
182 | ||
183 | // Impossible to happen | |
184 | return BGP_IPV4_NODE; | |
f51bae9c | 185 | } |
20eb8864 | 186 | |
5cb5f4d0 DD |
187 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
188 | { | |
189 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
190 | return "IPv4 Unicast"; | |
191 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
192 | return "IPv4 Multicast"; | |
193 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
194 | return "IPv4 Labeled Unicast"; | |
195 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
196 | return "IPv4 VPN"; | |
197 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
198 | return "IPv4 Encap"; | |
199 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
200 | return "IPv4 Flowspec"; | |
201 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
202 | return "IPv6 Unicast"; | |
203 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
204 | return "IPv6 Multicast"; | |
205 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
206 | return "IPv6 Labeled Unicast"; | |
207 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
208 | return "IPv6 VPN"; | |
209 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
210 | return "IPv6 Encap"; | |
211 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
212 | return "IPv6 Flowspec"; | |
213 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
214 | return "L2VPN EVPN"; | |
8e5509b0 | 215 | else |
5cb5f4d0 | 216 | return "Unknown"; |
5cb5f4d0 DD |
217 | } |
218 | ||
219 | /* | |
220 | * Please note that we have intentionally camelCased | |
221 | * the return strings here. So if you want | |
222 | * to use this function, please ensure you | |
223 | * are doing this within json output | |
224 | */ | |
225 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
226 | { | |
227 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
228 | return "ipv4Unicast"; | |
229 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
230 | return "ipv4Multicast"; | |
231 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
232 | return "ipv4LabeledUnicast"; | |
233 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
234 | return "ipv4Vpn"; | |
235 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
236 | return "ipv4Encap"; | |
237 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
238 | return "ipv4Flowspec"; | |
239 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
240 | return "ipv6Unicast"; | |
241 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
242 | return "ipv6Multicast"; | |
243 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
244 | return "ipv6LabeledUnicast"; | |
245 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
246 | return "ipv6Vpn"; | |
247 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
248 | return "ipv6Encap"; | |
249 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
250 | return "ipv6Flowspec"; | |
251 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
252 | return "l2VpnEvpn"; | |
8e5509b0 | 253 | else |
5cb5f4d0 | 254 | return "Unknown"; |
5cb5f4d0 DD |
255 | } |
256 | ||
718e3744 | 257 | /* Utility function to get address family from current node. */ |
d62a17ae | 258 | afi_t bgp_node_afi(struct vty *vty) |
259 | { | |
260 | afi_t afi; | |
261 | switch (vty->node) { | |
262 | case BGP_IPV6_NODE: | |
263 | case BGP_IPV6M_NODE: | |
264 | case BGP_IPV6L_NODE: | |
265 | case BGP_VPNV6_NODE: | |
7c40bf39 | 266 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 267 | afi = AFI_IP6; |
268 | break; | |
269 | case BGP_EVPN_NODE: | |
270 | afi = AFI_L2VPN; | |
271 | break; | |
272 | default: | |
273 | afi = AFI_IP; | |
274 | break; | |
275 | } | |
276 | return afi; | |
718e3744 | 277 | } |
278 | ||
279 | /* Utility function to get subsequent address family from current | |
280 | node. */ | |
d62a17ae | 281 | safi_t bgp_node_safi(struct vty *vty) |
282 | { | |
283 | safi_t safi; | |
284 | switch (vty->node) { | |
285 | case BGP_VPNV4_NODE: | |
286 | case BGP_VPNV6_NODE: | |
287 | safi = SAFI_MPLS_VPN; | |
288 | break; | |
289 | case BGP_IPV4M_NODE: | |
290 | case BGP_IPV6M_NODE: | |
291 | safi = SAFI_MULTICAST; | |
292 | break; | |
293 | case BGP_EVPN_NODE: | |
294 | safi = SAFI_EVPN; | |
295 | break; | |
296 | case BGP_IPV4L_NODE: | |
297 | case BGP_IPV6L_NODE: | |
298 | safi = SAFI_LABELED_UNICAST; | |
299 | break; | |
7c40bf39 | 300 | case BGP_FLOWSPECV4_NODE: |
301 | case BGP_FLOWSPECV6_NODE: | |
302 | safi = SAFI_FLOWSPEC; | |
303 | break; | |
d62a17ae | 304 | default: |
305 | safi = SAFI_UNICAST; | |
306 | break; | |
307 | } | |
308 | return safi; | |
718e3744 | 309 | } |
310 | ||
55f91488 QY |
311 | /** |
312 | * Converts an AFI in string form to afi_t | |
313 | * | |
314 | * @param afi string, one of | |
315 | * - "ipv4" | |
316 | * - "ipv6" | |
81cf0de5 | 317 | * - "l2vpn" |
55f91488 QY |
318 | * @return the corresponding afi_t |
319 | */ | |
d62a17ae | 320 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
321 | { | |
322 | afi_t afi = AFI_MAX; /* unknown */ | |
323 | if (strmatch(afi_str, "ipv4")) | |
324 | afi = AFI_IP; | |
325 | else if (strmatch(afi_str, "ipv6")) | |
326 | afi = AFI_IP6; | |
81cf0de5 CS |
327 | else if (strmatch(afi_str, "l2vpn")) |
328 | afi = AFI_L2VPN; | |
d62a17ae | 329 | return afi; |
330 | } | |
331 | ||
332 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
333 | afi_t *afi) | |
334 | { | |
335 | int ret = 0; | |
336 | if (argv_find(argv, argc, "ipv4", index)) { | |
337 | ret = 1; | |
338 | if (afi) | |
339 | *afi = AFI_IP; | |
340 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
341 | ret = 1; | |
342 | if (afi) | |
343 | *afi = AFI_IP6; | |
8688b3e7 DS |
344 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
345 | ret = 1; | |
346 | if (afi) | |
347 | *afi = AFI_L2VPN; | |
d62a17ae | 348 | } |
349 | return ret; | |
46f296b4 LB |
350 | } |
351 | ||
375a2e67 | 352 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 353 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
354 | { | |
355 | safi_t safi = SAFI_MAX; /* unknown */ | |
356 | if (strmatch(safi_str, "multicast")) | |
357 | safi = SAFI_MULTICAST; | |
358 | else if (strmatch(safi_str, "unicast")) | |
359 | safi = SAFI_UNICAST; | |
360 | else if (strmatch(safi_str, "vpn")) | |
361 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
362 | else if (strmatch(safi_str, "evpn")) |
363 | safi = SAFI_EVPN; | |
d62a17ae | 364 | else if (strmatch(safi_str, "labeled-unicast")) |
365 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 366 | else if (strmatch(safi_str, "flowspec")) |
367 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 368 | return safi; |
369 | } | |
370 | ||
371 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
372 | safi_t *safi) | |
373 | { | |
374 | int ret = 0; | |
375 | if (argv_find(argv, argc, "unicast", index)) { | |
376 | ret = 1; | |
377 | if (safi) | |
378 | *safi = SAFI_UNICAST; | |
379 | } else if (argv_find(argv, argc, "multicast", index)) { | |
380 | ret = 1; | |
381 | if (safi) | |
382 | *safi = SAFI_MULTICAST; | |
383 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
384 | ret = 1; | |
385 | if (safi) | |
386 | *safi = SAFI_LABELED_UNICAST; | |
387 | } else if (argv_find(argv, argc, "vpn", index)) { | |
388 | ret = 1; | |
389 | if (safi) | |
390 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
391 | } else if (argv_find(argv, argc, "evpn", index)) { |
392 | ret = 1; | |
393 | if (safi) | |
394 | *safi = SAFI_EVPN; | |
7c40bf39 | 395 | } else if (argv_find(argv, argc, "flowspec", index)) { |
396 | ret = 1; | |
397 | if (safi) | |
398 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 399 | } |
400 | return ret; | |
46f296b4 LB |
401 | } |
402 | ||
5d5393b9 DL |
403 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
404 | enum bgp_instance_type inst_type) | |
405 | { | |
406 | int ret = bgp_get(bgp, as, name, inst_type); | |
407 | ||
408 | if (ret == BGP_CREATED) { | |
409 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
410 | DFLT_BGP_CONNECT_RETRY); | |
411 | ||
412 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 413 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 414 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 415 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
5d5393b9 | 416 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 417 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 418 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 419 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
5d5393b9 DL |
420 | |
421 | ret = BGP_SUCCESS; | |
422 | } | |
423 | return ret; | |
424 | } | |
425 | ||
7eeee51e | 426 | /* |
f212a857 | 427 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 428 | * |
f212a857 DS |
429 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
430 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
431 | * to appropriate values for the calling function. This is to allow the |
432 | * calling function to make decisions appropriate for the show command | |
433 | * that is being parsed. | |
434 | * | |
435 | * The show commands are generally of the form: | |
d62a17ae | 436 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
437 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
438 | * |
439 | * Since we use argv_find if the show command in particular doesn't have: | |
440 | * [ip] | |
18c57037 | 441 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 442 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
443 | * The command parsing should still be ok. |
444 | * | |
445 | * vty -> The vty for the command so we can output some useful data in | |
446 | * the event of a parse error in the vrf. | |
447 | * argv -> The command tokens | |
448 | * argc -> How many command tokens we have | |
d62a17ae | 449 | * idx -> The current place in the command, generally should be 0 for this |
450 | * function | |
7eeee51e DS |
451 | * afi -> The parsed afi if it was included in the show command, returned here |
452 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 453 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 454 | * use_json -> json is configured or not |
7eeee51e DS |
455 | * |
456 | * The function returns the correct location in the parse tree for the | |
457 | * last token found. | |
0e37c258 DS |
458 | * |
459 | * Returns 0 for failure to parse correctly, else the idx position of where | |
460 | * it found the last token. | |
7eeee51e | 461 | */ |
d62a17ae | 462 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
463 | struct cmd_token **argv, int argc, | |
464 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 465 | struct bgp **bgp, bool use_json) |
d62a17ae | 466 | { |
467 | char *vrf_name = NULL; | |
468 | ||
469 | assert(afi); | |
470 | assert(safi); | |
471 | assert(bgp); | |
472 | ||
473 | if (argv_find(argv, argc, "ip", idx)) | |
474 | *afi = AFI_IP; | |
475 | ||
9a8bdf1c | 476 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 477 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
478 | else if (argv_find(argv, argc, "vrf", idx)) { |
479 | vrf_name = argv[*idx + 1]->arg; | |
480 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
481 | vrf_name = NULL; | |
482 | } | |
483 | if (vrf_name) { | |
d62a17ae | 484 | if (strmatch(vrf_name, "all")) |
485 | *bgp = NULL; | |
486 | else { | |
487 | *bgp = bgp_lookup_by_name(vrf_name); | |
488 | if (!*bgp) { | |
52e5b8c4 SP |
489 | if (use_json) { |
490 | json_object *json = NULL; | |
491 | json = json_object_new_object(); | |
492 | json_object_string_add( | |
493 | json, "warning", | |
494 | "View/Vrf is unknown"); | |
495 | vty_out(vty, "%s\n", | |
496 | json_object_to_json_string_ext(json, | |
497 | JSON_C_TO_STRING_PRETTY)); | |
498 | json_object_free(json); | |
499 | } | |
ca61fd25 DS |
500 | else |
501 | vty_out(vty, "View/Vrf %s is unknown\n", | |
502 | vrf_name); | |
d62a17ae | 503 | *idx = 0; |
504 | return 0; | |
505 | } | |
506 | } | |
507 | } else { | |
508 | *bgp = bgp_get_default(); | |
509 | if (!*bgp) { | |
52e5b8c4 SP |
510 | if (use_json) { |
511 | json_object *json = NULL; | |
512 | json = json_object_new_object(); | |
513 | json_object_string_add( | |
514 | json, "warning", | |
515 | "Default BGP instance not found"); | |
516 | vty_out(vty, "%s\n", | |
517 | json_object_to_json_string_ext(json, | |
518 | JSON_C_TO_STRING_PRETTY)); | |
519 | json_object_free(json); | |
520 | } | |
ca61fd25 DS |
521 | else |
522 | vty_out(vty, | |
523 | "Default BGP instance not found\n"); | |
d62a17ae | 524 | *idx = 0; |
525 | return 0; | |
526 | } | |
527 | } | |
528 | ||
529 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
530 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
531 | ||
532 | *idx += 1; | |
533 | return *idx; | |
534 | } | |
535 | ||
536 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
537 | { | |
538 | struct interface *ifp = NULL; | |
539 | ||
540 | if (su->sa.sa_family == AF_INET) | |
541 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
542 | else if (su->sa.sa_family == AF_INET6) | |
543 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
544 | su->sin6.sin6_scope_id, | |
545 | bgp->vrf_id); | |
546 | ||
547 | if (ifp) | |
548 | return 1; | |
549 | ||
550 | return 0; | |
718e3744 | 551 | } |
552 | ||
553 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
554 | /* This is used only for configuration, so disallow if attempted on |
555 | * a dynamic neighbor. | |
556 | */ | |
d62a17ae | 557 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
558 | { | |
559 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
560 | int ret; | |
561 | union sockunion su; | |
562 | struct peer *peer; | |
563 | ||
564 | if (!bgp) { | |
565 | return NULL; | |
566 | } | |
567 | ||
568 | ret = str2sockunion(ip_str, &su); | |
569 | if (ret < 0) { | |
570 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
571 | if (!peer) { | |
572 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
573 | == NULL) { | |
574 | vty_out(vty, | |
575 | "%% Malformed address or name: %s\n", | |
576 | ip_str); | |
577 | return NULL; | |
578 | } | |
579 | } | |
580 | } else { | |
581 | peer = peer_lookup(bgp, &su); | |
582 | if (!peer) { | |
583 | vty_out(vty, | |
584 | "%% Specify remote-as or peer-group commands first\n"); | |
585 | return NULL; | |
586 | } | |
587 | if (peer_dynamic_neighbor(peer)) { | |
588 | vty_out(vty, | |
589 | "%% Operation not allowed on a dynamic neighbor\n"); | |
590 | return NULL; | |
591 | } | |
592 | } | |
593 | return peer; | |
718e3744 | 594 | } |
595 | ||
596 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
597 | /* This is used only for configuration, so disallow if attempted on |
598 | * a dynamic neighbor. | |
599 | */ | |
d62a17ae | 600 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
601 | { | |
602 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
603 | int ret; | |
604 | union sockunion su; | |
605 | struct peer *peer = NULL; | |
606 | struct peer_group *group = NULL; | |
607 | ||
608 | if (!bgp) { | |
609 | return NULL; | |
610 | } | |
611 | ||
612 | ret = str2sockunion(peer_str, &su); | |
613 | if (ret == 0) { | |
614 | /* IP address, locate peer. */ | |
615 | peer = peer_lookup(bgp, &su); | |
616 | } else { | |
617 | /* Not IP, could match either peer configured on interface or a | |
618 | * group. */ | |
619 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
620 | if (!peer) | |
621 | group = peer_group_lookup(bgp, peer_str); | |
622 | } | |
623 | ||
624 | if (peer) { | |
625 | if (peer_dynamic_neighbor(peer)) { | |
626 | vty_out(vty, | |
627 | "%% Operation not allowed on a dynamic neighbor\n"); | |
628 | return NULL; | |
629 | } | |
630 | ||
631 | return peer; | |
632 | } | |
633 | ||
634 | if (group) | |
635 | return group->conf; | |
636 | ||
637 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
638 | ||
639 | return NULL; | |
640 | } | |
641 | ||
642 | int bgp_vty_return(struct vty *vty, int ret) | |
643 | { | |
644 | const char *str = NULL; | |
645 | ||
646 | switch (ret) { | |
647 | case BGP_ERR_INVALID_VALUE: | |
648 | str = "Invalid value"; | |
649 | break; | |
650 | case BGP_ERR_INVALID_FLAG: | |
651 | str = "Invalid flag"; | |
652 | break; | |
653 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
654 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
655 | break; | |
656 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
657 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
658 | break; | |
659 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
660 | str = "Specify remote-as or peer-group remote AS first"; | |
661 | break; | |
662 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
663 | str = "Cannot change the peer-group. Deconfigure first"; | |
664 | break; | |
665 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
666 | str = "Peer is not a member of this peer-group"; | |
667 | break; | |
668 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
669 | str = "Prefix/distribute list can not co-exist"; | |
670 | break; | |
671 | case BGP_ERR_NOT_INTERNAL_PEER: | |
672 | str = "Invalid command. Not an internal neighbor"; | |
673 | break; | |
674 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
675 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
676 | break; | |
677 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
678 | str = "Local-AS allowed only for EBGP peers"; | |
679 | break; | |
680 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
681 | str = "Cannot have local-as same as BGP AS number"; | |
682 | break; | |
683 | case BGP_ERR_TCPSIG_FAILED: | |
684 | str = "Error while applying TCP-Sig to session(s)"; | |
685 | break; | |
686 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
687 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
688 | break; | |
689 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
690 | str = "ttl-security only allowed for EBGP peers"; | |
691 | break; | |
692 | case BGP_ERR_AS_OVERRIDE: | |
693 | str = "as-override cannot be configured for IBGP peers"; | |
694 | break; | |
695 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
696 | str = "Invalid limit for number of dynamic neighbors"; | |
697 | break; | |
698 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
699 | str = "Dynamic neighbor listen range already exists"; | |
700 | break; | |
701 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
702 | str = "Operation not allowed on a dynamic neighbor"; | |
703 | break; | |
704 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
705 | str = "Operation not allowed on a directly connected neighbor"; | |
706 | break; | |
707 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 708 | str = GR_INVALID; |
709 | break; | |
710 | case BGP_ERR_GR_INVALID_CMD: | |
711 | str = "The Graceful Restart command used is not valid at this moment."; | |
712 | break; | |
713 | case BGP_ERR_GR_OPERATION_FAILED: | |
714 | str = "The Graceful Restart Operation failed due to an err."; | |
715 | break; | |
716 | case BGP_GR_NO_OPERATION: | |
717 | str = GR_NO_OPER; | |
d62a17ae | 718 | break; |
719 | } | |
720 | if (str) { | |
721 | vty_out(vty, "%% %s\n", str); | |
722 | return CMD_WARNING_CONFIG_FAILED; | |
723 | } | |
724 | return CMD_SUCCESS; | |
718e3744 | 725 | } |
726 | ||
7aafcaca | 727 | /* BGP clear sort. */ |
d62a17ae | 728 | enum clear_sort { |
729 | clear_all, | |
730 | clear_peer, | |
731 | clear_group, | |
732 | clear_external, | |
733 | clear_as | |
7aafcaca DS |
734 | }; |
735 | ||
d62a17ae | 736 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
737 | safi_t safi, int error) | |
738 | { | |
739 | switch (error) { | |
740 | case BGP_ERR_AF_UNCONFIGURED: | |
741 | vty_out(vty, | |
742 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 743 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 744 | break; |
745 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
746 | vty_out(vty, | |
747 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
748 | peer->host); | |
749 | break; | |
750 | default: | |
751 | break; | |
752 | } | |
7aafcaca DS |
753 | } |
754 | ||
dc912615 | 755 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 756 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
757 | { |
758 | int ret = 0; | |
759 | ||
760 | /* if afi/.safi not specified, spin thru all of them */ | |
761 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
762 | afi_t tmp_afi; | |
763 | safi_t tmp_safi; | |
764 | ||
765 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
766 | if (!peer->afc[tmp_afi][tmp_safi]) | |
767 | continue; | |
768 | ||
769 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 770 | ret = peer_clear(peer, nnode); |
dc912615 DS |
771 | else |
772 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
773 | stype); | |
774 | } | |
775 | /* if afi specified and safi not, spin thru safis on this afi */ | |
776 | } else if (safi == SAFI_UNSPEC) { | |
777 | safi_t tmp_safi; | |
778 | ||
779 | for (tmp_safi = SAFI_UNICAST; | |
780 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
781 | if (!peer->afc[afi][tmp_safi]) | |
782 | continue; | |
783 | ||
784 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 785 | ret = peer_clear(peer, nnode); |
dc912615 DS |
786 | else |
787 | ret = peer_clear_soft(peer, afi, | |
788 | tmp_safi, stype); | |
789 | } | |
790 | /* both afi/safi specified, let the caller know if not defined */ | |
791 | } else { | |
792 | if (!peer->afc[afi][safi]) | |
793 | return 1; | |
794 | ||
795 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 796 | ret = peer_clear(peer, nnode); |
dc912615 DS |
797 | else |
798 | ret = peer_clear_soft(peer, afi, safi, stype); | |
799 | } | |
800 | ||
801 | return ret; | |
802 | } | |
803 | ||
7aafcaca | 804 | /* `clear ip bgp' functions. */ |
d62a17ae | 805 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
806 | enum clear_sort sort, enum bgp_clear_type stype, | |
807 | const char *arg) | |
808 | { | |
dc912615 | 809 | int ret = 0; |
3ae8bfa5 | 810 | bool found = false; |
d62a17ae | 811 | struct peer *peer; |
dc95985f | 812 | |
813 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 814 | |
815 | /* Clear all neighbors. */ | |
816 | /* | |
817 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
818 | * nodes on the BGP instance as that may get freed if it is a |
819 | * doppelganger | |
d62a17ae | 820 | */ |
821 | if (sort == clear_all) { | |
822 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 823 | |
824 | bgp_peer_gr_flags_update(peer); | |
825 | ||
36235319 | 826 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 827 | gr_router_detected = true; |
828 | ||
c368171c | 829 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 830 | stype); |
d62a17ae | 831 | |
832 | if (ret < 0) | |
833 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
dc95985f | 834 | } |
835 | ||
36235319 QY |
836 | if (gr_router_detected |
837 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 838 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
839 | } else if (!gr_router_detected |
840 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 841 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 842 | } |
d62a17ae | 843 | |
844 | /* This is to apply read-only mode on this clear. */ | |
845 | if (stype == BGP_CLEAR_SOFT_NONE) | |
846 | bgp->update_delay_over = 0; | |
847 | ||
848 | return CMD_SUCCESS; | |
7aafcaca DS |
849 | } |
850 | ||
3ae8bfa5 | 851 | /* Clear specified neighbor. */ |
d62a17ae | 852 | if (sort == clear_peer) { |
853 | union sockunion su; | |
d62a17ae | 854 | |
855 | /* Make sockunion for lookup. */ | |
856 | ret = str2sockunion(arg, &su); | |
857 | if (ret < 0) { | |
858 | peer = peer_lookup_by_conf_if(bgp, arg); | |
859 | if (!peer) { | |
860 | peer = peer_lookup_by_hostname(bgp, arg); | |
861 | if (!peer) { | |
862 | vty_out(vty, | |
863 | "Malformed address or name: %s\n", | |
864 | arg); | |
865 | return CMD_WARNING; | |
866 | } | |
867 | } | |
868 | } else { | |
869 | peer = peer_lookup(bgp, &su); | |
870 | if (!peer) { | |
871 | vty_out(vty, | |
872 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
873 | arg); | |
874 | return CMD_WARNING; | |
875 | } | |
876 | } | |
7aafcaca | 877 | |
dc95985f | 878 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
879 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
880 | ||
dc912615 DS |
881 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
882 | ||
883 | /* if afi/safi not defined for this peer, let caller know */ | |
884 | if (ret == 1) | |
3ae8bfa5 | 885 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 886 | |
d62a17ae | 887 | if (ret < 0) |
888 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 889 | |
d62a17ae | 890 | return CMD_SUCCESS; |
7aafcaca | 891 | } |
7aafcaca | 892 | |
3ae8bfa5 | 893 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 894 | if (sort == clear_group) { |
895 | struct peer_group *group; | |
7aafcaca | 896 | |
d62a17ae | 897 | group = peer_group_lookup(bgp, arg); |
898 | if (!group) { | |
899 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
900 | return CMD_WARNING; | |
901 | } | |
902 | ||
903 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 904 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 905 | |
d62a17ae | 906 | if (ret < 0) |
907 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
908 | else |
909 | found = true; | |
d62a17ae | 910 | } |
3ae8bfa5 PM |
911 | |
912 | if (!found) | |
913 | vty_out(vty, | |
914 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 915 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 916 | |
d62a17ae | 917 | return CMD_SUCCESS; |
7aafcaca | 918 | } |
7aafcaca | 919 | |
3ae8bfa5 | 920 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 921 | if (sort == clear_external) { |
922 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
923 | if (peer->sort == BGP_PEER_IBGP) | |
924 | continue; | |
7aafcaca | 925 | |
dc95985f | 926 | bgp_peer_gr_flags_update(peer); |
927 | ||
36235319 | 928 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 929 | gr_router_detected = true; |
dc95985f | 930 | |
c368171c | 931 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 932 | |
d62a17ae | 933 | if (ret < 0) |
934 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
935 | else |
936 | found = true; | |
d62a17ae | 937 | } |
3ae8bfa5 | 938 | |
36235319 QY |
939 | if (gr_router_detected |
940 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 941 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
942 | } else if (!gr_router_detected |
943 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 944 | bgp_zebra_send_capabilities(bgp, true); |
945 | } | |
946 | ||
3ae8bfa5 PM |
947 | if (!found) |
948 | vty_out(vty, | |
949 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 950 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 951 | |
d62a17ae | 952 | return CMD_SUCCESS; |
953 | } | |
954 | ||
3ae8bfa5 | 955 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 956 | if (sort == clear_as) { |
3ae8bfa5 | 957 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 958 | |
959 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
960 | if (peer->as != as) | |
961 | continue; | |
962 | ||
dc95985f | 963 | bgp_peer_gr_flags_update(peer); |
964 | ||
36235319 | 965 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 966 | gr_router_detected = true; |
dc95985f | 967 | |
c368171c | 968 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 969 | |
970 | if (ret < 0) | |
971 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
972 | else |
973 | found = true; | |
d62a17ae | 974 | } |
3ae8bfa5 | 975 | |
36235319 QY |
976 | if (gr_router_detected |
977 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 978 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
979 | } else if (!gr_router_detected |
980 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 981 | bgp_zebra_send_capabilities(bgp, true); |
982 | } | |
983 | ||
3ae8bfa5 | 984 | if (!found) |
d62a17ae | 985 | vty_out(vty, |
3ae8bfa5 | 986 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 987 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 988 | |
d62a17ae | 989 | return CMD_SUCCESS; |
990 | } | |
991 | ||
992 | return CMD_SUCCESS; | |
993 | } | |
994 | ||
995 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
996 | safi_t safi, enum clear_sort sort, | |
997 | enum bgp_clear_type stype, const char *arg) | |
998 | { | |
999 | struct bgp *bgp; | |
1000 | ||
1001 | /* BGP structure lookup. */ | |
1002 | if (name) { | |
1003 | bgp = bgp_lookup_by_name(name); | |
1004 | if (bgp == NULL) { | |
1005 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1006 | return CMD_WARNING; | |
1007 | } | |
1008 | } else { | |
1009 | bgp = bgp_get_default(); | |
1010 | if (bgp == NULL) { | |
1011 | vty_out(vty, "No BGP process is configured\n"); | |
1012 | return CMD_WARNING; | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
1017 | } |
1018 | ||
1019 | /* clear soft inbound */ | |
d62a17ae | 1020 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1021 | { |
99b3ebd3 NS |
1022 | afi_t afi; |
1023 | safi_t safi; | |
1024 | ||
1025 | FOREACH_AFI_SAFI (afi, safi) | |
1026 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1027 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1028 | } |
1029 | ||
1030 | /* clear soft outbound */ | |
d62a17ae | 1031 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1032 | { |
99b3ebd3 NS |
1033 | afi_t afi; |
1034 | safi_t safi; | |
1035 | ||
1036 | FOREACH_AFI_SAFI (afi, safi) | |
1037 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1038 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1039 | } |
1040 | ||
1041 | ||
f787d7a0 | 1042 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1043 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1044 | #endif |
1045 | ||
8029b216 AK |
1046 | DEFUN_HIDDEN (bgp_local_mac, |
1047 | bgp_local_mac_cmd, | |
093e3f23 | 1048 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1049 | BGP_STR |
1050 | "Local MAC config\n" | |
1051 | "VxLAN Network Identifier\n" | |
1052 | "VNI number\n" | |
1053 | "local mac\n" | |
1054 | "mac address\n" | |
1055 | "mac-mobility sequence\n" | |
1056 | "seq number\n") | |
1057 | { | |
1058 | int rv; | |
1059 | vni_t vni; | |
1060 | struct ethaddr mac; | |
1061 | struct ipaddr ip; | |
1062 | uint32_t seq; | |
1063 | struct bgp *bgp; | |
1064 | ||
1065 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1066 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1067 | vty_out(vty, "%% Malformed MAC address\n"); | |
1068 | return CMD_WARNING; | |
1069 | } | |
1070 | memset(&ip, 0, sizeof(ip)); | |
1071 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1072 | ||
1073 | bgp = bgp_get_default(); | |
1074 | if (!bgp) { | |
1075 | vty_out(vty, "Default BGP instance is not there\n"); | |
1076 | return CMD_WARNING; | |
1077 | } | |
1078 | ||
1079 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1080 | if (rv < 0) { | |
1081 | vty_out(vty, "Internal error\n"); | |
1082 | return CMD_WARNING; | |
1083 | } | |
1084 | ||
1085 | return CMD_SUCCESS; | |
1086 | } | |
1087 | ||
1088 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1089 | no_bgp_local_mac_cmd, | |
093e3f23 | 1090 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1091 | NO_STR |
1092 | BGP_STR | |
1093 | "Local MAC config\n" | |
1094 | "VxLAN Network Identifier\n" | |
1095 | "VNI number\n" | |
1096 | "local mac\n" | |
1097 | "mac address\n") | |
1098 | { | |
1099 | int rv; | |
1100 | vni_t vni; | |
1101 | struct ethaddr mac; | |
1102 | struct ipaddr ip; | |
1103 | struct bgp *bgp; | |
1104 | ||
1105 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1106 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1107 | vty_out(vty, "%% Malformed MAC address\n"); | |
1108 | return CMD_WARNING; | |
1109 | } | |
1110 | memset(&ip, 0, sizeof(ip)); | |
1111 | ||
1112 | bgp = bgp_get_default(); | |
1113 | if (!bgp) { | |
1114 | vty_out(vty, "Default BGP instance is not there\n"); | |
1115 | return CMD_WARNING; | |
1116 | } | |
1117 | ||
ec0ab544 | 1118 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1119 | if (rv < 0) { |
1120 | vty_out(vty, "Internal error\n"); | |
1121 | return CMD_WARNING; | |
1122 | } | |
1123 | ||
1124 | return CMD_SUCCESS; | |
1125 | } | |
1126 | ||
718e3744 | 1127 | DEFUN (no_synchronization, |
1128 | no_synchronization_cmd, | |
1129 | "no synchronization", | |
1130 | NO_STR | |
1131 | "Perform IGP synchronization\n") | |
1132 | { | |
d62a17ae | 1133 | return CMD_SUCCESS; |
718e3744 | 1134 | } |
1135 | ||
1136 | DEFUN (no_auto_summary, | |
1137 | no_auto_summary_cmd, | |
1138 | "no auto-summary", | |
1139 | NO_STR | |
1140 | "Enable automatic network number summarization\n") | |
1141 | { | |
d62a17ae | 1142 | return CMD_SUCCESS; |
718e3744 | 1143 | } |
3d515fd9 | 1144 | |
718e3744 | 1145 | /* "router bgp" commands. */ |
505e5056 | 1146 | DEFUN_NOSH (router_bgp, |
f412b39a | 1147 | router_bgp_cmd, |
2ed9fe4a | 1148 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1149 | ROUTER_STR |
1150 | BGP_STR | |
31500417 DW |
1151 | AS_STR |
1152 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1153 | { |
d62a17ae | 1154 | int idx_asn = 2; |
1155 | int idx_view_vrf = 3; | |
1156 | int idx_vrf = 4; | |
ecec9495 | 1157 | int is_new_bgp = 0; |
d62a17ae | 1158 | int ret; |
1159 | as_t as; | |
1160 | struct bgp *bgp; | |
1161 | const char *name = NULL; | |
1162 | enum bgp_instance_type inst_type; | |
1163 | ||
1164 | // "router bgp" without an ASN | |
1165 | if (argc == 2) { | |
1166 | // Pending: Make VRF option available for ASN less config | |
1167 | bgp = bgp_get_default(); | |
1168 | ||
1169 | if (bgp == NULL) { | |
1170 | vty_out(vty, "%% No BGP process is configured\n"); | |
1171 | return CMD_WARNING_CONFIG_FAILED; | |
1172 | } | |
1173 | ||
1174 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1175 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1176 | return CMD_WARNING_CONFIG_FAILED; |
1177 | } | |
1178 | } | |
1179 | ||
1180 | // "router bgp X" | |
1181 | else { | |
1182 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1183 | ||
1184 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1185 | if (argc > 3) { | |
1186 | name = argv[idx_vrf]->arg; | |
1187 | ||
9a8bdf1c PG |
1188 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1189 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1190 | name = NULL; | |
1191 | else | |
1192 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1193 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1194 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1195 | } | |
1196 | ||
ecec9495 AD |
1197 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1198 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1199 | ||
5d5393b9 | 1200 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1201 | switch (ret) { |
d62a17ae | 1202 | case BGP_ERR_AS_MISMATCH: |
1203 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1204 | return CMD_WARNING_CONFIG_FAILED; | |
1205 | case BGP_ERR_INSTANCE_MISMATCH: | |
1206 | vty_out(vty, | |
1207 | "BGP instance name and AS number mismatch\n"); | |
1208 | vty_out(vty, | |
1209 | "BGP instance is already running; AS is %u\n", | |
1210 | as); | |
1211 | return CMD_WARNING_CONFIG_FAILED; | |
1212 | } | |
1213 | ||
3bd70bf8 PZ |
1214 | /* |
1215 | * If we just instantiated the default instance, complete | |
1216 | * any pending VRF-VPN leaking that was configured via | |
1217 | * earlier "router bgp X vrf FOO" blocks. | |
1218 | */ | |
ecec9495 | 1219 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1220 | vpn_leak_postchange_all(); |
1221 | ||
48381346 CS |
1222 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1223 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1224 | /* Pending: handle when user tries to change a view to vrf n vv. |
1225 | */ | |
1226 | } | |
1227 | ||
0b5131c9 MK |
1228 | /* unset the auto created flag as the user config is now present */ |
1229 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1230 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1231 | ||
1232 | return CMD_SUCCESS; | |
718e3744 | 1233 | } |
1234 | ||
718e3744 | 1235 | /* "no router bgp" commands. */ |
1236 | DEFUN (no_router_bgp, | |
1237 | no_router_bgp_cmd, | |
2ed9fe4a | 1238 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1239 | NO_STR |
1240 | ROUTER_STR | |
1241 | BGP_STR | |
31500417 DW |
1242 | AS_STR |
1243 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1244 | { |
d62a17ae | 1245 | int idx_asn = 3; |
1246 | int idx_vrf = 5; | |
1247 | as_t as; | |
1248 | struct bgp *bgp; | |
1249 | const char *name = NULL; | |
718e3744 | 1250 | |
d62a17ae | 1251 | // "no router bgp" without an ASN |
1252 | if (argc == 3) { | |
1253 | // Pending: Make VRF option available for ASN less config | |
1254 | bgp = bgp_get_default(); | |
718e3744 | 1255 | |
d62a17ae | 1256 | if (bgp == NULL) { |
1257 | vty_out(vty, "%% No BGP process is configured\n"); | |
1258 | return CMD_WARNING_CONFIG_FAILED; | |
1259 | } | |
7fb21a9f | 1260 | |
d62a17ae | 1261 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1262 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1263 | return CMD_WARNING_CONFIG_FAILED; |
1264 | } | |
0b5131c9 MK |
1265 | |
1266 | if (bgp->l3vni) { | |
1267 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1268 | bgp->l3vni); | |
1269 | return CMD_WARNING_CONFIG_FAILED; | |
1270 | } | |
d62a17ae | 1271 | } else { |
1272 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1273 | |
d62a17ae | 1274 | if (argc > 4) |
1275 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1276 | |
d62a17ae | 1277 | /* Lookup bgp structure. */ |
1278 | bgp = bgp_lookup(as, name); | |
1279 | if (!bgp) { | |
1280 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1281 | return CMD_WARNING_CONFIG_FAILED; | |
1282 | } | |
0b5131c9 MK |
1283 | |
1284 | if (bgp->l3vni) { | |
dd5868c2 | 1285 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1286 | bgp->l3vni); |
1287 | return CMD_WARNING_CONFIG_FAILED; | |
1288 | } | |
dd5868c2 DS |
1289 | |
1290 | /* Cannot delete default instance if vrf instances exist */ | |
1291 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1292 | struct listnode *node; | |
1293 | struct bgp *tmp_bgp; | |
1294 | ||
1295 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1296 | if (tmp_bgp->inst_type | |
1297 | == BGP_INSTANCE_TYPE_VRF) { | |
1298 | vty_out(vty, | |
1299 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1300 | return CMD_WARNING_CONFIG_FAILED; | |
1301 | } | |
1302 | } | |
1303 | } | |
d62a17ae | 1304 | } |
718e3744 | 1305 | |
9ecf931b CS |
1306 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1307 | return CMD_WARNING_CONFIG_FAILED; | |
1308 | ||
d62a17ae | 1309 | bgp_delete(bgp); |
718e3744 | 1310 | |
d62a17ae | 1311 | return CMD_SUCCESS; |
718e3744 | 1312 | } |
1313 | ||
6b0655a2 | 1314 | |
718e3744 | 1315 | /* BGP router-id. */ |
1316 | ||
f787d7a0 | 1317 | DEFPY (bgp_router_id, |
718e3744 | 1318 | bgp_router_id_cmd, |
1319 | "bgp router-id A.B.C.D", | |
1320 | BGP_STR | |
1321 | "Override configured router identifier\n" | |
1322 | "Manually configured router identifier\n") | |
1323 | { | |
d62a17ae | 1324 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1325 | bgp_router_id_static_set(bgp, router_id); | |
1326 | return CMD_SUCCESS; | |
718e3744 | 1327 | } |
1328 | ||
f787d7a0 | 1329 | DEFPY (no_bgp_router_id, |
718e3744 | 1330 | no_bgp_router_id_cmd, |
31500417 | 1331 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1332 | NO_STR |
1333 | BGP_STR | |
31500417 DW |
1334 | "Override configured router identifier\n" |
1335 | "Manually configured router identifier\n") | |
718e3744 | 1336 | { |
d62a17ae | 1337 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1338 | |
d62a17ae | 1339 | if (router_id_str) { |
1340 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1341 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1342 | return CMD_WARNING_CONFIG_FAILED; | |
1343 | } | |
e018c7cc | 1344 | } |
718e3744 | 1345 | |
d62a17ae | 1346 | router_id.s_addr = 0; |
1347 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1348 | |
d62a17ae | 1349 | return CMD_SUCCESS; |
718e3744 | 1350 | } |
1351 | ||
6b0655a2 | 1352 | |
718e3744 | 1353 | /* BGP Cluster ID. */ |
718e3744 | 1354 | DEFUN (bgp_cluster_id, |
1355 | bgp_cluster_id_cmd, | |
838758ac | 1356 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1357 | BGP_STR |
1358 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1359 | "Route-Reflector Cluster-id in IP address format\n" |
1360 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1361 | { |
d62a17ae | 1362 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1363 | int idx_ipv4 = 2; | |
1364 | int ret; | |
1365 | struct in_addr cluster; | |
718e3744 | 1366 | |
d62a17ae | 1367 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1368 | if (!ret) { | |
1369 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1370 | return CMD_WARNING_CONFIG_FAILED; | |
1371 | } | |
718e3744 | 1372 | |
d62a17ae | 1373 | bgp_cluster_id_set(bgp, &cluster); |
1374 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1375 | |
d62a17ae | 1376 | return CMD_SUCCESS; |
718e3744 | 1377 | } |
1378 | ||
718e3744 | 1379 | DEFUN (no_bgp_cluster_id, |
1380 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1381 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1382 | NO_STR |
1383 | BGP_STR | |
838758ac DW |
1384 | "Configure Route-Reflector Cluster-id\n" |
1385 | "Route-Reflector Cluster-id in IP address format\n" | |
1386 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1387 | { |
d62a17ae | 1388 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1389 | bgp_cluster_id_unset(bgp); | |
1390 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1391 | |
d62a17ae | 1392 | return CMD_SUCCESS; |
718e3744 | 1393 | } |
1394 | ||
718e3744 | 1395 | DEFUN (bgp_confederation_identifier, |
1396 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1397 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1398 | "BGP specific commands\n" |
1399 | "AS confederation parameters\n" | |
1400 | "AS number\n" | |
1401 | "Set routing domain confederation AS\n") | |
1402 | { | |
d62a17ae | 1403 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1404 | int idx_number = 3; | |
1405 | as_t as; | |
718e3744 | 1406 | |
d62a17ae | 1407 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1408 | |
d62a17ae | 1409 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1410 | |
d62a17ae | 1411 | return CMD_SUCCESS; |
718e3744 | 1412 | } |
1413 | ||
1414 | DEFUN (no_bgp_confederation_identifier, | |
1415 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1416 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1417 | NO_STR |
1418 | "BGP specific commands\n" | |
1419 | "AS confederation parameters\n" | |
3a2d747c QY |
1420 | "AS number\n" |
1421 | "Set routing domain confederation AS\n") | |
718e3744 | 1422 | { |
d62a17ae | 1423 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1424 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1425 | |
d62a17ae | 1426 | return CMD_SUCCESS; |
718e3744 | 1427 | } |
1428 | ||
718e3744 | 1429 | DEFUN (bgp_confederation_peers, |
1430 | bgp_confederation_peers_cmd, | |
12dcf78e | 1431 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1432 | "BGP specific commands\n" |
1433 | "AS confederation parameters\n" | |
1434 | "Peer ASs in BGP confederation\n" | |
1435 | AS_STR) | |
1436 | { | |
d62a17ae | 1437 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1438 | int idx_asn = 3; | |
1439 | as_t as; | |
1440 | int i; | |
718e3744 | 1441 | |
d62a17ae | 1442 | for (i = idx_asn; i < argc; i++) { |
1443 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1444 | |
d62a17ae | 1445 | if (bgp->as == as) { |
1446 | vty_out(vty, | |
1447 | "%% Local member-AS not allowed in confed peer list\n"); | |
1448 | continue; | |
1449 | } | |
718e3744 | 1450 | |
d62a17ae | 1451 | bgp_confederation_peers_add(bgp, as); |
1452 | } | |
1453 | return CMD_SUCCESS; | |
718e3744 | 1454 | } |
1455 | ||
1456 | DEFUN (no_bgp_confederation_peers, | |
1457 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1458 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1459 | NO_STR |
1460 | "BGP specific commands\n" | |
1461 | "AS confederation parameters\n" | |
1462 | "Peer ASs in BGP confederation\n" | |
1463 | AS_STR) | |
1464 | { | |
d62a17ae | 1465 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1466 | int idx_asn = 4; | |
1467 | as_t as; | |
1468 | int i; | |
718e3744 | 1469 | |
d62a17ae | 1470 | for (i = idx_asn; i < argc; i++) { |
1471 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1472 | |
d62a17ae | 1473 | bgp_confederation_peers_remove(bgp, as); |
1474 | } | |
1475 | return CMD_SUCCESS; | |
718e3744 | 1476 | } |
6b0655a2 | 1477 | |
5e242b0d DS |
1478 | /** |
1479 | * Central routine for maximum-paths configuration. | |
1480 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1481 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1482 | */ | |
d62a17ae | 1483 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1484 | const char *mpaths, uint16_t options, |
d62a17ae | 1485 | int set) |
1486 | { | |
1487 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1488 | uint16_t maxpaths = 0; |
d62a17ae | 1489 | int ret; |
1490 | afi_t afi; | |
1491 | safi_t safi; | |
1492 | ||
1493 | afi = bgp_node_afi(vty); | |
1494 | safi = bgp_node_safi(vty); | |
1495 | ||
1496 | if (set) { | |
1497 | maxpaths = strtol(mpaths, NULL, 10); | |
1498 | if (maxpaths > multipath_num) { | |
1499 | vty_out(vty, | |
1500 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1501 | maxpaths, multipath_num); | |
1502 | return CMD_WARNING_CONFIG_FAILED; | |
1503 | } | |
1504 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1505 | options); | |
1506 | } else | |
1507 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1508 | ||
1509 | if (ret < 0) { | |
1510 | vty_out(vty, | |
1511 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1512 | (set == 1) ? "" : "un", | |
1513 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1514 | maxpaths, afi, safi); | |
1515 | return CMD_WARNING_CONFIG_FAILED; | |
1516 | } | |
1517 | ||
1518 | bgp_recalculate_all_bestpaths(bgp); | |
1519 | ||
1520 | return CMD_SUCCESS; | |
165b5fff JB |
1521 | } |
1522 | ||
abc920f8 DS |
1523 | DEFUN (bgp_maxmed_admin, |
1524 | bgp_maxmed_admin_cmd, | |
1525 | "bgp max-med administrative ", | |
1526 | BGP_STR | |
1527 | "Advertise routes with max-med\n" | |
1528 | "Administratively applied, for an indefinite period\n") | |
1529 | { | |
d62a17ae | 1530 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1531 | |
d62a17ae | 1532 | bgp->v_maxmed_admin = 1; |
1533 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1534 | |
d62a17ae | 1535 | bgp_maxmed_update(bgp); |
abc920f8 | 1536 | |
d62a17ae | 1537 | return CMD_SUCCESS; |
abc920f8 DS |
1538 | } |
1539 | ||
1540 | DEFUN (bgp_maxmed_admin_medv, | |
1541 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1542 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1543 | BGP_STR |
1544 | "Advertise routes with max-med\n" | |
1545 | "Administratively applied, for an indefinite period\n" | |
1546 | "Max MED value to be used\n") | |
1547 | { | |
d62a17ae | 1548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1549 | int idx_number = 3; | |
abc920f8 | 1550 | |
d62a17ae | 1551 | bgp->v_maxmed_admin = 1; |
1552 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1553 | |
d62a17ae | 1554 | bgp_maxmed_update(bgp); |
abc920f8 | 1555 | |
d62a17ae | 1556 | return CMD_SUCCESS; |
abc920f8 DS |
1557 | } |
1558 | ||
1559 | DEFUN (no_bgp_maxmed_admin, | |
1560 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1561 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1562 | NO_STR |
1563 | BGP_STR | |
1564 | "Advertise routes with max-med\n" | |
838758ac DW |
1565 | "Administratively applied, for an indefinite period\n" |
1566 | "Max MED value to be used\n") | |
abc920f8 | 1567 | { |
d62a17ae | 1568 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1569 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1570 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1571 | bgp_maxmed_update(bgp); | |
abc920f8 | 1572 | |
d62a17ae | 1573 | return CMD_SUCCESS; |
abc920f8 DS |
1574 | } |
1575 | ||
abc920f8 DS |
1576 | DEFUN (bgp_maxmed_onstartup, |
1577 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1578 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1579 | BGP_STR |
1580 | "Advertise routes with max-med\n" | |
1581 | "Effective on a startup\n" | |
1582 | "Time (seconds) period for max-med\n" | |
1583 | "Max MED value to be used\n") | |
1584 | { | |
d62a17ae | 1585 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1586 | int idx = 0; | |
4668a151 | 1587 | |
d62a17ae | 1588 | argv_find(argv, argc, "(5-86400)", &idx); |
1589 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1590 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1591 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1592 | else | |
1593 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1594 | |
d62a17ae | 1595 | bgp_maxmed_update(bgp); |
abc920f8 | 1596 | |
d62a17ae | 1597 | return CMD_SUCCESS; |
abc920f8 DS |
1598 | } |
1599 | ||
1600 | DEFUN (no_bgp_maxmed_onstartup, | |
1601 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1602 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1603 | NO_STR |
1604 | BGP_STR | |
1605 | "Advertise routes with max-med\n" | |
838758ac DW |
1606 | "Effective on a startup\n" |
1607 | "Time (seconds) period for max-med\n" | |
1608 | "Max MED value to be used\n") | |
abc920f8 | 1609 | { |
d62a17ae | 1610 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1611 | |
d62a17ae | 1612 | /* Cancel max-med onstartup if its on */ |
1613 | if (bgp->t_maxmed_onstartup) { | |
1614 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1615 | bgp->maxmed_onstartup_over = 1; | |
1616 | } | |
abc920f8 | 1617 | |
d62a17ae | 1618 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1619 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1620 | |
d62a17ae | 1621 | bgp_maxmed_update(bgp); |
abc920f8 | 1622 | |
d62a17ae | 1623 | return CMD_SUCCESS; |
abc920f8 DS |
1624 | } |
1625 | ||
d62a17ae | 1626 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1627 | const char *wait) | |
f188f2c4 | 1628 | { |
d62a17ae | 1629 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1630 | uint16_t update_delay; |
1631 | uint16_t establish_wait; | |
f188f2c4 | 1632 | |
d62a17ae | 1633 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1634 | |
d62a17ae | 1635 | if (!wait) /* update-delay <delay> */ |
1636 | { | |
1637 | bgp->v_update_delay = update_delay; | |
1638 | bgp->v_establish_wait = bgp->v_update_delay; | |
1639 | return CMD_SUCCESS; | |
1640 | } | |
f188f2c4 | 1641 | |
d62a17ae | 1642 | /* update-delay <delay> <establish-wait> */ |
1643 | establish_wait = atoi(wait); | |
1644 | if (update_delay < establish_wait) { | |
1645 | vty_out(vty, | |
1646 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1647 | return CMD_WARNING_CONFIG_FAILED; | |
1648 | } | |
f188f2c4 | 1649 | |
d62a17ae | 1650 | bgp->v_update_delay = update_delay; |
1651 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1652 | |
d62a17ae | 1653 | return CMD_SUCCESS; |
f188f2c4 DS |
1654 | } |
1655 | ||
d62a17ae | 1656 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1657 | { |
d62a17ae | 1658 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1659 | |
d62a17ae | 1660 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1661 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1662 | |
d62a17ae | 1663 | return CMD_SUCCESS; |
f188f2c4 DS |
1664 | } |
1665 | ||
2b791107 | 1666 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1667 | { |
d62a17ae | 1668 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1669 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1670 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1671 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1672 | vty_out(vty, "\n"); | |
1673 | } | |
f188f2c4 DS |
1674 | } |
1675 | ||
1676 | ||
1677 | /* Update-delay configuration */ | |
1678 | DEFUN (bgp_update_delay, | |
1679 | bgp_update_delay_cmd, | |
6147e2c6 | 1680 | "update-delay (0-3600)", |
f188f2c4 DS |
1681 | "Force initial delay for best-path and updates\n" |
1682 | "Seconds\n") | |
1683 | { | |
d62a17ae | 1684 | int idx_number = 1; |
1685 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1686 | } |
1687 | ||
1688 | DEFUN (bgp_update_delay_establish_wait, | |
1689 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1690 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1691 | "Force initial delay for best-path and updates\n" |
1692 | "Seconds\n" | |
f188f2c4 DS |
1693 | "Seconds\n") |
1694 | { | |
d62a17ae | 1695 | int idx_number = 1; |
1696 | int idx_number_2 = 2; | |
1697 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1698 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1699 | } |
1700 | ||
1701 | /* Update-delay deconfiguration */ | |
1702 | DEFUN (no_bgp_update_delay, | |
1703 | no_bgp_update_delay_cmd, | |
838758ac DW |
1704 | "no update-delay [(0-3600) [(1-3600)]]", |
1705 | NO_STR | |
f188f2c4 | 1706 | "Force initial delay for best-path and updates\n" |
838758ac | 1707 | "Seconds\n" |
7111c1a0 | 1708 | "Seconds\n") |
f188f2c4 | 1709 | { |
d62a17ae | 1710 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1711 | } |
1712 | ||
5e242b0d | 1713 | |
8fa7732f QY |
1714 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1715 | bool set) | |
cb1faec9 | 1716 | { |
d62a17ae | 1717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1718 | |
8fa7732f QY |
1719 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1720 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1721 | |
1722 | return CMD_SUCCESS; | |
1723 | } | |
1724 | ||
8fa7732f QY |
1725 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1726 | bool set) | |
555e09d4 QY |
1727 | { |
1728 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1729 | ||
8fa7732f QY |
1730 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1731 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1732 | |
d62a17ae | 1733 | return CMD_SUCCESS; |
cb1faec9 DS |
1734 | } |
1735 | ||
2b791107 | 1736 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1737 | { |
555e09d4 QY |
1738 | uint32_t quanta = |
1739 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1740 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1741 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1742 | } |
1743 | ||
555e09d4 QY |
1744 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1745 | { | |
1746 | uint32_t quanta = | |
1747 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1748 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1749 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1750 | } |
cb1faec9 | 1751 | |
8fa7732f QY |
1752 | /* Packet quanta configuration |
1753 | * | |
1754 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1755 | * thread. When changing these limits be careful to prevent stack overflow. | |
1756 | * | |
1757 | * Furthermore, the maximums used here should correspond to | |
1758 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1759 | */ | |
1760 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1761 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1762 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1763 | NO_STR |
8fa7732f | 1764 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1765 | "Number of packets\n") |
1766 | { | |
8fa7732f | 1767 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1768 | } |
1769 | ||
8fa7732f | 1770 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1771 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1772 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1773 | NO_STR |
1774 | "How many packets to read from peer socket per I/O cycle\n" | |
1775 | "Number of packets\n") | |
1776 | { | |
8fa7732f | 1777 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1778 | } |
1779 | ||
2b791107 | 1780 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1781 | { |
37a333fe | 1782 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1783 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1784 | } |
1785 | ||
1786 | ||
1787 | DEFUN (bgp_coalesce_time, | |
1788 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1789 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1790 | "Subgroup coalesce timer\n" |
1791 | "Subgroup coalesce timer value (in ms)\n") | |
1792 | { | |
d62a17ae | 1793 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1794 | |
d62a17ae | 1795 | int idx = 0; |
1796 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1797 | bgp->heuristic_coalesce = false; |
d62a17ae | 1798 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1799 | return CMD_SUCCESS; | |
3f9c7369 DS |
1800 | } |
1801 | ||
1802 | DEFUN (no_bgp_coalesce_time, | |
1803 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1804 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1805 | NO_STR |
3f9c7369 DS |
1806 | "Subgroup coalesce timer\n" |
1807 | "Subgroup coalesce timer value (in ms)\n") | |
1808 | { | |
d62a17ae | 1809 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1810 | |
37a333fe | 1811 | bgp->heuristic_coalesce = true; |
d62a17ae | 1812 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1813 | return CMD_SUCCESS; | |
3f9c7369 DS |
1814 | } |
1815 | ||
5e242b0d DS |
1816 | /* Maximum-paths configuration */ |
1817 | DEFUN (bgp_maxpaths, | |
1818 | bgp_maxpaths_cmd, | |
6319fd63 | 1819 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1820 | "Forward packets over multiple paths\n" |
1821 | "Number of paths\n") | |
1822 | { | |
d62a17ae | 1823 | int idx_number = 1; |
1824 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1825 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1826 | } |
1827 | ||
d62a17ae | 1828 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1829 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1830 | "Forward packets over multiple paths\n" | |
1831 | "Number of paths\n") | |
596c17ba | 1832 | |
165b5fff JB |
1833 | DEFUN (bgp_maxpaths_ibgp, |
1834 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1835 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1836 | "Forward packets over multiple paths\n" |
1837 | "iBGP-multipath\n" | |
1838 | "Number of paths\n") | |
1839 | { | |
d62a17ae | 1840 | int idx_number = 2; |
1841 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1842 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1843 | } |
165b5fff | 1844 | |
d62a17ae | 1845 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1846 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1847 | "Forward packets over multiple paths\n" | |
1848 | "iBGP-multipath\n" | |
1849 | "Number of paths\n") | |
596c17ba | 1850 | |
5e242b0d DS |
1851 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1852 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1853 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1854 | "Forward packets over multiple paths\n" |
1855 | "iBGP-multipath\n" | |
1856 | "Number of paths\n" | |
1857 | "Match the cluster length\n") | |
1858 | { | |
d62a17ae | 1859 | int idx_number = 2; |
1860 | return bgp_maxpaths_config_vty( | |
1861 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1862 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1863 | } |
1864 | ||
d62a17ae | 1865 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1866 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1867 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1868 | "Forward packets over multiple paths\n" | |
1869 | "iBGP-multipath\n" | |
1870 | "Number of paths\n" | |
1871 | "Match the cluster length\n") | |
596c17ba | 1872 | |
165b5fff JB |
1873 | DEFUN (no_bgp_maxpaths, |
1874 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1875 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1876 | NO_STR |
1877 | "Forward packets over multiple paths\n" | |
1878 | "Number of paths\n") | |
1879 | { | |
d62a17ae | 1880 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1881 | } |
1882 | ||
d62a17ae | 1883 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1884 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1885 | "Forward packets over multiple paths\n" |
1886 | "Number of paths\n") | |
596c17ba | 1887 | |
165b5fff JB |
1888 | DEFUN (no_bgp_maxpaths_ibgp, |
1889 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1890 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1891 | NO_STR |
1892 | "Forward packets over multiple paths\n" | |
1893 | "iBGP-multipath\n" | |
838758ac DW |
1894 | "Number of paths\n" |
1895 | "Match the cluster length\n") | |
165b5fff | 1896 | { |
d62a17ae | 1897 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1898 | } |
1899 | ||
d62a17ae | 1900 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1901 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1902 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1903 | NO_STR | |
1904 | "Forward packets over multiple paths\n" | |
1905 | "iBGP-multipath\n" | |
1906 | "Number of paths\n" | |
1907 | "Match the cluster length\n") | |
596c17ba | 1908 | |
dd65f45e DL |
1909 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1910 | afi_t afi, safi_t safi) | |
165b5fff | 1911 | { |
d62a17ae | 1912 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1913 | vty_out(vty, " maximum-paths %d\n", |
1914 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1915 | } | |
165b5fff | 1916 | |
d62a17ae | 1917 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1918 | vty_out(vty, " maximum-paths ibgp %d", |
1919 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1920 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1921 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1922 | vty_out(vty, " equal-cluster-length"); | |
1923 | vty_out(vty, "\n"); | |
1924 | } | |
165b5fff | 1925 | } |
6b0655a2 | 1926 | |
718e3744 | 1927 | /* BGP timers. */ |
1928 | ||
1929 | DEFUN (bgp_timers, | |
1930 | bgp_timers_cmd, | |
6147e2c6 | 1931 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1932 | "Adjust routing timers\n" |
1933 | "BGP timers\n" | |
1934 | "Keepalive interval\n" | |
1935 | "Holdtime\n") | |
1936 | { | |
d62a17ae | 1937 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1938 | int idx_number = 2; | |
1939 | int idx_number_2 = 3; | |
1940 | unsigned long keepalive = 0; | |
1941 | unsigned long holdtime = 0; | |
718e3744 | 1942 | |
d62a17ae | 1943 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1944 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1945 | |
d62a17ae | 1946 | /* Holdtime value check. */ |
1947 | if (holdtime < 3 && holdtime != 0) { | |
1948 | vty_out(vty, | |
1949 | "%% hold time value must be either 0 or greater than 3\n"); | |
1950 | return CMD_WARNING_CONFIG_FAILED; | |
1951 | } | |
718e3744 | 1952 | |
5d5393b9 | 1953 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1954 | |
d62a17ae | 1955 | return CMD_SUCCESS; |
718e3744 | 1956 | } |
1957 | ||
1958 | DEFUN (no_bgp_timers, | |
1959 | no_bgp_timers_cmd, | |
838758ac | 1960 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1961 | NO_STR |
1962 | "Adjust routing timers\n" | |
838758ac DW |
1963 | "BGP timers\n" |
1964 | "Keepalive interval\n" | |
1965 | "Holdtime\n") | |
718e3744 | 1966 | { |
d62a17ae | 1967 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1968 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1969 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1970 | |
d62a17ae | 1971 | return CMD_SUCCESS; |
718e3744 | 1972 | } |
1973 | ||
6b0655a2 | 1974 | |
718e3744 | 1975 | DEFUN (bgp_client_to_client_reflection, |
1976 | bgp_client_to_client_reflection_cmd, | |
1977 | "bgp client-to-client reflection", | |
1978 | "BGP specific commands\n" | |
1979 | "Configure client to client route reflection\n" | |
1980 | "reflection of routes allowed\n") | |
1981 | { | |
d62a17ae | 1982 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 1983 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 1984 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 1985 | |
d62a17ae | 1986 | return CMD_SUCCESS; |
718e3744 | 1987 | } |
1988 | ||
1989 | DEFUN (no_bgp_client_to_client_reflection, | |
1990 | no_bgp_client_to_client_reflection_cmd, | |
1991 | "no bgp client-to-client reflection", | |
1992 | NO_STR | |
1993 | "BGP specific commands\n" | |
1994 | "Configure client to client route reflection\n" | |
1995 | "reflection of routes allowed\n") | |
1996 | { | |
d62a17ae | 1997 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 1998 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 1999 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 2000 | |
d62a17ae | 2001 | return CMD_SUCCESS; |
718e3744 | 2002 | } |
2003 | ||
2004 | /* "bgp always-compare-med" configuration. */ | |
2005 | DEFUN (bgp_always_compare_med, | |
2006 | bgp_always_compare_med_cmd, | |
2007 | "bgp always-compare-med", | |
2008 | "BGP specific commands\n" | |
2009 | "Allow comparing MED from different neighbors\n") | |
2010 | { | |
d62a17ae | 2011 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2012 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2013 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2014 | |
d62a17ae | 2015 | return CMD_SUCCESS; |
718e3744 | 2016 | } |
2017 | ||
2018 | DEFUN (no_bgp_always_compare_med, | |
2019 | no_bgp_always_compare_med_cmd, | |
2020 | "no bgp always-compare-med", | |
2021 | NO_STR | |
2022 | "BGP specific commands\n" | |
2023 | "Allow comparing MED from different neighbors\n") | |
2024 | { | |
d62a17ae | 2025 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2026 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2027 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2028 | |
d62a17ae | 2029 | return CMD_SUCCESS; |
718e3744 | 2030 | } |
6b0655a2 | 2031 | |
9dac9fc8 DA |
2032 | |
2033 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2034 | "bgp ebgp-requires-policy", | |
2035 | "BGP specific commands\n" | |
2036 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2037 | { | |
2038 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2039 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
2040 | return CMD_SUCCESS; | |
2041 | } | |
2042 | ||
2043 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2044 | "no bgp ebgp-requires-policy", | |
2045 | NO_STR | |
2046 | "BGP specific commands\n" | |
2047 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2048 | { | |
2049 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2050 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
2051 | return CMD_SUCCESS; | |
2052 | } | |
2053 | ||
fb29348a DA |
2054 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2055 | "bgp reject-as-sets", | |
2056 | "BGP specific commands\n" | |
2057 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2058 | { | |
2059 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2060 | struct listnode *node, *nnode; | |
2061 | struct peer *peer; | |
2062 | ||
2063 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_ENABLED; | |
2064 | ||
2065 | /* Reset existing BGP sessions to reject routes | |
2066 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2067 | */ | |
2068 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2069 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2070 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2071 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2072 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2073 | } | |
2074 | } | |
2075 | ||
2076 | return CMD_SUCCESS; | |
2077 | } | |
2078 | ||
2079 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2080 | "no bgp reject-as-sets", | |
2081 | NO_STR | |
2082 | "BGP specific commands\n" | |
2083 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2084 | { | |
2085 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2086 | struct listnode *node, *nnode; | |
2087 | struct peer *peer; | |
2088 | ||
2089 | bgp->reject_as_sets = BGP_REJECT_AS_SETS_DISABLED; | |
2090 | ||
2091 | /* Reset existing BGP sessions to reject routes | |
2092 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2093 | */ | |
2094 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2095 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2096 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2097 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2098 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2099 | } | |
2100 | } | |
2101 | ||
2102 | return CMD_SUCCESS; | |
2103 | } | |
9dac9fc8 | 2104 | |
718e3744 | 2105 | /* "bgp deterministic-med" configuration. */ |
2106 | DEFUN (bgp_deterministic_med, | |
2107 | bgp_deterministic_med_cmd, | |
2108 | "bgp deterministic-med", | |
2109 | "BGP specific commands\n" | |
2110 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2111 | { | |
d62a17ae | 2112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2113 | |
892fedb6 DA |
2114 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
2115 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
d62a17ae | 2116 | bgp_recalculate_all_bestpaths(bgp); |
2117 | } | |
7aafcaca | 2118 | |
d62a17ae | 2119 | return CMD_SUCCESS; |
718e3744 | 2120 | } |
2121 | ||
2122 | DEFUN (no_bgp_deterministic_med, | |
2123 | no_bgp_deterministic_med_cmd, | |
2124 | "no bgp deterministic-med", | |
2125 | NO_STR | |
2126 | "BGP specific commands\n" | |
2127 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2128 | { | |
d62a17ae | 2129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2130 | int bestpath_per_as_used; | |
2131 | afi_t afi; | |
2132 | safi_t safi; | |
2133 | struct peer *peer; | |
2134 | struct listnode *node, *nnode; | |
2135 | ||
892fedb6 | 2136 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
d62a17ae | 2137 | bestpath_per_as_used = 0; |
2138 | ||
2139 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2140 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2141 | if (bgp_addpath_dmed_required( |
2142 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2143 | bestpath_per_as_used = 1; |
2144 | break; | |
2145 | } | |
d62a17ae | 2146 | |
2147 | if (bestpath_per_as_used) | |
2148 | break; | |
2149 | } | |
2150 | ||
2151 | if (bestpath_per_as_used) { | |
2152 | vty_out(vty, | |
2153 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2154 | return CMD_WARNING_CONFIG_FAILED; | |
2155 | } else { | |
892fedb6 | 2156 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); |
d62a17ae | 2157 | bgp_recalculate_all_bestpaths(bgp); |
2158 | } | |
2159 | } | |
2160 | ||
2161 | return CMD_SUCCESS; | |
718e3744 | 2162 | } |
538621f2 | 2163 | |
055679e9 | 2164 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2165 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2166 | bgp_graceful_restart_cmd, |
2167 | "bgp graceful-restart", | |
2168 | "BGP specific commands\n" | |
2169 | GR_CMD | |
055679e9 | 2170 | ) |
538621f2 | 2171 | { |
055679e9 | 2172 | int ret = BGP_GR_FAILURE; |
2173 | ||
2174 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2175 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2176 | |
d62a17ae | 2177 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2178 | |
2179 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2180 | ||
36235319 QY |
2181 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2182 | ret); | |
5cce3f05 | 2183 | |
055679e9 | 2184 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2185 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2186 | vty_out(vty, |
2187 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2188 | return bgp_vty_return(vty, ret); |
538621f2 | 2189 | } |
2190 | ||
2191 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2192 | no_bgp_graceful_restart_cmd, |
2193 | "no bgp graceful-restart", | |
2194 | NO_STR | |
2195 | "BGP specific commands\n" | |
2196 | NO_GR_CMD | |
055679e9 | 2197 | ) |
538621f2 | 2198 | { |
d62a17ae | 2199 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2200 | |
2201 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2202 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2203 | |
2204 | int ret = BGP_GR_FAILURE; | |
2205 | ||
2206 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2207 | ||
36235319 QY |
2208 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2209 | ret); | |
5cce3f05 | 2210 | |
055679e9 | 2211 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2212 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2213 | vty_out(vty, |
2214 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2215 | |
2216 | return bgp_vty_return(vty, ret); | |
538621f2 | 2217 | } |
2218 | ||
93406d87 | 2219 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2220 | bgp_graceful_restart_stalepath_time_cmd, |
2221 | "bgp graceful-restart stalepath-time (1-4095)", | |
2222 | "BGP specific commands\n" | |
2223 | "Graceful restart capability parameters\n" | |
2224 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2225 | "Delay value (seconds)\n") | |
93406d87 | 2226 | { |
d62a17ae | 2227 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2228 | int idx_number = 3; | |
d7c0a89a | 2229 | uint32_t stalepath; |
93406d87 | 2230 | |
d62a17ae | 2231 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2232 | bgp->stalepath_time = stalepath; | |
2233 | return CMD_SUCCESS; | |
93406d87 | 2234 | } |
2235 | ||
eb6f1b41 | 2236 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2237 | bgp_graceful_restart_restart_time_cmd, |
2238 | "bgp graceful-restart restart-time (1-4095)", | |
2239 | "BGP specific commands\n" | |
2240 | "Graceful restart capability parameters\n" | |
2241 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2242 | "Delay value (seconds)\n") | |
eb6f1b41 | 2243 | { |
d62a17ae | 2244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2245 | int idx_number = 3; | |
d7c0a89a | 2246 | uint32_t restart; |
eb6f1b41 | 2247 | |
d62a17ae | 2248 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2249 | bgp->restart_time = restart; | |
2250 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2251 | } |
2252 | ||
cfd47646 | 2253 | DEFUN (bgp_graceful_restart_select_defer_time, |
2254 | bgp_graceful_restart_select_defer_time_cmd, | |
2255 | "bgp graceful-restart select-defer-time (0-3600)", | |
2256 | "BGP specific commands\n" | |
2257 | "Graceful restart capability parameters\n" | |
2258 | "Set the time to defer the BGP route selection after restart\n" | |
2259 | "Delay value (seconds, 0 - disable)\n") | |
2260 | { | |
2261 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2262 | int idx_number = 3; | |
2263 | uint32_t defer_time; | |
2264 | ||
2265 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2266 | bgp->select_defer_time = defer_time; | |
2267 | if (defer_time == 0) | |
892fedb6 | 2268 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2269 | else |
892fedb6 | 2270 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2271 | |
2272 | return CMD_SUCCESS; | |
2273 | } | |
2274 | ||
93406d87 | 2275 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2276 | no_bgp_graceful_restart_stalepath_time_cmd, |
2277 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2278 | NO_STR | |
2279 | "BGP specific commands\n" | |
2280 | "Graceful restart capability parameters\n" | |
2281 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2282 | "Delay value (seconds)\n") | |
93406d87 | 2283 | { |
d62a17ae | 2284 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2285 | |
d62a17ae | 2286 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2287 | return CMD_SUCCESS; | |
93406d87 | 2288 | } |
2289 | ||
eb6f1b41 | 2290 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2291 | no_bgp_graceful_restart_restart_time_cmd, |
2292 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2293 | NO_STR | |
2294 | "BGP specific commands\n" | |
2295 | "Graceful restart capability parameters\n" | |
2296 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2297 | "Delay value (seconds)\n") | |
eb6f1b41 | 2298 | { |
d62a17ae | 2299 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2300 | |
d62a17ae | 2301 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2302 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2303 | } |
2304 | ||
cfd47646 | 2305 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2306 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2307 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2308 | NO_STR | |
2309 | "BGP specific commands\n" | |
2310 | "Graceful restart capability parameters\n" | |
2311 | "Set the time to defer the BGP route selection after restart\n" | |
2312 | "Delay value (seconds)\n") | |
2313 | { | |
2314 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2315 | ||
2316 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2317 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2318 | |
2319 | return CMD_SUCCESS; | |
2320 | } | |
2321 | ||
43fc21b3 | 2322 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2323 | bgp_graceful_restart_preserve_fw_cmd, |
2324 | "bgp graceful-restart preserve-fw-state", | |
2325 | "BGP specific commands\n" | |
2326 | "Graceful restart capability parameters\n" | |
2327 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2328 | { |
d62a17ae | 2329 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2330 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2331 | return CMD_SUCCESS; |
43fc21b3 JC |
2332 | } |
2333 | ||
2334 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2335 | no_bgp_graceful_restart_preserve_fw_cmd, |
2336 | "no bgp graceful-restart preserve-fw-state", | |
2337 | NO_STR | |
2338 | "BGP specific commands\n" | |
2339 | "Graceful restart capability parameters\n" | |
2340 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2341 | { |
d62a17ae | 2342 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2343 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2344 | return CMD_SUCCESS; |
43fc21b3 JC |
2345 | } |
2346 | ||
055679e9 | 2347 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2348 | bgp_graceful_restart_disable_cmd, |
2349 | "bgp graceful-restart-disable", | |
2350 | "BGP specific commands\n" | |
2351 | GR_DISABLE) | |
055679e9 | 2352 | { |
2353 | int ret = BGP_GR_FAILURE; | |
2354 | ||
2355 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2356 | zlog_debug( | |
2ba1fe69 | 2357 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2358 | |
055679e9 | 2359 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2360 | ||
2361 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2362 | ||
dc95985f | 2363 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2364 | bgp->peer, ret); | |
5cce3f05 | 2365 | |
055679e9 | 2366 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2367 | zlog_debug( | |
2ba1fe69 | 2368 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2369 | vty_out(vty, |
2370 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2371 | ||
055679e9 | 2372 | return bgp_vty_return(vty, ret); |
2373 | } | |
2374 | ||
2375 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2376 | no_bgp_graceful_restart_disable_cmd, |
2377 | "no bgp graceful-restart-disable", | |
2378 | NO_STR | |
2379 | "BGP specific commands\n" | |
2380 | NO_GR_DISABLE | |
055679e9 | 2381 | ) |
2382 | { | |
2383 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2384 | ||
2385 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2386 | zlog_debug( | |
2ba1fe69 | 2387 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2388 | |
2389 | int ret = BGP_GR_FAILURE; | |
2390 | ||
2391 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2392 | ||
36235319 QY |
2393 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2394 | ret); | |
5cce3f05 | 2395 | |
055679e9 | 2396 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2397 | zlog_debug( | |
2ba1fe69 | 2398 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2399 | vty_out(vty, |
2400 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2401 | |
2402 | return bgp_vty_return(vty, ret); | |
2403 | } | |
2404 | ||
2405 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2406 | bgp_neighbor_graceful_restart_set_cmd, |
2407 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2408 | NEIGHBOR_STR | |
2409 | NEIGHBOR_ADDR_STR2 | |
2410 | GR_NEIGHBOR_CMD | |
055679e9 | 2411 | ) |
2412 | { | |
2413 | int idx_peer = 1; | |
2414 | struct peer *peer; | |
2415 | int ret = BGP_GR_FAILURE; | |
2416 | ||
dc95985f | 2417 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2418 | ||
055679e9 | 2419 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2420 | zlog_debug( | |
2ba1fe69 | 2421 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2422 | |
055679e9 | 2423 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2424 | if (!peer) | |
2425 | return CMD_WARNING_CONFIG_FAILED; | |
2426 | ||
2427 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2428 | ||
dc95985f | 2429 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2430 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2431 | |
2432 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2433 | zlog_debug( | |
2ba1fe69 | 2434 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2435 | vty_out(vty, |
2436 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2437 | |
2438 | return bgp_vty_return(vty, ret); | |
2439 | } | |
2440 | ||
2441 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2442 | no_bgp_neighbor_graceful_restart_set_cmd, |
2443 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2444 | NO_STR | |
2445 | NEIGHBOR_STR | |
2446 | NEIGHBOR_ADDR_STR2 | |
2447 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2448 | ) |
2449 | { | |
2450 | int idx_peer = 2; | |
2451 | int ret = BGP_GR_FAILURE; | |
2452 | struct peer *peer; | |
2453 | ||
dc95985f | 2454 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2455 | ||
055679e9 | 2456 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2457 | if (!peer) | |
2458 | return CMD_WARNING_CONFIG_FAILED; | |
2459 | ||
2460 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2461 | zlog_debug( | |
2ba1fe69 | 2462 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2463 | |
2464 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2465 | ||
dc95985f | 2466 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2467 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2468 | |
2469 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2470 | zlog_debug( | |
2ba1fe69 | 2471 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2472 | vty_out(vty, |
2473 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2474 | |
2475 | return bgp_vty_return(vty, ret); | |
2476 | } | |
2477 | ||
2478 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2479 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2480 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2481 | NEIGHBOR_STR | |
2482 | NEIGHBOR_ADDR_STR2 | |
2483 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2484 | ) |
2485 | { | |
2486 | int idx_peer = 1; | |
2487 | struct peer *peer; | |
2488 | int ret = BGP_GR_FAILURE; | |
2489 | ||
dc95985f | 2490 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2491 | ||
055679e9 | 2492 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2493 | zlog_debug( | |
2ba1fe69 | 2494 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2495 | |
055679e9 | 2496 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2497 | ||
055679e9 | 2498 | if (!peer) |
2499 | return CMD_WARNING_CONFIG_FAILED; | |
2500 | ||
2501 | ||
2502 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2503 | |
dc95985f | 2504 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2505 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2506 | |
055679e9 | 2507 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2508 | zlog_debug( | |
2ba1fe69 | 2509 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2510 | vty_out(vty, |
2511 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2512 | |
2513 | return bgp_vty_return(vty, ret); | |
2514 | } | |
2515 | ||
2516 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2517 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2518 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2519 | NO_STR | |
2520 | NEIGHBOR_STR | |
2521 | NEIGHBOR_ADDR_STR2 | |
2522 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2523 | ) |
2524 | { | |
2525 | int idx_peer = 2; | |
2526 | int ret = BGP_GR_FAILURE; | |
2527 | struct peer *peer; | |
2528 | ||
dc95985f | 2529 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2530 | ||
055679e9 | 2531 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2532 | if (!peer) | |
2533 | return CMD_WARNING_CONFIG_FAILED; | |
2534 | ||
2535 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2536 | zlog_debug( | |
2ba1fe69 | 2537 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2538 | |
36235319 | 2539 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2540 | |
dc95985f | 2541 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2542 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2543 | |
2544 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2545 | zlog_debug( | |
2ba1fe69 | 2546 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2547 | vty_out(vty, |
2548 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2549 | |
2550 | return bgp_vty_return(vty, ret); | |
2551 | } | |
2552 | ||
2553 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2554 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2555 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2556 | NEIGHBOR_STR | |
2557 | NEIGHBOR_ADDR_STR2 | |
2558 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2559 | ) |
2560 | { | |
2561 | int idx_peer = 1; | |
2562 | struct peer *peer; | |
2563 | int ret = BGP_GR_FAILURE; | |
2564 | ||
dc95985f | 2565 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2566 | ||
055679e9 | 2567 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2568 | zlog_debug( | |
2ba1fe69 | 2569 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2570 | |
2571 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2572 | if (!peer) | |
2573 | return CMD_WARNING_CONFIG_FAILED; | |
2574 | ||
36235319 | 2575 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2576 | |
2577 | if (peer->bgp->t_startup) | |
2578 | bgp_peer_gr_flags_update(peer); | |
2579 | ||
dc95985f | 2580 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2581 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2582 | ||
055679e9 | 2583 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2584 | zlog_debug( | |
2ba1fe69 | 2585 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2586 | vty_out(vty, |
2587 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2588 | |
2589 | return bgp_vty_return(vty, ret); | |
2590 | } | |
2591 | ||
2592 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2593 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2594 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2595 | NO_STR | |
2596 | NEIGHBOR_STR | |
2597 | NEIGHBOR_ADDR_STR2 | |
2598 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2599 | ) |
2600 | { | |
2601 | int idx_peer = 2; | |
2602 | int ret = BGP_GR_FAILURE; | |
2603 | struct peer *peer; | |
2604 | ||
dc95985f | 2605 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2606 | ||
055679e9 | 2607 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2608 | if (!peer) | |
2609 | return CMD_WARNING_CONFIG_FAILED; | |
2610 | ||
2611 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2612 | zlog_debug( | |
2ba1fe69 | 2613 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2614 | |
2615 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2616 | ||
dc95985f | 2617 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2618 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2619 | |
2620 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2621 | zlog_debug( | |
2ba1fe69 | 2622 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2623 | vty_out(vty, |
2624 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2625 | |
2626 | return bgp_vty_return(vty, ret); | |
2627 | } | |
2628 | ||
d6e3c15b | 2629 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2630 | bgp_graceful_restart_disable_eor_cmd, | |
2631 | "bgp graceful-restart disable-eor", | |
2632 | "BGP specific commands\n" | |
2633 | "Graceful restart configuration parameters\n" | |
2634 | "Disable EOR Check\n") | |
2635 | { | |
2636 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2637 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2638 | |
d6e3c15b | 2639 | return CMD_SUCCESS; |
2640 | } | |
2641 | ||
2642 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2643 | no_bgp_graceful_restart_disable_eor_cmd, | |
2644 | "no bgp graceful-restart disable-eor", | |
2645 | NO_STR | |
2646 | "BGP specific commands\n" | |
2647 | "Graceful restart configuration parameters\n" | |
2648 | "Disable EOR Check\n") | |
2649 | { | |
2650 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2651 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2652 | |
2653 | return CMD_SUCCESS; | |
2654 | } | |
2655 | ||
2656 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2657 | bgp_graceful_restart_rib_stale_time_cmd, | |
2658 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2659 | "BGP specific commands\n" | |
2660 | "Graceful restart configuration parameters\n" | |
2661 | "Specify the stale route removal timer in rib\n" | |
2662 | "Delay value (seconds)\n") | |
2663 | { | |
2664 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2665 | int idx_number = 3; | |
2666 | uint32_t stale_time; | |
2667 | ||
2668 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2669 | bgp->rib_stale_time = stale_time; | |
2670 | /* Send the stale timer update message to RIB */ | |
2671 | if (bgp_zebra_stale_timer_update(bgp)) | |
2672 | return CMD_WARNING; | |
2673 | ||
2674 | return CMD_SUCCESS; | |
2675 | } | |
2676 | ||
2677 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2678 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2679 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2680 | NO_STR | |
2681 | "BGP specific commands\n" | |
2682 | "Graceful restart configuration parameters\n" | |
2683 | "Specify the stale route removal timer in rib\n" | |
2684 | "Delay value (seconds)\n") | |
2685 | { | |
2686 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2687 | ||
2688 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2689 | /* Send the stale timer update message to RIB */ | |
2690 | if (bgp_zebra_stale_timer_update(bgp)) | |
2691 | return CMD_WARNING; | |
2692 | ||
d6e3c15b | 2693 | return CMD_SUCCESS; |
2694 | } | |
2695 | ||
7f323236 DW |
2696 | /* "bgp graceful-shutdown" configuration */ |
2697 | DEFUN (bgp_graceful_shutdown, | |
2698 | bgp_graceful_shutdown_cmd, | |
2699 | "bgp graceful-shutdown", | |
2700 | BGP_STR | |
2701 | "Graceful shutdown parameters\n") | |
2702 | { | |
2703 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2704 | ||
892fedb6 DA |
2705 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2706 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2707 | bgp_static_redo_import_check(bgp); |
2708 | bgp_redistribute_redo(bgp); | |
2709 | bgp_clear_star_soft_out(vty, bgp->name); | |
2710 | bgp_clear_star_soft_in(vty, bgp->name); | |
2711 | } | |
2712 | ||
2713 | return CMD_SUCCESS; | |
2714 | } | |
2715 | ||
2716 | DEFUN (no_bgp_graceful_shutdown, | |
2717 | no_bgp_graceful_shutdown_cmd, | |
2718 | "no bgp graceful-shutdown", | |
2719 | NO_STR | |
2720 | BGP_STR | |
2721 | "Graceful shutdown parameters\n") | |
2722 | { | |
2723 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2724 | ||
892fedb6 DA |
2725 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2726 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2727 | bgp_static_redo_import_check(bgp); |
2728 | bgp_redistribute_redo(bgp); | |
2729 | bgp_clear_star_soft_out(vty, bgp->name); | |
2730 | bgp_clear_star_soft_in(vty, bgp->name); | |
2731 | } | |
2732 | ||
2733 | return CMD_SUCCESS; | |
2734 | } | |
2735 | ||
718e3744 | 2736 | /* "bgp fast-external-failover" configuration. */ |
2737 | DEFUN (bgp_fast_external_failover, | |
2738 | bgp_fast_external_failover_cmd, | |
2739 | "bgp fast-external-failover", | |
2740 | BGP_STR | |
2741 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2742 | { | |
d62a17ae | 2743 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2744 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2745 | return CMD_SUCCESS; |
718e3744 | 2746 | } |
2747 | ||
2748 | DEFUN (no_bgp_fast_external_failover, | |
2749 | no_bgp_fast_external_failover_cmd, | |
2750 | "no bgp fast-external-failover", | |
2751 | NO_STR | |
2752 | BGP_STR | |
2753 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2754 | { | |
d62a17ae | 2755 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2756 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2757 | return CMD_SUCCESS; |
718e3744 | 2758 | } |
6b0655a2 | 2759 | |
718e3744 | 2760 | /* "bgp bestpath compare-routerid" configuration. */ |
2761 | DEFUN (bgp_bestpath_compare_router_id, | |
2762 | bgp_bestpath_compare_router_id_cmd, | |
2763 | "bgp bestpath compare-routerid", | |
2764 | "BGP specific commands\n" | |
2765 | "Change the default bestpath selection\n" | |
2766 | "Compare router-id for identical EBGP paths\n") | |
2767 | { | |
d62a17ae | 2768 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2769 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2770 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2771 | |
d62a17ae | 2772 | return CMD_SUCCESS; |
718e3744 | 2773 | } |
2774 | ||
2775 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2776 | no_bgp_bestpath_compare_router_id_cmd, | |
2777 | "no bgp bestpath compare-routerid", | |
2778 | NO_STR | |
2779 | "BGP specific commands\n" | |
2780 | "Change the default bestpath selection\n" | |
2781 | "Compare router-id for identical EBGP paths\n") | |
2782 | { | |
d62a17ae | 2783 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2784 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2785 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2786 | |
d62a17ae | 2787 | return CMD_SUCCESS; |
718e3744 | 2788 | } |
6b0655a2 | 2789 | |
718e3744 | 2790 | /* "bgp bestpath as-path ignore" configuration. */ |
2791 | DEFUN (bgp_bestpath_aspath_ignore, | |
2792 | bgp_bestpath_aspath_ignore_cmd, | |
2793 | "bgp bestpath as-path ignore", | |
2794 | "BGP specific commands\n" | |
2795 | "Change the default bestpath selection\n" | |
2796 | "AS-path attribute\n" | |
2797 | "Ignore as-path length in selecting a route\n") | |
2798 | { | |
d62a17ae | 2799 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2800 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2801 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2802 | |
d62a17ae | 2803 | return CMD_SUCCESS; |
718e3744 | 2804 | } |
2805 | ||
2806 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2807 | no_bgp_bestpath_aspath_ignore_cmd, | |
2808 | "no bgp bestpath as-path ignore", | |
2809 | NO_STR | |
2810 | "BGP specific commands\n" | |
2811 | "Change the default bestpath selection\n" | |
2812 | "AS-path attribute\n" | |
2813 | "Ignore as-path length in selecting a route\n") | |
2814 | { | |
d62a17ae | 2815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2816 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2817 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2818 | |
d62a17ae | 2819 | return CMD_SUCCESS; |
718e3744 | 2820 | } |
6b0655a2 | 2821 | |
6811845b | 2822 | /* "bgp bestpath as-path confed" configuration. */ |
2823 | DEFUN (bgp_bestpath_aspath_confed, | |
2824 | bgp_bestpath_aspath_confed_cmd, | |
2825 | "bgp bestpath as-path confed", | |
2826 | "BGP specific commands\n" | |
2827 | "Change the default bestpath selection\n" | |
2828 | "AS-path attribute\n" | |
2829 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2830 | { | |
d62a17ae | 2831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2832 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2833 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2834 | |
d62a17ae | 2835 | return CMD_SUCCESS; |
6811845b | 2836 | } |
2837 | ||
2838 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2839 | no_bgp_bestpath_aspath_confed_cmd, | |
2840 | "no bgp bestpath as-path confed", | |
2841 | NO_STR | |
2842 | "BGP specific commands\n" | |
2843 | "Change the default bestpath selection\n" | |
2844 | "AS-path attribute\n" | |
2845 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2846 | { | |
d62a17ae | 2847 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2848 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2849 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2850 | |
d62a17ae | 2851 | return CMD_SUCCESS; |
6811845b | 2852 | } |
6b0655a2 | 2853 | |
2fdd455c PM |
2854 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2855 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2856 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2857 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2858 | "BGP specific commands\n" |
2859 | "Change the default bestpath selection\n" | |
2860 | "AS-path attribute\n" | |
2861 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2862 | "Generate an AS_SET\n" |
16fc1eec DS |
2863 | "Do not generate an AS_SET\n") |
2864 | { | |
d62a17ae | 2865 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2866 | int idx = 0; | |
892fedb6 | 2867 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2868 | |
d62a17ae | 2869 | /* no-as-set is now the default behavior so we can silently |
2870 | * ignore it */ | |
2871 | if (argv_find(argv, argc, "as-set", &idx)) | |
892fedb6 | 2872 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 2873 | else |
892fedb6 | 2874 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
219178b6 | 2875 | |
d62a17ae | 2876 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2877 | |
d62a17ae | 2878 | return CMD_SUCCESS; |
16fc1eec DS |
2879 | } |
2880 | ||
219178b6 DW |
2881 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2882 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2883 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2884 | NO_STR |
2885 | "BGP specific commands\n" | |
2886 | "Change the default bestpath selection\n" | |
2887 | "AS-path attribute\n" | |
2888 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2889 | "Generate an AS_SET\n" |
16fc1eec DS |
2890 | "Do not generate an AS_SET\n") |
2891 | { | |
d62a17ae | 2892 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
2893 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
2894 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
d62a17ae | 2895 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2896 | |
d62a17ae | 2897 | return CMD_SUCCESS; |
2fdd455c | 2898 | } |
6b0655a2 | 2899 | |
848973c7 | 2900 | /* "bgp log-neighbor-changes" configuration. */ |
2901 | DEFUN (bgp_log_neighbor_changes, | |
2902 | bgp_log_neighbor_changes_cmd, | |
2903 | "bgp log-neighbor-changes", | |
2904 | "BGP specific commands\n" | |
2905 | "Log neighbor up/down and reset reason\n") | |
2906 | { | |
d62a17ae | 2907 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2908 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2909 | return CMD_SUCCESS; |
848973c7 | 2910 | } |
2911 | ||
2912 | DEFUN (no_bgp_log_neighbor_changes, | |
2913 | no_bgp_log_neighbor_changes_cmd, | |
2914 | "no bgp log-neighbor-changes", | |
2915 | NO_STR | |
2916 | "BGP specific commands\n" | |
2917 | "Log neighbor up/down and reset reason\n") | |
2918 | { | |
d62a17ae | 2919 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2920 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2921 | return CMD_SUCCESS; |
848973c7 | 2922 | } |
6b0655a2 | 2923 | |
718e3744 | 2924 | /* "bgp bestpath med" configuration. */ |
2925 | DEFUN (bgp_bestpath_med, | |
2926 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2927 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2928 | "BGP specific commands\n" |
2929 | "Change the default bestpath selection\n" | |
2930 | "MED attribute\n" | |
2931 | "Compare MED among confederation paths\n" | |
838758ac DW |
2932 | "Treat missing MED as the least preferred one\n" |
2933 | "Treat missing MED as the least preferred one\n" | |
2934 | "Compare MED among confederation paths\n") | |
718e3744 | 2935 | { |
d62a17ae | 2936 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2937 | |
d62a17ae | 2938 | int idx = 0; |
2939 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2940 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2941 | idx = 0; |
2942 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2943 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 2944 | |
d62a17ae | 2945 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2946 | |
d62a17ae | 2947 | return CMD_SUCCESS; |
718e3744 | 2948 | } |
2949 | ||
718e3744 | 2950 | DEFUN (no_bgp_bestpath_med, |
2951 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2952 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2953 | NO_STR |
2954 | "BGP specific commands\n" | |
2955 | "Change the default bestpath selection\n" | |
2956 | "MED attribute\n" | |
2957 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2958 | "Treat missing MED as the least preferred one\n" |
2959 | "Treat missing MED as the least preferred one\n" | |
2960 | "Compare MED among confederation paths\n") | |
718e3744 | 2961 | { |
d62a17ae | 2962 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2963 | |
d62a17ae | 2964 | int idx = 0; |
2965 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2966 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2967 | idx = 0; |
2968 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2969 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
718e3744 | 2970 | |
d62a17ae | 2971 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2972 | |
d62a17ae | 2973 | return CMD_SUCCESS; |
718e3744 | 2974 | } |
2975 | ||
718e3744 | 2976 | /* "no bgp default ipv4-unicast". */ |
2977 | DEFUN (no_bgp_default_ipv4_unicast, | |
2978 | no_bgp_default_ipv4_unicast_cmd, | |
2979 | "no bgp default ipv4-unicast", | |
2980 | NO_STR | |
2981 | "BGP specific commands\n" | |
2982 | "Configure BGP defaults\n" | |
2983 | "Activate ipv4-unicast for a peer by default\n") | |
2984 | { | |
d62a17ae | 2985 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2986 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 2987 | return CMD_SUCCESS; |
718e3744 | 2988 | } |
2989 | ||
2990 | DEFUN (bgp_default_ipv4_unicast, | |
2991 | bgp_default_ipv4_unicast_cmd, | |
2992 | "bgp default ipv4-unicast", | |
2993 | "BGP specific commands\n" | |
2994 | "Configure BGP defaults\n" | |
2995 | "Activate ipv4-unicast for a peer by default\n") | |
2996 | { | |
d62a17ae | 2997 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2998 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 2999 | return CMD_SUCCESS; |
718e3744 | 3000 | } |
6b0655a2 | 3001 | |
04b6bdc0 DW |
3002 | /* Display hostname in certain command outputs */ |
3003 | DEFUN (bgp_default_show_hostname, | |
3004 | bgp_default_show_hostname_cmd, | |
3005 | "bgp default show-hostname", | |
3006 | "BGP specific commands\n" | |
3007 | "Configure BGP defaults\n" | |
0437e105 | 3008 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3009 | { |
d62a17ae | 3010 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3011 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3012 | return CMD_SUCCESS; |
04b6bdc0 DW |
3013 | } |
3014 | ||
3015 | DEFUN (no_bgp_default_show_hostname, | |
3016 | no_bgp_default_show_hostname_cmd, | |
3017 | "no bgp default show-hostname", | |
3018 | NO_STR | |
3019 | "BGP specific commands\n" | |
3020 | "Configure BGP defaults\n" | |
0437e105 | 3021 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3022 | { |
d62a17ae | 3023 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3024 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3025 | return CMD_SUCCESS; |
04b6bdc0 DW |
3026 | } |
3027 | ||
8233ef81 | 3028 | /* "bgp network import-check" configuration. */ |
718e3744 | 3029 | DEFUN (bgp_network_import_check, |
3030 | bgp_network_import_check_cmd, | |
5623e905 | 3031 | "bgp network import-check", |
718e3744 | 3032 | "BGP specific commands\n" |
3033 | "BGP network command\n" | |
5623e905 | 3034 | "Check BGP network route exists in IGP\n") |
718e3744 | 3035 | { |
d62a17ae | 3036 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3037 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3038 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3039 | bgp_static_redo_import_check(bgp); |
3040 | } | |
078430f6 | 3041 | |
d62a17ae | 3042 | return CMD_SUCCESS; |
718e3744 | 3043 | } |
3044 | ||
d62a17ae | 3045 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3046 | "bgp network import-check exact", | |
3047 | "BGP specific commands\n" | |
3048 | "BGP network command\n" | |
3049 | "Check BGP network route exists in IGP\n" | |
3050 | "Match route precisely\n") | |
8233ef81 | 3051 | |
718e3744 | 3052 | DEFUN (no_bgp_network_import_check, |
3053 | no_bgp_network_import_check_cmd, | |
5623e905 | 3054 | "no bgp network import-check", |
718e3744 | 3055 | NO_STR |
3056 | "BGP specific commands\n" | |
3057 | "BGP network command\n" | |
3058 | "Check BGP network route exists in IGP\n") | |
3059 | { | |
d62a17ae | 3060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3061 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3062 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3063 | bgp_static_redo_import_check(bgp); |
3064 | } | |
5623e905 | 3065 | |
d62a17ae | 3066 | return CMD_SUCCESS; |
718e3744 | 3067 | } |
6b0655a2 | 3068 | |
718e3744 | 3069 | DEFUN (bgp_default_local_preference, |
3070 | bgp_default_local_preference_cmd, | |
6147e2c6 | 3071 | "bgp default local-preference (0-4294967295)", |
718e3744 | 3072 | "BGP specific commands\n" |
3073 | "Configure BGP defaults\n" | |
3074 | "local preference (higher=more preferred)\n" | |
3075 | "Configure default local preference value\n") | |
3076 | { | |
d62a17ae | 3077 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3078 | int idx_number = 3; | |
d7c0a89a | 3079 | uint32_t local_pref; |
718e3744 | 3080 | |
d62a17ae | 3081 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3082 | |
d62a17ae | 3083 | bgp_default_local_preference_set(bgp, local_pref); |
3084 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3085 | |
d62a17ae | 3086 | return CMD_SUCCESS; |
718e3744 | 3087 | } |
3088 | ||
3089 | DEFUN (no_bgp_default_local_preference, | |
3090 | no_bgp_default_local_preference_cmd, | |
838758ac | 3091 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 3092 | NO_STR |
3093 | "BGP specific commands\n" | |
3094 | "Configure BGP defaults\n" | |
838758ac DW |
3095 | "local preference (higher=more preferred)\n" |
3096 | "Configure default local preference value\n") | |
718e3744 | 3097 | { |
d62a17ae | 3098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3099 | bgp_default_local_preference_unset(bgp); | |
3100 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3101 | |
d62a17ae | 3102 | return CMD_SUCCESS; |
718e3744 | 3103 | } |
3104 | ||
6b0655a2 | 3105 | |
3f9c7369 DS |
3106 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3107 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3108 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3109 | "BGP specific commands\n" |
3110 | "Configure BGP defaults\n" | |
3111 | "subgroup-pkt-queue-max\n" | |
3112 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3113 | { |
d62a17ae | 3114 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3115 | int idx_number = 3; | |
d7c0a89a | 3116 | uint32_t max_size; |
8bd9d948 | 3117 | |
d62a17ae | 3118 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3119 | |
d62a17ae | 3120 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3121 | |
d62a17ae | 3122 | return CMD_SUCCESS; |
3f9c7369 DS |
3123 | } |
3124 | ||
3125 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3126 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3127 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3128 | NO_STR |
3129 | "BGP specific commands\n" | |
3130 | "Configure BGP defaults\n" | |
838758ac DW |
3131 | "subgroup-pkt-queue-max\n" |
3132 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3133 | { |
d62a17ae | 3134 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3135 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3136 | return CMD_SUCCESS; | |
8bd9d948 DS |
3137 | } |
3138 | ||
813d4307 | 3139 | |
8bd9d948 DS |
3140 | DEFUN (bgp_rr_allow_outbound_policy, |
3141 | bgp_rr_allow_outbound_policy_cmd, | |
3142 | "bgp route-reflector allow-outbound-policy", | |
3143 | "BGP specific commands\n" | |
3144 | "Allow modifications made by out route-map\n" | |
3145 | "on ibgp neighbors\n") | |
3146 | { | |
d62a17ae | 3147 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3148 | |
892fedb6 DA |
3149 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3150 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3151 | update_group_announce_rrclients(bgp); |
3152 | bgp_clear_star_soft_out(vty, bgp->name); | |
3153 | } | |
8bd9d948 | 3154 | |
d62a17ae | 3155 | return CMD_SUCCESS; |
8bd9d948 DS |
3156 | } |
3157 | ||
3158 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3159 | no_bgp_rr_allow_outbound_policy_cmd, | |
3160 | "no bgp route-reflector allow-outbound-policy", | |
3161 | NO_STR | |
3162 | "BGP specific commands\n" | |
3163 | "Allow modifications made by out route-map\n" | |
3164 | "on ibgp neighbors\n") | |
3165 | { | |
d62a17ae | 3166 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3167 | |
892fedb6 DA |
3168 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3169 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3170 | update_group_announce_rrclients(bgp); |
3171 | bgp_clear_star_soft_out(vty, bgp->name); | |
3172 | } | |
8bd9d948 | 3173 | |
d62a17ae | 3174 | return CMD_SUCCESS; |
8bd9d948 DS |
3175 | } |
3176 | ||
f14e6fdb DS |
3177 | DEFUN (bgp_listen_limit, |
3178 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3179 | "bgp listen limit (1-5000)", |
f14e6fdb | 3180 | "BGP specific commands\n" |
1601a46f | 3181 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3182 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3183 | "Configure Dynamic Neighbors listen limit value\n") |
3184 | { | |
d62a17ae | 3185 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3186 | int idx_number = 3; | |
3187 | int listen_limit; | |
f14e6fdb | 3188 | |
d62a17ae | 3189 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3190 | |
d62a17ae | 3191 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3192 | |
d62a17ae | 3193 | return CMD_SUCCESS; |
f14e6fdb DS |
3194 | } |
3195 | ||
3196 | DEFUN (no_bgp_listen_limit, | |
3197 | no_bgp_listen_limit_cmd, | |
838758ac | 3198 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3199 | NO_STR |
f14e6fdb | 3200 | "BGP specific commands\n" |
1601a46f | 3201 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3202 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3203 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3204 | { |
d62a17ae | 3205 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3206 | bgp_listen_limit_unset(bgp); | |
3207 | return CMD_SUCCESS; | |
f14e6fdb DS |
3208 | } |
3209 | ||
3210 | ||
20eb8864 | 3211 | /* |
3212 | * Check if this listen range is already configured. Check for exact | |
3213 | * match or overlap based on input. | |
3214 | */ | |
d62a17ae | 3215 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3216 | struct prefix *range, int exact) | |
3217 | { | |
3218 | struct listnode *node, *nnode; | |
3219 | struct listnode *node1, *nnode1; | |
3220 | struct peer_group *group; | |
3221 | struct prefix *lr; | |
3222 | afi_t afi; | |
3223 | int match; | |
3224 | ||
3225 | afi = family2afi(range->family); | |
3226 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3227 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3228 | lr)) { | |
3229 | if (exact) | |
3230 | match = prefix_same(range, lr); | |
3231 | else | |
3232 | match = (prefix_match(range, lr) | |
3233 | || prefix_match(lr, range)); | |
3234 | if (match) | |
3235 | return group; | |
3236 | } | |
3237 | } | |
3238 | ||
3239 | return NULL; | |
20eb8864 | 3240 | } |
3241 | ||
f14e6fdb DS |
3242 | DEFUN (bgp_listen_range, |
3243 | bgp_listen_range_cmd, | |
d7b9898c | 3244 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3245 | "BGP specific commands\n" |
d7fa34c1 QY |
3246 | "Configure BGP dynamic neighbors listen range\n" |
3247 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3248 | NEIGHBOR_ADDR_STR |
3249 | "Member of the peer-group\n" | |
3250 | "Peer-group name\n") | |
f14e6fdb | 3251 | { |
d62a17ae | 3252 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3253 | struct prefix range; | |
3254 | struct peer_group *group, *existing_group; | |
3255 | afi_t afi; | |
3256 | int ret; | |
3257 | int idx = 0; | |
3258 | ||
3259 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3260 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3261 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3262 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3263 | char *peergroup = argv[idx]->arg; |
3264 | ||
3265 | /* Convert IP prefix string to struct prefix. */ | |
3266 | ret = str2prefix(prefix, &range); | |
3267 | if (!ret) { | |
3268 | vty_out(vty, "%% Malformed listen range\n"); | |
3269 | return CMD_WARNING_CONFIG_FAILED; | |
3270 | } | |
3271 | ||
3272 | afi = family2afi(range.family); | |
3273 | ||
3274 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3275 | vty_out(vty, | |
3276 | "%% Malformed listen range (link-local address)\n"); | |
3277 | return CMD_WARNING_CONFIG_FAILED; | |
3278 | } | |
3279 | ||
3280 | apply_mask(&range); | |
3281 | ||
3282 | /* Check if same listen range is already configured. */ | |
3283 | existing_group = listen_range_exists(bgp, &range, 1); | |
3284 | if (existing_group) { | |
3285 | if (strcmp(existing_group->name, peergroup) == 0) | |
3286 | return CMD_SUCCESS; | |
3287 | else { | |
3288 | vty_out(vty, | |
3289 | "%% Same listen range is attached to peer-group %s\n", | |
3290 | existing_group->name); | |
3291 | return CMD_WARNING_CONFIG_FAILED; | |
3292 | } | |
3293 | } | |
3294 | ||
3295 | /* Check if an overlapping listen range exists. */ | |
3296 | if (listen_range_exists(bgp, &range, 0)) { | |
3297 | vty_out(vty, | |
3298 | "%% Listen range overlaps with existing listen range\n"); | |
3299 | return CMD_WARNING_CONFIG_FAILED; | |
3300 | } | |
3301 | ||
3302 | group = peer_group_lookup(bgp, peergroup); | |
3303 | if (!group) { | |
3304 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3305 | return CMD_WARNING_CONFIG_FAILED; | |
3306 | } | |
3307 | ||
3308 | ret = peer_group_listen_range_add(group, &range); | |
3309 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3310 | } |
3311 | ||
3312 | DEFUN (no_bgp_listen_range, | |
3313 | no_bgp_listen_range_cmd, | |
d7b9898c | 3314 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3315 | NO_STR |
f14e6fdb | 3316 | "BGP specific commands\n" |
d7fa34c1 QY |
3317 | "Unconfigure BGP dynamic neighbors listen range\n" |
3318 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3319 | NEIGHBOR_ADDR_STR | |
3320 | "Member of the peer-group\n" | |
3321 | "Peer-group name\n") | |
f14e6fdb | 3322 | { |
d62a17ae | 3323 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3324 | struct prefix range; | |
3325 | struct peer_group *group; | |
3326 | afi_t afi; | |
3327 | int ret; | |
3328 | int idx = 0; | |
3329 | ||
3330 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3331 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3332 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3333 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3334 | char *peergroup = argv[idx]->arg; |
3335 | ||
3336 | /* Convert IP prefix string to struct prefix. */ | |
3337 | ret = str2prefix(prefix, &range); | |
3338 | if (!ret) { | |
3339 | vty_out(vty, "%% Malformed listen range\n"); | |
3340 | return CMD_WARNING_CONFIG_FAILED; | |
3341 | } | |
3342 | ||
3343 | afi = family2afi(range.family); | |
3344 | ||
3345 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3346 | vty_out(vty, | |
3347 | "%% Malformed listen range (link-local address)\n"); | |
3348 | return CMD_WARNING_CONFIG_FAILED; | |
3349 | } | |
3350 | ||
3351 | apply_mask(&range); | |
3352 | ||
3353 | group = peer_group_lookup(bgp, peergroup); | |
3354 | if (!group) { | |
3355 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3356 | return CMD_WARNING_CONFIG_FAILED; | |
3357 | } | |
3358 | ||
3359 | ret = peer_group_listen_range_del(group, &range); | |
3360 | return bgp_vty_return(vty, ret); | |
3361 | } | |
3362 | ||
2b791107 | 3363 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3364 | { |
3365 | struct peer_group *group; | |
3366 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3367 | struct prefix *range; | |
3368 | afi_t afi; | |
3369 | char buf[PREFIX2STR_BUFFER]; | |
3370 | ||
3371 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3372 | vty_out(vty, " bgp listen limit %d\n", | |
3373 | bgp->dynamic_neighbors_limit); | |
3374 | ||
3375 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3376 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3377 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3378 | nrnode, range)) { | |
3379 | prefix2str(range, buf, sizeof(buf)); | |
3380 | vty_out(vty, | |
3381 | " bgp listen range %s peer-group %s\n", | |
3382 | buf, group->name); | |
3383 | } | |
3384 | } | |
3385 | } | |
f14e6fdb DS |
3386 | } |
3387 | ||
3388 | ||
907f92c8 DS |
3389 | DEFUN (bgp_disable_connected_route_check, |
3390 | bgp_disable_connected_route_check_cmd, | |
3391 | "bgp disable-ebgp-connected-route-check", | |
3392 | "BGP specific commands\n" | |
3393 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3394 | { | |
d62a17ae | 3395 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3396 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3397 | bgp_clear_star_soft_in(vty, bgp->name); |
7aafcaca | 3398 | |
d62a17ae | 3399 | return CMD_SUCCESS; |
907f92c8 DS |
3400 | } |
3401 | ||
3402 | DEFUN (no_bgp_disable_connected_route_check, | |
3403 | no_bgp_disable_connected_route_check_cmd, | |
3404 | "no bgp disable-ebgp-connected-route-check", | |
3405 | NO_STR | |
3406 | "BGP specific commands\n" | |
3407 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3408 | { | |
d62a17ae | 3409 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3410 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3411 | bgp_clear_star_soft_in(vty, bgp->name); |
3412 | ||
3413 | return CMD_SUCCESS; | |
3414 | } | |
3415 | ||
3416 | ||
3417 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3418 | const char *as_str, afi_t afi, safi_t safi) | |
3419 | { | |
3420 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3421 | int ret; | |
3422 | as_t as; | |
3423 | int as_type = AS_SPECIFIED; | |
3424 | union sockunion su; | |
3425 | ||
3426 | if (as_str[0] == 'i') { | |
3427 | as = 0; | |
3428 | as_type = AS_INTERNAL; | |
3429 | } else if (as_str[0] == 'e') { | |
3430 | as = 0; | |
3431 | as_type = AS_EXTERNAL; | |
3432 | } else { | |
3433 | /* Get AS number. */ | |
3434 | as = strtoul(as_str, NULL, 10); | |
3435 | } | |
3436 | ||
390485fd | 3437 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3438 | ret = str2sockunion(peer_str, &su); |
3439 | if (ret < 0) { | |
390485fd DS |
3440 | struct peer *peer; |
3441 | ||
3442 | /* Check if existing interface peer */ | |
3443 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3444 | ||
d62a17ae | 3445 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3446 | safi); | |
390485fd DS |
3447 | |
3448 | /* if not interface peer, check peer-group settings */ | |
3449 | if (ret < 0 && !peer) { | |
d62a17ae | 3450 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3451 | if (ret < 0) { | |
3452 | vty_out(vty, | |
390485fd | 3453 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3454 | return CMD_WARNING_CONFIG_FAILED; |
3455 | } | |
3456 | return CMD_SUCCESS; | |
3457 | } | |
3458 | } else { | |
3459 | if (peer_address_self_check(bgp, &su)) { | |
3460 | vty_out(vty, | |
3461 | "%% Can not configure the local system as neighbor\n"); | |
3462 | return CMD_WARNING_CONFIG_FAILED; | |
3463 | } | |
3464 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3465 | } | |
3466 | ||
3467 | /* This peer belongs to peer group. */ | |
3468 | switch (ret) { | |
3469 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3470 | vty_out(vty, | |
faa16034 | 3471 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3472 | return CMD_WARNING_CONFIG_FAILED; |
3473 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3474 | vty_out(vty, | |
faa16034 | 3475 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3476 | return CMD_WARNING_CONFIG_FAILED; |
3477 | } | |
3478 | return bgp_vty_return(vty, ret); | |
718e3744 | 3479 | } |
3480 | ||
f26845f9 QY |
3481 | DEFUN (bgp_default_shutdown, |
3482 | bgp_default_shutdown_cmd, | |
3483 | "[no] bgp default shutdown", | |
3484 | NO_STR | |
3485 | BGP_STR | |
3486 | "Configure BGP defaults\n" | |
b012cbe2 | 3487 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3488 | { |
3489 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3490 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3491 | return CMD_SUCCESS; | |
3492 | } | |
3493 | ||
718e3744 | 3494 | DEFUN (neighbor_remote_as, |
3495 | neighbor_remote_as_cmd, | |
3a2d747c | 3496 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3497 | NEIGHBOR_STR |
3498 | NEIGHBOR_ADDR_STR2 | |
3499 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3500 | AS_STR |
3a2d747c QY |
3501 | "Internal BGP peer\n" |
3502 | "External BGP peer\n") | |
718e3744 | 3503 | { |
d62a17ae | 3504 | int idx_peer = 1; |
3505 | int idx_remote_as = 3; | |
3506 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3507 | argv[idx_remote_as]->arg, AFI_IP, | |
3508 | SAFI_UNICAST); | |
3509 | } | |
3510 | ||
3511 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3512 | afi_t afi, safi_t safi, int v6only, | |
3513 | const char *peer_group_name, | |
3514 | const char *as_str) | |
3515 | { | |
3516 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3517 | as_t as = 0; | |
3518 | int as_type = AS_UNSPECIFIED; | |
3519 | struct peer *peer; | |
3520 | struct peer_group *group; | |
3521 | int ret = 0; | |
3522 | union sockunion su; | |
3523 | ||
3524 | group = peer_group_lookup(bgp, conf_if); | |
3525 | ||
3526 | if (group) { | |
3527 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3528 | return CMD_WARNING_CONFIG_FAILED; | |
3529 | } | |
3530 | ||
3531 | if (as_str) { | |
3532 | if (as_str[0] == 'i') { | |
3533 | as_type = AS_INTERNAL; | |
3534 | } else if (as_str[0] == 'e') { | |
3535 | as_type = AS_EXTERNAL; | |
3536 | } else { | |
3537 | /* Get AS number. */ | |
3538 | as = strtoul(as_str, NULL, 10); | |
3539 | as_type = AS_SPECIFIED; | |
3540 | } | |
3541 | } | |
3542 | ||
3543 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3544 | if (peer) { | |
3545 | if (as_str) | |
cc4d4ce8 | 3546 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3547 | afi, safi); |
3548 | } else { | |
892fedb6 | 3549 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 3550 | && afi == AFI_IP && safi == SAFI_UNICAST) |
3551 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3552 | as_type, 0, 0, NULL); | |
3553 | else | |
3554 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3555 | as_type, afi, safi, NULL); | |
3556 | ||
3557 | if (!peer) { | |
3558 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3559 | return CMD_WARNING_CONFIG_FAILED; | |
3560 | } | |
3561 | ||
3562 | if (v6only) | |
527de3dc | 3563 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3564 | |
3565 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3566 | * this | |
3567 | * any unnumbered peer in order to not worry about run-time | |
3568 | * transitions | |
3569 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3570 | * address | |
3571 | * gets deleted later etc.) | |
3572 | */ | |
3573 | if (peer->ifp) | |
3574 | bgp_zebra_initiate_radv(bgp, peer); | |
3575 | } | |
3576 | ||
3577 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3578 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3579 | if (v6only) | |
527de3dc | 3580 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3581 | else |
527de3dc | 3582 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3583 | |
3584 | /* v6only flag changed. Reset bgp seesion */ | |
3585 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3586 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3587 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3588 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3589 | } else | |
3590 | bgp_session_reset(peer); | |
3591 | } | |
3592 | ||
9fb964de PM |
3593 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3594 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3595 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3596 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3597 | } |
d62a17ae | 3598 | |
3599 | if (peer_group_name) { | |
3600 | group = peer_group_lookup(bgp, peer_group_name); | |
3601 | if (!group) { | |
3602 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3603 | return CMD_WARNING_CONFIG_FAILED; | |
3604 | } | |
3605 | ||
3606 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3607 | } | |
3608 | ||
3609 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3610 | } |
3611 | ||
4c48cf63 DW |
3612 | DEFUN (neighbor_interface_config, |
3613 | neighbor_interface_config_cmd, | |
d7b9898c | 3614 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3615 | NEIGHBOR_STR |
3616 | "Interface name or neighbor tag\n" | |
31500417 DW |
3617 | "Enable BGP on interface\n" |
3618 | "Member of the peer-group\n" | |
16cedbb0 | 3619 | "Peer-group name\n") |
4c48cf63 | 3620 | { |
d62a17ae | 3621 | int idx_word = 1; |
3622 | int idx_peer_group_word = 4; | |
31500417 | 3623 | |
d62a17ae | 3624 | if (argc > idx_peer_group_word) |
3625 | return peer_conf_interface_get( | |
3626 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3627 | argv[idx_peer_group_word]->arg, NULL); | |
3628 | else | |
3629 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3630 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3631 | } |
3632 | ||
4c48cf63 DW |
3633 | DEFUN (neighbor_interface_config_v6only, |
3634 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3635 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3636 | NEIGHBOR_STR |
3637 | "Interface name or neighbor tag\n" | |
3638 | "Enable BGP on interface\n" | |
31500417 DW |
3639 | "Enable BGP with v6 link-local only\n" |
3640 | "Member of the peer-group\n" | |
16cedbb0 | 3641 | "Peer-group name\n") |
4c48cf63 | 3642 | { |
d62a17ae | 3643 | int idx_word = 1; |
3644 | int idx_peer_group_word = 5; | |
31500417 | 3645 | |
d62a17ae | 3646 | if (argc > idx_peer_group_word) |
3647 | return peer_conf_interface_get( | |
3648 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3649 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3650 | |
d62a17ae | 3651 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3652 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3653 | } |
3654 | ||
a80beece | 3655 | |
b3a39dc5 DD |
3656 | DEFUN (neighbor_interface_config_remote_as, |
3657 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3658 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3659 | NEIGHBOR_STR |
3660 | "Interface name or neighbor tag\n" | |
3661 | "Enable BGP on interface\n" | |
3a2d747c | 3662 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3663 | AS_STR |
3a2d747c QY |
3664 | "Internal BGP peer\n" |
3665 | "External BGP peer\n") | |
b3a39dc5 | 3666 | { |
d62a17ae | 3667 | int idx_word = 1; |
3668 | int idx_remote_as = 4; | |
3669 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3670 | SAFI_UNICAST, 0, NULL, | |
3671 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3672 | } |
3673 | ||
3674 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3675 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3676 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3677 | NEIGHBOR_STR |
3678 | "Interface name or neighbor tag\n" | |
3a2d747c | 3679 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3680 | "Enable BGP on interface\n" |
3a2d747c | 3681 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3682 | AS_STR |
3a2d747c QY |
3683 | "Internal BGP peer\n" |
3684 | "External BGP peer\n") | |
b3a39dc5 | 3685 | { |
d62a17ae | 3686 | int idx_word = 1; |
3687 | int idx_remote_as = 5; | |
3688 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3689 | SAFI_UNICAST, 1, NULL, | |
3690 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3691 | } |
3692 | ||
718e3744 | 3693 | DEFUN (neighbor_peer_group, |
3694 | neighbor_peer_group_cmd, | |
3695 | "neighbor WORD peer-group", | |
3696 | NEIGHBOR_STR | |
a80beece | 3697 | "Interface name or neighbor tag\n" |
718e3744 | 3698 | "Configure peer-group\n") |
3699 | { | |
d62a17ae | 3700 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3701 | int idx_word = 1; | |
3702 | struct peer *peer; | |
3703 | struct peer_group *group; | |
718e3744 | 3704 | |
d62a17ae | 3705 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3706 | if (peer) { | |
3707 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3708 | return CMD_WARNING_CONFIG_FAILED; | |
3709 | } | |
718e3744 | 3710 | |
d62a17ae | 3711 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3712 | if (!group) { | |
3713 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3714 | return CMD_WARNING_CONFIG_FAILED; | |
3715 | } | |
718e3744 | 3716 | |
d62a17ae | 3717 | return CMD_SUCCESS; |
718e3744 | 3718 | } |
3719 | ||
3720 | DEFUN (no_neighbor, | |
3721 | no_neighbor_cmd, | |
dab8cd00 | 3722 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3723 | NO_STR |
3724 | NEIGHBOR_STR | |
3a2d747c QY |
3725 | NEIGHBOR_ADDR_STR2 |
3726 | "Specify a BGP neighbor\n" | |
3727 | AS_STR | |
3728 | "Internal BGP peer\n" | |
3729 | "External BGP peer\n") | |
718e3744 | 3730 | { |
d62a17ae | 3731 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3732 | int idx_peer = 2; | |
3733 | int ret; | |
3734 | union sockunion su; | |
3735 | struct peer_group *group; | |
3736 | struct peer *peer; | |
3737 | struct peer *other; | |
3738 | ||
3739 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3740 | if (ret < 0) { | |
3741 | /* look up for neighbor by interface name config. */ | |
3742 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3743 | if (peer) { | |
3744 | /* Request zebra to terminate IPv6 RAs on this | |
3745 | * interface. */ | |
3746 | if (peer->ifp) | |
3747 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3748 | peer_notify_unconfig(peer); |
d62a17ae | 3749 | peer_delete(peer); |
3750 | return CMD_SUCCESS; | |
3751 | } | |
f14e6fdb | 3752 | |
d62a17ae | 3753 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3754 | if (group) { |
3755 | peer_group_notify_unconfig(group); | |
d62a17ae | 3756 | peer_group_delete(group); |
4e2786df | 3757 | } else { |
d62a17ae | 3758 | vty_out(vty, "%% Create the peer-group first\n"); |
3759 | return CMD_WARNING_CONFIG_FAILED; | |
3760 | } | |
3761 | } else { | |
3762 | peer = peer_lookup(bgp, &su); | |
3763 | if (peer) { | |
3764 | if (peer_dynamic_neighbor(peer)) { | |
3765 | vty_out(vty, | |
3766 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3767 | return CMD_WARNING_CONFIG_FAILED; | |
3768 | } | |
3769 | ||
3770 | other = peer->doppelganger; | |
4e2786df | 3771 | peer_notify_unconfig(peer); |
d62a17ae | 3772 | peer_delete(peer); |
4e2786df DA |
3773 | if (other && other->status != Deleted) { |
3774 | peer_notify_unconfig(other); | |
d62a17ae | 3775 | peer_delete(other); |
4e2786df | 3776 | } |
d62a17ae | 3777 | } |
1ff9a340 | 3778 | } |
718e3744 | 3779 | |
d62a17ae | 3780 | return CMD_SUCCESS; |
718e3744 | 3781 | } |
3782 | ||
a80beece DS |
3783 | DEFUN (no_neighbor_interface_config, |
3784 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3785 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3786 | NO_STR |
3787 | NEIGHBOR_STR | |
3788 | "Interface name\n" | |
31500417 DW |
3789 | "Configure BGP on interface\n" |
3790 | "Enable BGP with v6 link-local only\n" | |
3791 | "Member of the peer-group\n" | |
16cedbb0 | 3792 | "Peer-group name\n" |
3a2d747c QY |
3793 | "Specify a BGP neighbor\n" |
3794 | AS_STR | |
3795 | "Internal BGP peer\n" | |
3796 | "External BGP peer\n") | |
a80beece | 3797 | { |
d62a17ae | 3798 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3799 | int idx_word = 2; | |
3800 | struct peer *peer; | |
3801 | ||
3802 | /* look up for neighbor by interface name config. */ | |
3803 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3804 | if (peer) { | |
3805 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3806 | if (peer->ifp) | |
3807 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3808 | peer_notify_unconfig(peer); |
d62a17ae | 3809 | peer_delete(peer); |
3810 | } else { | |
3811 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3812 | return CMD_WARNING_CONFIG_FAILED; | |
3813 | } | |
3814 | return CMD_SUCCESS; | |
a80beece DS |
3815 | } |
3816 | ||
718e3744 | 3817 | DEFUN (no_neighbor_peer_group, |
3818 | no_neighbor_peer_group_cmd, | |
3819 | "no neighbor WORD peer-group", | |
3820 | NO_STR | |
3821 | NEIGHBOR_STR | |
3822 | "Neighbor tag\n" | |
3823 | "Configure peer-group\n") | |
3824 | { | |
d62a17ae | 3825 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3826 | int idx_word = 2; | |
3827 | struct peer_group *group; | |
718e3744 | 3828 | |
d62a17ae | 3829 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3830 | if (group) { |
3831 | peer_group_notify_unconfig(group); | |
d62a17ae | 3832 | peer_group_delete(group); |
4e2786df | 3833 | } else { |
d62a17ae | 3834 | vty_out(vty, "%% Create the peer-group first\n"); |
3835 | return CMD_WARNING_CONFIG_FAILED; | |
3836 | } | |
3837 | return CMD_SUCCESS; | |
718e3744 | 3838 | } |
3839 | ||
a80beece DS |
3840 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3841 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3842 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3843 | NO_STR |
3844 | NEIGHBOR_STR | |
a80beece | 3845 | "Interface name or neighbor tag\n" |
718e3744 | 3846 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3847 | AS_STR |
3848 | "Internal BGP peer\n" | |
3849 | "External BGP peer\n") | |
718e3744 | 3850 | { |
d62a17ae | 3851 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3852 | int idx_word = 2; | |
3853 | struct peer_group *group; | |
3854 | struct peer *peer; | |
3855 | ||
3856 | /* look up for neighbor by interface name config. */ | |
3857 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3858 | if (peer) { | |
390485fd | 3859 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3860 | return CMD_SUCCESS; |
3861 | } | |
3862 | ||
3863 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3864 | if (group) | |
3865 | peer_group_remote_as_delete(group); | |
3866 | else { | |
3867 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3868 | return CMD_WARNING_CONFIG_FAILED; | |
3869 | } | |
3870 | return CMD_SUCCESS; | |
718e3744 | 3871 | } |
6b0655a2 | 3872 | |
718e3744 | 3873 | DEFUN (neighbor_local_as, |
3874 | neighbor_local_as_cmd, | |
9ccf14f7 | 3875 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3876 | NEIGHBOR_STR |
3877 | NEIGHBOR_ADDR_STR2 | |
3878 | "Specify a local-as number\n" | |
3879 | "AS number used as local AS\n") | |
3880 | { | |
d62a17ae | 3881 | int idx_peer = 1; |
3882 | int idx_number = 3; | |
3883 | struct peer *peer; | |
3884 | int ret; | |
3885 | as_t as; | |
718e3744 | 3886 | |
d62a17ae | 3887 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3888 | if (!peer) | |
3889 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3890 | |
d62a17ae | 3891 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3892 | ret = peer_local_as_set(peer, as, 0, 0); | |
3893 | return bgp_vty_return(vty, ret); | |
718e3744 | 3894 | } |
3895 | ||
3896 | DEFUN (neighbor_local_as_no_prepend, | |
3897 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3898 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3899 | NEIGHBOR_STR |
3900 | NEIGHBOR_ADDR_STR2 | |
3901 | "Specify a local-as number\n" | |
3902 | "AS number used as local AS\n" | |
3903 | "Do not prepend local-as to updates from ebgp peers\n") | |
3904 | { | |
d62a17ae | 3905 | int idx_peer = 1; |
3906 | int idx_number = 3; | |
3907 | struct peer *peer; | |
3908 | int ret; | |
3909 | as_t as; | |
718e3744 | 3910 | |
d62a17ae | 3911 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3912 | if (!peer) | |
3913 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3914 | |
d62a17ae | 3915 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3916 | ret = peer_local_as_set(peer, as, 1, 0); | |
3917 | return bgp_vty_return(vty, ret); | |
718e3744 | 3918 | } |
3919 | ||
9d3f9705 AC |
3920 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3921 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3922 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3923 | NEIGHBOR_STR |
3924 | NEIGHBOR_ADDR_STR2 | |
3925 | "Specify a local-as number\n" | |
3926 | "AS number used as local AS\n" | |
3927 | "Do not prepend local-as to updates from ebgp peers\n" | |
3928 | "Do not prepend local-as to updates from ibgp peers\n") | |
3929 | { | |
d62a17ae | 3930 | int idx_peer = 1; |
3931 | int idx_number = 3; | |
3932 | struct peer *peer; | |
3933 | int ret; | |
3934 | as_t as; | |
9d3f9705 | 3935 | |
d62a17ae | 3936 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3937 | if (!peer) | |
3938 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3939 | |
d62a17ae | 3940 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3941 | ret = peer_local_as_set(peer, as, 1, 1); | |
3942 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3943 | } |
3944 | ||
718e3744 | 3945 | DEFUN (no_neighbor_local_as, |
3946 | no_neighbor_local_as_cmd, | |
a636c635 | 3947 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3948 | NO_STR |
3949 | NEIGHBOR_STR | |
3950 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3951 | "Specify a local-as number\n" |
3952 | "AS number used as local AS\n" | |
3953 | "Do not prepend local-as to updates from ebgp peers\n" | |
3954 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3955 | { |
d62a17ae | 3956 | int idx_peer = 2; |
3957 | struct peer *peer; | |
3958 | int ret; | |
718e3744 | 3959 | |
d62a17ae | 3960 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3961 | if (!peer) | |
3962 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3963 | |
d62a17ae | 3964 | ret = peer_local_as_unset(peer); |
3965 | return bgp_vty_return(vty, ret); | |
718e3744 | 3966 | } |
3967 | ||
718e3744 | 3968 | |
3f9c7369 DS |
3969 | DEFUN (neighbor_solo, |
3970 | neighbor_solo_cmd, | |
9ccf14f7 | 3971 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3972 | NEIGHBOR_STR |
3973 | NEIGHBOR_ADDR_STR2 | |
3974 | "Solo peer - part of its own update group\n") | |
3975 | { | |
d62a17ae | 3976 | int idx_peer = 1; |
3977 | struct peer *peer; | |
3978 | int ret; | |
3f9c7369 | 3979 | |
d62a17ae | 3980 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3981 | if (!peer) | |
3982 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3983 | |
d62a17ae | 3984 | ret = update_group_adjust_soloness(peer, 1); |
3985 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3986 | } |
3987 | ||
3988 | DEFUN (no_neighbor_solo, | |
3989 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3990 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3991 | NO_STR |
3992 | NEIGHBOR_STR | |
3993 | NEIGHBOR_ADDR_STR2 | |
3994 | "Solo peer - part of its own update group\n") | |
3995 | { | |
d62a17ae | 3996 | int idx_peer = 2; |
3997 | struct peer *peer; | |
3998 | int ret; | |
3f9c7369 | 3999 | |
d62a17ae | 4000 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4001 | if (!peer) | |
4002 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4003 | |
d62a17ae | 4004 | ret = update_group_adjust_soloness(peer, 0); |
4005 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4006 | } |
4007 | ||
0df7c91f PJ |
4008 | DEFUN (neighbor_password, |
4009 | neighbor_password_cmd, | |
9ccf14f7 | 4010 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4011 | NEIGHBOR_STR |
4012 | NEIGHBOR_ADDR_STR2 | |
4013 | "Set a password\n" | |
4014 | "The password\n") | |
4015 | { | |
d62a17ae | 4016 | int idx_peer = 1; |
4017 | int idx_line = 3; | |
4018 | struct peer *peer; | |
4019 | int ret; | |
0df7c91f | 4020 | |
d62a17ae | 4021 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4022 | if (!peer) | |
4023 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4024 | |
d62a17ae | 4025 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4026 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4027 | } |
4028 | ||
4029 | DEFUN (no_neighbor_password, | |
4030 | no_neighbor_password_cmd, | |
a636c635 | 4031 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4032 | NO_STR |
4033 | NEIGHBOR_STR | |
4034 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4035 | "Set a password\n" |
4036 | "The password\n") | |
0df7c91f | 4037 | { |
d62a17ae | 4038 | int idx_peer = 2; |
4039 | struct peer *peer; | |
4040 | int ret; | |
0df7c91f | 4041 | |
d62a17ae | 4042 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4043 | if (!peer) | |
4044 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4045 | |
d62a17ae | 4046 | ret = peer_password_unset(peer); |
4047 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4048 | } |
6b0655a2 | 4049 | |
718e3744 | 4050 | DEFUN (neighbor_activate, |
4051 | neighbor_activate_cmd, | |
9ccf14f7 | 4052 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4053 | NEIGHBOR_STR |
4054 | NEIGHBOR_ADDR_STR2 | |
4055 | "Enable the Address Family for this Neighbor\n") | |
4056 | { | |
d62a17ae | 4057 | int idx_peer = 1; |
4058 | int ret; | |
4059 | struct peer *peer; | |
718e3744 | 4060 | |
d62a17ae | 4061 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4062 | if (!peer) | |
4063 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4064 | |
d62a17ae | 4065 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4066 | return bgp_vty_return(vty, ret); | |
718e3744 | 4067 | } |
4068 | ||
d62a17ae | 4069 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4070 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4071 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4072 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4073 | |
718e3744 | 4074 | DEFUN (no_neighbor_activate, |
4075 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4076 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4077 | NO_STR |
4078 | NEIGHBOR_STR | |
4079 | NEIGHBOR_ADDR_STR2 | |
4080 | "Enable the Address Family for this Neighbor\n") | |
4081 | { | |
d62a17ae | 4082 | int idx_peer = 2; |
4083 | int ret; | |
4084 | struct peer *peer; | |
718e3744 | 4085 | |
d62a17ae | 4086 | /* Lookup peer. */ |
4087 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4088 | if (!peer) | |
4089 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4090 | |
d62a17ae | 4091 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4092 | return bgp_vty_return(vty, ret); | |
718e3744 | 4093 | } |
6b0655a2 | 4094 | |
d62a17ae | 4095 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4096 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4097 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4098 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4099 | |
718e3744 | 4100 | DEFUN (neighbor_set_peer_group, |
4101 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4102 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4103 | NEIGHBOR_STR |
a80beece | 4104 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4105 | "Member of the peer-group\n" |
16cedbb0 | 4106 | "Peer-group name\n") |
718e3744 | 4107 | { |
d62a17ae | 4108 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4109 | int idx_peer = 1; | |
4110 | int idx_word = 3; | |
4111 | int ret; | |
4112 | as_t as; | |
4113 | union sockunion su; | |
4114 | struct peer *peer; | |
4115 | struct peer_group *group; | |
4116 | ||
d62a17ae | 4117 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4118 | if (ret < 0) { | |
4119 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4120 | if (!peer) { | |
4121 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4122 | argv[idx_peer]->arg); | |
4123 | return CMD_WARNING_CONFIG_FAILED; | |
4124 | } | |
4125 | } else { | |
4126 | if (peer_address_self_check(bgp, &su)) { | |
4127 | vty_out(vty, | |
4128 | "%% Can not configure the local system as neighbor\n"); | |
4129 | return CMD_WARNING_CONFIG_FAILED; | |
4130 | } | |
4131 | ||
4132 | /* Disallow for dynamic neighbor. */ | |
4133 | peer = peer_lookup(bgp, &su); | |
4134 | if (peer && peer_dynamic_neighbor(peer)) { | |
4135 | vty_out(vty, | |
4136 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4137 | return CMD_WARNING_CONFIG_FAILED; | |
4138 | } | |
4139 | } | |
4140 | ||
4141 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4142 | if (!group) { | |
4143 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4144 | return CMD_WARNING_CONFIG_FAILED; | |
4145 | } | |
4146 | ||
4147 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4148 | ||
4149 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4150 | vty_out(vty, | |
4151 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4152 | as); | |
4153 | return CMD_WARNING_CONFIG_FAILED; | |
4154 | } | |
4155 | ||
4156 | return bgp_vty_return(vty, ret); | |
4157 | } | |
4158 | ||
4159 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4160 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4161 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4162 | "Member of the peer-group\n" | |
4163 | "Peer-group name\n") | |
596c17ba | 4164 | |
718e3744 | 4165 | DEFUN (no_neighbor_set_peer_group, |
4166 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4167 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4168 | NO_STR |
4169 | NEIGHBOR_STR | |
a80beece | 4170 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4171 | "Member of the peer-group\n" |
16cedbb0 | 4172 | "Peer-group name\n") |
718e3744 | 4173 | { |
d62a17ae | 4174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4175 | int idx_peer = 2; | |
4176 | int idx_word = 4; | |
4177 | int ret; | |
4178 | struct peer *peer; | |
4179 | struct peer_group *group; | |
4180 | ||
4181 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4182 | if (!peer) | |
4183 | return CMD_WARNING_CONFIG_FAILED; | |
4184 | ||
4185 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4186 | if (!group) { | |
4187 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4188 | return CMD_WARNING_CONFIG_FAILED; | |
4189 | } | |
718e3744 | 4190 | |
4e2786df | 4191 | peer_notify_unconfig(peer); |
827ed707 | 4192 | ret = peer_delete(peer); |
718e3744 | 4193 | |
d62a17ae | 4194 | return bgp_vty_return(vty, ret); |
718e3744 | 4195 | } |
6b0655a2 | 4196 | |
d62a17ae | 4197 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4199 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4200 | "Member of the peer-group\n" | |
4201 | "Peer-group name\n") | |
596c17ba | 4202 | |
d62a17ae | 4203 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4204 | uint32_t flag, int set) |
718e3744 | 4205 | { |
d62a17ae | 4206 | int ret; |
4207 | struct peer *peer; | |
718e3744 | 4208 | |
d62a17ae | 4209 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4210 | if (!peer) | |
4211 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4212 | |
7ebe625c QY |
4213 | /* |
4214 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4215 | * we should not accept disable-connected-check. | |
4216 | */ | |
4217 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4218 | vty_out(vty, | |
4219 | "%s is directly connected peer, cannot accept disable-" | |
4220 | "connected-check\n", | |
4221 | ip_str); | |
4222 | return CMD_WARNING_CONFIG_FAILED; | |
4223 | } | |
4224 | ||
d62a17ae | 4225 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4226 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4227 | |
d62a17ae | 4228 | if (set) |
4229 | ret = peer_flag_set(peer, flag); | |
4230 | else | |
4231 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4232 | |
d62a17ae | 4233 | return bgp_vty_return(vty, ret); |
718e3744 | 4234 | } |
4235 | ||
47cbc09b | 4236 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4237 | { |
d62a17ae | 4238 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4239 | } |
4240 | ||
d62a17ae | 4241 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4242 | uint32_t flag) |
718e3744 | 4243 | { |
d62a17ae | 4244 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4245 | } |
4246 | ||
4247 | /* neighbor passive. */ | |
4248 | DEFUN (neighbor_passive, | |
4249 | neighbor_passive_cmd, | |
9ccf14f7 | 4250 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4251 | NEIGHBOR_STR |
4252 | NEIGHBOR_ADDR_STR2 | |
4253 | "Don't send open messages to this neighbor\n") | |
4254 | { | |
d62a17ae | 4255 | int idx_peer = 1; |
4256 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4257 | } |
4258 | ||
4259 | DEFUN (no_neighbor_passive, | |
4260 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4261 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4262 | NO_STR |
4263 | NEIGHBOR_STR | |
4264 | NEIGHBOR_ADDR_STR2 | |
4265 | "Don't send open messages to this neighbor\n") | |
4266 | { | |
d62a17ae | 4267 | int idx_peer = 2; |
4268 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4269 | } |
6b0655a2 | 4270 | |
718e3744 | 4271 | /* neighbor shutdown. */ |
73d70fa6 DL |
4272 | DEFUN (neighbor_shutdown_msg, |
4273 | neighbor_shutdown_msg_cmd, | |
4274 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4275 | NEIGHBOR_STR |
4276 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
4277 | "Administratively shut down this neighbor\n" |
4278 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4279 | "Shutdown message\n") | |
718e3744 | 4280 | { |
d62a17ae | 4281 | int idx_peer = 1; |
73d70fa6 | 4282 | |
d62a17ae | 4283 | if (argc >= 5) { |
4284 | struct peer *peer = | |
4285 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4286 | char *message; | |
73d70fa6 | 4287 | |
d62a17ae | 4288 | if (!peer) |
4289 | return CMD_WARNING_CONFIG_FAILED; | |
4290 | message = argv_concat(argv, argc, 4); | |
4291 | peer_tx_shutdown_message_set(peer, message); | |
4292 | XFREE(MTYPE_TMP, message); | |
4293 | } | |
73d70fa6 | 4294 | |
d62a17ae | 4295 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4296 | } |
4297 | ||
d62a17ae | 4298 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4299 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4300 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4301 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4302 | |
4303 | DEFUN (no_neighbor_shutdown_msg, | |
4304 | no_neighbor_shutdown_msg_cmd, | |
4305 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4306 | NO_STR | |
4307 | NEIGHBOR_STR | |
4308 | NEIGHBOR_ADDR_STR2 | |
4309 | "Administratively shut down this neighbor\n" | |
4310 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4311 | "Shutdown message\n") | |
718e3744 | 4312 | { |
d62a17ae | 4313 | int idx_peer = 2; |
73d70fa6 | 4314 | |
d62a17ae | 4315 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4316 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4317 | } |
6b0655a2 | 4318 | |
d62a17ae | 4319 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4321 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4322 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4323 | |
718e3744 | 4324 | /* neighbor capability dynamic. */ |
4325 | DEFUN (neighbor_capability_dynamic, | |
4326 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4327 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4328 | NEIGHBOR_STR |
4329 | NEIGHBOR_ADDR_STR2 | |
4330 | "Advertise capability to the peer\n" | |
4331 | "Advertise dynamic capability to this neighbor\n") | |
4332 | { | |
d62a17ae | 4333 | int idx_peer = 1; |
4334 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4335 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4336 | } |
4337 | ||
4338 | DEFUN (no_neighbor_capability_dynamic, | |
4339 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4340 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4341 | NO_STR |
4342 | NEIGHBOR_STR | |
4343 | NEIGHBOR_ADDR_STR2 | |
4344 | "Advertise capability to the peer\n" | |
4345 | "Advertise dynamic capability to this neighbor\n") | |
4346 | { | |
d62a17ae | 4347 | int idx_peer = 2; |
4348 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4349 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4350 | } |
6b0655a2 | 4351 | |
718e3744 | 4352 | /* neighbor dont-capability-negotiate */ |
4353 | DEFUN (neighbor_dont_capability_negotiate, | |
4354 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4355 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4356 | NEIGHBOR_STR |
4357 | NEIGHBOR_ADDR_STR2 | |
4358 | "Do not perform capability negotiation\n") | |
4359 | { | |
d62a17ae | 4360 | int idx_peer = 1; |
4361 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4362 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4363 | } |
4364 | ||
4365 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4366 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4367 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4368 | NO_STR |
4369 | NEIGHBOR_STR | |
4370 | NEIGHBOR_ADDR_STR2 | |
4371 | "Do not perform capability negotiation\n") | |
4372 | { | |
d62a17ae | 4373 | int idx_peer = 2; |
4374 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4375 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4376 | } |
6b0655a2 | 4377 | |
8a92a8a0 DS |
4378 | /* neighbor capability extended next hop encoding */ |
4379 | DEFUN (neighbor_capability_enhe, | |
4380 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4381 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4382 | NEIGHBOR_STR |
4383 | NEIGHBOR_ADDR_STR2 | |
4384 | "Advertise capability to the peer\n" | |
4385 | "Advertise extended next-hop capability to the peer\n") | |
4386 | { | |
d62a17ae | 4387 | int idx_peer = 1; |
4388 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4389 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4390 | } |
4391 | ||
4392 | DEFUN (no_neighbor_capability_enhe, | |
4393 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4394 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4395 | NO_STR |
4396 | NEIGHBOR_STR | |
4397 | NEIGHBOR_ADDR_STR2 | |
4398 | "Advertise capability to the peer\n" | |
4399 | "Advertise extended next-hop capability to the peer\n") | |
4400 | { | |
d62a17ae | 4401 | int idx_peer = 2; |
4402 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4403 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4404 | } |
4405 | ||
d62a17ae | 4406 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4407 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4408 | int set) |
718e3744 | 4409 | { |
d62a17ae | 4410 | int ret; |
4411 | struct peer *peer; | |
718e3744 | 4412 | |
d62a17ae | 4413 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4414 | if (!peer) | |
4415 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4416 | |
d62a17ae | 4417 | if (set) |
4418 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4419 | else | |
4420 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4421 | |
d62a17ae | 4422 | return bgp_vty_return(vty, ret); |
718e3744 | 4423 | } |
4424 | ||
d62a17ae | 4425 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4426 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4427 | { |
d62a17ae | 4428 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4429 | } |
4430 | ||
d62a17ae | 4431 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4432 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4433 | { |
d62a17ae | 4434 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4435 | } |
6b0655a2 | 4436 | |
718e3744 | 4437 | /* neighbor capability orf prefix-list. */ |
4438 | DEFUN (neighbor_capability_orf_prefix, | |
4439 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4440 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4441 | NEIGHBOR_STR |
4442 | NEIGHBOR_ADDR_STR2 | |
4443 | "Advertise capability to the peer\n" | |
4444 | "Advertise ORF capability to the peer\n" | |
4445 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4446 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4447 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4448 | "Capability to SEND the ORF to this neighbor\n") | |
4449 | { | |
d62a17ae | 4450 | int idx_peer = 1; |
4451 | int idx_send_recv = 5; | |
d7c0a89a | 4452 | uint16_t flag = 0; |
d62a17ae | 4453 | |
4454 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4455 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4456 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4457 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4458 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4459 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4460 | else { | |
4461 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4462 | return CMD_WARNING_CONFIG_FAILED; | |
4463 | } | |
4464 | ||
4465 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4466 | bgp_node_safi(vty), flag); | |
4467 | } | |
4468 | ||
4469 | ALIAS_HIDDEN( | |
4470 | neighbor_capability_orf_prefix, | |
4471 | neighbor_capability_orf_prefix_hidden_cmd, | |
4472 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4473 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4474 | "Advertise capability to the peer\n" | |
4475 | "Advertise ORF capability to the peer\n" | |
4476 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4477 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4478 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4479 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4480 | |
718e3744 | 4481 | DEFUN (no_neighbor_capability_orf_prefix, |
4482 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4483 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4484 | NO_STR |
4485 | NEIGHBOR_STR | |
4486 | NEIGHBOR_ADDR_STR2 | |
4487 | "Advertise capability to the peer\n" | |
4488 | "Advertise ORF capability to the peer\n" | |
4489 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4490 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4491 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4492 | "Capability to SEND the ORF to this neighbor\n") | |
4493 | { | |
d62a17ae | 4494 | int idx_peer = 2; |
4495 | int idx_send_recv = 6; | |
d7c0a89a | 4496 | uint16_t flag = 0; |
d62a17ae | 4497 | |
4498 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4499 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4500 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4501 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4502 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4503 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4504 | else { | |
4505 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4506 | return CMD_WARNING_CONFIG_FAILED; | |
4507 | } | |
4508 | ||
4509 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4510 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4511 | flag); | |
4512 | } | |
4513 | ||
4514 | ALIAS_HIDDEN( | |
4515 | no_neighbor_capability_orf_prefix, | |
4516 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4517 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4518 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4519 | "Advertise capability to the peer\n" | |
4520 | "Advertise ORF capability to the peer\n" | |
4521 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4522 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4523 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4524 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4525 | |
718e3744 | 4526 | /* neighbor next-hop-self. */ |
4527 | DEFUN (neighbor_nexthop_self, | |
4528 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4529 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4530 | NEIGHBOR_STR |
4531 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4532 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4533 | { |
d62a17ae | 4534 | int idx_peer = 1; |
4535 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4536 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4537 | } |
9e7a53c1 | 4538 | |
d62a17ae | 4539 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4540 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4541 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4542 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4543 | |
a538debe DS |
4544 | /* neighbor next-hop-self. */ |
4545 | DEFUN (neighbor_nexthop_self_force, | |
4546 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4547 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4548 | NEIGHBOR_STR |
4549 | NEIGHBOR_ADDR_STR2 | |
4550 | "Disable the next hop calculation for this neighbor\n" | |
4551 | "Set the next hop to self for reflected routes\n") | |
4552 | { | |
d62a17ae | 4553 | int idx_peer = 1; |
4554 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4555 | bgp_node_safi(vty), | |
4556 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4557 | } |
4558 | ||
d62a17ae | 4559 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4560 | neighbor_nexthop_self_force_hidden_cmd, | |
4561 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4562 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4563 | "Disable the next hop calculation for this neighbor\n" | |
4564 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4565 | |
1bc4e531 DA |
4566 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4567 | neighbor_nexthop_self_all_hidden_cmd, | |
4568 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4569 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4570 | "Disable the next hop calculation for this neighbor\n" | |
4571 | "Set the next hop to self for reflected routes\n") | |
4572 | ||
718e3744 | 4573 | DEFUN (no_neighbor_nexthop_self, |
4574 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4575 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4576 | NO_STR |
4577 | NEIGHBOR_STR | |
4578 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4579 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4580 | { |
d62a17ae | 4581 | int idx_peer = 2; |
4582 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4583 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4584 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4585 | } |
6b0655a2 | 4586 | |
d62a17ae | 4587 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4588 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4589 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4590 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4591 | |
88b8ed8d | 4592 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4593 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4594 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4595 | NO_STR |
4596 | NEIGHBOR_STR | |
4597 | NEIGHBOR_ADDR_STR2 | |
4598 | "Disable the next hop calculation for this neighbor\n" | |
4599 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4600 | { |
d62a17ae | 4601 | int idx_peer = 2; |
4602 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4603 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4604 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4605 | } |
a538debe | 4606 | |
d62a17ae | 4607 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4608 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4610 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4611 | "Disable the next hop calculation for this neighbor\n" | |
4612 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4613 | |
1bc4e531 DA |
4614 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4615 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4616 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4617 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4618 | "Disable the next hop calculation for this neighbor\n" | |
4619 | "Set the next hop to self for reflected routes\n") | |
4620 | ||
c7122e14 DS |
4621 | /* neighbor as-override */ |
4622 | DEFUN (neighbor_as_override, | |
4623 | neighbor_as_override_cmd, | |
9ccf14f7 | 4624 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4625 | NEIGHBOR_STR |
4626 | NEIGHBOR_ADDR_STR2 | |
4627 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4628 | { | |
d62a17ae | 4629 | int idx_peer = 1; |
4630 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4631 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4632 | } |
4633 | ||
d62a17ae | 4634 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4635 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4636 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4637 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4638 | |
c7122e14 DS |
4639 | DEFUN (no_neighbor_as_override, |
4640 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4641 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4642 | NO_STR |
4643 | NEIGHBOR_STR | |
4644 | NEIGHBOR_ADDR_STR2 | |
4645 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4646 | { | |
d62a17ae | 4647 | int idx_peer = 2; |
4648 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4649 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4650 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4651 | } |
4652 | ||
d62a17ae | 4653 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4654 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4655 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4656 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4657 | |
718e3744 | 4658 | /* neighbor remove-private-AS. */ |
4659 | DEFUN (neighbor_remove_private_as, | |
4660 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4661 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4662 | NEIGHBOR_STR |
4663 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4664 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4665 | { |
d62a17ae | 4666 | int idx_peer = 1; |
4667 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4668 | bgp_node_safi(vty), | |
4669 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4670 | } |
4671 | ||
d62a17ae | 4672 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4673 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4674 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4675 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4676 | |
5000f21c DS |
4677 | DEFUN (neighbor_remove_private_as_all, |
4678 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4679 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4680 | NEIGHBOR_STR |
4681 | NEIGHBOR_ADDR_STR2 | |
4682 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4683 | "Apply to all AS numbers\n") |
5000f21c | 4684 | { |
d62a17ae | 4685 | int idx_peer = 1; |
4686 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4687 | bgp_node_safi(vty), | |
4688 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4689 | } |
4690 | ||
d62a17ae | 4691 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4692 | neighbor_remove_private_as_all_hidden_cmd, | |
4693 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4694 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4695 | "Remove private ASNs in outbound updates\n" | |
4696 | "Apply to all AS numbers") | |
596c17ba | 4697 | |
5000f21c DS |
4698 | DEFUN (neighbor_remove_private_as_replace_as, |
4699 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4700 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4701 | NEIGHBOR_STR |
4702 | NEIGHBOR_ADDR_STR2 | |
4703 | "Remove private ASNs in outbound updates\n" | |
4704 | "Replace private ASNs with our ASN in outbound updates\n") | |
4705 | { | |
d62a17ae | 4706 | int idx_peer = 1; |
4707 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4708 | bgp_node_safi(vty), | |
4709 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4710 | } |
4711 | ||
d62a17ae | 4712 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4713 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4714 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4715 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4716 | "Remove private ASNs in outbound updates\n" | |
4717 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4718 | |
5000f21c DS |
4719 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4720 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4721 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4722 | NEIGHBOR_STR |
4723 | NEIGHBOR_ADDR_STR2 | |
4724 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4725 | "Apply to all AS numbers\n" |
5000f21c DS |
4726 | "Replace private ASNs with our ASN in outbound updates\n") |
4727 | { | |
d62a17ae | 4728 | int idx_peer = 1; |
4729 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4730 | bgp_node_safi(vty), | |
4731 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4732 | } |
4733 | ||
d62a17ae | 4734 | ALIAS_HIDDEN( |
4735 | neighbor_remove_private_as_all_replace_as, | |
4736 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4737 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4738 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4739 | "Remove private ASNs in outbound updates\n" | |
4740 | "Apply to all AS numbers\n" | |
4741 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4742 | |
718e3744 | 4743 | DEFUN (no_neighbor_remove_private_as, |
4744 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4745 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4746 | NO_STR |
4747 | NEIGHBOR_STR | |
4748 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4749 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4750 | { |
d62a17ae | 4751 | int idx_peer = 2; |
4752 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4753 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4754 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4755 | } |
6b0655a2 | 4756 | |
d62a17ae | 4757 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4758 | no_neighbor_remove_private_as_hidden_cmd, | |
4759 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4760 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4761 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4762 | |
88b8ed8d | 4763 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4764 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4766 | NO_STR |
4767 | NEIGHBOR_STR | |
4768 | NEIGHBOR_ADDR_STR2 | |
4769 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4770 | "Apply to all AS numbers\n") |
88b8ed8d | 4771 | { |
d62a17ae | 4772 | int idx_peer = 2; |
4773 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4774 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4775 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4776 | } |
5000f21c | 4777 | |
d62a17ae | 4778 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4779 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4780 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4781 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4782 | "Remove private ASNs in outbound updates\n" | |
4783 | "Apply to all AS numbers\n") | |
596c17ba | 4784 | |
88b8ed8d | 4785 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4786 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4787 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4788 | NO_STR |
4789 | NEIGHBOR_STR | |
4790 | NEIGHBOR_ADDR_STR2 | |
4791 | "Remove private ASNs in outbound updates\n" | |
4792 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4793 | { |
d62a17ae | 4794 | int idx_peer = 2; |
4795 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4796 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4797 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4798 | } |
5000f21c | 4799 | |
d62a17ae | 4800 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4801 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4802 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4803 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4804 | "Remove private ASNs in outbound updates\n" | |
4805 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4806 | |
88b8ed8d | 4807 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4808 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4810 | NO_STR |
4811 | NEIGHBOR_STR | |
4812 | NEIGHBOR_ADDR_STR2 | |
4813 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4814 | "Apply to all AS numbers\n" |
5000f21c | 4815 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4816 | { |
d62a17ae | 4817 | int idx_peer = 2; |
4818 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4819 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4820 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4821 | } |
5000f21c | 4822 | |
d62a17ae | 4823 | ALIAS_HIDDEN( |
4824 | no_neighbor_remove_private_as_all_replace_as, | |
4825 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4826 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4827 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4828 | "Remove private ASNs in outbound updates\n" | |
4829 | "Apply to all AS numbers\n" | |
4830 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4831 | |
5000f21c | 4832 | |
718e3744 | 4833 | /* neighbor send-community. */ |
4834 | DEFUN (neighbor_send_community, | |
4835 | neighbor_send_community_cmd, | |
9ccf14f7 | 4836 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4837 | NEIGHBOR_STR |
4838 | NEIGHBOR_ADDR_STR2 | |
4839 | "Send Community attribute to this neighbor\n") | |
4840 | { | |
d62a17ae | 4841 | int idx_peer = 1; |
27c05d4d | 4842 | |
d62a17ae | 4843 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4844 | bgp_node_safi(vty), | |
4845 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4846 | } |
4847 | ||
d62a17ae | 4848 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4849 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4850 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4851 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4852 | |
718e3744 | 4853 | DEFUN (no_neighbor_send_community, |
4854 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4856 | NO_STR |
4857 | NEIGHBOR_STR | |
4858 | NEIGHBOR_ADDR_STR2 | |
4859 | "Send Community attribute to this neighbor\n") | |
4860 | { | |
d62a17ae | 4861 | int idx_peer = 2; |
27c05d4d | 4862 | |
d62a17ae | 4863 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4864 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4865 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4866 | } |
6b0655a2 | 4867 | |
d62a17ae | 4868 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4869 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4870 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4871 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4872 | |
718e3744 | 4873 | /* neighbor send-community extended. */ |
4874 | DEFUN (neighbor_send_community_type, | |
4875 | neighbor_send_community_type_cmd, | |
57d187bc | 4876 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4877 | NEIGHBOR_STR |
4878 | NEIGHBOR_ADDR_STR2 | |
4879 | "Send Community attribute to this neighbor\n" | |
4880 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4881 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4882 | "Send Extended Community attributes\n" |
57d187bc JS |
4883 | "Send Standard Community attributes\n" |
4884 | "Send Large Community attributes\n") | |
718e3744 | 4885 | { |
27c05d4d | 4886 | int idx_peer = 1; |
d7c0a89a | 4887 | uint32_t flag = 0; |
27c05d4d | 4888 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4889 | |
27c05d4d | 4890 | if (strmatch(type, "standard")) { |
d62a17ae | 4891 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4892 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4893 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4894 | } else if (strmatch(type, "large")) { |
d62a17ae | 4895 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4896 | } else if (strmatch(type, "both")) { |
d62a17ae | 4897 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4898 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4899 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4900 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4901 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4902 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4903 | } | |
4904 | ||
27c05d4d | 4905 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4906 | bgp_node_safi(vty), flag); |
4907 | } | |
4908 | ||
4909 | ALIAS_HIDDEN( | |
4910 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4911 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4912 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4913 | "Send Community attribute to this neighbor\n" | |
4914 | "Send Standard and Extended Community attributes\n" | |
4915 | "Send Standard, Large and Extended Community attributes\n" | |
4916 | "Send Extended Community attributes\n" | |
4917 | "Send Standard Community attributes\n" | |
4918 | "Send Large Community attributes\n") | |
596c17ba | 4919 | |
718e3744 | 4920 | DEFUN (no_neighbor_send_community_type, |
4921 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4922 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4923 | NO_STR |
4924 | NEIGHBOR_STR | |
4925 | NEIGHBOR_ADDR_STR2 | |
4926 | "Send Community attribute to this neighbor\n" | |
4927 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4928 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4929 | "Send Extended Community attributes\n" |
57d187bc JS |
4930 | "Send Standard Community attributes\n" |
4931 | "Send Large Community attributes\n") | |
718e3744 | 4932 | { |
d62a17ae | 4933 | int idx_peer = 2; |
27c05d4d | 4934 | uint32_t flag = 0; |
d62a17ae | 4935 | const char *type = argv[argc - 1]->text; |
4936 | ||
27c05d4d PM |
4937 | if (strmatch(type, "standard")) { |
4938 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4939 | } else if (strmatch(type, "extended")) { | |
4940 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4941 | } else if (strmatch(type, "large")) { | |
4942 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4943 | } else if (strmatch(type, "both")) { | |
4944 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4945 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4946 | } else { /* if (strmatch(type, "all")) */ | |
4947 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4948 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4949 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4950 | } | |
4951 | ||
4952 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4953 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4954 | flag); | |
d62a17ae | 4955 | } |
4956 | ||
4957 | ALIAS_HIDDEN( | |
4958 | no_neighbor_send_community_type, | |
4959 | no_neighbor_send_community_type_hidden_cmd, | |
4960 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4961 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4962 | "Send Community attribute to this neighbor\n" | |
4963 | "Send Standard and Extended Community attributes\n" | |
4964 | "Send Standard, Large and Extended Community attributes\n" | |
4965 | "Send Extended Community attributes\n" | |
4966 | "Send Standard Community attributes\n" | |
4967 | "Send Large Community attributes\n") | |
596c17ba | 4968 | |
718e3744 | 4969 | /* neighbor soft-reconfig. */ |
4970 | DEFUN (neighbor_soft_reconfiguration, | |
4971 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4972 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4973 | NEIGHBOR_STR |
4974 | NEIGHBOR_ADDR_STR2 | |
4975 | "Per neighbor soft reconfiguration\n" | |
4976 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4977 | { | |
d62a17ae | 4978 | int idx_peer = 1; |
4979 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4980 | bgp_node_safi(vty), | |
4981 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4982 | } |
4983 | ||
d62a17ae | 4984 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4985 | neighbor_soft_reconfiguration_hidden_cmd, | |
4986 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4987 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4988 | "Per neighbor soft reconfiguration\n" | |
4989 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4990 | |
718e3744 | 4991 | DEFUN (no_neighbor_soft_reconfiguration, |
4992 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4993 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4994 | NO_STR |
4995 | NEIGHBOR_STR | |
4996 | NEIGHBOR_ADDR_STR2 | |
4997 | "Per neighbor soft reconfiguration\n" | |
4998 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4999 | { | |
d62a17ae | 5000 | int idx_peer = 2; |
5001 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5002 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5003 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5004 | } |
6b0655a2 | 5005 | |
d62a17ae | 5006 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5007 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5009 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5010 | "Per neighbor soft reconfiguration\n" | |
5011 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5012 | |
718e3744 | 5013 | DEFUN (neighbor_route_reflector_client, |
5014 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5015 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5016 | NEIGHBOR_STR |
5017 | NEIGHBOR_ADDR_STR2 | |
5018 | "Configure a neighbor as Route Reflector client\n") | |
5019 | { | |
d62a17ae | 5020 | int idx_peer = 1; |
5021 | struct peer *peer; | |
718e3744 | 5022 | |
5023 | ||
d62a17ae | 5024 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5025 | if (!peer) | |
5026 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5027 | |
d62a17ae | 5028 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5029 | bgp_node_safi(vty), | |
5030 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5031 | } |
5032 | ||
d62a17ae | 5033 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5034 | neighbor_route_reflector_client_hidden_cmd, | |
5035 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5036 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5037 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5038 | |
718e3744 | 5039 | DEFUN (no_neighbor_route_reflector_client, |
5040 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5041 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5042 | NO_STR |
5043 | NEIGHBOR_STR | |
5044 | NEIGHBOR_ADDR_STR2 | |
5045 | "Configure a neighbor as Route Reflector client\n") | |
5046 | { | |
d62a17ae | 5047 | int idx_peer = 2; |
5048 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5049 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5050 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5051 | } |
6b0655a2 | 5052 | |
d62a17ae | 5053 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5054 | no_neighbor_route_reflector_client_hidden_cmd, | |
5055 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5056 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5057 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5058 | |
718e3744 | 5059 | /* neighbor route-server-client. */ |
5060 | DEFUN (neighbor_route_server_client, | |
5061 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5062 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5063 | NEIGHBOR_STR |
5064 | NEIGHBOR_ADDR_STR2 | |
5065 | "Configure a neighbor as Route Server client\n") | |
5066 | { | |
d62a17ae | 5067 | int idx_peer = 1; |
5068 | struct peer *peer; | |
2a3d5731 | 5069 | |
d62a17ae | 5070 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5071 | if (!peer) | |
5072 | return CMD_WARNING_CONFIG_FAILED; | |
5073 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5074 | bgp_node_safi(vty), | |
5075 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5076 | } |
5077 | ||
d62a17ae | 5078 | ALIAS_HIDDEN(neighbor_route_server_client, |
5079 | neighbor_route_server_client_hidden_cmd, | |
5080 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5081 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5082 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5083 | |
718e3744 | 5084 | DEFUN (no_neighbor_route_server_client, |
5085 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5086 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5087 | NO_STR |
5088 | NEIGHBOR_STR | |
5089 | NEIGHBOR_ADDR_STR2 | |
5090 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5091 | { |
d62a17ae | 5092 | int idx_peer = 2; |
5093 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5094 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5095 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5096 | } |
6b0655a2 | 5097 | |
d62a17ae | 5098 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5099 | no_neighbor_route_server_client_hidden_cmd, | |
5100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5101 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5102 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5103 | |
fee0f4c6 | 5104 | DEFUN (neighbor_nexthop_local_unchanged, |
5105 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5106 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5107 | NEIGHBOR_STR |
5108 | NEIGHBOR_ADDR_STR2 | |
5109 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5110 | "Leave link-local nexthop unchanged for this peer\n") | |
5111 | { | |
d62a17ae | 5112 | int idx_peer = 1; |
5113 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5114 | bgp_node_safi(vty), | |
5115 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5116 | } |
6b0655a2 | 5117 | |
fee0f4c6 | 5118 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5119 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5121 | NO_STR |
5122 | NEIGHBOR_STR | |
5123 | NEIGHBOR_ADDR_STR2 | |
5124 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5125 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5126 | { |
d62a17ae | 5127 | int idx_peer = 2; |
5128 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5129 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5130 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5131 | } |
6b0655a2 | 5132 | |
718e3744 | 5133 | DEFUN (neighbor_attr_unchanged, |
5134 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5135 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5136 | NEIGHBOR_STR |
5137 | NEIGHBOR_ADDR_STR2 | |
5138 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5139 | "As-path attribute\n" | |
5140 | "Nexthop attribute\n" | |
a8206004 | 5141 | "Med attribute\n") |
718e3744 | 5142 | { |
d62a17ae | 5143 | int idx = 0; |
8eeb0335 DW |
5144 | char *peer_str = argv[1]->arg; |
5145 | struct peer *peer; | |
d7c0a89a | 5146 | uint16_t flags = 0; |
8eeb0335 DW |
5147 | afi_t afi = bgp_node_afi(vty); |
5148 | safi_t safi = bgp_node_safi(vty); | |
5149 | ||
5150 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5151 | if (!peer) | |
5152 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5153 | |
5154 | if (argv_find(argv, argc, "as-path", &idx)) | |
5155 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5156 | idx = 0; | |
5157 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5158 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5159 | idx = 0; | |
5160 | if (argv_find(argv, argc, "med", &idx)) | |
5161 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5162 | ||
8eeb0335 DW |
5163 | /* no flags means all of them! */ |
5164 | if (!flags) { | |
d62a17ae | 5165 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
5166 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5167 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5168 | } else { |
a4d82a8a PZ |
5169 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
5170 | && peer_af_flag_check(peer, afi, safi, | |
5171 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
5172 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5173 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5174 | } | |
5175 | ||
a4d82a8a PZ |
5176 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
5177 | && peer_af_flag_check(peer, afi, safi, | |
5178 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
5179 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5180 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5181 | } | |
5182 | ||
a4d82a8a PZ |
5183 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
5184 | && peer_af_flag_check(peer, afi, safi, | |
5185 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
5186 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5187 | PEER_FLAG_MED_UNCHANGED); | |
5188 | } | |
d62a17ae | 5189 | } |
5190 | ||
8eeb0335 | 5191 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 5192 | } |
5193 | ||
5194 | ALIAS_HIDDEN( | |
5195 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5196 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5197 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5198 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5199 | "As-path attribute\n" | |
5200 | "Nexthop attribute\n" | |
5201 | "Med attribute\n") | |
596c17ba | 5202 | |
718e3744 | 5203 | DEFUN (no_neighbor_attr_unchanged, |
5204 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5205 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5206 | NO_STR |
718e3744 | 5207 | NEIGHBOR_STR |
5208 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5209 | "BGP attribute is propagated unchanged to this neighbor\n" |
5210 | "As-path attribute\n" | |
40e718b5 | 5211 | "Nexthop attribute\n" |
a8206004 | 5212 | "Med attribute\n") |
718e3744 | 5213 | { |
d62a17ae | 5214 | int idx = 0; |
5215 | char *peer = argv[2]->arg; | |
d7c0a89a | 5216 | uint16_t flags = 0; |
d62a17ae | 5217 | |
5218 | if (argv_find(argv, argc, "as-path", &idx)) | |
5219 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5220 | idx = 0; | |
5221 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5222 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5223 | idx = 0; | |
5224 | if (argv_find(argv, argc, "med", &idx)) | |
5225 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5226 | ||
5227 | if (!flags) // no flags means all of them! | |
5228 | { | |
5229 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5230 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5231 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5232 | } | |
5233 | ||
5234 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
5235 | bgp_node_safi(vty), flags); | |
5236 | } | |
5237 | ||
5238 | ALIAS_HIDDEN( | |
5239 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5240 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5241 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5242 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5243 | "As-path attribute\n" | |
5244 | "Nexthop attribute\n" | |
5245 | "Med attribute\n") | |
718e3744 | 5246 | |
718e3744 | 5247 | /* EBGP multihop configuration. */ |
d62a17ae | 5248 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5249 | const char *ttl_str) | |
718e3744 | 5250 | { |
d62a17ae | 5251 | struct peer *peer; |
5252 | unsigned int ttl; | |
718e3744 | 5253 | |
d62a17ae | 5254 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5255 | if (!peer) | |
5256 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5257 | |
d62a17ae | 5258 | if (peer->conf_if) |
5259 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5260 | |
d62a17ae | 5261 | if (!ttl_str) |
5262 | ttl = MAXTTL; | |
5263 | else | |
5264 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5265 | |
d62a17ae | 5266 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5267 | } |
5268 | ||
d62a17ae | 5269 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5270 | { |
d62a17ae | 5271 | struct peer *peer; |
718e3744 | 5272 | |
d62a17ae | 5273 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5274 | if (!peer) | |
5275 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5276 | |
d62a17ae | 5277 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5278 | } |
5279 | ||
5280 | /* neighbor ebgp-multihop. */ | |
5281 | DEFUN (neighbor_ebgp_multihop, | |
5282 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5283 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5284 | NEIGHBOR_STR |
5285 | NEIGHBOR_ADDR_STR2 | |
5286 | "Allow EBGP neighbors not on directly connected networks\n") | |
5287 | { | |
d62a17ae | 5288 | int idx_peer = 1; |
5289 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5290 | } |
5291 | ||
5292 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5293 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5294 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5295 | NEIGHBOR_STR |
5296 | NEIGHBOR_ADDR_STR2 | |
5297 | "Allow EBGP neighbors not on directly connected networks\n" | |
5298 | "maximum hop count\n") | |
5299 | { | |
d62a17ae | 5300 | int idx_peer = 1; |
5301 | int idx_number = 3; | |
5302 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5303 | argv[idx_number]->arg); | |
718e3744 | 5304 | } |
5305 | ||
5306 | DEFUN (no_neighbor_ebgp_multihop, | |
5307 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5308 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5309 | NO_STR |
5310 | NEIGHBOR_STR | |
5311 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5312 | "Allow EBGP neighbors not on directly connected networks\n" |
5313 | "maximum hop count\n") | |
718e3744 | 5314 | { |
d62a17ae | 5315 | int idx_peer = 2; |
5316 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5317 | } |
5318 | ||
6b0655a2 | 5319 | |
6ffd2079 | 5320 | /* disable-connected-check */ |
5321 | DEFUN (neighbor_disable_connected_check, | |
5322 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5323 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5324 | NEIGHBOR_STR |
7ebe625c | 5325 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5326 | "one-hop away EBGP peer using loopback address\n" |
5327 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5328 | { |
d62a17ae | 5329 | int idx_peer = 1; |
5330 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5331 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5332 | } |
5333 | ||
5334 | DEFUN (no_neighbor_disable_connected_check, | |
5335 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5337 | NO_STR |
5338 | NEIGHBOR_STR | |
7ebe625c | 5339 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5340 | "one-hop away EBGP peer using loopback address\n" |
5341 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5342 | { |
d62a17ae | 5343 | int idx_peer = 2; |
5344 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5345 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5346 | } |
5347 | ||
47cbc09b PM |
5348 | |
5349 | /* enforce-first-as */ | |
5350 | DEFUN (neighbor_enforce_first_as, | |
5351 | neighbor_enforce_first_as_cmd, | |
5352 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5353 | NEIGHBOR_STR | |
5354 | NEIGHBOR_ADDR_STR2 | |
5355 | "Enforce the first AS for EBGP routes\n") | |
5356 | { | |
5357 | int idx_peer = 1; | |
5358 | ||
5359 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5360 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5361 | } | |
5362 | ||
5363 | DEFUN (no_neighbor_enforce_first_as, | |
5364 | no_neighbor_enforce_first_as_cmd, | |
5365 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5366 | NO_STR | |
5367 | NEIGHBOR_STR | |
5368 | NEIGHBOR_ADDR_STR2 | |
5369 | "Enforce the first AS for EBGP routes\n") | |
5370 | { | |
5371 | int idx_peer = 2; | |
5372 | ||
5373 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5374 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5375 | } | |
5376 | ||
5377 | ||
718e3744 | 5378 | DEFUN (neighbor_description, |
5379 | neighbor_description_cmd, | |
e961923c | 5380 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5381 | NEIGHBOR_STR |
5382 | NEIGHBOR_ADDR_STR2 | |
5383 | "Neighbor specific description\n" | |
5384 | "Up to 80 characters describing this neighbor\n") | |
5385 | { | |
d62a17ae | 5386 | int idx_peer = 1; |
5387 | int idx_line = 3; | |
5388 | struct peer *peer; | |
5389 | char *str; | |
718e3744 | 5390 | |
d62a17ae | 5391 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5392 | if (!peer) | |
5393 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5394 | |
d62a17ae | 5395 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5396 | |
d62a17ae | 5397 | peer_description_set(peer, str); |
718e3744 | 5398 | |
d62a17ae | 5399 | XFREE(MTYPE_TMP, str); |
718e3744 | 5400 | |
d62a17ae | 5401 | return CMD_SUCCESS; |
718e3744 | 5402 | } |
5403 | ||
5404 | DEFUN (no_neighbor_description, | |
5405 | no_neighbor_description_cmd, | |
a14810f4 | 5406 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5407 | NO_STR |
5408 | NEIGHBOR_STR | |
5409 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5410 | "Neighbor specific description\n") |
718e3744 | 5411 | { |
d62a17ae | 5412 | int idx_peer = 2; |
5413 | struct peer *peer; | |
718e3744 | 5414 | |
d62a17ae | 5415 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5416 | if (!peer) | |
5417 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5418 | |
d62a17ae | 5419 | peer_description_unset(peer); |
718e3744 | 5420 | |
d62a17ae | 5421 | return CMD_SUCCESS; |
718e3744 | 5422 | } |
5423 | ||
a14810f4 PM |
5424 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5425 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5426 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5427 | "Neighbor specific description\n" | |
5428 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5429 | |
718e3744 | 5430 | /* Neighbor update-source. */ |
d62a17ae | 5431 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5432 | const char *source_str) | |
5433 | { | |
5434 | struct peer *peer; | |
5435 | struct prefix p; | |
a14810f4 | 5436 | union sockunion su; |
d62a17ae | 5437 | |
5438 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5439 | if (!peer) | |
5440 | return CMD_WARNING_CONFIG_FAILED; | |
5441 | ||
5442 | if (peer->conf_if) | |
5443 | return CMD_WARNING; | |
5444 | ||
5445 | if (source_str) { | |
a14810f4 | 5446 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5447 | peer_update_source_addr_set(peer, &su); |
5448 | else { | |
5449 | if (str2prefix(source_str, &p)) { | |
5450 | vty_out(vty, | |
5451 | "%% Invalid update-source, remove prefix length \n"); | |
5452 | return CMD_WARNING_CONFIG_FAILED; | |
5453 | } else | |
5454 | peer_update_source_if_set(peer, source_str); | |
5455 | } | |
5456 | } else | |
5457 | peer_update_source_unset(peer); | |
5458 | ||
5459 | return CMD_SUCCESS; | |
5460 | } | |
5461 | ||
5462 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5463 | "IPv4 address\n" \ | |
5464 | "IPv6 address\n" \ | |
5465 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5466 | |
718e3744 | 5467 | DEFUN (neighbor_update_source, |
5468 | neighbor_update_source_cmd, | |
9ccf14f7 | 5469 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5470 | NEIGHBOR_STR |
5471 | NEIGHBOR_ADDR_STR2 | |
5472 | "Source of routing updates\n" | |
369688c0 | 5473 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5474 | { |
d62a17ae | 5475 | int idx_peer = 1; |
5476 | int idx_peer_2 = 3; | |
5477 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5478 | argv[idx_peer_2]->arg); | |
718e3744 | 5479 | } |
5480 | ||
5481 | DEFUN (no_neighbor_update_source, | |
5482 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5483 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5484 | NO_STR |
5485 | NEIGHBOR_STR | |
5486 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5487 | "Source of routing updates\n" |
5488 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5489 | { |
d62a17ae | 5490 | int idx_peer = 2; |
5491 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5492 | } |
6b0655a2 | 5493 | |
d62a17ae | 5494 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5495 | afi_t afi, safi_t safi, | |
5496 | const char *rmap, int set) | |
718e3744 | 5497 | { |
d62a17ae | 5498 | int ret; |
5499 | struct peer *peer; | |
80912664 | 5500 | struct route_map *route_map = NULL; |
718e3744 | 5501 | |
d62a17ae | 5502 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5503 | if (!peer) | |
5504 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5505 | |
1de27621 | 5506 | if (set) { |
80912664 DS |
5507 | if (rmap) |
5508 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5509 | ret = peer_default_originate_set(peer, afi, safi, |
5510 | rmap, route_map); | |
5511 | } else | |
d62a17ae | 5512 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5513 | |
d62a17ae | 5514 | return bgp_vty_return(vty, ret); |
718e3744 | 5515 | } |
5516 | ||
5517 | /* neighbor default-originate. */ | |
5518 | DEFUN (neighbor_default_originate, | |
5519 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5520 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5521 | NEIGHBOR_STR |
5522 | NEIGHBOR_ADDR_STR2 | |
5523 | "Originate default route to this neighbor\n") | |
5524 | { | |
d62a17ae | 5525 | int idx_peer = 1; |
5526 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5527 | bgp_node_afi(vty), | |
5528 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5529 | } |
5530 | ||
d62a17ae | 5531 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5532 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5533 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5534 | "Originate default route to this neighbor\n") | |
596c17ba | 5535 | |
718e3744 | 5536 | DEFUN (neighbor_default_originate_rmap, |
5537 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5538 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5539 | NEIGHBOR_STR |
5540 | NEIGHBOR_ADDR_STR2 | |
5541 | "Originate default route to this neighbor\n" | |
5542 | "Route-map to specify criteria to originate default\n" | |
5543 | "route-map name\n") | |
5544 | { | |
d62a17ae | 5545 | int idx_peer = 1; |
5546 | int idx_word = 4; | |
5547 | return peer_default_originate_set_vty( | |
5548 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5549 | argv[idx_word]->arg, 1); | |
718e3744 | 5550 | } |
5551 | ||
d62a17ae | 5552 | ALIAS_HIDDEN( |
5553 | neighbor_default_originate_rmap, | |
5554 | neighbor_default_originate_rmap_hidden_cmd, | |
5555 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5556 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5557 | "Originate default route to this neighbor\n" | |
5558 | "Route-map to specify criteria to originate default\n" | |
5559 | "route-map name\n") | |
596c17ba | 5560 | |
718e3744 | 5561 | DEFUN (no_neighbor_default_originate, |
5562 | no_neighbor_default_originate_cmd, | |
a636c635 | 5563 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5564 | NO_STR |
5565 | NEIGHBOR_STR | |
5566 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5567 | "Originate default route to this neighbor\n" |
5568 | "Route-map to specify criteria to originate default\n" | |
5569 | "route-map name\n") | |
718e3744 | 5570 | { |
d62a17ae | 5571 | int idx_peer = 2; |
5572 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5573 | bgp_node_afi(vty), | |
5574 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5575 | } |
5576 | ||
d62a17ae | 5577 | ALIAS_HIDDEN( |
5578 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5579 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5580 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5581 | "Originate default route to this neighbor\n" | |
5582 | "Route-map to specify criteria to originate default\n" | |
5583 | "route-map name\n") | |
596c17ba | 5584 | |
6b0655a2 | 5585 | |
718e3744 | 5586 | /* Set neighbor's BGP port. */ |
d62a17ae | 5587 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5588 | const char *port_str) | |
5589 | { | |
5590 | struct peer *peer; | |
d7c0a89a | 5591 | uint16_t port; |
d62a17ae | 5592 | struct servent *sp; |
5593 | ||
5594 | peer = peer_lookup_vty(vty, ip_str); | |
5595 | if (!peer) | |
5596 | return CMD_WARNING_CONFIG_FAILED; | |
5597 | ||
5598 | if (!port_str) { | |
5599 | sp = getservbyname("bgp", "tcp"); | |
5600 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5601 | } else { | |
5602 | port = strtoul(port_str, NULL, 10); | |
5603 | } | |
718e3744 | 5604 | |
d62a17ae | 5605 | peer_port_set(peer, port); |
718e3744 | 5606 | |
d62a17ae | 5607 | return CMD_SUCCESS; |
718e3744 | 5608 | } |
5609 | ||
f418446b | 5610 | /* Set specified peer's BGP port. */ |
718e3744 | 5611 | DEFUN (neighbor_port, |
5612 | neighbor_port_cmd, | |
9ccf14f7 | 5613 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5614 | NEIGHBOR_STR |
5615 | NEIGHBOR_ADDR_STR | |
5616 | "Neighbor's BGP port\n" | |
5617 | "TCP port number\n") | |
5618 | { | |
d62a17ae | 5619 | int idx_ip = 1; |
5620 | int idx_number = 3; | |
5621 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5622 | argv[idx_number]->arg); | |
718e3744 | 5623 | } |
5624 | ||
5625 | DEFUN (no_neighbor_port, | |
5626 | no_neighbor_port_cmd, | |
9ccf14f7 | 5627 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5628 | NO_STR |
5629 | NEIGHBOR_STR | |
5630 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5631 | "Neighbor's BGP port\n" |
5632 | "TCP port number\n") | |
718e3744 | 5633 | { |
d62a17ae | 5634 | int idx_ip = 2; |
5635 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5636 | } |
5637 | ||
6b0655a2 | 5638 | |
718e3744 | 5639 | /* neighbor weight. */ |
d62a17ae | 5640 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5641 | safi_t safi, const char *weight_str) | |
718e3744 | 5642 | { |
d62a17ae | 5643 | int ret; |
5644 | struct peer *peer; | |
5645 | unsigned long weight; | |
718e3744 | 5646 | |
d62a17ae | 5647 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5648 | if (!peer) | |
5649 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5650 | |
d62a17ae | 5651 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5652 | |
d62a17ae | 5653 | ret = peer_weight_set(peer, afi, safi, weight); |
5654 | return bgp_vty_return(vty, ret); | |
718e3744 | 5655 | } |
5656 | ||
d62a17ae | 5657 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5658 | safi_t safi) | |
718e3744 | 5659 | { |
d62a17ae | 5660 | int ret; |
5661 | struct peer *peer; | |
718e3744 | 5662 | |
d62a17ae | 5663 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5664 | if (!peer) | |
5665 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5666 | |
d62a17ae | 5667 | ret = peer_weight_unset(peer, afi, safi); |
5668 | return bgp_vty_return(vty, ret); | |
718e3744 | 5669 | } |
5670 | ||
5671 | DEFUN (neighbor_weight, | |
5672 | neighbor_weight_cmd, | |
9ccf14f7 | 5673 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5674 | NEIGHBOR_STR |
5675 | NEIGHBOR_ADDR_STR2 | |
5676 | "Set default weight for routes from this neighbor\n" | |
5677 | "default weight\n") | |
5678 | { | |
d62a17ae | 5679 | int idx_peer = 1; |
5680 | int idx_number = 3; | |
5681 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5682 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5683 | } |
5684 | ||
d62a17ae | 5685 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5686 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5687 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5688 | "Set default weight for routes from this neighbor\n" | |
5689 | "default weight\n") | |
596c17ba | 5690 | |
718e3744 | 5691 | DEFUN (no_neighbor_weight, |
5692 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5693 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5694 | NO_STR |
5695 | NEIGHBOR_STR | |
5696 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5697 | "Set default weight for routes from this neighbor\n" |
5698 | "default weight\n") | |
718e3744 | 5699 | { |
d62a17ae | 5700 | int idx_peer = 2; |
5701 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5702 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5703 | } |
5704 | ||
d62a17ae | 5705 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5706 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5707 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5708 | "Set default weight for routes from this neighbor\n" | |
5709 | "default weight\n") | |
596c17ba | 5710 | |
6b0655a2 | 5711 | |
718e3744 | 5712 | /* Override capability negotiation. */ |
5713 | DEFUN (neighbor_override_capability, | |
5714 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5715 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5716 | NEIGHBOR_STR |
5717 | NEIGHBOR_ADDR_STR2 | |
5718 | "Override capability negotiation result\n") | |
5719 | { | |
d62a17ae | 5720 | int idx_peer = 1; |
5721 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5722 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5723 | } |
5724 | ||
5725 | DEFUN (no_neighbor_override_capability, | |
5726 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5727 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5728 | NO_STR |
5729 | NEIGHBOR_STR | |
5730 | NEIGHBOR_ADDR_STR2 | |
5731 | "Override capability negotiation result\n") | |
5732 | { | |
d62a17ae | 5733 | int idx_peer = 2; |
5734 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5735 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5736 | } |
6b0655a2 | 5737 | |
718e3744 | 5738 | DEFUN (neighbor_strict_capability, |
5739 | neighbor_strict_capability_cmd, | |
9fb964de | 5740 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5741 | NEIGHBOR_STR |
9fb964de | 5742 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5743 | "Strict capability negotiation match\n") |
5744 | { | |
9fb964de PM |
5745 | int idx_peer = 1; |
5746 | ||
5747 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5748 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5749 | } |
5750 | ||
5751 | DEFUN (no_neighbor_strict_capability, | |
5752 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5753 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5754 | NO_STR |
5755 | NEIGHBOR_STR | |
9fb964de | 5756 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5757 | "Strict capability negotiation match\n") |
5758 | { | |
9fb964de PM |
5759 | int idx_peer = 2; |
5760 | ||
5761 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5762 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5763 | } |
6b0655a2 | 5764 | |
d62a17ae | 5765 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5766 | const char *keep_str, const char *hold_str) | |
718e3744 | 5767 | { |
d62a17ae | 5768 | int ret; |
5769 | struct peer *peer; | |
d7c0a89a QY |
5770 | uint32_t keepalive; |
5771 | uint32_t holdtime; | |
718e3744 | 5772 | |
d62a17ae | 5773 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5774 | if (!peer) | |
5775 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5776 | |
d62a17ae | 5777 | keepalive = strtoul(keep_str, NULL, 10); |
5778 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5779 | |
d62a17ae | 5780 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5781 | |
d62a17ae | 5782 | return bgp_vty_return(vty, ret); |
718e3744 | 5783 | } |
6b0655a2 | 5784 | |
d62a17ae | 5785 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5786 | { |
d62a17ae | 5787 | int ret; |
5788 | struct peer *peer; | |
718e3744 | 5789 | |
d62a17ae | 5790 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5791 | if (!peer) | |
5792 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5793 | |
d62a17ae | 5794 | ret = peer_timers_unset(peer); |
718e3744 | 5795 | |
d62a17ae | 5796 | return bgp_vty_return(vty, ret); |
718e3744 | 5797 | } |
5798 | ||
5799 | DEFUN (neighbor_timers, | |
5800 | neighbor_timers_cmd, | |
9ccf14f7 | 5801 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5802 | NEIGHBOR_STR |
5803 | NEIGHBOR_ADDR_STR2 | |
5804 | "BGP per neighbor timers\n" | |
5805 | "Keepalive interval\n" | |
5806 | "Holdtime\n") | |
5807 | { | |
d62a17ae | 5808 | int idx_peer = 1; |
5809 | int idx_number = 3; | |
5810 | int idx_number_2 = 4; | |
5811 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5812 | argv[idx_number]->arg, | |
5813 | argv[idx_number_2]->arg); | |
718e3744 | 5814 | } |
5815 | ||
5816 | DEFUN (no_neighbor_timers, | |
5817 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5819 | NO_STR |
5820 | NEIGHBOR_STR | |
5821 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5822 | "BGP per neighbor timers\n" |
5823 | "Keepalive interval\n" | |
5824 | "Holdtime\n") | |
718e3744 | 5825 | { |
d62a17ae | 5826 | int idx_peer = 2; |
5827 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5828 | } |
6b0655a2 | 5829 | |
813d4307 | 5830 | |
d62a17ae | 5831 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5832 | const char *time_str) | |
718e3744 | 5833 | { |
d62a17ae | 5834 | int ret; |
5835 | struct peer *peer; | |
d7c0a89a | 5836 | uint32_t connect; |
718e3744 | 5837 | |
d62a17ae | 5838 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5839 | if (!peer) | |
5840 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5841 | |
d62a17ae | 5842 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5843 | |
d62a17ae | 5844 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5845 | |
d62a17ae | 5846 | return bgp_vty_return(vty, ret); |
718e3744 | 5847 | } |
5848 | ||
d62a17ae | 5849 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5850 | { |
d62a17ae | 5851 | int ret; |
5852 | struct peer *peer; | |
718e3744 | 5853 | |
d62a17ae | 5854 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5855 | if (!peer) | |
5856 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5857 | |
d62a17ae | 5858 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5859 | |
d62a17ae | 5860 | return bgp_vty_return(vty, ret); |
718e3744 | 5861 | } |
5862 | ||
5863 | DEFUN (neighbor_timers_connect, | |
5864 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5865 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5866 | NEIGHBOR_STR |
966f821c | 5867 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5868 | "BGP per neighbor timers\n" |
5869 | "BGP connect timer\n" | |
5870 | "Connect timer\n") | |
5871 | { | |
d62a17ae | 5872 | int idx_peer = 1; |
5873 | int idx_number = 4; | |
5874 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5875 | argv[idx_number]->arg); | |
718e3744 | 5876 | } |
5877 | ||
5878 | DEFUN (no_neighbor_timers_connect, | |
5879 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5880 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5881 | NO_STR |
5882 | NEIGHBOR_STR | |
966f821c | 5883 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5884 | "BGP per neighbor timers\n" |
8334fd5a DW |
5885 | "BGP connect timer\n" |
5886 | "Connect timer\n") | |
718e3744 | 5887 | { |
d62a17ae | 5888 | int idx_peer = 2; |
5889 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5890 | } |
5891 | ||
6b0655a2 | 5892 | |
d62a17ae | 5893 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5894 | const char *time_str, int set) | |
718e3744 | 5895 | { |
d62a17ae | 5896 | int ret; |
5897 | struct peer *peer; | |
d7c0a89a | 5898 | uint32_t routeadv = 0; |
718e3744 | 5899 | |
d62a17ae | 5900 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5901 | if (!peer) | |
5902 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5903 | |
d62a17ae | 5904 | if (time_str) |
5905 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5906 | |
d62a17ae | 5907 | if (set) |
5908 | ret = peer_advertise_interval_set(peer, routeadv); | |
5909 | else | |
5910 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5911 | |
d62a17ae | 5912 | return bgp_vty_return(vty, ret); |
718e3744 | 5913 | } |
5914 | ||
5915 | DEFUN (neighbor_advertise_interval, | |
5916 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5917 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5918 | NEIGHBOR_STR |
966f821c | 5919 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5920 | "Minimum interval between sending BGP routing updates\n" |
5921 | "time in seconds\n") | |
5922 | { | |
d62a17ae | 5923 | int idx_peer = 1; |
5924 | int idx_number = 3; | |
5925 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5926 | argv[idx_number]->arg, 1); | |
718e3744 | 5927 | } |
5928 | ||
5929 | DEFUN (no_neighbor_advertise_interval, | |
5930 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5931 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5932 | NO_STR |
5933 | NEIGHBOR_STR | |
966f821c | 5934 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5935 | "Minimum interval between sending BGP routing updates\n" |
5936 | "time in seconds\n") | |
718e3744 | 5937 | { |
d62a17ae | 5938 | int idx_peer = 2; |
5939 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5940 | } |
5941 | ||
6b0655a2 | 5942 | |
518f0eb1 DS |
5943 | /* Time to wait before processing route-map updates */ |
5944 | DEFUN (bgp_set_route_map_delay_timer, | |
5945 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5946 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5947 | SET_STR |
5948 | "BGP route-map delay timer\n" | |
5949 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5950 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5951 | { |
d62a17ae | 5952 | int idx_number = 3; |
d7c0a89a | 5953 | uint32_t rmap_delay_timer; |
d62a17ae | 5954 | |
5955 | if (argv[idx_number]->arg) { | |
5956 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5957 | bm->rmap_update_timer = rmap_delay_timer; | |
5958 | ||
5959 | /* if the dynamic update handling is being disabled, and a timer | |
5960 | * is | |
5961 | * running, stop the timer and act as if the timer has already | |
5962 | * fired. | |
5963 | */ | |
5964 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5965 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5966 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5967 | NULL, 0); | |
5968 | } | |
5969 | return CMD_SUCCESS; | |
5970 | } else { | |
5971 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5972 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5973 | } |
518f0eb1 DS |
5974 | } |
5975 | ||
5976 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5977 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5978 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5979 | NO_STR |
3a2d747c | 5980 | BGP_STR |
518f0eb1 | 5981 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5982 | "Reset to default time to wait for processing route-map changes\n" |
5983 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5984 | { |
518f0eb1 | 5985 | |
d62a17ae | 5986 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5987 | |
d62a17ae | 5988 | return CMD_SUCCESS; |
518f0eb1 DS |
5989 | } |
5990 | ||
f414725f | 5991 | |
718e3744 | 5992 | /* neighbor interface */ |
d62a17ae | 5993 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5994 | const char *str) | |
718e3744 | 5995 | { |
d62a17ae | 5996 | struct peer *peer; |
718e3744 | 5997 | |
d62a17ae | 5998 | peer = peer_lookup_vty(vty, ip_str); |
5999 | if (!peer || peer->conf_if) { | |
6000 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6001 | return CMD_WARNING_CONFIG_FAILED; | |
6002 | } | |
718e3744 | 6003 | |
d62a17ae | 6004 | if (str) |
6005 | peer_interface_set(peer, str); | |
6006 | else | |
6007 | peer_interface_unset(peer); | |
718e3744 | 6008 | |
d62a17ae | 6009 | return CMD_SUCCESS; |
718e3744 | 6010 | } |
6011 | ||
6012 | DEFUN (neighbor_interface, | |
6013 | neighbor_interface_cmd, | |
9ccf14f7 | 6014 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6015 | NEIGHBOR_STR |
6016 | NEIGHBOR_ADDR_STR | |
6017 | "Interface\n" | |
6018 | "Interface name\n") | |
6019 | { | |
d62a17ae | 6020 | int idx_ip = 1; |
6021 | int idx_word = 3; | |
6022 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6023 | } |
6024 | ||
6025 | DEFUN (no_neighbor_interface, | |
6026 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6027 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6028 | NO_STR |
6029 | NEIGHBOR_STR | |
16cedbb0 | 6030 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6031 | "Interface\n" |
6032 | "Interface name\n") | |
6033 | { | |
d62a17ae | 6034 | int idx_peer = 2; |
6035 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6036 | } |
6b0655a2 | 6037 | |
718e3744 | 6038 | DEFUN (neighbor_distribute_list, |
6039 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6040 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6041 | NEIGHBOR_STR |
6042 | NEIGHBOR_ADDR_STR2 | |
6043 | "Filter updates to/from this neighbor\n" | |
6044 | "IP access-list number\n" | |
6045 | "IP access-list number (expanded range)\n" | |
6046 | "IP Access-list name\n" | |
6047 | "Filter incoming updates\n" | |
6048 | "Filter outgoing updates\n") | |
6049 | { | |
d62a17ae | 6050 | int idx_peer = 1; |
6051 | int idx_acl = 3; | |
6052 | int direct, ret; | |
6053 | struct peer *peer; | |
a8206004 | 6054 | |
d62a17ae | 6055 | const char *pstr = argv[idx_peer]->arg; |
6056 | const char *acl = argv[idx_acl]->arg; | |
6057 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6058 | |
d62a17ae | 6059 | peer = peer_and_group_lookup_vty(vty, pstr); |
6060 | if (!peer) | |
6061 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6062 | |
d62a17ae | 6063 | /* Check filter direction. */ |
6064 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6065 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6066 | direct, acl); | |
a8206004 | 6067 | |
d62a17ae | 6068 | return bgp_vty_return(vty, ret); |
718e3744 | 6069 | } |
6070 | ||
d62a17ae | 6071 | ALIAS_HIDDEN( |
6072 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6073 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6074 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6075 | "Filter updates to/from this neighbor\n" | |
6076 | "IP access-list number\n" | |
6077 | "IP access-list number (expanded range)\n" | |
6078 | "IP Access-list name\n" | |
6079 | "Filter incoming updates\n" | |
6080 | "Filter outgoing updates\n") | |
596c17ba | 6081 | |
718e3744 | 6082 | DEFUN (no_neighbor_distribute_list, |
6083 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6084 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6085 | NO_STR |
6086 | NEIGHBOR_STR | |
6087 | NEIGHBOR_ADDR_STR2 | |
6088 | "Filter updates to/from this neighbor\n" | |
6089 | "IP access-list number\n" | |
6090 | "IP access-list number (expanded range)\n" | |
6091 | "IP Access-list name\n" | |
6092 | "Filter incoming updates\n" | |
6093 | "Filter outgoing updates\n") | |
6094 | { | |
d62a17ae | 6095 | int idx_peer = 2; |
6096 | int direct, ret; | |
6097 | struct peer *peer; | |
a8206004 | 6098 | |
d62a17ae | 6099 | const char *pstr = argv[idx_peer]->arg; |
6100 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6101 | |
d62a17ae | 6102 | peer = peer_and_group_lookup_vty(vty, pstr); |
6103 | if (!peer) | |
6104 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6105 | |
d62a17ae | 6106 | /* Check filter direction. */ |
6107 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6108 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6109 | direct); | |
a8206004 | 6110 | |
d62a17ae | 6111 | return bgp_vty_return(vty, ret); |
718e3744 | 6112 | } |
6b0655a2 | 6113 | |
d62a17ae | 6114 | ALIAS_HIDDEN( |
6115 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6116 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6117 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6118 | "Filter updates to/from this neighbor\n" | |
6119 | "IP access-list number\n" | |
6120 | "IP access-list number (expanded range)\n" | |
6121 | "IP Access-list name\n" | |
6122 | "Filter incoming updates\n" | |
6123 | "Filter outgoing updates\n") | |
596c17ba | 6124 | |
718e3744 | 6125 | /* Set prefix list to the peer. */ |
d62a17ae | 6126 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6127 | afi_t afi, safi_t safi, | |
6128 | const char *name_str, | |
6129 | const char *direct_str) | |
718e3744 | 6130 | { |
d62a17ae | 6131 | int ret; |
d62a17ae | 6132 | int direct = FILTER_IN; |
cf9ac8bf | 6133 | struct peer *peer; |
718e3744 | 6134 | |
d62a17ae | 6135 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6136 | if (!peer) | |
6137 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6138 | |
d62a17ae | 6139 | /* Check filter direction. */ |
6140 | if (strncmp(direct_str, "i", 1) == 0) | |
6141 | direct = FILTER_IN; | |
6142 | else if (strncmp(direct_str, "o", 1) == 0) | |
6143 | direct = FILTER_OUT; | |
718e3744 | 6144 | |
d62a17ae | 6145 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6146 | |
d62a17ae | 6147 | return bgp_vty_return(vty, ret); |
718e3744 | 6148 | } |
6149 | ||
d62a17ae | 6150 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6151 | afi_t afi, safi_t safi, | |
6152 | const char *direct_str) | |
718e3744 | 6153 | { |
d62a17ae | 6154 | int ret; |
6155 | struct peer *peer; | |
6156 | int direct = FILTER_IN; | |
718e3744 | 6157 | |
d62a17ae | 6158 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6159 | if (!peer) | |
6160 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6161 | |
d62a17ae | 6162 | /* Check filter direction. */ |
6163 | if (strncmp(direct_str, "i", 1) == 0) | |
6164 | direct = FILTER_IN; | |
6165 | else if (strncmp(direct_str, "o", 1) == 0) | |
6166 | direct = FILTER_OUT; | |
718e3744 | 6167 | |
d62a17ae | 6168 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6169 | |
d62a17ae | 6170 | return bgp_vty_return(vty, ret); |
718e3744 | 6171 | } |
6172 | ||
6173 | DEFUN (neighbor_prefix_list, | |
6174 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6175 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6176 | NEIGHBOR_STR |
6177 | NEIGHBOR_ADDR_STR2 | |
6178 | "Filter updates to/from this neighbor\n" | |
6179 | "Name of a prefix list\n" | |
6180 | "Filter incoming updates\n" | |
6181 | "Filter outgoing updates\n") | |
6182 | { | |
d62a17ae | 6183 | int idx_peer = 1; |
6184 | int idx_word = 3; | |
6185 | int idx_in_out = 4; | |
6186 | return peer_prefix_list_set_vty( | |
6187 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6188 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6189 | } |
6190 | ||
d62a17ae | 6191 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6192 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6193 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6194 | "Filter updates to/from this neighbor\n" | |
6195 | "Name of a prefix list\n" | |
6196 | "Filter incoming updates\n" | |
6197 | "Filter outgoing updates\n") | |
596c17ba | 6198 | |
718e3744 | 6199 | DEFUN (no_neighbor_prefix_list, |
6200 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6201 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6202 | NO_STR |
6203 | NEIGHBOR_STR | |
6204 | NEIGHBOR_ADDR_STR2 | |
6205 | "Filter updates to/from this neighbor\n" | |
6206 | "Name of a prefix list\n" | |
6207 | "Filter incoming updates\n" | |
6208 | "Filter outgoing updates\n") | |
6209 | { | |
d62a17ae | 6210 | int idx_peer = 2; |
6211 | int idx_in_out = 5; | |
6212 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6213 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6214 | argv[idx_in_out]->arg); | |
718e3744 | 6215 | } |
6b0655a2 | 6216 | |
d62a17ae | 6217 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6218 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6219 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6220 | "Filter updates to/from this neighbor\n" | |
6221 | "Name of a prefix list\n" | |
6222 | "Filter incoming updates\n" | |
6223 | "Filter outgoing updates\n") | |
596c17ba | 6224 | |
d62a17ae | 6225 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6226 | safi_t safi, const char *name_str, | |
6227 | const char *direct_str) | |
718e3744 | 6228 | { |
d62a17ae | 6229 | int ret; |
6230 | struct peer *peer; | |
6231 | int direct = FILTER_IN; | |
718e3744 | 6232 | |
d62a17ae | 6233 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6234 | if (!peer) | |
6235 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6236 | |
d62a17ae | 6237 | /* Check filter direction. */ |
6238 | if (strncmp(direct_str, "i", 1) == 0) | |
6239 | direct = FILTER_IN; | |
6240 | else if (strncmp(direct_str, "o", 1) == 0) | |
6241 | direct = FILTER_OUT; | |
718e3744 | 6242 | |
d62a17ae | 6243 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6244 | |
d62a17ae | 6245 | return bgp_vty_return(vty, ret); |
718e3744 | 6246 | } |
6247 | ||
d62a17ae | 6248 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6249 | safi_t safi, const char *direct_str) | |
718e3744 | 6250 | { |
d62a17ae | 6251 | int ret; |
6252 | struct peer *peer; | |
6253 | int direct = FILTER_IN; | |
718e3744 | 6254 | |
d62a17ae | 6255 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6256 | if (!peer) | |
6257 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6258 | |
d62a17ae | 6259 | /* Check filter direction. */ |
6260 | if (strncmp(direct_str, "i", 1) == 0) | |
6261 | direct = FILTER_IN; | |
6262 | else if (strncmp(direct_str, "o", 1) == 0) | |
6263 | direct = FILTER_OUT; | |
718e3744 | 6264 | |
d62a17ae | 6265 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6266 | |
d62a17ae | 6267 | return bgp_vty_return(vty, ret); |
718e3744 | 6268 | } |
6269 | ||
6270 | DEFUN (neighbor_filter_list, | |
6271 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6272 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6273 | NEIGHBOR_STR |
6274 | NEIGHBOR_ADDR_STR2 | |
6275 | "Establish BGP filters\n" | |
6276 | "AS path access-list name\n" | |
6277 | "Filter incoming routes\n" | |
6278 | "Filter outgoing routes\n") | |
6279 | { | |
d62a17ae | 6280 | int idx_peer = 1; |
6281 | int idx_word = 3; | |
6282 | int idx_in_out = 4; | |
6283 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6284 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6285 | argv[idx_in_out]->arg); | |
718e3744 | 6286 | } |
6287 | ||
d62a17ae | 6288 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6289 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6290 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6291 | "Establish BGP filters\n" | |
6292 | "AS path access-list name\n" | |
6293 | "Filter incoming routes\n" | |
6294 | "Filter outgoing routes\n") | |
596c17ba | 6295 | |
718e3744 | 6296 | DEFUN (no_neighbor_filter_list, |
6297 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6298 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6299 | NO_STR |
6300 | NEIGHBOR_STR | |
6301 | NEIGHBOR_ADDR_STR2 | |
6302 | "Establish BGP filters\n" | |
6303 | "AS path access-list name\n" | |
6304 | "Filter incoming routes\n" | |
6305 | "Filter outgoing routes\n") | |
6306 | { | |
d62a17ae | 6307 | int idx_peer = 2; |
6308 | int idx_in_out = 5; | |
6309 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6310 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6311 | argv[idx_in_out]->arg); | |
718e3744 | 6312 | } |
6b0655a2 | 6313 | |
d62a17ae | 6314 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6315 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6316 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6317 | "Establish BGP filters\n" | |
6318 | "AS path access-list name\n" | |
6319 | "Filter incoming routes\n" | |
6320 | "Filter outgoing routes\n") | |
596c17ba | 6321 | |
718e3744 | 6322 | /* Set route-map to the peer. */ |
d62a17ae | 6323 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6324 | afi_t afi, safi_t safi, const char *name_str, | |
6325 | const char *direct_str) | |
718e3744 | 6326 | { |
d62a17ae | 6327 | int ret; |
6328 | struct peer *peer; | |
6329 | int direct = RMAP_IN; | |
1de27621 | 6330 | struct route_map *route_map; |
718e3744 | 6331 | |
d62a17ae | 6332 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6333 | if (!peer) | |
6334 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6335 | |
d62a17ae | 6336 | /* Check filter direction. */ |
6337 | if (strncmp(direct_str, "in", 2) == 0) | |
6338 | direct = RMAP_IN; | |
6339 | else if (strncmp(direct_str, "o", 1) == 0) | |
6340 | direct = RMAP_OUT; | |
718e3744 | 6341 | |
1de27621 DA |
6342 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6343 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6344 | |
d62a17ae | 6345 | return bgp_vty_return(vty, ret); |
718e3744 | 6346 | } |
6347 | ||
d62a17ae | 6348 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6349 | afi_t afi, safi_t safi, | |
6350 | const char *direct_str) | |
718e3744 | 6351 | { |
d62a17ae | 6352 | int ret; |
6353 | struct peer *peer; | |
6354 | int direct = RMAP_IN; | |
718e3744 | 6355 | |
d62a17ae | 6356 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6357 | if (!peer) | |
6358 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6359 | |
d62a17ae | 6360 | /* Check filter direction. */ |
6361 | if (strncmp(direct_str, "in", 2) == 0) | |
6362 | direct = RMAP_IN; | |
6363 | else if (strncmp(direct_str, "o", 1) == 0) | |
6364 | direct = RMAP_OUT; | |
718e3744 | 6365 | |
d62a17ae | 6366 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6367 | |
d62a17ae | 6368 | return bgp_vty_return(vty, ret); |
718e3744 | 6369 | } |
6370 | ||
6371 | DEFUN (neighbor_route_map, | |
6372 | neighbor_route_map_cmd, | |
9ccf14f7 | 6373 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6374 | NEIGHBOR_STR |
6375 | NEIGHBOR_ADDR_STR2 | |
6376 | "Apply route map to neighbor\n" | |
6377 | "Name of route map\n" | |
6378 | "Apply map to incoming routes\n" | |
2a3d5731 | 6379 | "Apply map to outbound routes\n") |
718e3744 | 6380 | { |
d62a17ae | 6381 | int idx_peer = 1; |
6382 | int idx_word = 3; | |
6383 | int idx_in_out = 4; | |
6384 | return peer_route_map_set_vty( | |
6385 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6386 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6387 | } |
6388 | ||
d62a17ae | 6389 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6390 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6391 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6392 | "Apply route map to neighbor\n" | |
6393 | "Name of route map\n" | |
6394 | "Apply map to incoming routes\n" | |
6395 | "Apply map to outbound routes\n") | |
596c17ba | 6396 | |
718e3744 | 6397 | DEFUN (no_neighbor_route_map, |
6398 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6399 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6400 | NO_STR |
6401 | NEIGHBOR_STR | |
6402 | NEIGHBOR_ADDR_STR2 | |
6403 | "Apply route map to neighbor\n" | |
6404 | "Name of route map\n" | |
6405 | "Apply map to incoming routes\n" | |
2a3d5731 | 6406 | "Apply map to outbound routes\n") |
718e3744 | 6407 | { |
d62a17ae | 6408 | int idx_peer = 2; |
6409 | int idx_in_out = 5; | |
6410 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6411 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6412 | argv[idx_in_out]->arg); | |
718e3744 | 6413 | } |
6b0655a2 | 6414 | |
d62a17ae | 6415 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6416 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6417 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6418 | "Apply route map to neighbor\n" | |
6419 | "Name of route map\n" | |
6420 | "Apply map to incoming routes\n" | |
6421 | "Apply map to outbound routes\n") | |
596c17ba | 6422 | |
718e3744 | 6423 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6424 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6425 | afi_t afi, safi_t safi, | |
6426 | const char *name_str) | |
718e3744 | 6427 | { |
d62a17ae | 6428 | int ret; |
6429 | struct peer *peer; | |
1de27621 | 6430 | struct route_map *route_map; |
718e3744 | 6431 | |
d62a17ae | 6432 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6433 | if (!peer) | |
6434 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6435 | |
1de27621 DA |
6436 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6437 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6438 | |
d62a17ae | 6439 | return bgp_vty_return(vty, ret); |
718e3744 | 6440 | } |
6441 | ||
6442 | /* Unset route-map from the peer. */ | |
d62a17ae | 6443 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6444 | afi_t afi, safi_t safi) | |
718e3744 | 6445 | { |
d62a17ae | 6446 | int ret; |
6447 | struct peer *peer; | |
718e3744 | 6448 | |
d62a17ae | 6449 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6450 | if (!peer) | |
6451 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6452 | |
d62a17ae | 6453 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6454 | |
d62a17ae | 6455 | return bgp_vty_return(vty, ret); |
718e3744 | 6456 | } |
6457 | ||
6458 | DEFUN (neighbor_unsuppress_map, | |
6459 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6460 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6461 | NEIGHBOR_STR |
6462 | NEIGHBOR_ADDR_STR2 | |
6463 | "Route-map to selectively unsuppress suppressed routes\n" | |
6464 | "Name of route map\n") | |
6465 | { | |
d62a17ae | 6466 | int idx_peer = 1; |
6467 | int idx_word = 3; | |
6468 | return peer_unsuppress_map_set_vty( | |
6469 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6470 | argv[idx_word]->arg); | |
718e3744 | 6471 | } |
6472 | ||
d62a17ae | 6473 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6474 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6475 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6476 | "Route-map to selectively unsuppress suppressed routes\n" | |
6477 | "Name of route map\n") | |
596c17ba | 6478 | |
718e3744 | 6479 | DEFUN (no_neighbor_unsuppress_map, |
6480 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6481 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6482 | NO_STR |
6483 | NEIGHBOR_STR | |
6484 | NEIGHBOR_ADDR_STR2 | |
6485 | "Route-map to selectively unsuppress suppressed routes\n" | |
6486 | "Name of route map\n") | |
6487 | { | |
d62a17ae | 6488 | int idx_peer = 2; |
6489 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6490 | bgp_node_afi(vty), | |
6491 | bgp_node_safi(vty)); | |
718e3744 | 6492 | } |
6b0655a2 | 6493 | |
d62a17ae | 6494 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6495 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6496 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6497 | "Route-map to selectively unsuppress suppressed routes\n" | |
6498 | "Name of route map\n") | |
596c17ba | 6499 | |
d62a17ae | 6500 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6501 | afi_t afi, safi_t safi, | |
6502 | const char *num_str, | |
6503 | const char *threshold_str, int warning, | |
6504 | const char *restart_str) | |
718e3744 | 6505 | { |
d62a17ae | 6506 | int ret; |
6507 | struct peer *peer; | |
d7c0a89a QY |
6508 | uint32_t max; |
6509 | uint8_t threshold; | |
6510 | uint16_t restart; | |
718e3744 | 6511 | |
d62a17ae | 6512 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6513 | if (!peer) | |
6514 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6515 | |
d62a17ae | 6516 | max = strtoul(num_str, NULL, 10); |
6517 | if (threshold_str) | |
6518 | threshold = atoi(threshold_str); | |
6519 | else | |
6520 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6521 | |
d62a17ae | 6522 | if (restart_str) |
6523 | restart = atoi(restart_str); | |
6524 | else | |
6525 | restart = 0; | |
0a486e5f | 6526 | |
d62a17ae | 6527 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6528 | restart); | |
718e3744 | 6529 | |
d62a17ae | 6530 | return bgp_vty_return(vty, ret); |
718e3744 | 6531 | } |
6532 | ||
d62a17ae | 6533 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6534 | afi_t afi, safi_t safi) | |
718e3744 | 6535 | { |
d62a17ae | 6536 | int ret; |
6537 | struct peer *peer; | |
718e3744 | 6538 | |
d62a17ae | 6539 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6540 | if (!peer) | |
6541 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6542 | |
d62a17ae | 6543 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6544 | |
d62a17ae | 6545 | return bgp_vty_return(vty, ret); |
718e3744 | 6546 | } |
6547 | ||
fde246e8 DA |
6548 | /* Maximum number of prefix to be sent to the neighbor. */ |
6549 | DEFUN(neighbor_maximum_prefix_out, | |
6550 | neighbor_maximum_prefix_out_cmd, | |
6551 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6552 | NEIGHBOR_STR | |
6553 | NEIGHBOR_ADDR_STR2 | |
6554 | "Maximum number of prefixes to be sent to this peer\n" | |
6555 | "Maximum no. of prefix limit\n") | |
6556 | { | |
6557 | int idx_peer = 1; | |
6558 | int idx_number = 3; | |
6559 | struct peer *peer; | |
6560 | uint32_t max; | |
6561 | afi_t afi = bgp_node_afi(vty); | |
6562 | safi_t safi = bgp_node_safi(vty); | |
6563 | ||
6564 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6565 | if (!peer) | |
6566 | return CMD_WARNING_CONFIG_FAILED; | |
6567 | ||
6568 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6569 | ||
6570 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6571 | peer->pmax_out[afi][safi] = max; | |
6572 | ||
6573 | return CMD_SUCCESS; | |
6574 | } | |
6575 | ||
6576 | DEFUN(no_neighbor_maximum_prefix_out, | |
6577 | no_neighbor_maximum_prefix_out_cmd, | |
6578 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6579 | NO_STR | |
6580 | NEIGHBOR_STR | |
6581 | NEIGHBOR_ADDR_STR2 | |
6582 | "Maximum number of prefixes to be sent to this peer\n") | |
6583 | { | |
6584 | int idx_peer = 2; | |
6585 | struct peer *peer; | |
6586 | afi_t afi = bgp_node_afi(vty); | |
6587 | safi_t safi = bgp_node_safi(vty); | |
6588 | ||
6589 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6590 | if (!peer) | |
6591 | return CMD_WARNING_CONFIG_FAILED; | |
6592 | ||
6593 | peer->pmax_out[afi][safi] = 0; | |
6594 | ||
6595 | return CMD_SUCCESS; | |
6596 | } | |
6597 | ||
718e3744 | 6598 | /* Maximum number of prefix configuration. prefix count is different |
6599 | for each peer configuration. So this configuration can be set for | |
6600 | each peer configuration. */ | |
6601 | DEFUN (neighbor_maximum_prefix, | |
6602 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6603 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6604 | NEIGHBOR_STR |
6605 | NEIGHBOR_ADDR_STR2 | |
6606 | "Maximum number of prefix accept from this peer\n" | |
6607 | "maximum no. of prefix limit\n") | |
6608 | { | |
d62a17ae | 6609 | int idx_peer = 1; |
6610 | int idx_number = 3; | |
6611 | return peer_maximum_prefix_set_vty( | |
6612 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6613 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6614 | } |
6615 | ||
d62a17ae | 6616 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6617 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6618 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6619 | "Maximum number of prefix accept from this peer\n" | |
6620 | "maximum no. of prefix limit\n") | |
596c17ba | 6621 | |
e0701b79 | 6622 | DEFUN (neighbor_maximum_prefix_threshold, |
6623 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6624 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6625 | NEIGHBOR_STR |
6626 | NEIGHBOR_ADDR_STR2 | |
6627 | "Maximum number of prefix accept from this peer\n" | |
6628 | "maximum no. of prefix limit\n" | |
6629 | "Threshold value (%) at which to generate a warning msg\n") | |
6630 | { | |
d62a17ae | 6631 | int idx_peer = 1; |
6632 | int idx_number = 3; | |
6633 | int idx_number_2 = 4; | |
6634 | return peer_maximum_prefix_set_vty( | |
6635 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6636 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6637 | } |
e0701b79 | 6638 | |
d62a17ae | 6639 | ALIAS_HIDDEN( |
6640 | neighbor_maximum_prefix_threshold, | |
6641 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6642 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6643 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6644 | "Maximum number of prefix accept from this peer\n" | |
6645 | "maximum no. of prefix limit\n" | |
6646 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6647 | |
718e3744 | 6648 | DEFUN (neighbor_maximum_prefix_warning, |
6649 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6650 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6651 | NEIGHBOR_STR |
6652 | NEIGHBOR_ADDR_STR2 | |
6653 | "Maximum number of prefix accept from this peer\n" | |
6654 | "maximum no. of prefix limit\n" | |
6655 | "Only give warning message when limit is exceeded\n") | |
6656 | { | |
d62a17ae | 6657 | int idx_peer = 1; |
6658 | int idx_number = 3; | |
6659 | return peer_maximum_prefix_set_vty( | |
6660 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6661 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6662 | } |
6663 | ||
d62a17ae | 6664 | ALIAS_HIDDEN( |
6665 | neighbor_maximum_prefix_warning, | |
6666 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6667 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6668 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6669 | "Maximum number of prefix accept from this peer\n" | |
6670 | "maximum no. of prefix limit\n" | |
6671 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6672 | |
e0701b79 | 6673 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6674 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6675 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6676 | NEIGHBOR_STR |
6677 | NEIGHBOR_ADDR_STR2 | |
6678 | "Maximum number of prefix accept from this peer\n" | |
6679 | "maximum no. of prefix limit\n" | |
6680 | "Threshold value (%) at which to generate a warning msg\n" | |
6681 | "Only give warning message when limit is exceeded\n") | |
6682 | { | |
d62a17ae | 6683 | int idx_peer = 1; |
6684 | int idx_number = 3; | |
6685 | int idx_number_2 = 4; | |
6686 | return peer_maximum_prefix_set_vty( | |
6687 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6688 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6689 | } |
6690 | ||
d62a17ae | 6691 | ALIAS_HIDDEN( |
6692 | neighbor_maximum_prefix_threshold_warning, | |
6693 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6694 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6695 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6696 | "Maximum number of prefix accept from this peer\n" | |
6697 | "maximum no. of prefix limit\n" | |
6698 | "Threshold value (%) at which to generate a warning msg\n" | |
6699 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6700 | |
0a486e5f | 6701 | DEFUN (neighbor_maximum_prefix_restart, |
6702 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6703 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6704 | NEIGHBOR_STR |
6705 | NEIGHBOR_ADDR_STR2 | |
6706 | "Maximum number of prefix accept from this peer\n" | |
6707 | "maximum no. of prefix limit\n" | |
6708 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6709 | "Restart interval in minutes\n") |
0a486e5f | 6710 | { |
d62a17ae | 6711 | int idx_peer = 1; |
6712 | int idx_number = 3; | |
6713 | int idx_number_2 = 5; | |
6714 | return peer_maximum_prefix_set_vty( | |
6715 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6716 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6717 | } |
6718 | ||
d62a17ae | 6719 | ALIAS_HIDDEN( |
6720 | neighbor_maximum_prefix_restart, | |
6721 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6722 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6723 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6724 | "Maximum number of prefix accept from this peer\n" | |
6725 | "maximum no. of prefix limit\n" | |
6726 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6727 | "Restart interval in minutes\n") |
596c17ba | 6728 | |
0a486e5f | 6729 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6730 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6731 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6732 | NEIGHBOR_STR |
6733 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6734 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6735 | "maximum no. of prefix limit\n" |
6736 | "Threshold value (%) at which to generate a warning msg\n" | |
6737 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6738 | "Restart interval in minutes\n") |
0a486e5f | 6739 | { |
d62a17ae | 6740 | int idx_peer = 1; |
6741 | int idx_number = 3; | |
6742 | int idx_number_2 = 4; | |
6743 | int idx_number_3 = 6; | |
6744 | return peer_maximum_prefix_set_vty( | |
6745 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6746 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6747 | argv[idx_number_3]->arg); | |
6748 | } | |
6749 | ||
6750 | ALIAS_HIDDEN( | |
6751 | neighbor_maximum_prefix_threshold_restart, | |
6752 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6753 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6754 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6755 | "Maximum number of prefixes to accept from this peer\n" | |
6756 | "maximum no. of prefix limit\n" | |
6757 | "Threshold value (%) at which to generate a warning msg\n" | |
6758 | "Restart bgp connection after limit is exceeded\n" | |
6759 | "Restart interval in minutes\n") | |
596c17ba | 6760 | |
718e3744 | 6761 | DEFUN (no_neighbor_maximum_prefix, |
6762 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6763 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6764 | NO_STR |
6765 | NEIGHBOR_STR | |
6766 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6767 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6768 | "maximum no. of prefix limit\n" |
6769 | "Threshold value (%) at which to generate a warning msg\n" | |
6770 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6771 | "Restart interval in minutes\n" |
31500417 | 6772 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6773 | { |
d62a17ae | 6774 | int idx_peer = 2; |
6775 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6776 | bgp_node_afi(vty), | |
6777 | bgp_node_safi(vty)); | |
718e3744 | 6778 | } |
e52702f2 | 6779 | |
d62a17ae | 6780 | ALIAS_HIDDEN( |
6781 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6782 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6783 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6784 | "Maximum number of prefixes to accept from this peer\n" | |
6785 | "maximum no. of prefix limit\n" | |
6786 | "Threshold value (%) at which to generate a warning msg\n" | |
6787 | "Restart bgp connection after limit is exceeded\n" | |
6788 | "Restart interval in minutes\n" | |
6789 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6790 | |
718e3744 | 6791 | |
718e3744 | 6792 | /* "neighbor allowas-in" */ |
6793 | DEFUN (neighbor_allowas_in, | |
6794 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6795 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6796 | NEIGHBOR_STR |
6797 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6798 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6799 | "Number of occurrences of AS number\n" |
fd8503f5 | 6800 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6801 | { |
d62a17ae | 6802 | int idx_peer = 1; |
6803 | int idx_number_origin = 3; | |
6804 | int ret; | |
6805 | int origin = 0; | |
6806 | struct peer *peer; | |
6807 | int allow_num = 0; | |
6808 | ||
6809 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6810 | if (!peer) | |
6811 | return CMD_WARNING_CONFIG_FAILED; | |
6812 | ||
6813 | if (argc <= idx_number_origin) | |
6814 | allow_num = 3; | |
6815 | else { | |
6816 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6817 | origin = 1; | |
6818 | else | |
6819 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6820 | } | |
6821 | ||
6822 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6823 | allow_num, origin); | |
6824 | ||
6825 | return bgp_vty_return(vty, ret); | |
6826 | } | |
6827 | ||
6828 | ALIAS_HIDDEN( | |
6829 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6830 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6831 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6832 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6833 | "Number of occurrences of AS number\n" |
d62a17ae | 6834 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6835 | |
718e3744 | 6836 | DEFUN (no_neighbor_allowas_in, |
6837 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6839 | NO_STR |
6840 | NEIGHBOR_STR | |
6841 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6842 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6843 | "Number of occurrences of AS number\n" |
fd8503f5 | 6844 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6845 | { |
d62a17ae | 6846 | int idx_peer = 2; |
6847 | int ret; | |
6848 | struct peer *peer; | |
718e3744 | 6849 | |
d62a17ae | 6850 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6851 | if (!peer) | |
6852 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6853 | |
d62a17ae | 6854 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6855 | bgp_node_safi(vty)); | |
718e3744 | 6856 | |
d62a17ae | 6857 | return bgp_vty_return(vty, ret); |
718e3744 | 6858 | } |
6b0655a2 | 6859 | |
d62a17ae | 6860 | ALIAS_HIDDEN( |
6861 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6862 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6863 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6864 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6865 | "Number of occurrences of AS number\n" |
d62a17ae | 6866 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6867 | |
fa411a21 NH |
6868 | DEFUN (neighbor_ttl_security, |
6869 | neighbor_ttl_security_cmd, | |
7ebe625c | 6870 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6871 | NEIGHBOR_STR |
7ebe625c | 6872 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6873 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6874 | "Specify the maximum number of hops to the BGP peer\n" |
6875 | "Number of hops to BGP peer\n") | |
fa411a21 | 6876 | { |
d62a17ae | 6877 | int idx_peer = 1; |
6878 | int idx_number = 4; | |
6879 | struct peer *peer; | |
6880 | int gtsm_hops; | |
6881 | ||
6882 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6883 | if (!peer) | |
6884 | return CMD_WARNING_CONFIG_FAILED; | |
6885 | ||
6886 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6887 | ||
7ebe625c QY |
6888 | /* |
6889 | * If 'neighbor swpX', then this is for directly connected peers, | |
6890 | * we should not accept a ttl-security hops value greater than 1. | |
6891 | */ | |
e2521429 | 6892 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
6893 | vty_out(vty, |
6894 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6895 | argv[idx_peer]->arg); | |
6896 | return CMD_WARNING_CONFIG_FAILED; | |
6897 | } | |
6898 | ||
d62a17ae | 6899 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6900 | } |
6901 | ||
6902 | DEFUN (no_neighbor_ttl_security, | |
6903 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6904 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6905 | NO_STR |
6906 | NEIGHBOR_STR | |
7ebe625c | 6907 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6908 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6909 | "Specify the maximum number of hops to the BGP peer\n" |
6910 | "Number of hops to BGP peer\n") | |
fa411a21 | 6911 | { |
d62a17ae | 6912 | int idx_peer = 2; |
6913 | struct peer *peer; | |
fa411a21 | 6914 | |
d62a17ae | 6915 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6916 | if (!peer) | |
6917 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6918 | |
d62a17ae | 6919 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6920 | } |
6b0655a2 | 6921 | |
adbac85e DW |
6922 | DEFUN (neighbor_addpath_tx_all_paths, |
6923 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6924 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6925 | NEIGHBOR_STR |
6926 | NEIGHBOR_ADDR_STR2 | |
6927 | "Use addpath to advertise all paths to a neighbor\n") | |
6928 | { | |
d62a17ae | 6929 | int idx_peer = 1; |
6930 | struct peer *peer; | |
adbac85e | 6931 | |
d62a17ae | 6932 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6933 | if (!peer) | |
6934 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6935 | |
dcc68b5e MS |
6936 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6937 | BGP_ADDPATH_ALL); | |
6938 | return CMD_SUCCESS; | |
adbac85e DW |
6939 | } |
6940 | ||
d62a17ae | 6941 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6942 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6943 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6944 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6945 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6946 | |
adbac85e DW |
6947 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6948 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6949 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6950 | NO_STR |
6951 | NEIGHBOR_STR | |
6952 | NEIGHBOR_ADDR_STR2 | |
6953 | "Use addpath to advertise all paths to a neighbor\n") | |
6954 | { | |
d62a17ae | 6955 | int idx_peer = 2; |
dcc68b5e MS |
6956 | struct peer *peer; |
6957 | ||
6958 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6959 | if (!peer) | |
6960 | return CMD_WARNING_CONFIG_FAILED; | |
6961 | ||
6962 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6963 | != BGP_ADDPATH_ALL) { | |
6964 | vty_out(vty, | |
6965 | "%% Peer not currently configured to transmit all paths."); | |
6966 | return CMD_WARNING_CONFIG_FAILED; | |
6967 | } | |
6968 | ||
6969 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6970 | BGP_ADDPATH_NONE); | |
6971 | ||
6972 | return CMD_SUCCESS; | |
adbac85e DW |
6973 | } |
6974 | ||
d62a17ae | 6975 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6976 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6977 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6978 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6979 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6980 | |
06370dac DW |
6981 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6982 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6983 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6984 | NEIGHBOR_STR |
6985 | NEIGHBOR_ADDR_STR2 | |
6986 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6987 | { | |
d62a17ae | 6988 | int idx_peer = 1; |
6989 | struct peer *peer; | |
06370dac | 6990 | |
d62a17ae | 6991 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6992 | if (!peer) | |
6993 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6994 | |
dcc68b5e MS |
6995 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6996 | BGP_ADDPATH_BEST_PER_AS); | |
6997 | ||
6998 | return CMD_SUCCESS; | |
06370dac DW |
6999 | } |
7000 | ||
d62a17ae | 7001 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7002 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7003 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7004 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7005 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7006 | |
06370dac DW |
7007 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7008 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7009 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7010 | NO_STR |
7011 | NEIGHBOR_STR | |
7012 | NEIGHBOR_ADDR_STR2 | |
7013 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7014 | { | |
d62a17ae | 7015 | int idx_peer = 2; |
dcc68b5e MS |
7016 | struct peer *peer; |
7017 | ||
7018 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7019 | if (!peer) | |
7020 | return CMD_WARNING_CONFIG_FAILED; | |
7021 | ||
7022 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7023 | != BGP_ADDPATH_BEST_PER_AS) { | |
7024 | vty_out(vty, | |
7025 | "%% Peer not currently configured to transmit all best path per as."); | |
7026 | return CMD_WARNING_CONFIG_FAILED; | |
7027 | } | |
7028 | ||
7029 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7030 | BGP_ADDPATH_NONE); | |
7031 | ||
7032 | return CMD_SUCCESS; | |
06370dac DW |
7033 | } |
7034 | ||
d62a17ae | 7035 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7036 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7037 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7038 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7039 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7040 | |
2b31007c RZ |
7041 | DEFPY( |
7042 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7043 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7044 | NEIGHBOR_STR | |
7045 | NEIGHBOR_ADDR_STR2 | |
7046 | "Detect AS loops before sending to neighbor\n") | |
7047 | { | |
7048 | struct peer *peer; | |
7049 | ||
7050 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7051 | if (!peer) | |
7052 | return CMD_WARNING_CONFIG_FAILED; | |
7053 | ||
7054 | peer->as_path_loop_detection = true; | |
7055 | ||
7056 | return CMD_SUCCESS; | |
7057 | } | |
7058 | ||
7059 | DEFPY( | |
7060 | no_neighbor_aspath_loop_detection, | |
7061 | no_neighbor_aspath_loop_detection_cmd, | |
7062 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7063 | NO_STR | |
7064 | NEIGHBOR_STR | |
7065 | NEIGHBOR_ADDR_STR2 | |
7066 | "Detect AS loops before sending to neighbor\n") | |
7067 | { | |
7068 | struct peer *peer; | |
7069 | ||
7070 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7071 | if (!peer) | |
7072 | return CMD_WARNING_CONFIG_FAILED; | |
7073 | ||
7074 | peer->as_path_loop_detection = false; | |
7075 | ||
7076 | return CMD_SUCCESS; | |
7077 | } | |
7078 | ||
b9c7bc5a PZ |
7079 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7080 | struct ecommunity **list) | |
ddb5b488 | 7081 | { |
b9c7bc5a PZ |
7082 | struct ecommunity *ecom = NULL; |
7083 | struct ecommunity *ecomadd; | |
ddb5b488 | 7084 | |
b9c7bc5a | 7085 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7086 | |
b9c7bc5a PZ |
7087 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7088 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7089 | if (!ecomadd) { | |
7090 | vty_out(vty, "Malformed community-list value\n"); | |
7091 | if (ecom) | |
7092 | ecommunity_free(&ecom); | |
7093 | return CMD_WARNING_CONFIG_FAILED; | |
7094 | } | |
ddb5b488 | 7095 | |
b9c7bc5a PZ |
7096 | if (ecom) { |
7097 | ecommunity_merge(ecom, ecomadd); | |
7098 | ecommunity_free(&ecomadd); | |
7099 | } else { | |
7100 | ecom = ecomadd; | |
7101 | } | |
7102 | } | |
7103 | ||
7104 | if (*list) { | |
7105 | ecommunity_free(&*list); | |
ddb5b488 | 7106 | } |
b9c7bc5a PZ |
7107 | *list = ecom; |
7108 | ||
7109 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7110 | } |
7111 | ||
0ca70ba5 DS |
7112 | /* |
7113 | * v2vimport is true if we are handling a `import vrf ...` command | |
7114 | */ | |
7115 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7116 | { |
0ca70ba5 DS |
7117 | afi_t afi; |
7118 | ||
ddb5b488 | 7119 | switch (vty->node) { |
b9c7bc5a | 7120 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7121 | afi = AFI_IP; |
7122 | break; | |
b9c7bc5a | 7123 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7124 | afi = AFI_IP6; |
7125 | break; | |
ddb5b488 PZ |
7126 | default: |
7127 | vty_out(vty, | |
b9c7bc5a | 7128 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7129 | return AFI_MAX; |
ddb5b488 | 7130 | } |
69b07479 | 7131 | |
0ca70ba5 DS |
7132 | if (!v2vimport) { |
7133 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7134 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7135 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7136 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7137 | vty_out(vty, | |
7138 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7139 | return AFI_MAX; | |
7140 | } | |
7141 | } else { | |
7142 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7143 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7144 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7145 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7146 | vty_out(vty, | |
7147 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7148 | return AFI_MAX; | |
7149 | } | |
7150 | } | |
7151 | return afi; | |
ddb5b488 PZ |
7152 | } |
7153 | ||
b9c7bc5a PZ |
7154 | DEFPY (af_rd_vpn_export, |
7155 | af_rd_vpn_export_cmd, | |
7156 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7157 | NO_STR | |
ddb5b488 | 7158 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7159 | "Between current address-family and vpn\n" |
7160 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7161 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7162 | { | |
7163 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7164 | struct prefix_rd prd; | |
7165 | int ret; | |
ddb5b488 | 7166 | afi_t afi; |
b9c7bc5a PZ |
7167 | int idx = 0; |
7168 | int yes = 1; | |
ddb5b488 | 7169 | |
b9c7bc5a | 7170 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7171 | yes = 0; |
b9c7bc5a PZ |
7172 | |
7173 | if (yes) { | |
7174 | ret = str2prefix_rd(rd_str, &prd); | |
7175 | if (!ret) { | |
7176 | vty_out(vty, "%% Malformed rd\n"); | |
7177 | return CMD_WARNING_CONFIG_FAILED; | |
7178 | } | |
ddb5b488 PZ |
7179 | } |
7180 | ||
0ca70ba5 | 7181 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7182 | if (afi == AFI_MAX) |
7183 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7184 | |
69b07479 DS |
7185 | /* |
7186 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7187 | */ | |
7188 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7189 | bgp_get_default(), bgp); | |
ddb5b488 | 7190 | |
69b07479 DS |
7191 | if (yes) { |
7192 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7193 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7194 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7195 | } else { | |
7196 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7197 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7198 | } |
7199 | ||
69b07479 DS |
7200 | /* post-change: re-export vpn routes */ |
7201 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7202 | bgp_get_default(), bgp); | |
7203 | ||
ddb5b488 PZ |
7204 | return CMD_SUCCESS; |
7205 | } | |
7206 | ||
b9c7bc5a PZ |
7207 | ALIAS (af_rd_vpn_export, |
7208 | af_no_rd_vpn_export_cmd, | |
7209 | "no rd vpn export", | |
ddb5b488 | 7210 | NO_STR |
b9c7bc5a PZ |
7211 | "Specify route distinguisher\n" |
7212 | "Between current address-family and vpn\n" | |
7213 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7214 | |
b9c7bc5a PZ |
7215 | DEFPY (af_label_vpn_export, |
7216 | af_label_vpn_export_cmd, | |
e70e9f8e | 7217 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7218 | NO_STR |
ddb5b488 | 7219 | "label value for VRF\n" |
b9c7bc5a PZ |
7220 | "Between current address-family and vpn\n" |
7221 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7222 | "Label Value <0-1048575>\n" |
7223 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7224 | { |
7225 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7226 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7227 | afi_t afi; |
b9c7bc5a PZ |
7228 | int idx = 0; |
7229 | int yes = 1; | |
7230 | ||
7231 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7232 | yes = 0; |
ddb5b488 | 7233 | |
21a16cc2 PZ |
7234 | /* If "no ...", squash trailing parameter */ |
7235 | if (!yes) | |
7236 | label_auto = NULL; | |
7237 | ||
e70e9f8e PZ |
7238 | if (yes) { |
7239 | if (!label_auto) | |
7240 | label = label_val; /* parser should force unsigned */ | |
7241 | } | |
ddb5b488 | 7242 | |
0ca70ba5 | 7243 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7244 | if (afi == AFI_MAX) |
7245 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7246 | |
e70e9f8e | 7247 | |
69b07479 DS |
7248 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7249 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7250 | /* no change */ | |
7251 | return CMD_SUCCESS; | |
e70e9f8e | 7252 | |
69b07479 DS |
7253 | /* |
7254 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7255 | */ | |
7256 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7257 | bgp_get_default(), bgp); | |
7258 | ||
7259 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7260 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7261 | ||
7262 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7263 | ||
7264 | /* | |
7265 | * label has previously been automatically | |
7266 | * assigned by labelpool: release it | |
7267 | * | |
7268 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7269 | * means the automatic assignment is in flight | |
7270 | * and therefore the labelpool callback must | |
7271 | * detect that the auto label is not needed. | |
7272 | */ | |
7273 | ||
7274 | bgp_lp_release(LP_TYPE_VRF, | |
7275 | &bgp->vpn_policy[afi], | |
7276 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7277 | } |
69b07479 DS |
7278 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7279 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7280 | } | |
ddb5b488 | 7281 | |
69b07479 DS |
7282 | bgp->vpn_policy[afi].tovpn_label = label; |
7283 | if (label_auto) { | |
7284 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7285 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7286 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7287 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7288 | } |
7289 | ||
69b07479 DS |
7290 | /* post-change: re-export vpn routes */ |
7291 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7292 | bgp_get_default(), bgp); | |
7293 | ||
ddb5b488 PZ |
7294 | return CMD_SUCCESS; |
7295 | } | |
7296 | ||
b9c7bc5a PZ |
7297 | ALIAS (af_label_vpn_export, |
7298 | af_no_label_vpn_export_cmd, | |
7299 | "no label vpn export", | |
7300 | NO_STR | |
7301 | "label value for VRF\n" | |
7302 | "Between current address-family and vpn\n" | |
7303 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7304 | |
b9c7bc5a PZ |
7305 | DEFPY (af_nexthop_vpn_export, |
7306 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7307 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7308 | NO_STR |
ddb5b488 | 7309 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7310 | "Between current address-family and vpn\n" |
7311 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7312 | "IPv4 prefix\n" |
7313 | "IPv6 prefix\n") | |
7314 | { | |
7315 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7316 | afi_t afi; |
ddb5b488 PZ |
7317 | struct prefix p; |
7318 | ||
8c85ca28 QY |
7319 | if (!no) { |
7320 | if (!nexthop_su) { | |
7321 | vty_out(vty, "%% Nexthop required\n"); | |
7322 | return CMD_WARNING_CONFIG_FAILED; | |
7323 | } | |
b9c7bc5a | 7324 | |
8c85ca28 | 7325 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7326 | return CMD_WARNING_CONFIG_FAILED; |
7327 | } | |
ddb5b488 | 7328 | |
0ca70ba5 | 7329 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7330 | if (afi == AFI_MAX) |
7331 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7332 | |
69b07479 DS |
7333 | /* |
7334 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7335 | */ | |
7336 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7337 | bgp_get_default(), bgp); | |
ddb5b488 | 7338 | |
8c85ca28 | 7339 | if (!no) { |
69b07479 DS |
7340 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7341 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7342 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7343 | } else { | |
7344 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7345 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7346 | } |
7347 | ||
69b07479 DS |
7348 | /* post-change: re-export vpn routes */ |
7349 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7350 | bgp_get_default(), bgp); | |
7351 | ||
ddb5b488 PZ |
7352 | return CMD_SUCCESS; |
7353 | } | |
7354 | ||
b9c7bc5a | 7355 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7356 | { |
b9c7bc5a PZ |
7357 | if (!strcmp(dstr, "import")) { |
7358 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7359 | } else if (!strcmp(dstr, "export")) { | |
7360 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7361 | } else if (!strcmp(dstr, "both")) { | |
7362 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7363 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7364 | } else { | |
7365 | vty_out(vty, "%% direction parse error\n"); | |
7366 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7367 | } |
ddb5b488 PZ |
7368 | return CMD_SUCCESS; |
7369 | } | |
7370 | ||
b9c7bc5a PZ |
7371 | DEFPY (af_rt_vpn_imexport, |
7372 | af_rt_vpn_imexport_cmd, | |
7373 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7374 | NO_STR | |
7375 | "Specify route target list\n" | |
ddb5b488 | 7376 | "Specify route target list\n" |
b9c7bc5a PZ |
7377 | "Between current address-family and vpn\n" |
7378 | "For routes leaked from vpn to current address-family: match any\n" | |
7379 | "For routes leaked from current address-family to vpn: set\n" | |
7380 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7381 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7382 | { | |
7383 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7384 | int ret; | |
7385 | struct ecommunity *ecom = NULL; | |
7386 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7387 | vpn_policy_direction_t dir; |
7388 | afi_t afi; | |
7389 | int idx = 0; | |
b9c7bc5a | 7390 | int yes = 1; |
ddb5b488 | 7391 | |
b9c7bc5a | 7392 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7393 | yes = 0; |
b9c7bc5a | 7394 | |
0ca70ba5 | 7395 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7396 | if (afi == AFI_MAX) |
7397 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7398 | |
b9c7bc5a | 7399 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7400 | if (ret != CMD_SUCCESS) |
7401 | return ret; | |
7402 | ||
b9c7bc5a PZ |
7403 | if (yes) { |
7404 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7405 | vty_out(vty, "%% Missing RTLIST\n"); | |
7406 | return CMD_WARNING_CONFIG_FAILED; | |
7407 | } | |
7408 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7409 | if (ret != CMD_SUCCESS) { | |
7410 | return ret; | |
7411 | } | |
ddb5b488 PZ |
7412 | } |
7413 | ||
69b07479 DS |
7414 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7415 | if (!dodir[dir]) | |
ddb5b488 | 7416 | continue; |
ddb5b488 | 7417 | |
69b07479 | 7418 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7419 | |
69b07479 DS |
7420 | if (yes) { |
7421 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7422 | ecommunity_free( | |
7423 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7424 | bgp->vpn_policy[afi].rtlist[dir] = | |
7425 | ecommunity_dup(ecom); | |
7426 | } else { | |
7427 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7428 | ecommunity_free( | |
7429 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7430 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7431 | } |
69b07479 DS |
7432 | |
7433 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7434 | } |
69b07479 | 7435 | |
d555f3e9 PZ |
7436 | if (ecom) |
7437 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7438 | |
7439 | return CMD_SUCCESS; | |
7440 | } | |
7441 | ||
b9c7bc5a PZ |
7442 | ALIAS (af_rt_vpn_imexport, |
7443 | af_no_rt_vpn_imexport_cmd, | |
7444 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7445 | NO_STR |
7446 | "Specify route target list\n" | |
b9c7bc5a PZ |
7447 | "Specify route target list\n" |
7448 | "Between current address-family and vpn\n" | |
7449 | "For routes leaked from vpn to current address-family\n" | |
7450 | "For routes leaked from current address-family to vpn\n" | |
7451 | "both import and export\n") | |
7452 | ||
7453 | DEFPY (af_route_map_vpn_imexport, | |
7454 | af_route_map_vpn_imexport_cmd, | |
7455 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7456 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7457 | NO_STR | |
ddb5b488 | 7458 | "Specify route map\n" |
b9c7bc5a PZ |
7459 | "Between current address-family and vpn\n" |
7460 | "For routes leaked from vpn to current address-family\n" | |
7461 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7462 | "name of route-map\n") |
7463 | { | |
7464 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7465 | int ret; | |
7466 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7467 | vpn_policy_direction_t dir; |
7468 | afi_t afi; | |
ddb5b488 | 7469 | int idx = 0; |
b9c7bc5a | 7470 | int yes = 1; |
ddb5b488 | 7471 | |
b9c7bc5a | 7472 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7473 | yes = 0; |
b9c7bc5a | 7474 | |
0ca70ba5 | 7475 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7476 | if (afi == AFI_MAX) |
7477 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7478 | |
b9c7bc5a | 7479 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7480 | if (ret != CMD_SUCCESS) |
7481 | return ret; | |
7482 | ||
69b07479 DS |
7483 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7484 | if (!dodir[dir]) | |
ddb5b488 | 7485 | continue; |
ddb5b488 | 7486 | |
69b07479 | 7487 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7488 | |
69b07479 DS |
7489 | if (yes) { |
7490 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7491 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7492 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7493 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7494 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7495 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7496 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7497 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7498 | return CMD_SUCCESS; | |
7499 | } else { | |
7500 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7501 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7502 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7503 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7504 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7505 | } |
69b07479 DS |
7506 | |
7507 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7508 | } |
7509 | ||
7510 | return CMD_SUCCESS; | |
7511 | } | |
7512 | ||
b9c7bc5a PZ |
7513 | ALIAS (af_route_map_vpn_imexport, |
7514 | af_no_route_map_vpn_imexport_cmd, | |
7515 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7516 | NO_STR |
7517 | "Specify route map\n" | |
b9c7bc5a PZ |
7518 | "Between current address-family and vpn\n" |
7519 | "For routes leaked from vpn to current address-family\n" | |
7520 | "For routes leaked from current address-family to vpn\n") | |
7521 | ||
bb4f6190 DS |
7522 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
7523 | "[no] import vrf route-map RMAP$rmap_str", | |
7524 | NO_STR | |
7525 | "Import routes from another VRF\n" | |
7526 | "Vrf routes being filtered\n" | |
7527 | "Specify route map\n" | |
7528 | "name of route-map\n") | |
7529 | { | |
7530 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7531 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7532 | afi_t afi; | |
7533 | int idx = 0; | |
7534 | int yes = 1; | |
7535 | struct bgp *bgp_default; | |
7536 | ||
7537 | if (argv_find(argv, argc, "no", &idx)) | |
7538 | yes = 0; | |
7539 | ||
0ca70ba5 | 7540 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7541 | if (afi == AFI_MAX) |
7542 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7543 | |
7544 | bgp_default = bgp_get_default(); | |
7545 | if (!bgp_default) { | |
7546 | int32_t ret; | |
7547 | as_t as = bgp->as; | |
7548 | ||
7549 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7550 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7551 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7552 | |
7553 | if (ret) { | |
7554 | vty_out(vty, | |
7555 | "VRF default is not configured as a bgp instance\n"); | |
7556 | return CMD_WARNING; | |
7557 | } | |
7558 | } | |
7559 | ||
69b07479 | 7560 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7561 | |
69b07479 DS |
7562 | if (yes) { |
7563 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7564 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7565 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7566 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7567 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7568 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7569 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7570 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7571 | return CMD_SUCCESS; | |
7572 | } else { | |
7573 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7574 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7575 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7576 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7577 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
7578 | } |
7579 | ||
69b07479 DS |
7580 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7581 | ||
bb4f6190 DS |
7582 | return CMD_SUCCESS; |
7583 | } | |
7584 | ||
7585 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
7586 | "no import vrf route-map", | |
7587 | NO_STR | |
7588 | "Import routes from another VRF\n" | |
7589 | "Vrf routes being filtered\n" | |
7590 | "Specify route map\n") | |
7591 | ||
4d1b335c DA |
7592 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7593 | "[no] import vrf VIEWVRFNAME$import_name", | |
7594 | NO_STR | |
7595 | "Import routes from another VRF\n" | |
7596 | "VRF to import from\n" | |
7597 | "The name of the VRF\n") | |
12a844a5 DS |
7598 | { |
7599 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7600 | struct listnode *node; | |
79ef8664 DS |
7601 | struct bgp *vrf_bgp, *bgp_default; |
7602 | int32_t ret = 0; | |
7603 | as_t as = bgp->as; | |
12a844a5 DS |
7604 | bool remove = false; |
7605 | int32_t idx = 0; | |
7606 | char *vname; | |
a8dadcf6 | 7607 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7608 | safi_t safi; |
7609 | afi_t afi; | |
7610 | ||
867f0cca | 7611 | if (import_name == NULL) { |
7612 | vty_out(vty, "%% Missing import name\n"); | |
7613 | return CMD_WARNING; | |
7614 | } | |
7615 | ||
12a844a5 DS |
7616 | if (argv_find(argv, argc, "no", &idx)) |
7617 | remove = true; | |
7618 | ||
0ca70ba5 DS |
7619 | afi = vpn_policy_getafi(vty, bgp, true); |
7620 | if (afi == AFI_MAX) | |
7621 | return CMD_WARNING_CONFIG_FAILED; | |
7622 | ||
12a844a5 DS |
7623 | safi = bgp_node_safi(vty); |
7624 | ||
25679caa | 7625 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7626 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7627 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7628 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7629 | remove ? "unimport" : "import", import_name); | |
7630 | return CMD_WARNING; | |
7631 | } | |
7632 | ||
79ef8664 DS |
7633 | bgp_default = bgp_get_default(); |
7634 | if (!bgp_default) { | |
7635 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7636 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7637 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7638 | |
7639 | if (ret) { | |
7640 | vty_out(vty, | |
7641 | "VRF default is not configured as a bgp instance\n"); | |
7642 | return CMD_WARNING; | |
7643 | } | |
7644 | } | |
7645 | ||
12a844a5 DS |
7646 | vrf_bgp = bgp_lookup_by_name(import_name); |
7647 | if (!vrf_bgp) { | |
5742e42b | 7648 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7649 | vrf_bgp = bgp_default; |
7650 | else | |
0fb8d6e6 | 7651 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7652 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7653 | |
6e2c7fe6 | 7654 | if (ret) { |
020a3f60 DS |
7655 | vty_out(vty, |
7656 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7657 | import_name); |
7658 | return CMD_WARNING; | |
7659 | } | |
12a844a5 DS |
7660 | } |
7661 | ||
12a844a5 | 7662 | if (remove) { |
44338987 | 7663 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7664 | } else { |
44338987 | 7665 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7666 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7667 | vname)) { | |
7668 | if (strcmp(vname, import_name) == 0) | |
7669 | return CMD_WARNING; | |
7670 | } | |
7671 | ||
44338987 | 7672 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7673 | } |
7674 | ||
7675 | return CMD_SUCCESS; | |
7676 | } | |
7677 | ||
b9c7bc5a PZ |
7678 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7679 | DEFPY (bgp_imexport_vpn, | |
7680 | bgp_imexport_vpn_cmd, | |
7681 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7682 | NO_STR |
7683 | "Import routes to this address-family\n" | |
7684 | "Export routes from this address-family\n" | |
7685 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7686 | { |
7687 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7688 | int previous_state; |
ddb5b488 | 7689 | afi_t afi; |
b9c7bc5a | 7690 | safi_t safi; |
ddb5b488 | 7691 | int idx = 0; |
b9c7bc5a PZ |
7692 | int yes = 1; |
7693 | int flag; | |
7694 | vpn_policy_direction_t dir; | |
ddb5b488 | 7695 | |
b9c7bc5a | 7696 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7697 | yes = 0; |
ddb5b488 | 7698 | |
b9c7bc5a PZ |
7699 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7700 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7701 | |
b9c7bc5a PZ |
7702 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7703 | return CMD_WARNING_CONFIG_FAILED; | |
7704 | } | |
ddb5b488 | 7705 | |
b9c7bc5a PZ |
7706 | afi = bgp_node_afi(vty); |
7707 | safi = bgp_node_safi(vty); | |
7708 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7709 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7710 | return CMD_WARNING_CONFIG_FAILED; | |
7711 | } | |
ddb5b488 | 7712 | |
b9c7bc5a PZ |
7713 | if (!strcmp(direction_str, "import")) { |
7714 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7715 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7716 | } else if (!strcmp(direction_str, "export")) { | |
7717 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7718 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7719 | } else { | |
7720 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7721 | return CMD_WARNING_CONFIG_FAILED; | |
7722 | } | |
7723 | ||
7724 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7725 | |
b9c7bc5a PZ |
7726 | if (yes) { |
7727 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7728 | if (!previous_state) { | |
7729 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7730 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7731 | } | |
b9c7bc5a PZ |
7732 | } else { |
7733 | if (previous_state) { | |
7734 | /* trigger un-export current vrf */ | |
7735 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7736 | } | |
7737 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7738 | } |
7739 | ||
7740 | return CMD_SUCCESS; | |
7741 | } | |
7742 | ||
301ad80a PG |
7743 | DEFPY (af_routetarget_import, |
7744 | af_routetarget_import_cmd, | |
7745 | "[no] <rt|route-target> redirect import RTLIST...", | |
7746 | NO_STR | |
7747 | "Specify route target list\n" | |
7748 | "Specify route target list\n" | |
7749 | "Flow-spec redirect type route target\n" | |
7750 | "Import routes to this address-family\n" | |
7751 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7752 | { | |
7753 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7754 | int ret; | |
7755 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7756 | afi_t afi; |
7757 | int idx = 0; | |
7758 | int yes = 1; | |
7759 | ||
7760 | if (argv_find(argv, argc, "no", &idx)) | |
7761 | yes = 0; | |
7762 | ||
0ca70ba5 | 7763 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7764 | if (afi == AFI_MAX) |
7765 | return CMD_WARNING_CONFIG_FAILED; | |
7766 | ||
301ad80a PG |
7767 | if (yes) { |
7768 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7769 | vty_out(vty, "%% Missing RTLIST\n"); | |
7770 | return CMD_WARNING_CONFIG_FAILED; | |
7771 | } | |
7772 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7773 | if (ret != CMD_SUCCESS) | |
7774 | return ret; | |
7775 | } | |
69b07479 DS |
7776 | |
7777 | if (yes) { | |
7778 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7779 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7780 | .import_redirect_rtlist); |
69b07479 DS |
7781 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7782 | ecommunity_dup(ecom); | |
7783 | } else { | |
7784 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7785 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7786 | .import_redirect_rtlist); |
69b07479 | 7787 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7788 | } |
69b07479 | 7789 | |
301ad80a PG |
7790 | if (ecom) |
7791 | ecommunity_free(&ecom); | |
7792 | ||
7793 | return CMD_SUCCESS; | |
7794 | } | |
7795 | ||
505e5056 | 7796 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7797 | address_family_ipv4_safi_cmd, |
7798 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7799 | "Enter Address Family command mode\n" | |
7800 | "Address Family\n" | |
7801 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7802 | { |
f51bae9c | 7803 | |
d62a17ae | 7804 | if (argc == 3) { |
2131d5cf | 7805 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7806 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7807 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7808 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7809 | && safi != SAFI_EVPN) { |
31947174 MK |
7810 | vty_out(vty, |
7811 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7812 | return CMD_WARNING_CONFIG_FAILED; |
7813 | } | |
d62a17ae | 7814 | vty->node = bgp_node_type(AFI_IP, safi); |
7815 | } else | |
7816 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7817 | |
d62a17ae | 7818 | return CMD_SUCCESS; |
718e3744 | 7819 | } |
7820 | ||
505e5056 | 7821 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7822 | address_family_ipv6_safi_cmd, |
7823 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7824 | "Enter Address Family command mode\n" | |
7825 | "Address Family\n" | |
7826 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7827 | { |
d62a17ae | 7828 | if (argc == 3) { |
2131d5cf | 7829 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7830 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7831 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7832 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7833 | && safi != SAFI_EVPN) { |
31947174 MK |
7834 | vty_out(vty, |
7835 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7836 | return CMD_WARNING_CONFIG_FAILED; |
7837 | } | |
d62a17ae | 7838 | vty->node = bgp_node_type(AFI_IP6, safi); |
7839 | } else | |
7840 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7841 | |
d62a17ae | 7842 | return CMD_SUCCESS; |
25ffbdc1 | 7843 | } |
718e3744 | 7844 | |
d6902373 | 7845 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7846 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7847 | address_family_vpnv4_cmd, |
8334fd5a | 7848 | "address-family vpnv4 [unicast]", |
718e3744 | 7849 | "Enter Address Family command mode\n" |
8c3deaae | 7850 | "Address Family\n" |
3a2d747c | 7851 | "Address Family modifier\n") |
718e3744 | 7852 | { |
d62a17ae | 7853 | vty->node = BGP_VPNV4_NODE; |
7854 | return CMD_SUCCESS; | |
718e3744 | 7855 | } |
7856 | ||
505e5056 | 7857 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7858 | address_family_vpnv6_cmd, |
8334fd5a | 7859 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7860 | "Enter Address Family command mode\n" |
8c3deaae | 7861 | "Address Family\n" |
3a2d747c | 7862 | "Address Family modifier\n") |
8ecd3266 | 7863 | { |
d62a17ae | 7864 | vty->node = BGP_VPNV6_NODE; |
7865 | return CMD_SUCCESS; | |
8ecd3266 | 7866 | } |
64e4a6c5 | 7867 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7868 | |
505e5056 | 7869 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7870 | address_family_evpn_cmd, |
7111c1a0 | 7871 | "address-family l2vpn evpn", |
4e0b7b6d | 7872 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7873 | "Address Family\n" |
7874 | "Address Family modifier\n") | |
4e0b7b6d | 7875 | { |
2131d5cf | 7876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7877 | vty->node = BGP_EVPN_NODE; |
7878 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7879 | } |
7880 | ||
505e5056 | 7881 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7882 | exit_address_family_cmd, |
7883 | "exit-address-family", | |
7884 | "Exit from Address Family configuration mode\n") | |
7885 | { | |
d62a17ae | 7886 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7887 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7888 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7889 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7890 | || vty->node == BGP_EVPN_NODE |
7891 | || vty->node == BGP_FLOWSPECV4_NODE | |
7892 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7893 | vty->node = BGP_NODE; |
7894 | return CMD_SUCCESS; | |
718e3744 | 7895 | } |
6b0655a2 | 7896 | |
8ad7271d | 7897 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7898 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7899 | const char *ip_str, afi_t afi, safi_t safi, | |
7900 | struct prefix_rd *prd) | |
7901 | { | |
7902 | int ret; | |
7903 | struct prefix match; | |
7904 | struct bgp_node *rn; | |
7905 | struct bgp_node *rm; | |
7906 | struct bgp *bgp; | |
7907 | struct bgp_table *table; | |
7908 | struct bgp_table *rib; | |
7909 | ||
7910 | /* BGP structure lookup. */ | |
7911 | if (view_name) { | |
7912 | bgp = bgp_lookup_by_name(view_name); | |
7913 | if (bgp == NULL) { | |
7914 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7915 | view_name); | |
7916 | return CMD_WARNING; | |
7917 | } | |
7918 | } else { | |
7919 | bgp = bgp_get_default(); | |
7920 | if (bgp == NULL) { | |
7921 | vty_out(vty, "%% No BGP process is configured\n"); | |
7922 | return CMD_WARNING; | |
7923 | } | |
7924 | } | |
7925 | ||
7926 | /* Check IP address argument. */ | |
7927 | ret = str2prefix(ip_str, &match); | |
7928 | if (!ret) { | |
7929 | vty_out(vty, "%% address is malformed\n"); | |
7930 | return CMD_WARNING; | |
7931 | } | |
7932 | ||
7933 | match.family = afi2family(afi); | |
7934 | rib = bgp->rib[afi][safi]; | |
7935 | ||
7936 | if (safi == SAFI_MPLS_VPN) { | |
7937 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7938 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7939 | continue; | |
7940 | ||
67009e22 DS |
7941 | table = bgp_node_get_bgp_table_info(rn); |
7942 | if (table != NULL) { | |
7943 | ||
d62a17ae | 7944 | if ((rm = bgp_node_match(table, &match)) |
7945 | != NULL) { | |
7946 | if (rm->p.prefixlen | |
7947 | == match.prefixlen) { | |
343cdb61 | 7948 | SET_FLAG(rm->flags, |
d62a17ae | 7949 | BGP_NODE_USER_CLEAR); |
7950 | bgp_process(bgp, rm, afi, safi); | |
7951 | } | |
7952 | bgp_unlock_node(rm); | |
7953 | } | |
7954 | } | |
7955 | } | |
7956 | } else { | |
7957 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7958 | if (rn->p.prefixlen == match.prefixlen) { | |
7959 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7960 | bgp_process(bgp, rn, afi, safi); | |
7961 | } | |
7962 | bgp_unlock_node(rn); | |
7963 | } | |
7964 | } | |
7965 | ||
7966 | return CMD_SUCCESS; | |
8ad7271d DS |
7967 | } |
7968 | ||
b09b5ae0 | 7969 | /* one clear bgp command to rule them all */ |
718e3744 | 7970 | DEFUN (clear_ip_bgp_all, |
7971 | clear_ip_bgp_all_cmd, | |
453c92f6 | 7972 | "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 | 7973 | CLEAR_STR |
7974 | IP_STR | |
7975 | BGP_STR | |
838758ac | 7976 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7977 | BGP_AFI_HELP_STR |
fd5e7b70 | 7978 | "Address Family\n" |
510afcd6 | 7979 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7980 | "Address Family modifier\n" |
b09b5ae0 | 7981 | "Clear all peers\n" |
453c92f6 | 7982 | "BGP IPv4 neighbor to clear\n" |
a80beece | 7983 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7984 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7985 | "Clear peers with the AS number\n" |
7986 | "Clear all external peers\n" | |
718e3744 | 7987 | "Clear all members of peer-group\n" |
b09b5ae0 | 7988 | "BGP peer-group name\n" |
b09b5ae0 DW |
7989 | BGP_SOFT_STR |
7990 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7991 | BGP_SOFT_OUT_STR |
7992 | BGP_SOFT_IN_STR | |
7993 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7994 | BGP_SOFT_OUT_STR) |
718e3744 | 7995 | { |
d62a17ae | 7996 | char *vrf = NULL; |
7997 | ||
dc912615 DS |
7998 | afi_t afi = AFI_UNSPEC; |
7999 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8000 | enum clear_sort clr_sort = clear_peer; |
8001 | enum bgp_clear_type clr_type; | |
8002 | char *clr_arg = NULL; | |
8003 | ||
8004 | int idx = 0; | |
8005 | ||
8006 | /* clear [ip] bgp */ | |
8007 | if (argv_find(argv, argc, "ip", &idx)) | |
8008 | afi = AFI_IP; | |
8009 | ||
9a8bdf1c PG |
8010 | /* [<vrf> VIEWVRFNAME] */ |
8011 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8012 | vrf = argv[idx + 1]->arg; | |
8013 | idx += 2; | |
8014 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8015 | vrf = NULL; | |
8016 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8017 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8018 | vrf = argv[idx + 1]->arg; |
8019 | idx += 2; | |
8020 | } | |
d62a17ae | 8021 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8022 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8023 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8024 | ||
d7b9898c | 8025 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8026 | if (argv_find(argv, argc, "*", &idx)) { |
8027 | clr_sort = clear_all; | |
8028 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8029 | clr_sort = clear_peer; | |
8030 | clr_arg = argv[idx]->arg; | |
8031 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8032 | clr_sort = clear_peer; | |
8033 | clr_arg = argv[idx]->arg; | |
8034 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8035 | clr_sort = clear_group; | |
8036 | idx++; | |
8037 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8038 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8039 | clr_sort = clear_peer; |
8040 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8041 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8042 | clr_sort = clear_peer; | |
8043 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8044 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8045 | clr_sort = clear_as; | |
8046 | clr_arg = argv[idx]->arg; | |
8047 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8048 | clr_sort = clear_external; | |
8049 | } | |
8050 | ||
8051 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8052 | if (argv_find(argv, argc, "soft", &idx)) { | |
8053 | if (argv_find(argv, argc, "in", &idx) | |
8054 | || argv_find(argv, argc, "out", &idx)) | |
8055 | clr_type = strmatch(argv[idx]->text, "in") | |
8056 | ? BGP_CLEAR_SOFT_IN | |
8057 | : BGP_CLEAR_SOFT_OUT; | |
8058 | else | |
8059 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8060 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8061 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8062 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8063 | : BGP_CLEAR_SOFT_IN; | |
8064 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8065 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8066 | } else | |
8067 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8068 | ||
8069 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8070 | } |
01080f7c | 8071 | |
8ad7271d DS |
8072 | DEFUN (clear_ip_bgp_prefix, |
8073 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8074 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8075 | CLEAR_STR |
8076 | IP_STR | |
8077 | BGP_STR | |
838758ac | 8078 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8079 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8080 | "IPv4 prefix\n") |
8ad7271d | 8081 | { |
d62a17ae | 8082 | char *vrf = NULL; |
8083 | char *prefix = NULL; | |
8ad7271d | 8084 | |
d62a17ae | 8085 | int idx = 0; |
01080f7c | 8086 | |
d62a17ae | 8087 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8088 | if (argv_find(argv, argc, "vrf", &idx)) { |
8089 | vrf = argv[idx + 1]->arg; | |
8090 | idx += 2; | |
8091 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8092 | vrf = NULL; | |
8093 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8094 | /* [<view> VIEWVRFNAME] */ | |
8095 | vrf = argv[idx + 1]->arg; | |
8096 | idx += 2; | |
8097 | } | |
0c7b1b01 | 8098 | |
d62a17ae | 8099 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8100 | |
d62a17ae | 8101 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8102 | } |
8ad7271d | 8103 | |
b09b5ae0 DW |
8104 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8105 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8106 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8107 | CLEAR_STR |
3a2d747c | 8108 | IP_STR |
718e3744 | 8109 | BGP_STR |
8c3deaae | 8110 | "Address Family\n" |
46f296b4 | 8111 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8112 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8113 | "IPv6 prefix\n") |
718e3744 | 8114 | { |
9b475e76 PG |
8115 | int idx_safi = 0; |
8116 | int idx_ipv6_prefix = 0; | |
8117 | safi_t safi = SAFI_UNICAST; | |
8118 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8119 | argv[idx_ipv6_prefix]->arg : NULL; | |
8120 | ||
8121 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8122 | return bgp_clear_prefix( |
9b475e76 PG |
8123 | vty, NULL, prefix, AFI_IP6, |
8124 | safi, NULL); | |
838758ac | 8125 | } |
01080f7c | 8126 | |
b09b5ae0 DW |
8127 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8128 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8129 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8130 | CLEAR_STR |
3a2d747c | 8131 | IP_STR |
718e3744 | 8132 | BGP_STR |
838758ac | 8133 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8134 | "Address Family\n" |
46f296b4 | 8135 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8136 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8137 | "IPv6 prefix\n") |
718e3744 | 8138 | { |
9b475e76 | 8139 | int idx_safi = 0; |
9a8bdf1c | 8140 | int idx_vrfview = 0; |
9b475e76 PG |
8141 | int idx_ipv6_prefix = 0; |
8142 | safi_t safi = SAFI_UNICAST; | |
8143 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8144 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8145 | char *vrfview = NULL; |
9b475e76 | 8146 | |
9a8bdf1c PG |
8147 | /* [<view|vrf> VIEWVRFNAME] */ |
8148 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8149 | vrfview = argv[idx_vrfview + 1]->arg; | |
8150 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8151 | vrfview = NULL; | |
8152 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8153 | /* [<view> VIEWVRFNAME] */ | |
8154 | vrfview = argv[idx_vrfview + 1]->arg; | |
8155 | } | |
9b475e76 PG |
8156 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8157 | ||
d62a17ae | 8158 | return bgp_clear_prefix( |
9b475e76 PG |
8159 | vty, vrfview, prefix, |
8160 | AFI_IP6, safi, NULL); | |
718e3744 | 8161 | } |
8162 | ||
b09b5ae0 DW |
8163 | DEFUN (show_bgp_views, |
8164 | show_bgp_views_cmd, | |
d6e3c605 | 8165 | "show [ip] bgp views", |
b09b5ae0 | 8166 | SHOW_STR |
d6e3c605 | 8167 | IP_STR |
01080f7c | 8168 | BGP_STR |
b09b5ae0 | 8169 | "Show the defined BGP views\n") |
01080f7c | 8170 | { |
d62a17ae | 8171 | struct list *inst = bm->bgp; |
8172 | struct listnode *node; | |
8173 | struct bgp *bgp; | |
01080f7c | 8174 | |
d62a17ae | 8175 | vty_out(vty, "Defined BGP views:\n"); |
8176 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8177 | /* Skip VRFs. */ | |
8178 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8179 | continue; | |
8180 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8181 | bgp->as); | |
8182 | } | |
e52702f2 | 8183 | |
d62a17ae | 8184 | return CMD_SUCCESS; |
e0081f70 ML |
8185 | } |
8186 | ||
8386ac43 | 8187 | DEFUN (show_bgp_vrfs, |
8188 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8189 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8190 | SHOW_STR |
d6e3c605 | 8191 | IP_STR |
8386ac43 | 8192 | BGP_STR |
8193 | "Show BGP VRFs\n" | |
9973d184 | 8194 | JSON_STR) |
8386ac43 | 8195 | { |
fe1dc5a3 | 8196 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8197 | struct list *inst = bm->bgp; |
8198 | struct listnode *node; | |
8199 | struct bgp *bgp; | |
9f049418 | 8200 | bool uj = use_json(argc, argv); |
d62a17ae | 8201 | json_object *json = NULL; |
8202 | json_object *json_vrfs = NULL; | |
8203 | int count = 0; | |
d62a17ae | 8204 | |
d62a17ae | 8205 | if (uj) { |
8206 | json = json_object_new_object(); | |
8207 | json_vrfs = json_object_new_object(); | |
8208 | } | |
8209 | ||
8210 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8211 | const char *name, *type; | |
8212 | struct peer *peer; | |
7fe96307 | 8213 | struct listnode *node2, *nnode2; |
d62a17ae | 8214 | int peers_cfg, peers_estb; |
8215 | json_object *json_vrf = NULL; | |
d62a17ae | 8216 | |
8217 | /* Skip Views. */ | |
8218 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8219 | continue; | |
8220 | ||
8221 | count++; | |
efb4077a | 8222 | if (!uj && count == 1) { |
fe1dc5a3 | 8223 | vty_out(vty, |
efb4077a | 8224 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8225 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8226 | "#PeersEstb", "Name"); |
8227 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8228 | "L3-VNI", "RouterMAC", "Interface"); | |
8229 | } | |
d62a17ae | 8230 | |
8231 | peers_cfg = peers_estb = 0; | |
8232 | if (uj) | |
8233 | json_vrf = json_object_new_object(); | |
8234 | ||
8235 | ||
7fe96307 | 8236 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8237 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8238 | continue; | |
8239 | peers_cfg++; | |
8240 | if (peer->status == Established) | |
8241 | peers_estb++; | |
8242 | } | |
8243 | ||
8244 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8245 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8246 | type = "DFLT"; |
8247 | } else { | |
8248 | name = bgp->name; | |
8249 | type = "VRF"; | |
8250 | } | |
8251 | ||
a8bf7d9c | 8252 | |
d62a17ae | 8253 | if (uj) { |
a4d82a8a PZ |
8254 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8255 | ? -1 | |
8256 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8257 | json_object_string_add(json_vrf, "type", type); |
8258 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8259 | json_object_string_add(json_vrf, "routerId", | |
8260 | inet_ntoa(bgp->router_id)); | |
8261 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8262 | peers_cfg); | |
8263 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8264 | peers_estb); | |
8265 | ||
fe1dc5a3 | 8266 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8267 | json_object_string_add( |
8268 | json_vrf, "rmac", | |
8269 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8270 | json_object_string_add(json_vrf, "interface", |
8271 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8272 | bgp->vrf_id)); | |
d62a17ae | 8273 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8274 | } else { |
fe1dc5a3 | 8275 | vty_out(vty, |
efb4077a | 8276 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8277 | type, |
8278 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8279 | : (int)bgp->vrf_id, | |
8280 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8281 | peers_estb, name); |
8282 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8283 | bgp->l3vni, | |
8284 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8285 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8286 | bgp->vrf_id)); | |
8287 | } | |
d62a17ae | 8288 | } |
8289 | ||
8290 | if (uj) { | |
8291 | json_object_object_add(json, "vrfs", json_vrfs); | |
8292 | ||
8293 | json_object_int_add(json, "totalVrfs", count); | |
8294 | ||
996c9314 LB |
8295 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8296 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8297 | json_object_free(json); |
8298 | } else { | |
8299 | if (count) | |
8300 | vty_out(vty, | |
8301 | "\nTotal number of VRFs (including default): %d\n", | |
8302 | count); | |
8303 | } | |
8304 | ||
8305 | return CMD_SUCCESS; | |
8386ac43 | 8306 | } |
8307 | ||
48ecf8f5 DS |
8308 | DEFUN (show_bgp_mac_hash, |
8309 | show_bgp_mac_hash_cmd, | |
8310 | "show bgp mac hash", | |
8311 | SHOW_STR | |
8312 | BGP_STR | |
8313 | "Mac Address\n" | |
8314 | "Mac Address database\n") | |
8315 | { | |
8316 | bgp_mac_dump_table(vty); | |
8317 | ||
8318 | return CMD_SUCCESS; | |
8319 | } | |
acf71666 | 8320 | |
e3b78da8 | 8321 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8322 | { |
0291c246 | 8323 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8324 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8325 | |
60466a63 | 8326 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8327 | tip->refcnt); |
8328 | } | |
8329 | ||
8330 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8331 | { | |
8332 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8333 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8334 | |
8335 | vty_out(vty, "Tunnel-ip database:\n"); | |
8336 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8337 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8338 | vty); |
8339 | } | |
8340 | ||
15c81ca4 DS |
8341 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8342 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8343 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8344 | "martian next-hops\n" |
8345 | "martian next-hop database\n") | |
acf71666 | 8346 | { |
0291c246 | 8347 | struct bgp *bgp = NULL; |
15c81ca4 | 8348 | int idx = 0; |
9a8bdf1c PG |
8349 | char *name = NULL; |
8350 | ||
8351 | /* [<vrf> VIEWVRFNAME] */ | |
8352 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8353 | name = argv[idx + 1]->arg; | |
8354 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8355 | name = NULL; | |
8356 | } else if (argv_find(argv, argc, "view", &idx)) | |
8357 | /* [<view> VIEWVRFNAME] */ | |
8358 | name = argv[idx + 1]->arg; | |
8359 | if (name) | |
8360 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8361 | else |
8362 | bgp = bgp_get_default(); | |
acf71666 | 8363 | |
acf71666 MK |
8364 | if (!bgp) { |
8365 | vty_out(vty, "%% No BGP process is configured\n"); | |
8366 | return CMD_WARNING; | |
8367 | } | |
8368 | bgp_show_martian_nexthops(vty, bgp); | |
8369 | ||
8370 | return CMD_SUCCESS; | |
8371 | } | |
8372 | ||
f412b39a | 8373 | DEFUN (show_bgp_memory, |
4bf6a362 | 8374 | show_bgp_memory_cmd, |
7fa12b13 | 8375 | "show [ip] bgp memory", |
4bf6a362 | 8376 | SHOW_STR |
3a2d747c | 8377 | IP_STR |
4bf6a362 PJ |
8378 | BGP_STR |
8379 | "Global BGP memory statistics\n") | |
8380 | { | |
d62a17ae | 8381 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8382 | unsigned long count; | |
8383 | ||
8384 | /* RIB related usage stats */ | |
8385 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8386 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8387 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8388 | count * sizeof(struct bgp_node))); | |
8389 | ||
8390 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8391 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8392 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8393 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8394 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8395 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8396 | count, | |
4b7e6066 DS |
8397 | mtype_memstr( |
8398 | memstrbuf, sizeof(memstrbuf), | |
8399 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8400 | |
8401 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8402 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8403 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8404 | count * sizeof(struct bgp_static))); | |
8405 | ||
8406 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8407 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8408 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8409 | count * sizeof(struct bpacket))); | |
8410 | ||
8411 | /* Adj-In/Out */ | |
8412 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8413 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8414 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8415 | count * sizeof(struct bgp_adj_in))); | |
8416 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8417 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8418 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8419 | count * sizeof(struct bgp_adj_out))); | |
8420 | ||
8421 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8422 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8423 | count, | |
8424 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8425 | count * sizeof(struct bgp_nexthop_cache))); | |
8426 | ||
8427 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8428 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8429 | count, | |
8430 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8431 | count * sizeof(struct bgp_damp_info))); | |
8432 | ||
8433 | /* Attributes */ | |
8434 | count = attr_count(); | |
8435 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8436 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8437 | count * sizeof(struct attr))); | |
8438 | ||
8439 | if ((count = attr_unknown_count())) | |
8440 | vty_out(vty, "%ld unknown attributes\n", count); | |
8441 | ||
8442 | /* AS_PATH attributes */ | |
8443 | count = aspath_count(); | |
8444 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8445 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8446 | count * sizeof(struct aspath))); | |
8447 | ||
8448 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8449 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8450 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8451 | count * sizeof(struct assegment))); | |
8452 | ||
8453 | /* Other attributes */ | |
8454 | if ((count = community_count())) | |
8455 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8456 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8457 | count * sizeof(struct community))); | |
d62a17ae | 8458 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8459 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8460 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8461 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8462 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8463 | vty_out(vty, | |
8464 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8465 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8466 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8467 | |
8468 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8469 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8470 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8471 | count * sizeof(struct cluster_list))); | |
8472 | ||
8473 | /* Peer related usage */ | |
8474 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8475 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8476 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8477 | count * sizeof(struct peer))); | |
8478 | ||
8479 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8480 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8481 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8482 | count * sizeof(struct peer_group))); | |
8483 | ||
8484 | /* Other */ | |
d62a17ae | 8485 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8486 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8487 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8488 | count * sizeof(regex_t))); | |
d62a17ae | 8489 | return CMD_SUCCESS; |
4bf6a362 | 8490 | } |
fee0f4c6 | 8491 | |
57a9c8a8 DS |
8492 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8493 | { | |
8494 | json_object *bestpath = json_object_new_object(); | |
8495 | ||
892fedb6 | 8496 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8497 | json_object_string_add(bestpath, "asPath", "ignore"); |
8498 | ||
892fedb6 | 8499 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8500 | json_object_string_add(bestpath, "asPath", "confed"); |
8501 | ||
892fedb6 DA |
8502 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8503 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8504 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8505 | "as-set"); |
8506 | else | |
a4d82a8a | 8507 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8508 | "true"); |
8509 | } else | |
a4d82a8a | 8510 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8511 | |
892fedb6 | 8512 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8513 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8514 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8515 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8516 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8517 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8518 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8519 | json_object_string_add(bestpath, "med", |
8520 | "missing-as-worst"); | |
8521 | else | |
8522 | json_object_string_add(bestpath, "med", "true"); | |
8523 | } | |
8524 | ||
8525 | json_object_object_add(json, "bestPath", bestpath); | |
8526 | } | |
8527 | ||
3577f1c5 DD |
8528 | /* Print the error code/subcode for why the peer is down */ |
8529 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8530 | json_object *json_peer, bool use_json) | |
8531 | { | |
8532 | const char *code_str; | |
8533 | const char *subcode_str; | |
8534 | ||
8535 | if (use_json) { | |
8536 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8537 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8538 | char errorcodesubcode_hexstr[5]; | |
8539 | char errorcodesubcode_str[256]; | |
8540 | ||
8541 | code_str = bgp_notify_code_str(peer->notify.code); | |
8542 | subcode_str = bgp_notify_subcode_str( | |
8543 | peer->notify.code, | |
8544 | peer->notify.subcode); | |
8545 | ||
8546 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
8547 | peer->notify.code, peer->notify.subcode); | |
8548 | json_object_string_add(json_peer, | |
8549 | "lastErrorCodeSubcode", | |
8550 | errorcodesubcode_hexstr); | |
8551 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8552 | code_str, subcode_str); | |
8553 | json_object_string_add(json_peer, | |
8554 | "lastNotificationReason", | |
8555 | errorcodesubcode_str); | |
8556 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8557 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8558 | && (peer->notify.subcode | |
8559 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8560 | || peer->notify.subcode | |
8561 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8562 | && peer->notify.length) { | |
8563 | char msgbuf[1024]; | |
8564 | const char *msg_str; | |
8565 | ||
8566 | msg_str = bgp_notify_admin_message( | |
8567 | msgbuf, sizeof(msgbuf), | |
8568 | (uint8_t *)peer->notify.data, | |
8569 | peer->notify.length); | |
8570 | if (msg_str) | |
8571 | json_object_string_add( | |
8572 | json_peer, | |
8573 | "lastShutdownDescription", | |
8574 | msg_str); | |
8575 | } | |
8576 | ||
c258527b | 8577 | } |
3577f1c5 DD |
8578 | json_object_string_add(json_peer, "lastResetDueTo", |
8579 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8580 | json_object_int_add(json_peer, "lastResetCode", |
8581 | peer->last_reset); | |
3577f1c5 DD |
8582 | } else { |
8583 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8584 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8585 | code_str = bgp_notify_code_str(peer->notify.code); | |
8586 | subcode_str = | |
8587 | bgp_notify_subcode_str(peer->notify.code, | |
8588 | peer->notify.subcode); | |
8589 | vty_out(vty, " Notification %s (%s%s)\n", | |
8590 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8591 | ? "sent" | |
8592 | : "received", | |
8593 | code_str, subcode_str); | |
8594 | } else { | |
e91c24c8 | 8595 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8596 | peer_down_str[(int)peer->last_reset]); |
8597 | } | |
8598 | } | |
8599 | } | |
8600 | ||
8601 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8602 | safi_t safi) | |
8603 | { | |
8604 | return ((peer->status != Established) || | |
8605 | !peer->afc_recv[afi][safi]); | |
8606 | } | |
8607 | ||
8608 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8609 | struct peer *peer, json_object *json_peer, | |
8610 | int max_neighbor_width, bool use_json) | |
8611 | { | |
8612 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8613 | int len; | |
8614 | ||
8615 | if (use_json) { | |
8616 | if (peer_dynamic_neighbor(peer)) | |
8617 | json_object_boolean_true_add(json_peer, | |
8618 | "dynamicPeer"); | |
8619 | if (peer->hostname) | |
8620 | json_object_string_add(json_peer, "hostname", | |
8621 | peer->hostname); | |
8622 | ||
8623 | if (peer->domainname) | |
8624 | json_object_string_add(json_peer, "domainname", | |
8625 | peer->domainname); | |
8626 | json_object_int_add(json_peer, "connectionsEstablished", | |
8627 | peer->established); | |
8628 | json_object_int_add(json_peer, "connectionsDropped", | |
8629 | peer->dropped); | |
8630 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8631 | use_json, json_peer); | |
8632 | if (peer->status == Established) | |
8633 | json_object_string_add(json_peer, "lastResetDueTo", | |
8634 | "AFI/SAFI Not Negotiated"); | |
8635 | else | |
8636 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8637 | } else { | |
8638 | dn_flag[1] = '\0'; | |
8639 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8640 | if (peer->hostname | |
892fedb6 | 8641 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8642 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8643 | peer->hostname, peer->host); | |
8644 | else | |
8645 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8646 | ||
8647 | /* pad the neighbor column with spaces */ | |
8648 | if (len < max_neighbor_width) | |
8649 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8650 | " "); | |
e91c24c8 | 8651 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8652 | peer->dropped, |
8653 | peer_uptime(peer->uptime, timebuf, | |
8654 | BGP_UPTIME_LEN, 0, NULL)); | |
8655 | if (peer->status == Established) | |
8656 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8657 | else | |
8658 | bgp_show_peer_reset(vty, peer, NULL, | |
8659 | false); | |
8660 | } | |
8661 | } | |
c258527b | 8662 | |
3577f1c5 | 8663 | |
718e3744 | 8664 | /* Show BGP peer's summary information. */ |
d62a17ae | 8665 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8666 | bool show_failed, bool use_json) |
d62a17ae | 8667 | { |
8668 | struct peer *peer; | |
8669 | struct listnode *node, *nnode; | |
8670 | unsigned int count = 0, dn_count = 0; | |
8671 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8672 | char neighbor_buf[VTY_BUFSIZ]; | |
8673 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8674 | int len, failed_count = 0; |
d62a17ae | 8675 | int max_neighbor_width = 0; |
8676 | int pfx_rcd_safi; | |
3c13337d | 8677 | json_object *json = NULL; |
d62a17ae | 8678 | json_object *json_peer = NULL; |
8679 | json_object *json_peers = NULL; | |
50e05855 | 8680 | struct peer_af *paf; |
d62a17ae | 8681 | |
8682 | /* labeled-unicast routes are installed in the unicast table so in order | |
8683 | * to | |
8684 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8685 | */ | |
3577f1c5 | 8686 | |
d62a17ae | 8687 | if (safi == SAFI_LABELED_UNICAST) |
8688 | pfx_rcd_safi = SAFI_UNICAST; | |
8689 | else | |
8690 | pfx_rcd_safi = safi; | |
8691 | ||
8692 | if (use_json) { | |
3c13337d | 8693 | json = json_object_new_object(); |
d62a17ae | 8694 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8695 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8696 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8697 | continue; | |
8698 | ||
8699 | if (peer->afc[afi][safi]) { | |
8700 | /* See if we have at least a single failed peer */ | |
8701 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8702 | failed_count++; | |
8703 | count++; | |
8704 | } | |
8705 | if (peer_dynamic_neighbor(peer)) | |
8706 | dn_count++; | |
8707 | } | |
c258527b | 8708 | |
d62a17ae | 8709 | } else { |
8710 | /* Loop over all neighbors that will be displayed to determine | |
8711 | * how many | |
8712 | * characters are needed for the Neighbor column | |
8713 | */ | |
8714 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8715 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8716 | continue; | |
8717 | ||
8718 | if (peer->afc[afi][safi]) { | |
8719 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8720 | if (peer_dynamic_neighbor(peer)) | |
8721 | dn_flag[0] = '*'; | |
8722 | ||
8723 | if (peer->hostname | |
892fedb6 DA |
8724 | && CHECK_FLAG(bgp->flags, |
8725 | BGP_FLAG_SHOW_HOSTNAME)) | |
d62a17ae | 8726 | sprintf(neighbor_buf, "%s%s(%s) ", |
8727 | dn_flag, peer->hostname, | |
8728 | peer->host); | |
8729 | else | |
8730 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8731 | peer->host); | |
8732 | ||
8733 | len = strlen(neighbor_buf); | |
8734 | ||
8735 | if (len > max_neighbor_width) | |
8736 | max_neighbor_width = len; | |
c258527b | 8737 | |
3577f1c5 DD |
8738 | /* See if we have at least a single failed peer */ |
8739 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8740 | failed_count++; | |
8741 | count++; | |
d62a17ae | 8742 | } |
8743 | } | |
f933309e | 8744 | |
d62a17ae | 8745 | /* Originally we displayed the Neighbor column as 16 |
8746 | * characters wide so make that the default | |
8747 | */ | |
8748 | if (max_neighbor_width < neighbor_col_default_width) | |
8749 | max_neighbor_width = neighbor_col_default_width; | |
8750 | } | |
f933309e | 8751 | |
3577f1c5 DD |
8752 | if (show_failed && !failed_count) { |
8753 | if (use_json) { | |
8754 | json_object_int_add(json, "failedPeersCount", 0); | |
8755 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8756 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8757 | |
8758 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8759 | json, JSON_C_TO_STRING_PRETTY)); | |
8760 | json_object_free(json); | |
8761 | } else { | |
8762 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8763 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8764 | } | |
8765 | return CMD_SUCCESS; | |
8766 | } | |
c258527b | 8767 | |
3577f1c5 | 8768 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8769 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8770 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8771 | continue; | |
8772 | ||
ea47320b DL |
8773 | if (!peer->afc[afi][safi]) |
8774 | continue; | |
d62a17ae | 8775 | |
ea47320b DL |
8776 | if (!count) { |
8777 | unsigned long ents; | |
8778 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8779 | int64_t vrf_id_ui; |
d62a17ae | 8780 | |
a4d82a8a PZ |
8781 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8782 | ? -1 | |
8783 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8784 | |
8785 | /* Usage summary and header */ | |
8786 | if (use_json) { | |
8787 | json_object_string_add( | |
8788 | json, "routerId", | |
8789 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8790 | json_object_int_add(json, "as", bgp->as); |
8791 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8792 | json_object_string_add( |
8793 | json, "vrfName", | |
8794 | (bgp->inst_type | |
8795 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8796 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8797 | : bgp->name); |
8798 | } else { | |
8799 | vty_out(vty, | |
8800 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8801 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8802 | bgp->vrf_id == VRF_UNKNOWN |
8803 | ? -1 | |
8804 | : (int)bgp->vrf_id); | |
ea47320b DL |
8805 | vty_out(vty, "\n"); |
8806 | } | |
d62a17ae | 8807 | |
ea47320b | 8808 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8809 | if (use_json) { |
ea47320b | 8810 | json_object_int_add( |
60466a63 | 8811 | json, "updateDelayLimit", |
ea47320b | 8812 | bgp->v_update_delay); |
d62a17ae | 8813 | |
ea47320b DL |
8814 | if (bgp->v_update_delay |
8815 | != bgp->v_establish_wait) | |
d62a17ae | 8816 | json_object_int_add( |
8817 | json, | |
ea47320b DL |
8818 | "updateDelayEstablishWait", |
8819 | bgp->v_establish_wait); | |
d62a17ae | 8820 | |
60466a63 | 8821 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8822 | json_object_string_add( |
8823 | json, | |
8824 | "updateDelayFirstNeighbor", | |
8825 | bgp->update_delay_begin_time); | |
8826 | json_object_boolean_true_add( | |
8827 | json, | |
8828 | "updateDelayInProgress"); | |
8829 | } else { | |
8830 | if (bgp->update_delay_over) { | |
d62a17ae | 8831 | json_object_string_add( |
8832 | json, | |
8833 | "updateDelayFirstNeighbor", | |
8834 | bgp->update_delay_begin_time); | |
ea47320b | 8835 | json_object_string_add( |
d62a17ae | 8836 | json, |
ea47320b DL |
8837 | "updateDelayBestpathResumed", |
8838 | bgp->update_delay_end_time); | |
8839 | json_object_string_add( | |
d62a17ae | 8840 | json, |
ea47320b DL |
8841 | "updateDelayZebraUpdateResume", |
8842 | bgp->update_delay_zebra_resume_time); | |
8843 | json_object_string_add( | |
8844 | json, | |
8845 | "updateDelayPeerUpdateResume", | |
8846 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8847 | } |
ea47320b DL |
8848 | } |
8849 | } else { | |
8850 | vty_out(vty, | |
8851 | "Read-only mode update-delay limit: %d seconds\n", | |
8852 | bgp->v_update_delay); | |
8853 | if (bgp->v_update_delay | |
8854 | != bgp->v_establish_wait) | |
d62a17ae | 8855 | vty_out(vty, |
ea47320b DL |
8856 | " Establish wait: %d seconds\n", |
8857 | bgp->v_establish_wait); | |
d62a17ae | 8858 | |
60466a63 | 8859 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8860 | vty_out(vty, |
8861 | " First neighbor established: %s\n", | |
8862 | bgp->update_delay_begin_time); | |
8863 | vty_out(vty, | |
8864 | " Delay in progress\n"); | |
8865 | } else { | |
8866 | if (bgp->update_delay_over) { | |
d62a17ae | 8867 | vty_out(vty, |
8868 | " First neighbor established: %s\n", | |
8869 | bgp->update_delay_begin_time); | |
8870 | vty_out(vty, | |
ea47320b DL |
8871 | " Best-paths resumed: %s\n", |
8872 | bgp->update_delay_end_time); | |
8873 | vty_out(vty, | |
8874 | " zebra update resumed: %s\n", | |
8875 | bgp->update_delay_zebra_resume_time); | |
8876 | vty_out(vty, | |
8877 | " peers update resumed: %s\n", | |
8878 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8879 | } |
8880 | } | |
8881 | } | |
ea47320b | 8882 | } |
d62a17ae | 8883 | |
ea47320b DL |
8884 | if (use_json) { |
8885 | if (bgp_maxmed_onstartup_configured(bgp) | |
8886 | && bgp->maxmed_active) | |
8887 | json_object_boolean_true_add( | |
60466a63 | 8888 | json, "maxMedOnStartup"); |
ea47320b DL |
8889 | if (bgp->v_maxmed_admin) |
8890 | json_object_boolean_true_add( | |
60466a63 | 8891 | json, "maxMedAdministrative"); |
d62a17ae | 8892 | |
ea47320b DL |
8893 | json_object_int_add( |
8894 | json, "tableVersion", | |
60466a63 | 8895 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8896 | |
60466a63 QY |
8897 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8898 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8899 | json_object_int_add( |
8900 | json, "ribMemory", | |
8901 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8902 | |
210ec2a0 | 8903 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8904 | json_object_int_add(json, "peerCount", ents); |
8905 | json_object_int_add(json, "peerMemory", | |
8906 | ents * sizeof(struct peer)); | |
d62a17ae | 8907 | |
ea47320b DL |
8908 | if ((ents = listcount(bgp->group))) { |
8909 | json_object_int_add( | |
60466a63 | 8910 | json, "peerGroupCount", ents); |
ea47320b DL |
8911 | json_object_int_add( |
8912 | json, "peerGroupMemory", | |
996c9314 LB |
8913 | ents * sizeof(struct |
8914 | peer_group)); | |
ea47320b | 8915 | } |
d62a17ae | 8916 | |
ea47320b DL |
8917 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8918 | BGP_CONFIG_DAMPENING)) | |
8919 | json_object_boolean_true_add( | |
60466a63 | 8920 | json, "dampeningEnabled"); |
ea47320b DL |
8921 | } else { |
8922 | if (bgp_maxmed_onstartup_configured(bgp) | |
8923 | && bgp->maxmed_active) | |
d62a17ae | 8924 | vty_out(vty, |
ea47320b DL |
8925 | "Max-med on-startup active\n"); |
8926 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8927 | vty_out(vty, |
ea47320b | 8928 | "Max-med administrative active\n"); |
d62a17ae | 8929 | |
60466a63 QY |
8930 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8931 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8932 | |
60466a63 | 8933 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8934 | vty_out(vty, |
8935 | "RIB entries %ld, using %s of memory\n", | |
8936 | ents, | |
996c9314 LB |
8937 | mtype_memstr(memstrbuf, |
8938 | sizeof(memstrbuf), | |
8939 | ents * sizeof(struct | |
8940 | bgp_node))); | |
ea47320b DL |
8941 | |
8942 | /* Peer related usage */ | |
210ec2a0 | 8943 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8944 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8945 | ents, |
8946 | mtype_memstr( | |
60466a63 QY |
8947 | memstrbuf, sizeof(memstrbuf), |
8948 | ents * sizeof(struct peer))); | |
ea47320b DL |
8949 | |
8950 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8951 | vty_out(vty, |
ea47320b | 8952 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8953 | ents, |
8954 | mtype_memstr( | |
8955 | memstrbuf, | |
8956 | sizeof(memstrbuf), | |
996c9314 LB |
8957 | ents * sizeof(struct |
8958 | peer_group))); | |
d62a17ae | 8959 | |
ea47320b DL |
8960 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8961 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8962 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8963 | vty_out(vty, "\n"); |
d62a17ae | 8964 | |
ea47320b DL |
8965 | /* Subtract 8 here because 'Neighbor' is |
8966 | * 8 characters */ | |
8967 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8968 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8969 | " "); | |
3577f1c5 DD |
8970 | if (show_failed) |
8971 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8972 | else | |
8973 | vty_out(vty, | |
bed8d78b | 8974 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 8975 | } |
ea47320b | 8976 | } |
d62a17ae | 8977 | |
ea47320b | 8978 | count++; |
3577f1c5 DD |
8979 | /* Works for both failed & successful cases */ |
8980 | if (peer_dynamic_neighbor(peer)) | |
8981 | dn_count++; | |
d62a17ae | 8982 | |
ea47320b | 8983 | if (use_json) { |
3577f1c5 DD |
8984 | json_peer = NULL; |
8985 | ||
8986 | if (show_failed && | |
8987 | bgp_has_peer_failed(peer, afi, safi)) { | |
8988 | json_peer = json_object_new_object(); | |
8989 | bgp_show_failed_summary(vty, bgp, peer, | |
8990 | json_peer, 0, use_json); | |
8991 | } else if (!show_failed) { | |
8992 | json_peer = json_object_new_object(); | |
8993 | if (peer_dynamic_neighbor(peer)) { | |
8994 | json_object_boolean_true_add(json_peer, | |
8995 | "dynamicPeer"); | |
8996 | } | |
d62a17ae | 8997 | |
3577f1c5 DD |
8998 | if (peer->hostname) |
8999 | json_object_string_add(json_peer, "hostname", | |
9000 | peer->hostname); | |
9001 | ||
9002 | if (peer->domainname) | |
9003 | json_object_string_add(json_peer, "domainname", | |
9004 | peer->domainname); | |
9005 | ||
9006 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9007 | json_object_int_add(json_peer, "version", 4); | |
9008 | json_object_int_add(json_peer, "msgRcvd", | |
9009 | PEER_TOTAL_RX(peer)); | |
9010 | json_object_int_add(json_peer, "msgSent", | |
9011 | PEER_TOTAL_TX(peer)); | |
9012 | ||
9013 | json_object_int_add(json_peer, "tableVersion", | |
9014 | peer->version[afi][safi]); | |
9015 | json_object_int_add(json_peer, "outq", | |
9016 | peer->obuf->count); | |
9017 | json_object_int_add(json_peer, "inq", 0); | |
9018 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9019 | use_json, json_peer); | |
9020 | ||
9021 | /* | |
9022 | * Adding "pfxRcd" field to match with the corresponding | |
9023 | * CLI. "prefixReceivedCount" will be deprecated in | |
9024 | * future. | |
9025 | */ | |
9026 | json_object_int_add(json_peer, "prefixReceivedCount", | |
9027 | peer->pcount[afi][pfx_rcd_safi]); | |
9028 | json_object_int_add(json_peer, "pfxRcd", | |
9029 | peer->pcount[afi][pfx_rcd_safi]); | |
9030 | ||
9031 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
9032 | if (paf && PAF_SUBGRP(paf)) | |
9033 | json_object_int_add(json_peer, | |
9034 | "pfxSnt", | |
9035 | (PAF_SUBGRP(paf))->scount); | |
9036 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9037 | json_object_string_add(json_peer, "state", | |
9038 | "Idle (Admin)"); | |
9039 | else if (peer->afc_recv[afi][safi]) | |
9040 | json_object_string_add( | |
9041 | json_peer, "state", | |
9042 | lookup_msg(bgp_status_msg, peer->status, | |
9043 | NULL)); | |
9044 | else if (CHECK_FLAG(peer->sflags, | |
9045 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9046 | json_object_string_add(json_peer, "state", | |
9047 | "Idle (PfxCt)"); | |
9048 | else | |
9049 | json_object_string_add( | |
9050 | json_peer, "state", | |
9051 | lookup_msg(bgp_status_msg, peer->status, | |
9052 | NULL)); | |
200116db DD |
9053 | json_object_int_add(json_peer, "connectionsEstablished", |
9054 | peer->established); | |
9055 | json_object_int_add(json_peer, "connectionsDropped", | |
9056 | peer->dropped); | |
b4e9dcba | 9057 | } |
3577f1c5 DD |
9058 | /* Avoid creating empty peer dicts in JSON */ |
9059 | if (json_peer == NULL) | |
9060 | continue; | |
ea47320b DL |
9061 | |
9062 | if (peer->conf_if) | |
60466a63 | 9063 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9064 | "interface"); |
9065 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9066 | json_object_string_add(json_peer, "idType", |
9067 | "ipv4"); | |
ea47320b | 9068 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9069 | json_object_string_add(json_peer, "idType", |
9070 | "ipv6"); | |
ea47320b DL |
9071 | json_object_object_add(json_peers, peer->host, |
9072 | json_peer); | |
9073 | } else { | |
3577f1c5 DD |
9074 | if (show_failed && |
9075 | bgp_has_peer_failed(peer, afi, safi)) { | |
9076 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9077 | max_neighbor_width, | |
9078 | use_json); | |
9079 | } else if (!show_failed) { | |
9080 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9081 | if (peer_dynamic_neighbor(peer)) { | |
9082 | dn_flag[0] = '*'; | |
9083 | } | |
d62a17ae | 9084 | |
3577f1c5 | 9085 | if (peer->hostname |
892fedb6 DA |
9086 | && CHECK_FLAG(bgp->flags, |
9087 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9088 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9089 | peer->hostname, |
9090 | peer->host); | |
d62a17ae | 9091 | else |
3577f1c5 DD |
9092 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9093 | ||
9094 | /* pad the neighbor column with spaces */ | |
9095 | if (len < max_neighbor_width) | |
9096 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9097 | " "); | |
9098 | ||
bed8d78b | 9099 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 " %4d %4zd %8s", |
3577f1c5 DD |
9100 | peer->as, PEER_TOTAL_RX(peer), |
9101 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
9102 | 0, peer->obuf->count, | |
9103 | peer_uptime(peer->uptime, timebuf, | |
9104 | BGP_UPTIME_LEN, 0, NULL)); | |
9105 | ||
9106 | if (peer->status == Established) | |
9107 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
9108 | vty_out(vty, " %12" PRIu32, |
9109 | peer->pcount | |
9110 | [afi] | |
9111 | [pfx_rcd_safi]); | |
3577f1c5 DD |
9112 | else |
9113 | vty_out(vty, " NoNeg"); | |
9114 | else { | |
9115 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9116 | vty_out(vty, " Idle (Admin)"); | |
9117 | else if (CHECK_FLAG( | |
9118 | peer->sflags, | |
9119 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9120 | vty_out(vty, " Idle (PfxCt)"); | |
9121 | else | |
9122 | vty_out(vty, " %12s", | |
9123 | lookup_msg(bgp_status_msg, | |
9124 | peer->status, NULL)); | |
9125 | } | |
9126 | vty_out(vty, "\n"); | |
d62a17ae | 9127 | } |
3577f1c5 | 9128 | |
d62a17ae | 9129 | } |
9130 | } | |
f933309e | 9131 | |
d62a17ae | 9132 | if (use_json) { |
9133 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9134 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9135 | json_object_int_add(json, "totalPeers", count); |
9136 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9137 | ||
3577f1c5 DD |
9138 | if (!show_failed) |
9139 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9140 | |
996c9314 LB |
9141 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9142 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9143 | json_object_free(json); |
9144 | } else { | |
9145 | if (count) | |
9146 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9147 | else { | |
d6ceaca3 | 9148 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9149 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9150 | } |
b05a1c8b | 9151 | |
d6ceaca3 | 9152 | if (dn_count) { |
d62a17ae | 9153 | vty_out(vty, "* - dynamic neighbor\n"); |
9154 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9155 | dn_count, bgp->dynamic_neighbors_limit); | |
9156 | } | |
9157 | } | |
1ff9a340 | 9158 | |
d62a17ae | 9159 | return CMD_SUCCESS; |
718e3744 | 9160 | } |
9161 | ||
d62a17ae | 9162 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9163 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9164 | { |
9165 | int is_first = 1; | |
9166 | int afi_wildcard = (afi == AFI_MAX); | |
9167 | int safi_wildcard = (safi == SAFI_MAX); | |
9168 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9169 | bool nbr_output = false; |
d62a17ae | 9170 | |
9171 | if (use_json && is_wildcard) | |
9172 | vty_out(vty, "{\n"); | |
9173 | if (afi_wildcard) | |
9174 | afi = 1; /* AFI_IP */ | |
9175 | while (afi < AFI_MAX) { | |
9176 | if (safi_wildcard) | |
9177 | safi = 1; /* SAFI_UNICAST */ | |
9178 | while (safi < SAFI_MAX) { | |
318cac96 | 9179 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9180 | nbr_output = true; |
f86897b9 | 9181 | |
d62a17ae | 9182 | if (is_wildcard) { |
9183 | /* | |
9184 | * So limit output to those afi/safi | |
9185 | * pairs that | |
9186 | * actualy have something interesting in | |
9187 | * them | |
9188 | */ | |
9189 | if (use_json) { | |
d62a17ae | 9190 | if (!is_first) |
9191 | vty_out(vty, ",\n"); | |
9192 | else | |
9193 | is_first = 0; | |
9194 | ||
9195 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9196 | get_afi_safi_str(afi, |
9197 | safi, | |
9198 | true)); | |
d62a17ae | 9199 | } else { |
9200 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9201 | get_afi_safi_str(afi, |
9202 | safi, | |
9203 | false)); | |
d62a17ae | 9204 | } |
9205 | } | |
3577f1c5 DD |
9206 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9207 | use_json); | |
d62a17ae | 9208 | } |
9209 | safi++; | |
d62a17ae | 9210 | if (!safi_wildcard) |
9211 | safi = SAFI_MAX; | |
9212 | } | |
9213 | afi++; | |
ee851c8c | 9214 | if (!afi_wildcard) |
d62a17ae | 9215 | afi = AFI_MAX; |
9216 | } | |
9217 | ||
9218 | if (use_json && is_wildcard) | |
9219 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9220 | else if (!nbr_output) { |
9221 | if (use_json) | |
9222 | vty_out(vty, "{}\n"); | |
9223 | else | |
9224 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9225 | } | |
d62a17ae | 9226 | } |
9227 | ||
9228 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9229 | safi_t safi, bool show_failed, |
9230 | bool use_json) | |
d62a17ae | 9231 | { |
9232 | struct listnode *node, *nnode; | |
9233 | struct bgp *bgp; | |
d62a17ae | 9234 | int is_first = 1; |
9f049418 | 9235 | bool nbr_output = false; |
d62a17ae | 9236 | |
9237 | if (use_json) | |
9238 | vty_out(vty, "{\n"); | |
9239 | ||
9240 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9241 | nbr_output = true; |
d62a17ae | 9242 | if (use_json) { |
d62a17ae | 9243 | if (!is_first) |
9244 | vty_out(vty, ",\n"); | |
9245 | else | |
9246 | is_first = 0; | |
9247 | ||
9248 | vty_out(vty, "\"%s\":", | |
9249 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9250 | ? VRF_DEFAULT_NAME |
d62a17ae | 9251 | : bgp->name); |
9252 | } else { | |
9253 | vty_out(vty, "\nInstance %s:\n", | |
9254 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9255 | ? VRF_DEFAULT_NAME |
d62a17ae | 9256 | : bgp->name); |
9257 | } | |
3577f1c5 DD |
9258 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9259 | use_json); | |
d62a17ae | 9260 | } |
9261 | ||
9262 | if (use_json) | |
9263 | vty_out(vty, "}\n"); | |
9f049418 DS |
9264 | else if (!nbr_output) |
9265 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9266 | } |
9267 | ||
9268 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9269 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9270 | { |
9271 | struct bgp *bgp; | |
9272 | ||
9273 | if (name) { | |
9274 | if (strmatch(name, "all")) { | |
9275 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9276 | show_failed, |
d62a17ae | 9277 | use_json); |
9278 | return CMD_SUCCESS; | |
9279 | } else { | |
9280 | bgp = bgp_lookup_by_name(name); | |
9281 | ||
9282 | if (!bgp) { | |
9283 | if (use_json) | |
9284 | vty_out(vty, "{}\n"); | |
9285 | else | |
9286 | vty_out(vty, | |
ca61fd25 | 9287 | "%% BGP instance not found\n"); |
d62a17ae | 9288 | return CMD_WARNING; |
9289 | } | |
9290 | ||
f86897b9 | 9291 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9292 | show_failed, use_json); |
d62a17ae | 9293 | return CMD_SUCCESS; |
9294 | } | |
9295 | } | |
9296 | ||
9297 | bgp = bgp_get_default(); | |
9298 | ||
9299 | if (bgp) | |
3577f1c5 DD |
9300 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9301 | use_json); | |
9f049418 | 9302 | else { |
ca61fd25 DS |
9303 | if (use_json) |
9304 | vty_out(vty, "{}\n"); | |
9305 | else | |
9306 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9307 | return CMD_WARNING; |
9308 | } | |
d62a17ae | 9309 | |
9310 | return CMD_SUCCESS; | |
4fb25c53 DW |
9311 | } |
9312 | ||
716b2d8a | 9313 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9314 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9315 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9316 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9317 | SHOW_STR |
9318 | IP_STR | |
9319 | BGP_STR | |
8386ac43 | 9320 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9321 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9322 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9323 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9324 | "Show only sessions not in Established state\n" |
9973d184 | 9325 | JSON_STR) |
718e3744 | 9326 | { |
d62a17ae | 9327 | char *vrf = NULL; |
9328 | afi_t afi = AFI_MAX; | |
9329 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9330 | bool show_failed = false; |
d62a17ae | 9331 | |
9332 | int idx = 0; | |
9333 | ||
9334 | /* show [ip] bgp */ | |
9335 | if (argv_find(argv, argc, "ip", &idx)) | |
9336 | afi = AFI_IP; | |
9a8bdf1c PG |
9337 | /* [<vrf> VIEWVRFNAME] */ |
9338 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9339 | vrf = argv[idx + 1]->arg; | |
9340 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9341 | vrf = NULL; | |
9342 | } else if (argv_find(argv, argc, "view", &idx)) | |
9343 | /* [<view> VIEWVRFNAME] */ | |
9344 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9345 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9346 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9347 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9348 | } | |
9349 | ||
3577f1c5 DD |
9350 | if (argv_find(argv, argc, "failed", &idx)) |
9351 | show_failed = true; | |
9352 | ||
9f049418 | 9353 | bool uj = use_json(argc, argv); |
d62a17ae | 9354 | |
3577f1c5 | 9355 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9356 | } |
9357 | ||
5cb5f4d0 | 9358 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9359 | { |
5cb5f4d0 DD |
9360 | if (for_json) |
9361 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9362 | else |
5cb5f4d0 | 9363 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9364 | } |
9365 | ||
d62a17ae | 9366 | |
9367 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9368 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9369 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9370 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9371 | bool use_json, json_object *json_pref) |
d62a17ae | 9372 | { |
9373 | /* Send-Mode */ | |
9374 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9375 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9376 | if (use_json) { | |
9377 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9378 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9379 | json_object_string_add(json_pref, "sendMode", | |
9380 | "advertisedAndReceived"); | |
9381 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9382 | json_object_string_add(json_pref, "sendMode", | |
9383 | "advertised"); | |
9384 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9385 | json_object_string_add(json_pref, "sendMode", | |
9386 | "received"); | |
9387 | } else { | |
9388 | vty_out(vty, " Send-mode: "); | |
9389 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9390 | vty_out(vty, "advertised"); | |
9391 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9392 | vty_out(vty, "%sreceived", | |
9393 | CHECK_FLAG(p->af_cap[afi][safi], | |
9394 | adv_smcap) | |
9395 | ? ", " | |
9396 | : ""); | |
9397 | vty_out(vty, "\n"); | |
9398 | } | |
9399 | } | |
9400 | ||
9401 | /* Receive-Mode */ | |
9402 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9403 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9404 | if (use_json) { | |
9405 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9406 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9407 | json_object_string_add(json_pref, "recvMode", | |
9408 | "advertisedAndReceived"); | |
9409 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9410 | json_object_string_add(json_pref, "recvMode", | |
9411 | "advertised"); | |
9412 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9413 | json_object_string_add(json_pref, "recvMode", | |
9414 | "received"); | |
9415 | } else { | |
9416 | vty_out(vty, " Receive-mode: "); | |
9417 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9418 | vty_out(vty, "advertised"); | |
9419 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9420 | vty_out(vty, "%sreceived", | |
9421 | CHECK_FLAG(p->af_cap[afi][safi], | |
9422 | adv_rmcap) | |
9423 | ? ", " | |
9424 | : ""); | |
9425 | vty_out(vty, "\n"); | |
9426 | } | |
9427 | } | |
9428 | } | |
9429 | ||
13909c4f DS |
9430 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9431 | struct peer *p, | |
9432 | bool use_json, | |
9433 | json_object *json) | |
2986cac2 | 9434 | { |
08c2d52a | 9435 | bool rbit_status = false; |
2986cac2 | 9436 | |
9437 | if (!use_json) | |
a53ca37b | 9438 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9439 | |
13909c4f DS |
9440 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9441 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9442 | && (p->status == Established)) { | |
2986cac2 | 9443 | |
9444 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9445 | rbit_status = true; |
2986cac2 | 9446 | else |
08c2d52a | 9447 | rbit_status = false; |
2986cac2 | 9448 | } |
9449 | ||
9450 | if (rbit_status) { | |
9451 | if (use_json) | |
13909c4f | 9452 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9453 | else |
9454 | vty_out(vty, "True\n"); | |
9455 | } else { | |
9456 | if (use_json) | |
13909c4f | 9457 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9458 | else |
9459 | vty_out(vty, "False\n"); | |
9460 | } | |
9461 | } | |
9462 | ||
13909c4f DS |
9463 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9464 | struct peer *peer, | |
9465 | bool use_json, | |
9466 | json_object *json) | |
2986cac2 | 9467 | { |
2bb5d39b | 9468 | const char *mode = "NotApplicable"; |
2986cac2 | 9469 | |
9470 | if (!use_json) | |
a53ca37b | 9471 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9472 | |
13909c4f DS |
9473 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9474 | && (peer->status == Established)) { | |
2986cac2 | 9475 | |
13909c4f DS |
9476 | if ((peer->nsf_af_count == 0) |
9477 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9478 | |
2986cac2 | 9479 | mode = "Disable"; |
9480 | ||
13909c4f DS |
9481 | } else if (peer->nsf_af_count == 0 |
9482 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9483 | |
2986cac2 | 9484 | mode = "Helper"; |
9485 | ||
13909c4f DS |
9486 | } else if (peer->nsf_af_count != 0 |
9487 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9488 | |
2986cac2 | 9489 | mode = "Restart"; |
2986cac2 | 9490 | } |
9491 | } | |
9492 | ||
9493 | if (use_json) { | |
13909c4f | 9494 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9495 | } else |
9496 | vty_out(vty, mode, "\n"); | |
9497 | } | |
9498 | ||
13909c4f DS |
9499 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9500 | struct peer *p, | |
9501 | bool use_json, | |
9502 | json_object *json) | |
2986cac2 | 9503 | { |
9504 | const char *mode = "Invalid"; | |
9505 | ||
9506 | if (!use_json) | |
a53ca37b | 9507 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9508 | |
9509 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9510 | mode = "Helper"; | |
9511 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9512 | mode = "Restart"; | |
9513 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9514 | mode = "Disable"; | |
2ba1fe69 | 9515 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9516 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9517 | mode = "Helper*"; | |
9518 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9519 | mode = "Restart*"; | |
9520 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9521 | mode = "Disable*"; | |
9522 | else | |
9523 | mode = "Invalid*"; | |
2ba1fe69 | 9524 | } |
2986cac2 | 9525 | |
9526 | if (use_json) { | |
13909c4f | 9527 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9528 | } else { |
9529 | vty_out(vty, mode, "\n"); | |
9530 | } | |
9531 | } | |
9532 | ||
13909c4f DS |
9533 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9534 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9535 | { |
2ba1fe69 | 9536 | afi_t afi; |
9537 | safi_t safi; | |
2986cac2 | 9538 | json_object *json_afi_safi = NULL; |
9539 | json_object *json_timer = NULL; | |
9540 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9541 | bool eor_flag = false; |
2986cac2 | 9542 | |
9543 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9544 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9545 | if (!peer->afc[afi][safi]) |
9546 | continue; | |
2986cac2 | 9547 | |
13909c4f DS |
9548 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9549 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9550 | continue; | |
9e3b51a7 | 9551 | |
13909c4f DS |
9552 | if (use_json) { |
9553 | json_afi_safi = json_object_new_object(); | |
9554 | json_endofrib_status = json_object_new_object(); | |
9555 | json_timer = json_object_new_object(); | |
9556 | } | |
2986cac2 | 9557 | |
13909c4f DS |
9558 | if (peer->eor_stime[afi][safi] |
9559 | >= peer->pkt_stime[afi][safi]) | |
9560 | eor_flag = true; | |
9561 | else | |
9562 | eor_flag = false; | |
2986cac2 | 9563 | |
13909c4f | 9564 | if (!use_json) { |
a53ca37b | 9565 | vty_out(vty, " %s:\n", |
13909c4f | 9566 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9567 | |
a53ca37b | 9568 | vty_out(vty, " F bit: "); |
698ba8d0 | 9569 | } |
2986cac2 | 9570 | |
13909c4f DS |
9571 | if (peer->nsf[afi][safi] |
9572 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9573 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9574 | |
13909c4f DS |
9575 | if (use_json) { |
9576 | json_object_boolean_true_add( | |
2986cac2 | 9577 | json_afi_safi, "fBit"); |
13909c4f DS |
9578 | } else |
9579 | vty_out(vty, "True\n"); | |
9580 | } else { | |
9581 | if (use_json) | |
9582 | json_object_boolean_false_add( | |
9583 | json_afi_safi, "fBit"); | |
9584 | else | |
9585 | vty_out(vty, "False\n"); | |
9586 | } | |
2986cac2 | 9587 | |
13909c4f | 9588 | if (!use_json) |
a53ca37b | 9589 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9590 | |
13909c4f DS |
9591 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9592 | PEER_STATUS_EOR_SEND)) { | |
9593 | if (use_json) { | |
9594 | json_object_boolean_true_add( | |
2986cac2 | 9595 | json_endofrib_status, |
13909c4f | 9596 | "endOfRibSend"); |
9e3b51a7 | 9597 | |
13909c4f DS |
9598 | PRINT_EOR_JSON(eor_flag); |
9599 | } else { | |
9600 | vty_out(vty, "Yes\n"); | |
9601 | vty_out(vty, | |
a53ca37b | 9602 | " End-of-RIB sent after update: "); |
2986cac2 | 9603 | |
13909c4f DS |
9604 | PRINT_EOR(eor_flag); |
9605 | } | |
9606 | } else { | |
9607 | if (use_json) { | |
9608 | json_object_boolean_false_add( | |
2986cac2 | 9609 | json_endofrib_status, |
13909c4f DS |
9610 | "endOfRibSend"); |
9611 | json_object_boolean_false_add( | |
9e3b51a7 | 9612 | json_endofrib_status, |
13909c4f DS |
9613 | "endOfRibSentAfterUpdate"); |
9614 | } else { | |
9615 | vty_out(vty, "No\n"); | |
9616 | vty_out(vty, | |
a53ca37b | 9617 | " End-of-RIB sent after update: "); |
13909c4f | 9618 | vty_out(vty, "No\n"); |
2986cac2 | 9619 | } |
13909c4f | 9620 | } |
2986cac2 | 9621 | |
a53ca37b DA |
9622 | if (!use_json) |
9623 | vty_out(vty, " End-of-RIB received: "); | |
9624 | ||
9625 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9626 | PEER_STATUS_EOR_RECEIVED)) { | |
9627 | if (use_json) | |
9628 | json_object_boolean_true_add( | |
9629 | json_endofrib_status, | |
9630 | "endOfRibRecv"); | |
9631 | else | |
9632 | vty_out(vty, "Yes\n"); | |
9633 | } else { | |
9634 | if (use_json) | |
9635 | json_object_boolean_false_add( | |
9636 | json_endofrib_status, | |
9637 | "endOfRibRecv"); | |
9638 | else | |
9639 | vty_out(vty, "No\n"); | |
9640 | } | |
9641 | ||
13909c4f DS |
9642 | if (use_json) { |
9643 | json_object_int_add(json_timer, | |
9644 | "stalePathTimer", | |
9645 | peer->bgp->stalepath_time); | |
2986cac2 | 9646 | |
13909c4f DS |
9647 | if (peer->t_gr_stale != NULL) { |
9648 | json_object_int_add( | |
2986cac2 | 9649 | json_timer, |
9650 | "stalePathTimerRemaining", | |
9651 | thread_timer_remain_second( | |
13909c4f DS |
9652 | peer->t_gr_stale)); |
9653 | } | |
3a75afa4 | 9654 | |
13909c4f DS |
9655 | /* Display Configured Selection |
9656 | * Deferral only when when | |
9657 | * Gr mode is enabled. | |
9658 | */ | |
9659 | if (CHECK_FLAG(peer->flags, | |
9660 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9661 | json_object_int_add( | |
3a75afa4 | 9662 | json_timer, |
2986cac2 | 9663 | "selectionDeferralTimer", |
9664 | peer->bgp->stalepath_time); | |
13909c4f | 9665 | } |
2986cac2 | 9666 | |
13909c4f DS |
9667 | if (peer->bgp->gr_info[afi][safi] |
9668 | .t_select_deferral | |
9669 | != NULL) { | |
2986cac2 | 9670 | |
13909c4f | 9671 | json_object_int_add( |
2986cac2 | 9672 | json_timer, |
9673 | "selectionDeferralTimerRemaining", | |
9674 | thread_timer_remain_second( | |
13909c4f DS |
9675 | peer->bgp |
9676 | ->gr_info[afi] | |
9677 | [safi] | |
9678 | .t_select_deferral)); | |
9679 | } | |
9680 | } else { | |
a53ca37b | 9681 | vty_out(vty, " Timers:\n"); |
13909c4f | 9682 | vty_out(vty, |
a53ca37b DA |
9683 | " Configured Stale Path Time(sec): %u\n", |
9684 | peer->bgp->stalepath_time); | |
2986cac2 | 9685 | |
a53ca37b | 9686 | if (peer->t_gr_stale != NULL) |
2986cac2 | 9687 | vty_out(vty, |
a53ca37b | 9688 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 9689 | thread_timer_remain_second( |
13909c4f | 9690 | peer->t_gr_stale)); |
13909c4f DS |
9691 | /* Display Configured Selection |
9692 | * Deferral only when when | |
9693 | * Gr mode is enabled. | |
9694 | */ | |
9695 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 9696 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 9697 | vty_out(vty, |
a53ca37b | 9698 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 9699 | peer->bgp->select_defer_time); |
2986cac2 | 9700 | |
13909c4f DS |
9701 | if (peer->bgp->gr_info[afi][safi] |
9702 | .t_select_deferral | |
a53ca37b | 9703 | != NULL) |
13909c4f | 9704 | vty_out(vty, |
a53ca37b | 9705 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 9706 | thread_timer_remain_second( |
13909c4f DS |
9707 | peer->bgp |
9708 | ->gr_info[afi] | |
9709 | [safi] | |
9710 | .t_select_deferral)); | |
2986cac2 | 9711 | } |
13909c4f DS |
9712 | if (use_json) { |
9713 | json_object_object_add(json_afi_safi, | |
9714 | "endOfRibStatus", | |
9715 | json_endofrib_status); | |
9716 | json_object_object_add(json_afi_safi, "timers", | |
9717 | json_timer); | |
9718 | json_object_object_add( | |
9719 | json, get_afi_safi_str(afi, safi, true), | |
9720 | json_afi_safi); | |
9721 | } | |
2986cac2 | 9722 | } |
9723 | } | |
9724 | } | |
9725 | ||
36235319 QY |
9726 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
9727 | struct peer *p, | |
9728 | bool use_json, | |
9729 | json_object *json) | |
2986cac2 | 9730 | { |
9731 | if (use_json) { | |
9732 | json_object *json_timer = NULL; | |
9733 | ||
9734 | json_timer = json_object_new_object(); | |
9735 | ||
13909c4f DS |
9736 | json_object_int_add(json_timer, "configuredRestartTimer", |
9737 | p->bgp->restart_time); | |
2986cac2 | 9738 | |
13909c4f DS |
9739 | json_object_int_add(json_timer, "receivedRestartTimer", |
9740 | p->v_gr_restart); | |
2986cac2 | 9741 | |
13909c4f DS |
9742 | if (p->t_gr_restart != NULL) |
9743 | json_object_int_add( | |
9744 | json_timer, "restartTimerRemaining", | |
9745 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 9746 | |
9747 | json_object_object_add(json, "timers", json_timer); | |
9748 | } else { | |
9749 | ||
a53ca37b DA |
9750 | vty_out(vty, " Timers:\n"); |
9751 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 9752 | p->bgp->restart_time); |
2986cac2 | 9753 | |
a53ca37b | 9754 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
9755 | p->v_gr_restart); |
9756 | if (p->t_gr_restart != NULL) | |
a53ca37b | 9757 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 9758 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 9759 | if (p->t_gr_restart != NULL) { |
a53ca37b | 9760 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
9761 | thread_timer_remain_second(p->t_gr_restart)); |
9762 | } | |
2986cac2 | 9763 | } |
9764 | } | |
9765 | ||
9766 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 9767 | bool use_json, json_object *json) |
2986cac2 | 9768 | { |
9769 | char buf[SU_ADDRSTRLEN] = {0}; | |
9770 | char dn_flag[2] = {0}; | |
9771 | char neighborAddr[INET6_ADDRSTRLEN] = {0}; | |
9772 | ||
2986cac2 | 9773 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
9774 | dn_flag[0] = '*'; | |
9775 | ||
9776 | if (p->conf_if) { | |
9777 | if (use_json) | |
13909c4f DS |
9778 | json_object_string_add( |
9779 | json, "neighborAddr", | |
2986cac2 | 9780 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
9781 | ? "none" |
9782 | : sockunion2str(&p->su, buf, | |
9783 | SU_ADDRSTRLEN)); | |
2986cac2 | 9784 | else |
13909c4f | 9785 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 9786 | BGP_PEER_SU_UNSPEC(p) |
9787 | ? "none" | |
9788 | : sockunion2str(&p->su, buf, | |
9789 | SU_ADDRSTRLEN)); | |
9790 | } else { | |
9791 | sprintf(neighborAddr, "%s%s", dn_flag, p->host); | |
9792 | ||
9793 | if (use_json) | |
36235319 QY |
9794 | json_object_string_add(json, "neighborAddr", |
9795 | neighborAddr); | |
2986cac2 | 9796 | else |
36235319 | 9797 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 9798 | } |
9799 | ||
9800 | /* more gr info in new format */ | |
9801 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9802 | } | |
9803 | ||
d62a17ae | 9804 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9805 | safi_t safi, bool use_json, |
d62a17ae | 9806 | json_object *json_neigh) |
9807 | { | |
0291c246 MK |
9808 | struct bgp_filter *filter; |
9809 | struct peer_af *paf; | |
9810 | char orf_pfx_name[BUFSIZ]; | |
9811 | int orf_pfx_count; | |
9812 | json_object *json_af = NULL; | |
9813 | json_object *json_prefA = NULL; | |
9814 | json_object *json_prefB = NULL; | |
9815 | json_object *json_addr = NULL; | |
d62a17ae | 9816 | |
9817 | if (use_json) { | |
9818 | json_addr = json_object_new_object(); | |
9819 | json_af = json_object_new_object(); | |
9820 | filter = &p->filter[afi][safi]; | |
9821 | ||
9822 | if (peer_group_active(p)) | |
9823 | json_object_string_add(json_addr, "peerGroupMember", | |
9824 | p->group->name); | |
9825 | ||
9826 | paf = peer_af_find(p, afi, safi); | |
9827 | if (paf && PAF_SUBGRP(paf)) { | |
9828 | json_object_int_add(json_addr, "updateGroupId", | |
9829 | PAF_UPDGRP(paf)->id); | |
9830 | json_object_int_add(json_addr, "subGroupId", | |
9831 | PAF_SUBGRP(paf)->id); | |
9832 | json_object_int_add(json_addr, "packetQueueLength", | |
9833 | bpacket_queue_virtual_length(paf)); | |
9834 | } | |
9835 | ||
9836 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9837 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9838 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9839 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9840 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9841 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9842 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9843 | json_object_int_add(json_af, "orfType", | |
9844 | ORF_TYPE_PREFIX); | |
9845 | json_prefA = json_object_new_object(); | |
9846 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
9847 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
9848 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9849 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9850 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
9851 | use_json, json_prefA); | |
9852 | json_object_object_add(json_af, "orfPrefixList", | |
9853 | json_prefA); | |
9854 | } | |
9855 | ||
9856 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9857 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9858 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9859 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9860 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9861 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9862 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9863 | json_object_int_add(json_af, "orfOldType", | |
9864 | ORF_TYPE_PREFIX_OLD); | |
9865 | json_prefB = json_object_new_object(); | |
9866 | bgp_show_peer_afi_orf_cap( | |
9867 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9868 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9869 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9870 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9871 | json_prefB); | |
9872 | json_object_object_add(json_af, "orfOldPrefixList", | |
9873 | json_prefB); | |
9874 | } | |
9875 | ||
9876 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9877 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9878 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9879 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9880 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9881 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9882 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9883 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9884 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9885 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9886 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9887 | json_object_object_add(json_addr, "afDependentCap", | |
9888 | json_af); | |
9889 | else | |
9890 | json_object_free(json_af); | |
9891 | ||
9892 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9893 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9894 | NULL, afi, orf_pfx_name, use_json); | |
9895 | ||
9896 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9897 | PEER_STATUS_ORF_PREFIX_SEND) | |
9898 | || orf_pfx_count) { | |
9899 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9900 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9901 | json_object_boolean_true_add(json_neigh, | |
9902 | "orfSent"); | |
9903 | if (orf_pfx_count) | |
9904 | json_object_int_add(json_addr, "orfRecvCounter", | |
9905 | orf_pfx_count); | |
9906 | } | |
9907 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9908 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9909 | json_object_string_add( | |
9910 | json_addr, "orfFirstUpdate", | |
9911 | "deferredUntilORFOrRouteRefreshRecvd"); | |
9912 | ||
9913 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9914 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9915 | json_object_boolean_true_add(json_addr, | |
9916 | "routeReflectorClient"); | |
9917 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9918 | PEER_FLAG_RSERVER_CLIENT)) | |
9919 | json_object_boolean_true_add(json_addr, | |
9920 | "routeServerClient"); | |
9921 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9922 | json_object_boolean_true_add(json_addr, | |
9923 | "inboundSoftConfigPermit"); | |
9924 | ||
9925 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9926 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9927 | json_object_boolean_true_add( | |
9928 | json_addr, | |
9929 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
9930 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9931 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9932 | json_object_boolean_true_add( | |
9933 | json_addr, | |
9934 | "privateAsNumsReplacedInUpdatesToNbr"); | |
9935 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9936 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9937 | json_object_boolean_true_add( | |
9938 | json_addr, | |
9939 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
9940 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9941 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9942 | json_object_boolean_true_add( | |
9943 | json_addr, | |
9944 | "privateAsNumsRemovedInUpdatesToNbr"); | |
9945 | ||
dcc68b5e MS |
9946 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9947 | json_object_boolean_true_add( | |
9948 | json_addr, | |
9949 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9950 | ->type_json_name); | |
d62a17ae | 9951 | |
9952 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9953 | json_object_string_add(json_addr, | |
9954 | "overrideASNsInOutboundUpdates", | |
9955 | "ifAspathEqualRemoteAs"); | |
9956 | ||
9957 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9958 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9959 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9960 | json_object_boolean_true_add(json_addr, | |
9961 | "routerAlwaysNextHop"); | |
9962 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9963 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9964 | json_object_boolean_true_add( | |
9965 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
9966 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9967 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9968 | json_object_boolean_true_add( | |
9969 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
9970 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9971 | json_object_boolean_true_add( | |
9972 | json_addr, "unchangedMedPropogatedToNbr"); | |
9973 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9974 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9975 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
9976 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9977 | PEER_FLAG_SEND_COMMUNITY) | |
9978 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9979 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9980 | json_object_string_add(json_addr, | |
9981 | "commAttriSentToNbr", | |
9982 | "extendedAndStandard"); | |
9983 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9984 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9985 | json_object_string_add(json_addr, | |
9986 | "commAttriSentToNbr", | |
9987 | "extended"); | |
9988 | else | |
9989 | json_object_string_add(json_addr, | |
9990 | "commAttriSentToNbr", | |
9991 | "standard"); | |
9992 | } | |
9993 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9994 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9995 | if (p->default_rmap[afi][safi].name) | |
9996 | json_object_string_add( | |
9997 | json_addr, "defaultRouteMap", | |
9998 | p->default_rmap[afi][safi].name); | |
9999 | ||
10000 | if (paf && PAF_SUBGRP(paf) | |
10001 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10002 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10003 | json_object_boolean_true_add(json_addr, | |
10004 | "defaultSent"); | |
10005 | else | |
10006 | json_object_boolean_true_add(json_addr, | |
10007 | "defaultNotSent"); | |
10008 | } | |
10009 | ||
dff8f48d | 10010 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10011 | if (is_evpn_enabled()) |
60466a63 QY |
10012 | json_object_boolean_true_add( |
10013 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10014 | } |
10015 | ||
d62a17ae | 10016 | if (filter->plist[FILTER_IN].name |
10017 | || filter->dlist[FILTER_IN].name | |
10018 | || filter->aslist[FILTER_IN].name | |
10019 | || filter->map[RMAP_IN].name) | |
10020 | json_object_boolean_true_add(json_addr, | |
10021 | "inboundPathPolicyConfig"); | |
10022 | if (filter->plist[FILTER_OUT].name | |
10023 | || filter->dlist[FILTER_OUT].name | |
10024 | || filter->aslist[FILTER_OUT].name | |
10025 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10026 | json_object_boolean_true_add( | |
10027 | json_addr, "outboundPathPolicyConfig"); | |
10028 | ||
10029 | /* prefix-list */ | |
10030 | if (filter->plist[FILTER_IN].name) | |
10031 | json_object_string_add(json_addr, | |
10032 | "incomingUpdatePrefixFilterList", | |
10033 | filter->plist[FILTER_IN].name); | |
10034 | if (filter->plist[FILTER_OUT].name) | |
10035 | json_object_string_add(json_addr, | |
10036 | "outgoingUpdatePrefixFilterList", | |
10037 | filter->plist[FILTER_OUT].name); | |
10038 | ||
10039 | /* distribute-list */ | |
10040 | if (filter->dlist[FILTER_IN].name) | |
10041 | json_object_string_add( | |
10042 | json_addr, "incomingUpdateNetworkFilterList", | |
10043 | filter->dlist[FILTER_IN].name); | |
10044 | if (filter->dlist[FILTER_OUT].name) | |
10045 | json_object_string_add( | |
10046 | json_addr, "outgoingUpdateNetworkFilterList", | |
10047 | filter->dlist[FILTER_OUT].name); | |
10048 | ||
10049 | /* filter-list. */ | |
10050 | if (filter->aslist[FILTER_IN].name) | |
10051 | json_object_string_add(json_addr, | |
10052 | "incomingUpdateAsPathFilterList", | |
10053 | filter->aslist[FILTER_IN].name); | |
10054 | if (filter->aslist[FILTER_OUT].name) | |
10055 | json_object_string_add(json_addr, | |
10056 | "outgoingUpdateAsPathFilterList", | |
10057 | filter->aslist[FILTER_OUT].name); | |
10058 | ||
10059 | /* route-map. */ | |
10060 | if (filter->map[RMAP_IN].name) | |
10061 | json_object_string_add( | |
10062 | json_addr, "routeMapForIncomingAdvertisements", | |
10063 | filter->map[RMAP_IN].name); | |
10064 | if (filter->map[RMAP_OUT].name) | |
10065 | json_object_string_add( | |
10066 | json_addr, "routeMapForOutgoingAdvertisements", | |
10067 | filter->map[RMAP_OUT].name); | |
10068 | ||
9dac9fc8 DA |
10069 | /* ebgp-requires-policy (inbound) */ |
10070 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10071 | && !bgp_inbound_policy_exists(p, filter)) | |
10072 | json_object_string_add( | |
10073 | json_addr, "inboundEbgpRequiresPolicy", | |
10074 | "Inbound updates discarded due to missing policy"); | |
10075 | ||
10076 | /* ebgp-requires-policy (outbound) */ | |
10077 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10078 | && (!bgp_outbound_policy_exists(p, filter))) | |
10079 | json_object_string_add( | |
10080 | json_addr, "outboundEbgpRequiresPolicy", | |
10081 | "Outbound updates discarded due to missing policy"); | |
10082 | ||
d62a17ae | 10083 | /* unsuppress-map */ |
10084 | if (filter->usmap.name) | |
10085 | json_object_string_add(json_addr, | |
10086 | "selectiveUnsuppressRouteMap", | |
10087 | filter->usmap.name); | |
10088 | ||
10089 | /* Receive prefix count */ | |
10090 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10091 | p->pcount[afi][safi]); | |
50e05855 AD |
10092 | if (paf && PAF_SUBGRP(paf)) |
10093 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10094 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10095 | |
fde246e8 DA |
10096 | /* Maximum prefix */ |
10097 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10098 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10099 | p->pmax_out[afi][safi]); | |
10100 | ||
d62a17ae | 10101 | /* Maximum prefix */ |
10102 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10103 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10104 | p->pmax[afi][safi]); | |
10105 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10106 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10107 | json_object_boolean_true_add( | |
10108 | json_addr, "prefixAllowedMaxWarning"); | |
10109 | json_object_int_add(json_addr, | |
10110 | "prefixAllowedWarningThresh", | |
10111 | p->pmax_threshold[afi][safi]); | |
10112 | if (p->pmax_restart[afi][safi]) | |
10113 | json_object_int_add( | |
10114 | json_addr, | |
10115 | "prefixAllowedRestartIntervalMsecs", | |
10116 | p->pmax_restart[afi][safi] * 60000); | |
10117 | } | |
2986cac2 | 10118 | json_object_object_add(json_neigh, |
36235319 | 10119 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10120 | json_addr); |
10121 | ||
10122 | } else { | |
10123 | filter = &p->filter[afi][safi]; | |
10124 | ||
10125 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10126 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10127 | |
10128 | if (peer_group_active(p)) | |
10129 | vty_out(vty, " %s peer-group member\n", | |
10130 | p->group->name); | |
10131 | ||
10132 | paf = peer_af_find(p, afi, safi); | |
10133 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10134 | vty_out(vty, " Update group %" PRIu64 |
10135 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10136 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10137 | vty_out(vty, " Packet Queue length %d\n", | |
10138 | bpacket_queue_virtual_length(paf)); | |
10139 | } else { | |
10140 | vty_out(vty, " Not part of any update group\n"); | |
10141 | } | |
10142 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10143 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10144 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10145 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10146 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10147 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10148 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10149 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10150 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10151 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10152 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10153 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10154 | ||
10155 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10156 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10157 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10158 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10159 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10160 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10161 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10162 | vty_out(vty, | |
10163 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10164 | ORF_TYPE_PREFIX); | |
10165 | bgp_show_peer_afi_orf_cap( | |
10166 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10167 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10168 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10169 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10170 | } | |
10171 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10172 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10173 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10174 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10175 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10176 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10177 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10178 | vty_out(vty, | |
10179 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10180 | ORF_TYPE_PREFIX_OLD); | |
10181 | bgp_show_peer_afi_orf_cap( | |
10182 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10183 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10184 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10185 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10186 | } | |
10187 | ||
10188 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
10189 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
10190 | NULL, afi, orf_pfx_name, use_json); | |
10191 | ||
10192 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10193 | PEER_STATUS_ORF_PREFIX_SEND) | |
10194 | || orf_pfx_count) { | |
10195 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10196 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10197 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10198 | vty_out(vty, " sent;"); | |
10199 | if (orf_pfx_count) | |
10200 | vty_out(vty, " received (%d entries)", | |
10201 | orf_pfx_count); | |
10202 | vty_out(vty, "\n"); | |
10203 | } | |
10204 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10205 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10206 | vty_out(vty, | |
10207 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10208 | ||
10209 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10210 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10211 | vty_out(vty, " Route-Reflector Client\n"); | |
10212 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10213 | PEER_FLAG_RSERVER_CLIENT)) | |
10214 | vty_out(vty, " Route-Server Client\n"); | |
10215 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10216 | vty_out(vty, | |
10217 | " Inbound soft reconfiguration allowed\n"); | |
10218 | ||
10219 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10220 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10221 | vty_out(vty, | |
10222 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10223 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10224 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10225 | vty_out(vty, | |
10226 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10227 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10228 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10229 | vty_out(vty, | |
10230 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10231 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10232 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10233 | vty_out(vty, | |
10234 | " Private AS numbers removed in updates to this neighbor\n"); | |
10235 | ||
dcc68b5e MS |
10236 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10237 | vty_out(vty, " %s\n", | |
10238 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10239 | ->human_description); | |
d62a17ae | 10240 | |
10241 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10242 | vty_out(vty, | |
10243 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10244 | ||
10245 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10246 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10247 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10248 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10249 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10250 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10251 | vty_out(vty, | |
10252 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10253 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10254 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10255 | vty_out(vty, | |
10256 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10257 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10258 | vty_out(vty, | |
10259 | " MED is propagated unchanged to this neighbor\n"); | |
10260 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10261 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10262 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10263 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10264 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10265 | vty_out(vty, | |
10266 | " Community attribute sent to this neighbor"); | |
10267 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10268 | PEER_FLAG_SEND_COMMUNITY) | |
10269 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10270 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10271 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10272 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10273 | vty_out(vty, "(all)\n"); | |
10274 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10275 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10276 | vty_out(vty, "(large)\n"); | |
10277 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10278 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10279 | vty_out(vty, "(extended)\n"); | |
10280 | else | |
10281 | vty_out(vty, "(standard)\n"); | |
10282 | } | |
10283 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10284 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10285 | vty_out(vty, " Default information originate,"); | |
10286 | ||
10287 | if (p->default_rmap[afi][safi].name) | |
10288 | vty_out(vty, " default route-map %s%s,", | |
10289 | p->default_rmap[afi][safi].map ? "*" | |
10290 | : "", | |
10291 | p->default_rmap[afi][safi].name); | |
10292 | if (paf && PAF_SUBGRP(paf) | |
10293 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10294 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10295 | vty_out(vty, " default sent\n"); | |
10296 | else | |
10297 | vty_out(vty, " default not sent\n"); | |
10298 | } | |
10299 | ||
dff8f48d MK |
10300 | /* advertise-vni-all */ |
10301 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10302 | if (is_evpn_enabled()) |
dff8f48d MK |
10303 | vty_out(vty, " advertise-all-vni\n"); |
10304 | } | |
10305 | ||
d62a17ae | 10306 | if (filter->plist[FILTER_IN].name |
10307 | || filter->dlist[FILTER_IN].name | |
10308 | || filter->aslist[FILTER_IN].name | |
10309 | || filter->map[RMAP_IN].name) | |
10310 | vty_out(vty, " Inbound path policy configured\n"); | |
10311 | if (filter->plist[FILTER_OUT].name | |
10312 | || filter->dlist[FILTER_OUT].name | |
10313 | || filter->aslist[FILTER_OUT].name | |
10314 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10315 | vty_out(vty, " Outbound path policy configured\n"); | |
10316 | ||
10317 | /* prefix-list */ | |
10318 | if (filter->plist[FILTER_IN].name) | |
10319 | vty_out(vty, | |
10320 | " Incoming update prefix filter list is %s%s\n", | |
10321 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10322 | filter->plist[FILTER_IN].name); | |
10323 | if (filter->plist[FILTER_OUT].name) | |
10324 | vty_out(vty, | |
10325 | " Outgoing update prefix filter list is %s%s\n", | |
10326 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10327 | filter->plist[FILTER_OUT].name); | |
10328 | ||
10329 | /* distribute-list */ | |
10330 | if (filter->dlist[FILTER_IN].name) | |
10331 | vty_out(vty, | |
10332 | " Incoming update network filter list is %s%s\n", | |
10333 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10334 | filter->dlist[FILTER_IN].name); | |
10335 | if (filter->dlist[FILTER_OUT].name) | |
10336 | vty_out(vty, | |
10337 | " Outgoing update network filter list is %s%s\n", | |
10338 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10339 | filter->dlist[FILTER_OUT].name); | |
10340 | ||
10341 | /* filter-list. */ | |
10342 | if (filter->aslist[FILTER_IN].name) | |
10343 | vty_out(vty, | |
10344 | " Incoming update AS path filter list is %s%s\n", | |
10345 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10346 | filter->aslist[FILTER_IN].name); | |
10347 | if (filter->aslist[FILTER_OUT].name) | |
10348 | vty_out(vty, | |
10349 | " Outgoing update AS path filter list is %s%s\n", | |
10350 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10351 | filter->aslist[FILTER_OUT].name); | |
10352 | ||
10353 | /* route-map. */ | |
10354 | if (filter->map[RMAP_IN].name) | |
10355 | vty_out(vty, | |
10356 | " Route map for incoming advertisements is %s%s\n", | |
10357 | filter->map[RMAP_IN].map ? "*" : "", | |
10358 | filter->map[RMAP_IN].name); | |
10359 | if (filter->map[RMAP_OUT].name) | |
10360 | vty_out(vty, | |
10361 | " Route map for outgoing advertisements is %s%s\n", | |
10362 | filter->map[RMAP_OUT].map ? "*" : "", | |
10363 | filter->map[RMAP_OUT].name); | |
10364 | ||
9dac9fc8 DA |
10365 | /* ebgp-requires-policy (inbound) */ |
10366 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10367 | && !bgp_inbound_policy_exists(p, filter)) | |
10368 | vty_out(vty, | |
10369 | " Inbound updates discarded due to missing policy\n"); | |
10370 | ||
10371 | /* ebgp-requires-policy (outbound) */ | |
10372 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10373 | && !bgp_outbound_policy_exists(p, filter)) | |
10374 | vty_out(vty, | |
10375 | " Outbound updates discarded due to missing policy\n"); | |
10376 | ||
d62a17ae | 10377 | /* unsuppress-map */ |
10378 | if (filter->usmap.name) | |
10379 | vty_out(vty, | |
10380 | " Route map for selective unsuppress is %s%s\n", | |
10381 | filter->usmap.map ? "*" : "", | |
10382 | filter->usmap.name); | |
10383 | ||
10384 | /* Receive prefix count */ | |
a0a87037 DA |
10385 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10386 | p->pcount[afi][safi]); | |
d62a17ae | 10387 | |
fde246e8 DA |
10388 | /* maximum-prefix-out */ |
10389 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10390 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10391 | vty_out(vty, | |
10392 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10393 | p->pmax_out[afi][safi]); | |
10394 | ||
d62a17ae | 10395 | /* Maximum prefix */ |
10396 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10397 | vty_out(vty, |
10398 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10399 | p->pmax[afi][safi], |
10400 | CHECK_FLAG(p->af_flags[afi][safi], | |
10401 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10402 | ? " (warning-only)" | |
10403 | : ""); | |
10404 | vty_out(vty, " Threshold for warning message %d%%", | |
10405 | p->pmax_threshold[afi][safi]); | |
10406 | if (p->pmax_restart[afi][safi]) | |
10407 | vty_out(vty, ", restart interval %d min", | |
10408 | p->pmax_restart[afi][safi]); | |
10409 | vty_out(vty, "\n"); | |
10410 | } | |
10411 | ||
10412 | vty_out(vty, "\n"); | |
10413 | } | |
10414 | } | |
10415 | ||
9f049418 | 10416 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10417 | json_object *json) |
718e3744 | 10418 | { |
d62a17ae | 10419 | struct bgp *bgp; |
10420 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10421 | char timebuf[BGP_UPTIME_LEN]; | |
10422 | char dn_flag[2]; | |
d62a17ae | 10423 | afi_t afi; |
10424 | safi_t safi; | |
d7c0a89a QY |
10425 | uint16_t i; |
10426 | uint8_t *msg; | |
d62a17ae | 10427 | json_object *json_neigh = NULL; |
10428 | time_t epoch_tbuf; | |
718e3744 | 10429 | |
d62a17ae | 10430 | bgp = p->bgp; |
10431 | ||
10432 | if (use_json) | |
10433 | json_neigh = json_object_new_object(); | |
10434 | ||
10435 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10436 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10437 | dn_flag[0] = '*'; | |
10438 | ||
10439 | if (!use_json) { | |
10440 | if (p->conf_if) /* Configured interface name. */ | |
10441 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10442 | BGP_PEER_SU_UNSPEC(p) | |
10443 | ? "None" | |
10444 | : sockunion2str(&p->su, buf, | |
10445 | SU_ADDRSTRLEN)); | |
10446 | else /* Configured IP address. */ | |
10447 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10448 | p->host); | |
10449 | } | |
10450 | ||
10451 | if (use_json) { | |
10452 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10453 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10454 | "none"); | |
10455 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10456 | json_object_string_add( | |
10457 | json_neigh, "bgpNeighborAddr", | |
10458 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10459 | ||
10460 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10461 | ||
10462 | if (p->change_local_as) | |
10463 | json_object_int_add(json_neigh, "localAs", | |
10464 | p->change_local_as); | |
10465 | else | |
10466 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10467 | ||
10468 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10469 | json_object_boolean_true_add(json_neigh, | |
10470 | "localAsNoPrepend"); | |
10471 | ||
10472 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10473 | json_object_boolean_true_add(json_neigh, | |
10474 | "localAsReplaceAs"); | |
10475 | } else { | |
10476 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10477 | || (p->as_type == AS_INTERNAL)) | |
10478 | vty_out(vty, "remote AS %u, ", p->as); | |
10479 | else | |
10480 | vty_out(vty, "remote AS Unspecified, "); | |
10481 | vty_out(vty, "local AS %u%s%s, ", | |
10482 | p->change_local_as ? p->change_local_as : p->local_as, | |
10483 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10484 | ? " no-prepend" | |
10485 | : "", | |
10486 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10487 | ? " replace-as" | |
10488 | : ""); | |
10489 | } | |
faa16034 DS |
10490 | /* peer type internal or confed-internal */ |
10491 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10492 | if (use_json) { |
10493 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10494 | json_object_boolean_true_add( | |
10495 | json_neigh, "nbrConfedInternalLink"); | |
10496 | else | |
10497 | json_object_boolean_true_add(json_neigh, | |
10498 | "nbrInternalLink"); | |
10499 | } else { | |
10500 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10501 | vty_out(vty, "confed-internal link\n"); | |
10502 | else | |
10503 | vty_out(vty, "internal link\n"); | |
10504 | } | |
faa16034 DS |
10505 | /* peer type external or confed-external */ |
10506 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10507 | if (use_json) { |
10508 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10509 | json_object_boolean_true_add( | |
10510 | json_neigh, "nbrConfedExternalLink"); | |
10511 | else | |
10512 | json_object_boolean_true_add(json_neigh, | |
10513 | "nbrExternalLink"); | |
10514 | } else { | |
10515 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10516 | vty_out(vty, "confed-external link\n"); | |
10517 | else | |
10518 | vty_out(vty, "external link\n"); | |
10519 | } | |
faa16034 DS |
10520 | } else { |
10521 | if (use_json) | |
10522 | json_object_boolean_true_add(json_neigh, | |
10523 | "nbrUnspecifiedLink"); | |
10524 | else | |
10525 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10526 | } |
10527 | ||
10528 | /* Description. */ | |
10529 | if (p->desc) { | |
10530 | if (use_json) | |
10531 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10532 | else | |
10533 | vty_out(vty, " Description: %s\n", p->desc); | |
10534 | } | |
10535 | ||
10536 | if (p->hostname) { | |
10537 | if (use_json) { | |
10538 | if (p->hostname) | |
10539 | json_object_string_add(json_neigh, "hostname", | |
10540 | p->hostname); | |
10541 | ||
10542 | if (p->domainname) | |
10543 | json_object_string_add(json_neigh, "domainname", | |
10544 | p->domainname); | |
10545 | } else { | |
10546 | if (p->domainname && (p->domainname[0] != '\0')) | |
10547 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10548 | p->domainname); | |
10549 | else | |
10550 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10551 | } | |
10552 | } | |
10553 | ||
10554 | /* Peer-group */ | |
10555 | if (p->group) { | |
10556 | if (use_json) { | |
10557 | json_object_string_add(json_neigh, "peerGroup", | |
10558 | p->group->name); | |
10559 | ||
10560 | if (dn_flag[0]) { | |
10561 | struct prefix prefix, *range = NULL; | |
10562 | ||
10563 | sockunion2hostprefix(&(p->su), &prefix); | |
10564 | range = peer_group_lookup_dynamic_neighbor_range( | |
10565 | p->group, &prefix); | |
10566 | ||
10567 | if (range) { | |
10568 | prefix2str(range, buf1, sizeof(buf1)); | |
10569 | json_object_string_add( | |
10570 | json_neigh, | |
10571 | "peerSubnetRangeGroup", buf1); | |
10572 | } | |
10573 | } | |
10574 | } else { | |
10575 | vty_out(vty, | |
10576 | " Member of peer-group %s for session parameters\n", | |
10577 | p->group->name); | |
10578 | ||
10579 | if (dn_flag[0]) { | |
10580 | struct prefix prefix, *range = NULL; | |
10581 | ||
10582 | sockunion2hostprefix(&(p->su), &prefix); | |
10583 | range = peer_group_lookup_dynamic_neighbor_range( | |
10584 | p->group, &prefix); | |
10585 | ||
10586 | if (range) { | |
10587 | prefix2str(range, buf1, sizeof(buf1)); | |
10588 | vty_out(vty, | |
10589 | " Belongs to the subnet range group: %s\n", | |
10590 | buf1); | |
10591 | } | |
10592 | } | |
10593 | } | |
10594 | } | |
10595 | ||
10596 | if (use_json) { | |
10597 | /* Administrative shutdown. */ | |
10598 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10599 | json_object_boolean_true_add(json_neigh, | |
10600 | "adminShutDown"); | |
10601 | ||
10602 | /* BGP Version. */ | |
10603 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10604 | json_object_string_add( | |
10605 | json_neigh, "remoteRouterId", | |
10606 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10607 | json_object_string_add( |
10608 | json_neigh, "localRouterId", | |
10609 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10610 | sizeof(buf1))); | |
d62a17ae | 10611 | |
10612 | /* Confederation */ | |
10613 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10614 | && bgp_confederation_peers_check(bgp, p->as)) | |
10615 | json_object_boolean_true_add(json_neigh, | |
10616 | "nbrCommonAdmin"); | |
10617 | ||
10618 | /* Status. */ | |
10619 | json_object_string_add( | |
10620 | json_neigh, "bgpState", | |
10621 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10622 | ||
10623 | if (p->status == Established) { | |
10624 | time_t uptime; | |
d62a17ae | 10625 | |
10626 | uptime = bgp_clock(); | |
10627 | uptime -= p->uptime; | |
d62a17ae | 10628 | epoch_tbuf = time(NULL) - uptime; |
10629 | ||
d3c7efed DS |
10630 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10631 | uptime * 1000); | |
d62a17ae | 10632 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10633 | peer_uptime(p->uptime, timebuf, | |
10634 | BGP_UPTIME_LEN, 0, | |
10635 | NULL)); | |
10636 | json_object_int_add(json_neigh, | |
10637 | "bgpTimerUpEstablishedEpoch", | |
10638 | epoch_tbuf); | |
10639 | } | |
10640 | ||
10641 | else if (p->status == Active) { | |
10642 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10643 | json_object_string_add(json_neigh, "bgpStateIs", | |
10644 | "passive"); | |
10645 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10646 | json_object_string_add(json_neigh, "bgpStateIs", | |
10647 | "passiveNSF"); | |
10648 | } | |
10649 | ||
10650 | /* read timer */ | |
10651 | time_t uptime; | |
a2700b50 | 10652 | struct tm tm; |
d62a17ae | 10653 | |
10654 | uptime = bgp_clock(); | |
10655 | uptime -= p->readtime; | |
a2700b50 MS |
10656 | gmtime_r(&uptime, &tm); |
10657 | ||
d62a17ae | 10658 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
10659 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10660 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10661 | |
10662 | uptime = bgp_clock(); | |
10663 | uptime -= p->last_write; | |
a2700b50 MS |
10664 | gmtime_r(&uptime, &tm); |
10665 | ||
d62a17ae | 10666 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
10667 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10668 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10669 | |
10670 | uptime = bgp_clock(); | |
10671 | uptime -= p->update_time; | |
a2700b50 MS |
10672 | gmtime_r(&uptime, &tm); |
10673 | ||
d62a17ae | 10674 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
10675 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10676 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10677 | |
10678 | /* Configured timer values. */ | |
10679 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10680 | p->v_holdtime * 1000); | |
10681 | json_object_int_add(json_neigh, | |
10682 | "bgpTimerKeepAliveIntervalMsecs", | |
10683 | p->v_keepalive * 1000); | |
b90a8e13 | 10684 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10685 | json_object_int_add(json_neigh, |
10686 | "bgpTimerConfiguredHoldTimeMsecs", | |
10687 | p->holdtime * 1000); | |
10688 | json_object_int_add( | |
10689 | json_neigh, | |
10690 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10691 | p->keepalive * 1000); | |
5d5393b9 DL |
10692 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10693 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10694 | json_object_int_add(json_neigh, |
10695 | "bgpTimerConfiguredHoldTimeMsecs", | |
10696 | bgp->default_holdtime); | |
10697 | json_object_int_add( | |
10698 | json_neigh, | |
10699 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10700 | bgp->default_keepalive); | |
d62a17ae | 10701 | } |
10702 | } else { | |
10703 | /* Administrative shutdown. */ | |
10704 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10705 | vty_out(vty, " Administratively shut down\n"); | |
10706 | ||
10707 | /* BGP Version. */ | |
10708 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10709 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10710 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10711 | vty_out(vty, ", local router ID %s\n", |
10712 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10713 | sizeof(buf1))); | |
d62a17ae | 10714 | |
10715 | /* Confederation */ | |
10716 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10717 | && bgp_confederation_peers_check(bgp, p->as)) | |
10718 | vty_out(vty, | |
10719 | " Neighbor under common administration\n"); | |
10720 | ||
10721 | /* Status. */ | |
10722 | vty_out(vty, " BGP state = %s", | |
10723 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10724 | ||
10725 | if (p->status == Established) | |
10726 | vty_out(vty, ", up for %8s", | |
10727 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10728 | 0, NULL)); | |
10729 | ||
10730 | else if (p->status == Active) { | |
10731 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10732 | vty_out(vty, " (passive)"); | |
10733 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10734 | vty_out(vty, " (NSF passive)"); | |
10735 | } | |
10736 | vty_out(vty, "\n"); | |
10737 | ||
10738 | /* read timer */ | |
10739 | vty_out(vty, " Last read %s", | |
10740 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10741 | NULL)); | |
10742 | vty_out(vty, ", Last write %s\n", | |
10743 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10744 | NULL)); | |
10745 | ||
10746 | /* Configured timer values. */ | |
10747 | vty_out(vty, | |
10748 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10749 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10750 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10751 | vty_out(vty, " Configured hold time is %d", |
10752 | p->holdtime); | |
10753 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10754 | p->keepalive); | |
5d5393b9 DL |
10755 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10756 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10757 | vty_out(vty, " Configured hold time is %d", |
10758 | bgp->default_holdtime); | |
10759 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10760 | bgp->default_keepalive); | |
d62a17ae | 10761 | } |
10762 | } | |
10763 | /* Capability. */ | |
10764 | if (p->status == Established) { | |
10765 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10766 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10767 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10768 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10769 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10770 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10771 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10772 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10773 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10774 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10775 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10776 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10777 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10778 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10779 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10780 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10781 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10782 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10783 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10784 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10785 | if (use_json) { | |
10786 | json_object *json_cap = NULL; | |
10787 | ||
10788 | json_cap = json_object_new_object(); | |
10789 | ||
10790 | /* AS4 */ | |
10791 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10792 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10793 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10794 | && CHECK_FLAG(p->cap, | |
10795 | PEER_CAP_AS4_RCV)) | |
10796 | json_object_string_add( | |
10797 | json_cap, "4byteAs", | |
10798 | "advertisedAndReceived"); | |
10799 | else if (CHECK_FLAG(p->cap, | |
10800 | PEER_CAP_AS4_ADV)) | |
10801 | json_object_string_add( | |
10802 | json_cap, "4byteAs", | |
10803 | "advertised"); | |
10804 | else if (CHECK_FLAG(p->cap, | |
10805 | PEER_CAP_AS4_RCV)) | |
10806 | json_object_string_add( | |
10807 | json_cap, "4byteAs", | |
10808 | "received"); | |
10809 | } | |
10810 | ||
10811 | /* AddPath */ | |
10812 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10813 | || CHECK_FLAG(p->cap, | |
10814 | PEER_CAP_ADDPATH_ADV)) { | |
10815 | json_object *json_add = NULL; | |
10816 | const char *print_store; | |
10817 | ||
10818 | json_add = json_object_new_object(); | |
10819 | ||
05c7a1cc QY |
10820 | FOREACH_AFI_SAFI (afi, safi) { |
10821 | json_object *json_sub = NULL; | |
10822 | json_sub = | |
10823 | json_object_new_object(); | |
5cb5f4d0 DD |
10824 | print_store = get_afi_safi_str( |
10825 | afi, safi, true); | |
d62a17ae | 10826 | |
05c7a1cc QY |
10827 | if (CHECK_FLAG( |
10828 | p->af_cap[afi] | |
10829 | [safi], | |
10830 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10831 | || CHECK_FLAG( | |
10832 | p->af_cap[afi] | |
10833 | [safi], | |
10834 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10835 | if (CHECK_FLAG( |
10836 | p->af_cap | |
10837 | [afi] | |
10838 | [safi], | |
10839 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10840 | && CHECK_FLAG( |
d62a17ae | 10841 | p->af_cap |
10842 | [afi] | |
10843 | [safi], | |
05c7a1cc QY |
10844 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
10845 | json_object_boolean_true_add( | |
10846 | json_sub, | |
10847 | "txAdvertisedAndReceived"); | |
10848 | else if ( | |
10849 | CHECK_FLAG( | |
10850 | p->af_cap | |
10851 | [afi] | |
10852 | [safi], | |
10853 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
10854 | json_object_boolean_true_add( | |
10855 | json_sub, | |
10856 | "txAdvertised"); | |
10857 | else if ( | |
10858 | CHECK_FLAG( | |
10859 | p->af_cap | |
10860 | [afi] | |
10861 | [safi], | |
10862 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10863 | json_object_boolean_true_add( | |
10864 | json_sub, | |
10865 | "txReceived"); | |
10866 | } | |
d62a17ae | 10867 | |
05c7a1cc QY |
10868 | if (CHECK_FLAG( |
10869 | p->af_cap[afi] | |
10870 | [safi], | |
10871 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10872 | || CHECK_FLAG( | |
10873 | p->af_cap[afi] | |
10874 | [safi], | |
10875 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10876 | if (CHECK_FLAG( |
10877 | p->af_cap | |
10878 | [afi] | |
10879 | [safi], | |
10880 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10881 | && CHECK_FLAG( |
d62a17ae | 10882 | p->af_cap |
10883 | [afi] | |
10884 | [safi], | |
10885 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10886 | json_object_boolean_true_add( |
10887 | json_sub, | |
10888 | "rxAdvertisedAndReceived"); | |
10889 | else if ( | |
10890 | CHECK_FLAG( | |
10891 | p->af_cap | |
10892 | [afi] | |
10893 | [safi], | |
10894 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10895 | json_object_boolean_true_add( | |
10896 | json_sub, | |
10897 | "rxAdvertised"); | |
10898 | else if ( | |
10899 | CHECK_FLAG( | |
10900 | p->af_cap | |
10901 | [afi] | |
10902 | [safi], | |
10903 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10904 | json_object_boolean_true_add( | |
10905 | json_sub, | |
10906 | "rxReceived"); | |
d62a17ae | 10907 | } |
10908 | ||
05c7a1cc QY |
10909 | if (CHECK_FLAG( |
10910 | p->af_cap[afi] | |
10911 | [safi], | |
10912 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10913 | || CHECK_FLAG( | |
10914 | p->af_cap[afi] | |
10915 | [safi], | |
10916 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
10917 | || CHECK_FLAG( | |
10918 | p->af_cap[afi] | |
10919 | [safi], | |
10920 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10921 | || CHECK_FLAG( | |
10922 | p->af_cap[afi] | |
10923 | [safi], | |
10924 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10925 | json_object_object_add( | |
10926 | json_add, | |
10927 | print_store, | |
10928 | json_sub); | |
10929 | else | |
10930 | json_object_free( | |
10931 | json_sub); | |
10932 | } | |
10933 | ||
d62a17ae | 10934 | json_object_object_add( |
10935 | json_cap, "addPath", json_add); | |
10936 | } | |
10937 | ||
10938 | /* Dynamic */ | |
10939 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10940 | || CHECK_FLAG(p->cap, | |
10941 | PEER_CAP_DYNAMIC_ADV)) { | |
10942 | if (CHECK_FLAG(p->cap, | |
10943 | PEER_CAP_DYNAMIC_ADV) | |
10944 | && CHECK_FLAG(p->cap, | |
10945 | PEER_CAP_DYNAMIC_RCV)) | |
10946 | json_object_string_add( | |
10947 | json_cap, "dynamic", | |
10948 | "advertisedAndReceived"); | |
10949 | else if (CHECK_FLAG( | |
10950 | p->cap, | |
10951 | PEER_CAP_DYNAMIC_ADV)) | |
10952 | json_object_string_add( | |
10953 | json_cap, "dynamic", | |
10954 | "advertised"); | |
10955 | else if (CHECK_FLAG( | |
10956 | p->cap, | |
10957 | PEER_CAP_DYNAMIC_RCV)) | |
10958 | json_object_string_add( | |
10959 | json_cap, "dynamic", | |
10960 | "received"); | |
10961 | } | |
10962 | ||
10963 | /* Extended nexthop */ | |
10964 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10965 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10966 | json_object *json_nxt = NULL; | |
10967 | const char *print_store; | |
10968 | ||
10969 | ||
10970 | if (CHECK_FLAG(p->cap, | |
10971 | PEER_CAP_ENHE_ADV) | |
10972 | && CHECK_FLAG(p->cap, | |
10973 | PEER_CAP_ENHE_RCV)) | |
10974 | json_object_string_add( | |
10975 | json_cap, | |
10976 | "extendedNexthop", | |
10977 | "advertisedAndReceived"); | |
10978 | else if (CHECK_FLAG(p->cap, | |
10979 | PEER_CAP_ENHE_ADV)) | |
10980 | json_object_string_add( | |
10981 | json_cap, | |
10982 | "extendedNexthop", | |
10983 | "advertised"); | |
10984 | else if (CHECK_FLAG(p->cap, | |
10985 | PEER_CAP_ENHE_RCV)) | |
10986 | json_object_string_add( | |
10987 | json_cap, | |
10988 | "extendedNexthop", | |
10989 | "received"); | |
10990 | ||
10991 | if (CHECK_FLAG(p->cap, | |
10992 | PEER_CAP_ENHE_RCV)) { | |
10993 | json_nxt = | |
10994 | json_object_new_object(); | |
10995 | ||
10996 | for (safi = SAFI_UNICAST; | |
10997 | safi < SAFI_MAX; safi++) { | |
10998 | if (CHECK_FLAG( | |
10999 | p->af_cap | |
11000 | [AFI_IP] | |
11001 | [safi], | |
11002 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11003 | print_store = get_afi_safi_str( |
d62a17ae | 11004 | AFI_IP, |
5cb5f4d0 | 11005 | safi, true); |
d62a17ae | 11006 | json_object_string_add( |
11007 | json_nxt, | |
11008 | print_store, | |
54f29523 | 11009 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11010 | } |
11011 | } | |
11012 | json_object_object_add( | |
11013 | json_cap, | |
11014 | "extendedNexthopFamililesByPeer", | |
11015 | json_nxt); | |
11016 | } | |
11017 | } | |
11018 | ||
11019 | /* Route Refresh */ | |
11020 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11021 | || CHECK_FLAG(p->cap, | |
11022 | PEER_CAP_REFRESH_NEW_RCV) | |
11023 | || CHECK_FLAG(p->cap, | |
11024 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11025 | if (CHECK_FLAG(p->cap, | |
11026 | PEER_CAP_REFRESH_ADV) | |
11027 | && (CHECK_FLAG( | |
11028 | p->cap, | |
11029 | PEER_CAP_REFRESH_NEW_RCV) | |
11030 | || CHECK_FLAG( | |
11031 | p->cap, | |
11032 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11033 | if (CHECK_FLAG( | |
11034 | p->cap, | |
11035 | PEER_CAP_REFRESH_OLD_RCV) | |
11036 | && CHECK_FLAG( | |
11037 | p->cap, | |
11038 | PEER_CAP_REFRESH_NEW_RCV)) | |
11039 | json_object_string_add( | |
11040 | json_cap, | |
11041 | "routeRefresh", | |
11042 | "advertisedAndReceivedOldNew"); | |
11043 | else { | |
11044 | if (CHECK_FLAG( | |
11045 | p->cap, | |
11046 | PEER_CAP_REFRESH_OLD_RCV)) | |
11047 | json_object_string_add( | |
11048 | json_cap, | |
11049 | "routeRefresh", | |
11050 | "advertisedAndReceivedOld"); | |
11051 | else | |
11052 | json_object_string_add( | |
11053 | json_cap, | |
11054 | "routeRefresh", | |
11055 | "advertisedAndReceivedNew"); | |
11056 | } | |
11057 | } else if ( | |
11058 | CHECK_FLAG( | |
11059 | p->cap, | |
11060 | PEER_CAP_REFRESH_ADV)) | |
11061 | json_object_string_add( | |
11062 | json_cap, | |
11063 | "routeRefresh", | |
11064 | "advertised"); | |
11065 | else if ( | |
11066 | CHECK_FLAG( | |
11067 | p->cap, | |
11068 | PEER_CAP_REFRESH_NEW_RCV) | |
11069 | || CHECK_FLAG( | |
11070 | p->cap, | |
11071 | PEER_CAP_REFRESH_OLD_RCV)) | |
11072 | json_object_string_add( | |
11073 | json_cap, | |
11074 | "routeRefresh", | |
11075 | "received"); | |
11076 | } | |
11077 | ||
11078 | /* Multiprotocol Extensions */ | |
11079 | json_object *json_multi = NULL; | |
11080 | json_multi = json_object_new_object(); | |
11081 | ||
05c7a1cc QY |
11082 | FOREACH_AFI_SAFI (afi, safi) { |
11083 | if (p->afc_adv[afi][safi] | |
11084 | || p->afc_recv[afi][safi]) { | |
11085 | json_object *json_exten = NULL; | |
11086 | json_exten = | |
11087 | json_object_new_object(); | |
11088 | ||
d62a17ae | 11089 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11090 | && p->afc_recv[afi][safi]) |
11091 | json_object_boolean_true_add( | |
11092 | json_exten, | |
11093 | "advertisedAndReceived"); | |
11094 | else if (p->afc_adv[afi][safi]) | |
11095 | json_object_boolean_true_add( | |
11096 | json_exten, | |
11097 | "advertised"); | |
11098 | else if (p->afc_recv[afi][safi]) | |
11099 | json_object_boolean_true_add( | |
11100 | json_exten, | |
11101 | "received"); | |
d62a17ae | 11102 | |
05c7a1cc QY |
11103 | json_object_object_add( |
11104 | json_multi, | |
5cb5f4d0 DD |
11105 | get_afi_safi_str(afi, |
11106 | safi, | |
11107 | true), | |
05c7a1cc | 11108 | json_exten); |
d62a17ae | 11109 | } |
11110 | } | |
11111 | json_object_object_add( | |
11112 | json_cap, "multiprotocolExtensions", | |
11113 | json_multi); | |
11114 | ||
d77114b7 | 11115 | /* Hostname capabilities */ |
60466a63 | 11116 | json_object *json_hname = NULL; |
d77114b7 MK |
11117 | |
11118 | json_hname = json_object_new_object(); | |
11119 | ||
11120 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11121 | json_object_string_add( | |
60466a63 QY |
11122 | json_hname, "advHostName", |
11123 | bgp->peer_self->hostname | |
11124 | ? bgp->peer_self | |
11125 | ->hostname | |
d77114b7 MK |
11126 | : "n/a"); |
11127 | json_object_string_add( | |
60466a63 QY |
11128 | json_hname, "advDomainName", |
11129 | bgp->peer_self->domainname | |
11130 | ? bgp->peer_self | |
11131 | ->domainname | |
d77114b7 MK |
11132 | : "n/a"); |
11133 | } | |
11134 | ||
11135 | ||
11136 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11137 | json_object_string_add( | |
60466a63 QY |
11138 | json_hname, "rcvHostName", |
11139 | p->hostname ? p->hostname | |
11140 | : "n/a"); | |
d77114b7 | 11141 | json_object_string_add( |
60466a63 QY |
11142 | json_hname, "rcvDomainName", |
11143 | p->domainname ? p->domainname | |
11144 | : "n/a"); | |
d77114b7 MK |
11145 | } |
11146 | ||
60466a63 | 11147 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11148 | json_hname); |
11149 | ||
d62a17ae | 11150 | /* Gracefull Restart */ |
11151 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11152 | || CHECK_FLAG(p->cap, | |
11153 | PEER_CAP_RESTART_ADV)) { | |
11154 | if (CHECK_FLAG(p->cap, | |
11155 | PEER_CAP_RESTART_ADV) | |
11156 | && CHECK_FLAG(p->cap, | |
11157 | PEER_CAP_RESTART_RCV)) | |
11158 | json_object_string_add( | |
11159 | json_cap, | |
11160 | "gracefulRestart", | |
11161 | "advertisedAndReceived"); | |
11162 | else if (CHECK_FLAG( | |
11163 | p->cap, | |
11164 | PEER_CAP_RESTART_ADV)) | |
11165 | json_object_string_add( | |
11166 | json_cap, | |
11167 | "gracefulRestartCapability", | |
11168 | "advertised"); | |
11169 | else if (CHECK_FLAG( | |
11170 | p->cap, | |
11171 | PEER_CAP_RESTART_RCV)) | |
11172 | json_object_string_add( | |
11173 | json_cap, | |
11174 | "gracefulRestartCapability", | |
11175 | "received"); | |
11176 | ||
11177 | if (CHECK_FLAG(p->cap, | |
11178 | PEER_CAP_RESTART_RCV)) { | |
11179 | int restart_af_count = 0; | |
11180 | json_object *json_restart = | |
11181 | NULL; | |
11182 | json_restart = | |
11183 | json_object_new_object(); | |
11184 | ||
11185 | json_object_int_add( | |
11186 | json_cap, | |
11187 | "gracefulRestartRemoteTimerMsecs", | |
11188 | p->v_gr_restart * 1000); | |
11189 | ||
05c7a1cc QY |
11190 | FOREACH_AFI_SAFI (afi, safi) { |
11191 | if (CHECK_FLAG( | |
11192 | p->af_cap | |
11193 | [afi] | |
11194 | [safi], | |
11195 | PEER_CAP_RESTART_AF_RCV)) { | |
11196 | json_object * | |
11197 | json_sub = | |
11198 | NULL; | |
11199 | json_sub = | |
11200 | json_object_new_object(); | |
11201 | ||
d62a17ae | 11202 | if (CHECK_FLAG( |
11203 | p->af_cap | |
11204 | [afi] | |
11205 | [safi], | |
05c7a1cc QY |
11206 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11207 | json_object_boolean_true_add( | |
11208 | json_sub, | |
11209 | "preserved"); | |
11210 | restart_af_count++; | |
11211 | json_object_object_add( | |
11212 | json_restart, | |
5cb5f4d0 | 11213 | get_afi_safi_str( |
05c7a1cc | 11214 | afi, |
5cb5f4d0 DD |
11215 | safi, |
11216 | true), | |
05c7a1cc | 11217 | json_sub); |
d62a17ae | 11218 | } |
11219 | } | |
11220 | if (!restart_af_count) { | |
11221 | json_object_string_add( | |
11222 | json_cap, | |
11223 | "addressFamiliesByPeer", | |
11224 | "none"); | |
11225 | json_object_free( | |
11226 | json_restart); | |
11227 | } else | |
11228 | json_object_object_add( | |
11229 | json_cap, | |
11230 | "addressFamiliesByPeer", | |
11231 | json_restart); | |
11232 | } | |
11233 | } | |
11234 | json_object_object_add(json_neigh, | |
11235 | "neighborCapabilities", | |
11236 | json_cap); | |
11237 | } else { | |
11238 | vty_out(vty, " Neighbor capabilities:\n"); | |
11239 | ||
11240 | /* AS4 */ | |
11241 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11242 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11243 | vty_out(vty, " 4 Byte AS:"); | |
11244 | if (CHECK_FLAG(p->cap, | |
11245 | PEER_CAP_AS4_ADV)) | |
11246 | vty_out(vty, " advertised"); | |
11247 | if (CHECK_FLAG(p->cap, | |
11248 | PEER_CAP_AS4_RCV)) | |
11249 | vty_out(vty, " %sreceived", | |
11250 | CHECK_FLAG( | |
11251 | p->cap, | |
11252 | PEER_CAP_AS4_ADV) | |
11253 | ? "and " | |
11254 | : ""); | |
11255 | vty_out(vty, "\n"); | |
11256 | } | |
11257 | ||
11258 | /* AddPath */ | |
11259 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11260 | || CHECK_FLAG(p->cap, | |
11261 | PEER_CAP_ADDPATH_ADV)) { | |
11262 | vty_out(vty, " AddPath:\n"); | |
11263 | ||
05c7a1cc QY |
11264 | FOREACH_AFI_SAFI (afi, safi) { |
11265 | if (CHECK_FLAG( | |
11266 | p->af_cap[afi] | |
11267 | [safi], | |
11268 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11269 | || CHECK_FLAG( | |
11270 | p->af_cap[afi] | |
11271 | [safi], | |
11272 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11273 | vty_out(vty, | |
11274 | " %s: TX ", | |
5cb5f4d0 | 11275 | get_afi_safi_str( |
05c7a1cc | 11276 | afi, |
5cb5f4d0 DD |
11277 | safi, |
11278 | false)); | |
05c7a1cc | 11279 | |
d62a17ae | 11280 | if (CHECK_FLAG( |
11281 | p->af_cap | |
11282 | [afi] | |
11283 | [safi], | |
05c7a1cc | 11284 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11285 | vty_out(vty, |
05c7a1cc | 11286 | "advertised %s", |
5cb5f4d0 | 11287 | get_afi_safi_str( |
d62a17ae | 11288 | afi, |
5cb5f4d0 DD |
11289 | safi, |
11290 | false)); | |
d62a17ae | 11291 | |
05c7a1cc QY |
11292 | if (CHECK_FLAG( |
11293 | p->af_cap | |
11294 | [afi] | |
11295 | [safi], | |
11296 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11297 | vty_out(vty, | |
11298 | "%sreceived", | |
11299 | CHECK_FLAG( | |
11300 | p->af_cap | |
11301 | [afi] | |
11302 | [safi], | |
11303 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11304 | ? " and " | |
11305 | : ""); | |
d62a17ae | 11306 | |
05c7a1cc QY |
11307 | vty_out(vty, "\n"); |
11308 | } | |
d62a17ae | 11309 | |
05c7a1cc QY |
11310 | if (CHECK_FLAG( |
11311 | p->af_cap[afi] | |
11312 | [safi], | |
11313 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11314 | || CHECK_FLAG( | |
11315 | p->af_cap[afi] | |
11316 | [safi], | |
11317 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11318 | vty_out(vty, | |
11319 | " %s: RX ", | |
5cb5f4d0 | 11320 | get_afi_safi_str( |
05c7a1cc | 11321 | afi, |
5cb5f4d0 DD |
11322 | safi, |
11323 | false)); | |
d62a17ae | 11324 | |
11325 | if (CHECK_FLAG( | |
11326 | p->af_cap | |
11327 | [afi] | |
11328 | [safi], | |
05c7a1cc | 11329 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11330 | vty_out(vty, |
05c7a1cc | 11331 | "advertised %s", |
5cb5f4d0 | 11332 | get_afi_safi_str( |
d62a17ae | 11333 | afi, |
5cb5f4d0 DD |
11334 | safi, |
11335 | false)); | |
d62a17ae | 11336 | |
05c7a1cc QY |
11337 | if (CHECK_FLAG( |
11338 | p->af_cap | |
11339 | [afi] | |
11340 | [safi], | |
11341 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11342 | vty_out(vty, |
05c7a1cc QY |
11343 | "%sreceived", |
11344 | CHECK_FLAG( | |
11345 | p->af_cap | |
11346 | [afi] | |
11347 | [safi], | |
11348 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11349 | ? " and " | |
11350 | : ""); | |
11351 | ||
11352 | vty_out(vty, "\n"); | |
d62a17ae | 11353 | } |
05c7a1cc | 11354 | } |
d62a17ae | 11355 | } |
11356 | ||
11357 | /* Dynamic */ | |
11358 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11359 | || CHECK_FLAG(p->cap, | |
11360 | PEER_CAP_DYNAMIC_ADV)) { | |
11361 | vty_out(vty, " Dynamic:"); | |
11362 | if (CHECK_FLAG(p->cap, | |
11363 | PEER_CAP_DYNAMIC_ADV)) | |
11364 | vty_out(vty, " advertised"); | |
11365 | if (CHECK_FLAG(p->cap, | |
11366 | PEER_CAP_DYNAMIC_RCV)) | |
11367 | vty_out(vty, " %sreceived", | |
11368 | CHECK_FLAG( | |
11369 | p->cap, | |
11370 | PEER_CAP_DYNAMIC_ADV) | |
11371 | ? "and " | |
11372 | : ""); | |
11373 | vty_out(vty, "\n"); | |
11374 | } | |
11375 | ||
11376 | /* Extended nexthop */ | |
11377 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11378 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11379 | vty_out(vty, " Extended nexthop:"); | |
11380 | if (CHECK_FLAG(p->cap, | |
11381 | PEER_CAP_ENHE_ADV)) | |
11382 | vty_out(vty, " advertised"); | |
11383 | if (CHECK_FLAG(p->cap, | |
11384 | PEER_CAP_ENHE_RCV)) | |
11385 | vty_out(vty, " %sreceived", | |
11386 | CHECK_FLAG( | |
11387 | p->cap, | |
11388 | PEER_CAP_ENHE_ADV) | |
11389 | ? "and " | |
11390 | : ""); | |
11391 | vty_out(vty, "\n"); | |
11392 | ||
11393 | if (CHECK_FLAG(p->cap, | |
11394 | PEER_CAP_ENHE_RCV)) { | |
11395 | vty_out(vty, | |
11396 | " Address families by peer:\n "); | |
11397 | for (safi = SAFI_UNICAST; | |
11398 | safi < SAFI_MAX; safi++) | |
11399 | if (CHECK_FLAG( | |
11400 | p->af_cap | |
11401 | [AFI_IP] | |
11402 | [safi], | |
11403 | PEER_CAP_ENHE_AF_RCV)) | |
11404 | vty_out(vty, | |
11405 | " %s\n", | |
5cb5f4d0 | 11406 | get_afi_safi_str( |
d62a17ae | 11407 | AFI_IP, |
5cb5f4d0 DD |
11408 | safi, |
11409 | false)); | |
d62a17ae | 11410 | } |
11411 | } | |
11412 | ||
11413 | /* Route Refresh */ | |
11414 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11415 | || CHECK_FLAG(p->cap, | |
11416 | PEER_CAP_REFRESH_NEW_RCV) | |
11417 | || CHECK_FLAG(p->cap, | |
11418 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11419 | vty_out(vty, " Route refresh:"); | |
11420 | if (CHECK_FLAG(p->cap, | |
11421 | PEER_CAP_REFRESH_ADV)) | |
11422 | vty_out(vty, " advertised"); | |
11423 | if (CHECK_FLAG(p->cap, | |
11424 | PEER_CAP_REFRESH_NEW_RCV) | |
11425 | || CHECK_FLAG( | |
11426 | p->cap, | |
11427 | PEER_CAP_REFRESH_OLD_RCV)) | |
11428 | vty_out(vty, " %sreceived(%s)", | |
11429 | CHECK_FLAG( | |
11430 | p->cap, | |
11431 | PEER_CAP_REFRESH_ADV) | |
11432 | ? "and " | |
11433 | : "", | |
11434 | (CHECK_FLAG( | |
11435 | p->cap, | |
11436 | PEER_CAP_REFRESH_OLD_RCV) | |
11437 | && CHECK_FLAG( | |
11438 | p->cap, | |
11439 | PEER_CAP_REFRESH_NEW_RCV)) | |
11440 | ? "old & new" | |
11441 | : CHECK_FLAG( | |
11442 | p->cap, | |
11443 | PEER_CAP_REFRESH_OLD_RCV) | |
11444 | ? "old" | |
11445 | : "new"); | |
11446 | ||
11447 | vty_out(vty, "\n"); | |
11448 | } | |
11449 | ||
11450 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11451 | FOREACH_AFI_SAFI (afi, safi) |
11452 | if (p->afc_adv[afi][safi] | |
11453 | || p->afc_recv[afi][safi]) { | |
11454 | vty_out(vty, | |
11455 | " Address Family %s:", | |
5cb5f4d0 DD |
11456 | get_afi_safi_str( |
11457 | afi, | |
11458 | safi, | |
11459 | false)); | |
05c7a1cc | 11460 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11461 | vty_out(vty, |
05c7a1cc QY |
11462 | " advertised"); |
11463 | if (p->afc_recv[afi][safi]) | |
11464 | vty_out(vty, | |
11465 | " %sreceived", | |
11466 | p->afc_adv[afi] | |
11467 | [safi] | |
11468 | ? "and " | |
11469 | : ""); | |
11470 | vty_out(vty, "\n"); | |
11471 | } | |
d62a17ae | 11472 | |
11473 | /* Hostname capability */ | |
60466a63 | 11474 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11475 | |
11476 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11477 | vty_out(vty, |
11478 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11479 | bgp->peer_self->hostname |
11480 | ? bgp->peer_self | |
11481 | ->hostname | |
d77114b7 | 11482 | : "n/a", |
60466a63 QY |
11483 | bgp->peer_self->domainname |
11484 | ? bgp->peer_self | |
11485 | ->domainname | |
d77114b7 MK |
11486 | : "n/a"); |
11487 | } else { | |
11488 | vty_out(vty, " not advertised"); | |
d62a17ae | 11489 | } |
11490 | ||
d77114b7 | 11491 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11492 | vty_out(vty, |
11493 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11494 | p->hostname ? p->hostname |
11495 | : "n/a", | |
11496 | p->domainname ? p->domainname | |
11497 | : "n/a"); | |
d77114b7 MK |
11498 | } else { |
11499 | vty_out(vty, " not received"); | |
11500 | } | |
11501 | ||
11502 | vty_out(vty, "\n"); | |
11503 | ||
61bfbd51 | 11504 | /* Graceful Restart */ |
d62a17ae | 11505 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11506 | || CHECK_FLAG(p->cap, | |
11507 | PEER_CAP_RESTART_ADV)) { | |
11508 | vty_out(vty, | |
61bfbd51 | 11509 | " Graceful Restart Capability:"); |
d62a17ae | 11510 | if (CHECK_FLAG(p->cap, |
11511 | PEER_CAP_RESTART_ADV)) | |
11512 | vty_out(vty, " advertised"); | |
11513 | if (CHECK_FLAG(p->cap, | |
11514 | PEER_CAP_RESTART_RCV)) | |
11515 | vty_out(vty, " %sreceived", | |
11516 | CHECK_FLAG( | |
11517 | p->cap, | |
11518 | PEER_CAP_RESTART_ADV) | |
11519 | ? "and " | |
11520 | : ""); | |
11521 | vty_out(vty, "\n"); | |
11522 | ||
11523 | if (CHECK_FLAG(p->cap, | |
11524 | PEER_CAP_RESTART_RCV)) { | |
11525 | int restart_af_count = 0; | |
11526 | ||
11527 | vty_out(vty, | |
11528 | " Remote Restart timer is %d seconds\n", | |
11529 | p->v_gr_restart); | |
11530 | vty_out(vty, | |
11531 | " Address families by peer:\n "); | |
11532 | ||
05c7a1cc QY |
11533 | FOREACH_AFI_SAFI (afi, safi) |
11534 | if (CHECK_FLAG( | |
11535 | p->af_cap | |
11536 | [afi] | |
11537 | [safi], | |
11538 | PEER_CAP_RESTART_AF_RCV)) { | |
11539 | vty_out(vty, | |
11540 | "%s%s(%s)", | |
11541 | restart_af_count | |
11542 | ? ", " | |
11543 | : "", | |
5cb5f4d0 | 11544 | get_afi_safi_str( |
05c7a1cc | 11545 | afi, |
5cb5f4d0 DD |
11546 | safi, |
11547 | false), | |
05c7a1cc QY |
11548 | CHECK_FLAG( |
11549 | p->af_cap | |
11550 | [afi] | |
11551 | [safi], | |
11552 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11553 | ? "preserved" | |
11554 | : "not preserved"); | |
11555 | restart_af_count++; | |
11556 | } | |
d62a17ae | 11557 | if (!restart_af_count) |
11558 | vty_out(vty, "none"); | |
11559 | vty_out(vty, "\n"); | |
11560 | } | |
2986cac2 | 11561 | } /* Gracefull Restart */ |
d62a17ae | 11562 | } |
11563 | } | |
11564 | } | |
11565 | ||
11566 | /* graceful restart information */ | |
d62a17ae | 11567 | json_object *json_grace = NULL; |
11568 | json_object *json_grace_send = NULL; | |
11569 | json_object *json_grace_recv = NULL; | |
11570 | int eor_send_af_count = 0; | |
11571 | int eor_receive_af_count = 0; | |
11572 | ||
11573 | if (use_json) { | |
11574 | json_grace = json_object_new_object(); | |
11575 | json_grace_send = json_object_new_object(); | |
11576 | json_grace_recv = json_object_new_object(); | |
11577 | ||
36235319 QY |
11578 | if ((p->status == Established) |
11579 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11580 | FOREACH_AFI_SAFI (afi, safi) { |
11581 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11582 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11583 | json_object_boolean_true_add( |
11584 | json_grace_send, | |
5cb5f4d0 DD |
11585 | get_afi_safi_str(afi, |
11586 | safi, | |
11587 | true)); | |
05c7a1cc | 11588 | eor_send_af_count++; |
d62a17ae | 11589 | } |
11590 | } | |
05c7a1cc QY |
11591 | FOREACH_AFI_SAFI (afi, safi) { |
11592 | if (CHECK_FLAG( | |
36235319 QY |
11593 | p->af_sflags[afi][safi], |
11594 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11595 | json_object_boolean_true_add( |
11596 | json_grace_recv, | |
5cb5f4d0 DD |
11597 | get_afi_safi_str(afi, |
11598 | safi, | |
11599 | true)); | |
05c7a1cc | 11600 | eor_receive_af_count++; |
d62a17ae | 11601 | } |
11602 | } | |
11603 | } | |
36235319 QY |
11604 | json_object_object_add(json_grace, "endOfRibSend", |
11605 | json_grace_send); | |
11606 | json_object_object_add(json_grace, "endOfRibRecv", | |
11607 | json_grace_recv); | |
d62a17ae | 11608 | |
d62a17ae | 11609 | |
11610 | if (p->t_gr_restart) | |
11611 | json_object_int_add(json_grace, | |
11612 | "gracefulRestartTimerMsecs", | |
11613 | thread_timer_remain_second( | |
11614 | p->t_gr_restart) | |
11615 | * 1000); | |
11616 | ||
11617 | if (p->t_gr_stale) | |
11618 | json_object_int_add( | |
11619 | json_grace, | |
11620 | "gracefulStalepathTimerMsecs", | |
11621 | thread_timer_remain_second( | |
11622 | p->t_gr_stale) | |
11623 | * 1000); | |
2986cac2 | 11624 | /* more gr info in new format */ |
11625 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11626 | json_grace); |
d62a17ae | 11627 | json_object_object_add( |
11628 | json_neigh, "gracefulRestartInfo", json_grace); | |
11629 | } else { | |
2089dd80 | 11630 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
11631 | if ((p->status == Established) |
11632 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11633 | |
d62a17ae | 11634 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11635 | FOREACH_AFI_SAFI (afi, safi) { |
11636 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11637 | PEER_STATUS_EOR_SEND)) { | |
11638 | vty_out(vty, "%s%s", | |
11639 | eor_send_af_count ? ", " | |
11640 | : "", | |
36235319 QY |
11641 | get_afi_safi_str( |
11642 | afi, safi, | |
11643 | false)); | |
05c7a1cc | 11644 | eor_send_af_count++; |
d62a17ae | 11645 | } |
11646 | } | |
11647 | vty_out(vty, "\n"); | |
11648 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11649 | FOREACH_AFI_SAFI (afi, safi) { |
11650 | if (CHECK_FLAG( | |
11651 | p->af_sflags[afi][safi], | |
11652 | PEER_STATUS_EOR_RECEIVED)) { | |
11653 | vty_out(vty, "%s%s", | |
11654 | eor_receive_af_count | |
11655 | ? ", " | |
11656 | : "", | |
5cb5f4d0 DD |
11657 | get_afi_safi_str(afi, |
11658 | safi, | |
11659 | false)); | |
05c7a1cc | 11660 | eor_receive_af_count++; |
d62a17ae | 11661 | } |
11662 | } | |
11663 | vty_out(vty, "\n"); | |
11664 | } | |
11665 | ||
11666 | if (p->t_gr_restart) | |
11667 | vty_out(vty, | |
11668 | " The remaining time of restart timer is %ld\n", | |
11669 | thread_timer_remain_second( | |
11670 | p->t_gr_restart)); | |
11671 | ||
11672 | if (p->t_gr_stale) | |
11673 | vty_out(vty, | |
11674 | " The remaining time of stalepath timer is %ld\n", | |
11675 | thread_timer_remain_second( | |
11676 | p->t_gr_stale)); | |
2986cac2 | 11677 | |
11678 | /* more gr info in new format */ | |
11679 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11680 | } |
2986cac2 | 11681 | |
d62a17ae | 11682 | if (use_json) { |
11683 | json_object *json_stat = NULL; | |
11684 | json_stat = json_object_new_object(); | |
11685 | /* Packet counts. */ | |
11686 | json_object_int_add(json_stat, "depthInq", 0); | |
11687 | json_object_int_add(json_stat, "depthOutq", | |
11688 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
11689 | json_object_int_add(json_stat, "opensSent", |
11690 | atomic_load_explicit(&p->open_out, | |
11691 | memory_order_relaxed)); | |
11692 | json_object_int_add(json_stat, "opensRecv", | |
11693 | atomic_load_explicit(&p->open_in, | |
11694 | memory_order_relaxed)); | |
d62a17ae | 11695 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11696 | atomic_load_explicit(&p->notify_out, |
11697 | memory_order_relaxed)); | |
d62a17ae | 11698 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11699 | atomic_load_explicit(&p->notify_in, |
11700 | memory_order_relaxed)); | |
11701 | json_object_int_add(json_stat, "updatesSent", | |
11702 | atomic_load_explicit(&p->update_out, | |
11703 | memory_order_relaxed)); | |
11704 | json_object_int_add(json_stat, "updatesRecv", | |
11705 | atomic_load_explicit(&p->update_in, | |
11706 | memory_order_relaxed)); | |
d62a17ae | 11707 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11708 | atomic_load_explicit(&p->keepalive_out, |
11709 | memory_order_relaxed)); | |
d62a17ae | 11710 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11711 | atomic_load_explicit(&p->keepalive_in, |
11712 | memory_order_relaxed)); | |
d62a17ae | 11713 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11714 | atomic_load_explicit(&p->refresh_out, |
11715 | memory_order_relaxed)); | |
d62a17ae | 11716 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11717 | atomic_load_explicit(&p->refresh_in, |
11718 | memory_order_relaxed)); | |
d62a17ae | 11719 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11720 | atomic_load_explicit(&p->dynamic_cap_out, |
11721 | memory_order_relaxed)); | |
d62a17ae | 11722 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11723 | atomic_load_explicit(&p->dynamic_cap_in, |
11724 | memory_order_relaxed)); | |
11725 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11726 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11727 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11728 | } else { | |
11729 | /* Packet counts. */ | |
11730 | vty_out(vty, " Message statistics:\n"); | |
11731 | vty_out(vty, " Inq depth is 0\n"); | |
11732 | vty_out(vty, " Outq depth is %lu\n", | |
11733 | (unsigned long)p->obuf->count); | |
11734 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
11735 | vty_out(vty, " Opens: %10d %10d\n", |
11736 | atomic_load_explicit(&p->open_out, | |
11737 | memory_order_relaxed), | |
11738 | atomic_load_explicit(&p->open_in, | |
11739 | memory_order_relaxed)); | |
11740 | vty_out(vty, " Notifications: %10d %10d\n", | |
11741 | atomic_load_explicit(&p->notify_out, | |
11742 | memory_order_relaxed), | |
11743 | atomic_load_explicit(&p->notify_in, | |
11744 | memory_order_relaxed)); | |
11745 | vty_out(vty, " Updates: %10d %10d\n", | |
11746 | atomic_load_explicit(&p->update_out, | |
11747 | memory_order_relaxed), | |
11748 | atomic_load_explicit(&p->update_in, | |
11749 | memory_order_relaxed)); | |
11750 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11751 | atomic_load_explicit(&p->keepalive_out, | |
11752 | memory_order_relaxed), | |
11753 | atomic_load_explicit(&p->keepalive_in, | |
11754 | memory_order_relaxed)); | |
11755 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11756 | atomic_load_explicit(&p->refresh_out, | |
11757 | memory_order_relaxed), | |
11758 | atomic_load_explicit(&p->refresh_in, | |
11759 | memory_order_relaxed)); | |
d62a17ae | 11760 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11761 | atomic_load_explicit(&p->dynamic_cap_out, |
11762 | memory_order_relaxed), | |
11763 | atomic_load_explicit(&p->dynamic_cap_in, | |
11764 | memory_order_relaxed)); | |
11765 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11766 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11767 | } |
11768 | ||
11769 | if (use_json) { | |
11770 | /* advertisement-interval */ | |
11771 | json_object_int_add(json_neigh, | |
11772 | "minBtwnAdvertisementRunsTimerMsecs", | |
11773 | p->v_routeadv * 1000); | |
11774 | ||
11775 | /* Update-source. */ | |
11776 | if (p->update_if || p->update_source) { | |
11777 | if (p->update_if) | |
11778 | json_object_string_add(json_neigh, | |
11779 | "updateSource", | |
11780 | p->update_if); | |
11781 | else if (p->update_source) | |
11782 | json_object_string_add( | |
11783 | json_neigh, "updateSource", | |
11784 | sockunion2str(p->update_source, buf1, | |
11785 | SU_ADDRSTRLEN)); | |
11786 | } | |
11787 | } else { | |
11788 | /* advertisement-interval */ | |
11789 | vty_out(vty, | |
11790 | " Minimum time between advertisement runs is %d seconds\n", | |
11791 | p->v_routeadv); | |
11792 | ||
11793 | /* Update-source. */ | |
11794 | if (p->update_if || p->update_source) { | |
11795 | vty_out(vty, " Update source is "); | |
11796 | if (p->update_if) | |
11797 | vty_out(vty, "%s", p->update_if); | |
11798 | else if (p->update_source) | |
11799 | vty_out(vty, "%s", | |
11800 | sockunion2str(p->update_source, buf1, | |
11801 | SU_ADDRSTRLEN)); | |
11802 | vty_out(vty, "\n"); | |
11803 | } | |
11804 | ||
11805 | vty_out(vty, "\n"); | |
11806 | } | |
11807 | ||
11808 | /* Address Family Information */ | |
11809 | json_object *json_hold = NULL; | |
11810 | ||
11811 | if (use_json) | |
11812 | json_hold = json_object_new_object(); | |
11813 | ||
05c7a1cc QY |
11814 | FOREACH_AFI_SAFI (afi, safi) |
11815 | if (p->afc[afi][safi]) | |
11816 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11817 | json_hold); | |
d62a17ae | 11818 | |
11819 | if (use_json) { | |
11820 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11821 | json_hold); | |
11822 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11823 | p->established); | |
11824 | json_object_int_add(json_neigh, "connectionsDropped", | |
11825 | p->dropped); | |
11826 | } else | |
11827 | vty_out(vty, " Connections established %d; dropped %d\n", | |
11828 | p->established, p->dropped); | |
11829 | ||
11830 | if (!p->last_reset) { | |
11831 | if (use_json) | |
11832 | json_object_string_add(json_neigh, "lastReset", | |
11833 | "never"); | |
11834 | else | |
11835 | vty_out(vty, " Last reset never\n"); | |
11836 | } else { | |
11837 | if (use_json) { | |
11838 | time_t uptime; | |
a2700b50 | 11839 | struct tm tm; |
d62a17ae | 11840 | |
11841 | uptime = bgp_clock(); | |
11842 | uptime -= p->resettime; | |
a2700b50 MS |
11843 | gmtime_r(&uptime, &tm); |
11844 | ||
d62a17ae | 11845 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
11846 | (tm.tm_sec * 1000) |
11847 | + (tm.tm_min * 60000) | |
11848 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 11849 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 11850 | } else { |
11851 | vty_out(vty, " Last reset %s, ", | |
11852 | peer_uptime(p->resettime, timebuf, | |
11853 | BGP_UPTIME_LEN, 0, NULL)); | |
11854 | ||
3577f1c5 | 11855 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 11856 | if (p->last_reset_cause_size) { |
11857 | msg = p->last_reset_cause; | |
11858 | vty_out(vty, | |
11859 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
11860 | for (i = 1; i <= p->last_reset_cause_size; | |
11861 | i++) { | |
11862 | vty_out(vty, "%02X", *msg++); | |
11863 | ||
11864 | if (i != p->last_reset_cause_size) { | |
11865 | if (i % 16 == 0) { | |
11866 | vty_out(vty, "\n "); | |
11867 | } else if (i % 4 == 0) { | |
11868 | vty_out(vty, " "); | |
11869 | } | |
11870 | } | |
11871 | } | |
11872 | vty_out(vty, "\n"); | |
11873 | } | |
11874 | } | |
11875 | } | |
11876 | ||
11877 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11878 | if (use_json) | |
11879 | json_object_boolean_true_add(json_neigh, | |
11880 | "prefixesConfigExceedMax"); | |
11881 | else | |
11882 | vty_out(vty, | |
11883 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11884 | ||
11885 | if (p->t_pmax_restart) { | |
11886 | if (use_json) { | |
11887 | json_object_boolean_true_add( | |
11888 | json_neigh, "reducePrefixNumFrom"); | |
11889 | json_object_int_add(json_neigh, | |
11890 | "restartInTimerMsec", | |
11891 | thread_timer_remain_second( | |
11892 | p->t_pmax_restart) | |
11893 | * 1000); | |
11894 | } else | |
11895 | vty_out(vty, | |
11896 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
11897 | p->host, thread_timer_remain_second( |
11898 | p->t_pmax_restart)); | |
d62a17ae | 11899 | } else { |
11900 | if (use_json) | |
11901 | json_object_boolean_true_add( | |
11902 | json_neigh, | |
11903 | "reducePrefixNumAndClearIpBgp"); | |
11904 | else | |
11905 | vty_out(vty, | |
11906 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
11907 | p->host); | |
11908 | } | |
11909 | } | |
11910 | ||
11911 | /* EBGP Multihop and GTSM */ | |
11912 | if (p->sort != BGP_PEER_IBGP) { | |
11913 | if (use_json) { | |
e2521429 | 11914 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 11915 | json_object_int_add(json_neigh, |
11916 | "externalBgpNbrMaxHopsAway", | |
11917 | p->gtsm_hops); | |
c8d6f0d6 | 11918 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11919 | json_object_int_add(json_neigh, |
11920 | "externalBgpNbrMaxHopsAway", | |
11921 | p->ttl); | |
11922 | } else { | |
e2521429 | 11923 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 11924 | vty_out(vty, |
11925 | " External BGP neighbor may be up to %d hops away.\n", | |
11926 | p->gtsm_hops); | |
c8d6f0d6 | 11927 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11928 | vty_out(vty, |
11929 | " External BGP neighbor may be up to %d hops away.\n", | |
11930 | p->ttl); | |
11931 | } | |
11932 | } else { | |
e2521429 | 11933 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 11934 | if (use_json) |
11935 | json_object_int_add(json_neigh, | |
11936 | "internalBgpNbrMaxHopsAway", | |
11937 | p->gtsm_hops); | |
11938 | else | |
11939 | vty_out(vty, | |
11940 | " Internal BGP neighbor may be up to %d hops away.\n", | |
11941 | p->gtsm_hops); | |
11942 | } | |
11943 | } | |
11944 | ||
11945 | /* Local address. */ | |
11946 | if (p->su_local) { | |
11947 | if (use_json) { | |
11948 | json_object_string_add(json_neigh, "hostLocal", | |
11949 | sockunion2str(p->su_local, buf1, | |
11950 | SU_ADDRSTRLEN)); | |
11951 | json_object_int_add(json_neigh, "portLocal", | |
11952 | ntohs(p->su_local->sin.sin_port)); | |
11953 | } else | |
11954 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
11955 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
11956 | ntohs(p->su_local->sin.sin_port)); | |
11957 | } | |
11958 | ||
11959 | /* Remote address. */ | |
11960 | if (p->su_remote) { | |
11961 | if (use_json) { | |
11962 | json_object_string_add(json_neigh, "hostForeign", | |
11963 | sockunion2str(p->su_remote, buf1, | |
11964 | SU_ADDRSTRLEN)); | |
11965 | json_object_int_add(json_neigh, "portForeign", | |
11966 | ntohs(p->su_remote->sin.sin_port)); | |
11967 | } else | |
11968 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
11969 | sockunion2str(p->su_remote, buf1, | |
11970 | SU_ADDRSTRLEN), | |
11971 | ntohs(p->su_remote->sin.sin_port)); | |
11972 | } | |
11973 | ||
11974 | /* Nexthop display. */ | |
11975 | if (p->su_local) { | |
11976 | if (use_json) { | |
11977 | json_object_string_add(json_neigh, "nexthop", | |
11978 | inet_ntop(AF_INET, | |
11979 | &p->nexthop.v4, buf1, | |
11980 | sizeof(buf1))); | |
11981 | json_object_string_add(json_neigh, "nexthopGlobal", | |
11982 | inet_ntop(AF_INET6, | |
11983 | &p->nexthop.v6_global, | |
11984 | buf1, sizeof(buf1))); | |
11985 | json_object_string_add(json_neigh, "nexthopLocal", | |
11986 | inet_ntop(AF_INET6, | |
11987 | &p->nexthop.v6_local, | |
11988 | buf1, sizeof(buf1))); | |
11989 | if (p->shared_network) | |
11990 | json_object_string_add(json_neigh, | |
11991 | "bgpConnection", | |
11992 | "sharedNetwork"); | |
11993 | else | |
11994 | json_object_string_add(json_neigh, | |
11995 | "bgpConnection", | |
11996 | "nonSharedNetwork"); | |
11997 | } else { | |
11998 | vty_out(vty, "Nexthop: %s\n", | |
11999 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12000 | sizeof(buf1))); | |
12001 | vty_out(vty, "Nexthop global: %s\n", | |
12002 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12003 | sizeof(buf1))); | |
12004 | vty_out(vty, "Nexthop local: %s\n", | |
12005 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12006 | sizeof(buf1))); | |
12007 | vty_out(vty, "BGP connection: %s\n", | |
12008 | p->shared_network ? "shared network" | |
12009 | : "non shared network"); | |
12010 | } | |
12011 | } | |
12012 | ||
12013 | /* Timer information. */ | |
12014 | if (use_json) { | |
12015 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12016 | p->v_connect); | |
12017 | if (p->status == Established && p->rtt) | |
12018 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12019 | p->rtt); | |
12020 | if (p->t_start) | |
12021 | json_object_int_add( | |
12022 | json_neigh, "nextStartTimerDueInMsecs", | |
12023 | thread_timer_remain_second(p->t_start) * 1000); | |
12024 | if (p->t_connect) | |
12025 | json_object_int_add( | |
12026 | json_neigh, "nextConnectTimerDueInMsecs", | |
12027 | thread_timer_remain_second(p->t_connect) | |
12028 | * 1000); | |
12029 | if (p->t_routeadv) { | |
12030 | json_object_int_add(json_neigh, "mraiInterval", | |
12031 | p->v_routeadv); | |
12032 | json_object_int_add( | |
12033 | json_neigh, "mraiTimerExpireInMsecs", | |
12034 | thread_timer_remain_second(p->t_routeadv) | |
12035 | * 1000); | |
12036 | } | |
12037 | if (p->password) | |
12038 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12039 | 1); | |
12040 | ||
12041 | if (p->t_read) | |
12042 | json_object_string_add(json_neigh, "readThread", "on"); | |
12043 | else | |
12044 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12045 | |
12046 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12047 | json_object_string_add(json_neigh, "writeThread", "on"); |
12048 | else | |
12049 | json_object_string_add(json_neigh, "writeThread", | |
12050 | "off"); | |
12051 | } else { | |
12052 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12053 | p->v_connect); | |
12054 | if (p->status == Established && p->rtt) | |
12055 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12056 | p->rtt); | |
12057 | if (p->t_start) | |
12058 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12059 | thread_timer_remain_second(p->t_start)); | |
12060 | if (p->t_connect) | |
12061 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12062 | thread_timer_remain_second(p->t_connect)); | |
12063 | if (p->t_routeadv) | |
12064 | vty_out(vty, | |
12065 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12066 | p->v_routeadv, | |
12067 | thread_timer_remain_second(p->t_routeadv)); | |
12068 | if (p->password) | |
12069 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12070 | ||
cac9e917 | 12071 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12072 | p->t_read ? "on" : "off", |
12073 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12074 | ? "on" | |
cac9e917 | 12075 | : "off", p->fd); |
d62a17ae | 12076 | } |
12077 | ||
12078 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12079 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12080 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12081 | ||
12082 | if (!use_json) | |
12083 | vty_out(vty, "\n"); | |
12084 | ||
12085 | /* BFD information. */ | |
12086 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12087 | ||
12088 | if (use_json) { | |
12089 | if (p->conf_if) /* Configured interface name. */ | |
12090 | json_object_object_add(json, p->conf_if, json_neigh); | |
12091 | else /* Configured IP address. */ | |
12092 | json_object_object_add(json, p->host, json_neigh); | |
12093 | } | |
12094 | } | |
12095 | ||
36235319 QY |
12096 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12097 | enum show_type type, | |
12098 | union sockunion *su, | |
12099 | const char *conf_if, afi_t afi, | |
12100 | bool use_json, json_object *json) | |
2986cac2 | 12101 | { |
12102 | struct listnode *node, *nnode; | |
12103 | struct peer *peer; | |
12104 | int find = 0; | |
12105 | safi_t safi = SAFI_UNICAST; | |
12106 | json_object *json_neighbor = NULL; | |
12107 | ||
12108 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12109 | ||
12110 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12111 | continue; | |
12112 | ||
12113 | if ((peer->afc[afi][safi]) == 0) | |
12114 | continue; | |
12115 | ||
12116 | if (use_json) | |
12117 | json_neighbor = json_object_new_object(); | |
12118 | ||
2ba1fe69 | 12119 | if (type == show_all) { |
2986cac2 | 12120 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12121 | json_neighbor); |
2986cac2 | 12122 | |
12123 | if (use_json) | |
13909c4f DS |
12124 | json_object_object_add(json, peer->host, |
12125 | json_neighbor); | |
2986cac2 | 12126 | |
2ba1fe69 | 12127 | } else if (type == show_peer) { |
2986cac2 | 12128 | if (conf_if) { |
12129 | if ((peer->conf_if | |
13909c4f DS |
12130 | && !strcmp(peer->conf_if, conf_if)) |
12131 | || (peer->hostname | |
2986cac2 | 12132 | && !strcmp(peer->hostname, conf_if))) { |
12133 | find = 1; | |
13909c4f DS |
12134 | bgp_show_peer_gr_status(vty, peer, |
12135 | use_json, | |
12136 | json_neighbor); | |
2986cac2 | 12137 | } |
12138 | } else { | |
12139 | if (sockunion_same(&peer->su, su)) { | |
12140 | find = 1; | |
13909c4f DS |
12141 | bgp_show_peer_gr_status(vty, peer, |
12142 | use_json, | |
12143 | json_neighbor); | |
2986cac2 | 12144 | } |
12145 | } | |
13909c4f DS |
12146 | if (use_json && find) |
12147 | json_object_object_add(json, peer->host, | |
12148 | json_neighbor); | |
2986cac2 | 12149 | } |
12150 | ||
12151 | if (find) | |
12152 | break; | |
12153 | } | |
12154 | ||
12155 | if (type == show_peer && !find) { | |
12156 | if (use_json) | |
13909c4f | 12157 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12158 | else |
12159 | vty_out(vty, "%% No such neighbor\n"); | |
12160 | } | |
12161 | if (use_json) { | |
13909c4f DS |
12162 | vty_out(vty, "%s\n", |
12163 | json_object_to_json_string_ext( | |
12164 | json, JSON_C_TO_STRING_PRETTY)); | |
2986cac2 | 12165 | } else { |
12166 | vty_out(vty, "\n"); | |
12167 | } | |
12168 | ||
12169 | return CMD_SUCCESS; | |
12170 | } | |
12171 | ||
d62a17ae | 12172 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12173 | enum show_type type, union sockunion *su, | |
9f049418 | 12174 | const char *conf_if, bool use_json, |
d62a17ae | 12175 | json_object *json) |
12176 | { | |
12177 | struct listnode *node, *nnode; | |
12178 | struct peer *peer; | |
12179 | int find = 0; | |
9f049418 | 12180 | bool nbr_output = false; |
d1927ebe AS |
12181 | afi_t afi = AFI_MAX; |
12182 | safi_t safi = SAFI_MAX; | |
12183 | ||
12184 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12185 | afi = AFI_IP; | |
12186 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12187 | afi = AFI_IP6; | |
12188 | } | |
d62a17ae | 12189 | |
12190 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12191 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12192 | continue; | |
12193 | ||
12194 | switch (type) { | |
12195 | case show_all: | |
12196 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12197 | nbr_output = true; |
d62a17ae | 12198 | break; |
12199 | case show_peer: | |
12200 | if (conf_if) { | |
12201 | if ((peer->conf_if | |
12202 | && !strcmp(peer->conf_if, conf_if)) | |
12203 | || (peer->hostname | |
12204 | && !strcmp(peer->hostname, conf_if))) { | |
12205 | find = 1; | |
12206 | bgp_show_peer(vty, peer, use_json, | |
12207 | json); | |
12208 | } | |
12209 | } else { | |
12210 | if (sockunion_same(&peer->su, su)) { | |
12211 | find = 1; | |
12212 | bgp_show_peer(vty, peer, use_json, | |
12213 | json); | |
12214 | } | |
12215 | } | |
12216 | break; | |
d1927ebe AS |
12217 | case show_ipv4_peer: |
12218 | case show_ipv6_peer: | |
12219 | FOREACH_SAFI (safi) { | |
12220 | if (peer->afc[afi][safi]) { | |
12221 | if (conf_if) { | |
12222 | if ((peer->conf_if | |
12223 | && !strcmp(peer->conf_if, conf_if)) | |
12224 | || (peer->hostname | |
12225 | && !strcmp(peer->hostname, conf_if))) { | |
12226 | find = 1; | |
12227 | bgp_show_peer(vty, peer, use_json, | |
12228 | json); | |
12229 | break; | |
12230 | } | |
12231 | } else { | |
12232 | if (sockunion_same(&peer->su, su)) { | |
12233 | find = 1; | |
12234 | bgp_show_peer(vty, peer, use_json, | |
12235 | json); | |
12236 | break; | |
12237 | } | |
12238 | } | |
12239 | } | |
12240 | } | |
12241 | break; | |
12242 | case show_ipv4_all: | |
12243 | case show_ipv6_all: | |
12244 | FOREACH_SAFI (safi) { | |
12245 | if (peer->afc[afi][safi]) { | |
12246 | bgp_show_peer(vty, peer, use_json, json); | |
12247 | nbr_output = true; | |
12248 | break; | |
12249 | } | |
12250 | } | |
12251 | break; | |
d62a17ae | 12252 | } |
12253 | } | |
12254 | ||
d1927ebe AS |
12255 | if ((type == show_peer || type == show_ipv4_peer || |
12256 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12257 | if (use_json) |
12258 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12259 | else | |
88b7d255 | 12260 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12261 | } |
12262 | ||
d1927ebe AS |
12263 | if (type != show_peer && type != show_ipv4_peer && |
12264 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12265 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12266 | |
d62a17ae | 12267 | if (use_json) { |
996c9314 LB |
12268 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12269 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12270 | } else { |
12271 | vty_out(vty, "\n"); | |
12272 | } | |
12273 | ||
12274 | return CMD_SUCCESS; | |
12275 | } | |
12276 | ||
36235319 QY |
12277 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12278 | enum show_type type, | |
12279 | const char *ip_str, | |
12280 | afi_t afi, bool use_json) | |
2986cac2 | 12281 | { |
12282 | ||
12283 | int ret; | |
12284 | struct bgp *bgp; | |
12285 | union sockunion su; | |
12286 | json_object *json = NULL; | |
12287 | ||
12288 | bgp = bgp_get_default(); | |
12289 | ||
13909c4f DS |
12290 | if (!bgp) |
12291 | return; | |
2986cac2 | 12292 | |
13909c4f DS |
12293 | if (!use_json) |
12294 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12295 | NULL); | |
2986cac2 | 12296 | |
13909c4f DS |
12297 | json = json_object_new_object(); |
12298 | if (ip_str) { | |
12299 | ret = str2sockunion(ip_str, &su); | |
12300 | if (ret < 0) | |
12301 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, | |
12302 | ip_str, afi, | |
12303 | use_json, json); | |
12304 | else | |
12305 | bgp_show_neighbor_graceful_restart( | |
12306 | vty, bgp, type, &su, NULL, afi, use_json, json); | |
12307 | } else | |
12308 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
12309 | afi, use_json, json); | |
12310 | json_object_free(json); | |
2986cac2 | 12311 | } |
12312 | ||
d62a17ae | 12313 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12314 | enum show_type type, |
12315 | const char *ip_str, | |
9f049418 | 12316 | bool use_json) |
d62a17ae | 12317 | { |
0291c246 MK |
12318 | struct listnode *node, *nnode; |
12319 | struct bgp *bgp; | |
71aedaa3 | 12320 | union sockunion su; |
0291c246 | 12321 | json_object *json = NULL; |
71aedaa3 | 12322 | int ret, is_first = 1; |
9f049418 | 12323 | bool nbr_output = false; |
d62a17ae | 12324 | |
12325 | if (use_json) | |
12326 | vty_out(vty, "{\n"); | |
12327 | ||
12328 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12329 | nbr_output = true; |
d62a17ae | 12330 | if (use_json) { |
12331 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12332 | flog_err( |
e50f7cfd | 12333 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12334 | "Unable to allocate memory for JSON object"); |
12335 | vty_out(vty, | |
12336 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12337 | return; | |
12338 | } | |
12339 | ||
12340 | json_object_int_add(json, "vrfId", | |
12341 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12342 | ? -1 |
12343 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12344 | json_object_string_add( |
12345 | json, "vrfName", | |
12346 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12347 | ? VRF_DEFAULT_NAME |
d62a17ae | 12348 | : bgp->name); |
12349 | ||
12350 | if (!is_first) | |
12351 | vty_out(vty, ",\n"); | |
12352 | else | |
12353 | is_first = 0; | |
12354 | ||
12355 | vty_out(vty, "\"%s\":", | |
12356 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12357 | ? VRF_DEFAULT_NAME |
d62a17ae | 12358 | : bgp->name); |
12359 | } else { | |
12360 | vty_out(vty, "\nInstance %s:\n", | |
12361 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12362 | ? VRF_DEFAULT_NAME |
d62a17ae | 12363 | : bgp->name); |
12364 | } | |
71aedaa3 | 12365 | |
d1927ebe AS |
12366 | if (type == show_peer || type == show_ipv4_peer || |
12367 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12368 | ret = str2sockunion(ip_str, &su); |
12369 | if (ret < 0) | |
12370 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12371 | use_json, json); | |
12372 | else | |
12373 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12374 | use_json, json); | |
12375 | } else { | |
d1927ebe | 12376 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12377 | use_json, json); |
12378 | } | |
b77004d6 | 12379 | json_object_free(json); |
d62a17ae | 12380 | } |
12381 | ||
01cbfd04 | 12382 | if (use_json) { |
d62a17ae | 12383 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12384 | json_object_free(json); |
12385 | } | |
9f049418 DS |
12386 | else if (!nbr_output) |
12387 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12388 | } |
12389 | ||
12390 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12391 | enum show_type type, const char *ip_str, | |
9f049418 | 12392 | bool use_json) |
d62a17ae | 12393 | { |
12394 | int ret; | |
12395 | struct bgp *bgp; | |
12396 | union sockunion su; | |
12397 | json_object *json = NULL; | |
12398 | ||
12399 | if (name) { | |
12400 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12401 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12402 | use_json); | |
d62a17ae | 12403 | return CMD_SUCCESS; |
12404 | } else { | |
12405 | bgp = bgp_lookup_by_name(name); | |
12406 | if (!bgp) { | |
12407 | if (use_json) { | |
12408 | json = json_object_new_object(); | |
d62a17ae | 12409 | vty_out(vty, "%s\n", |
12410 | json_object_to_json_string_ext( | |
12411 | json, | |
12412 | JSON_C_TO_STRING_PRETTY)); | |
12413 | json_object_free(json); | |
12414 | } else | |
12415 | vty_out(vty, | |
9f049418 | 12416 | "%% BGP instance not found\n"); |
d62a17ae | 12417 | |
12418 | return CMD_WARNING; | |
12419 | } | |
12420 | } | |
12421 | } else { | |
12422 | bgp = bgp_get_default(); | |
12423 | } | |
12424 | ||
12425 | if (bgp) { | |
12426 | json = json_object_new_object(); | |
12427 | if (ip_str) { | |
12428 | ret = str2sockunion(ip_str, &su); | |
12429 | if (ret < 0) | |
12430 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12431 | use_json, json); | |
12432 | else | |
12433 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12434 | use_json, json); | |
12435 | } else { | |
12436 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12437 | json); | |
12438 | } | |
12439 | json_object_free(json); | |
ca61fd25 DS |
12440 | } else { |
12441 | if (use_json) | |
12442 | vty_out(vty, "{}\n"); | |
12443 | else | |
12444 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12445 | } |
12446 | ||
12447 | return CMD_SUCCESS; | |
4fb25c53 DW |
12448 | } |
12449 | ||
2986cac2 | 12450 | |
12451 | ||
12452 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12453 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12454 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12455 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12456 | SHOW_STR | |
12457 | BGP_STR | |
12458 | IP_STR | |
12459 | IPV6_STR | |
12460 | NEIGHBOR_STR | |
12461 | "Neighbor to display information about\n" | |
12462 | "Neighbor to display information about\n" | |
12463 | "Neighbor on BGP configured interface\n" | |
12464 | GR_SHOW | |
12465 | JSON_STR) | |
12466 | { | |
12467 | char *sh_arg = NULL; | |
12468 | enum show_type sh_type; | |
12469 | int idx = 0; | |
12470 | afi_t afi = AFI_MAX; | |
2986cac2 | 12471 | bool uj = use_json(argc, argv); |
12472 | ||
36235319 | 12473 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12474 | afi = AFI_MAX; |
12475 | ||
12476 | idx++; | |
12477 | ||
12478 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12479 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12480 | || argv_find(argv, argc, "WORD", &idx)) { | |
12481 | sh_type = show_peer; | |
12482 | sh_arg = argv[idx]->arg; | |
12483 | } else | |
12484 | sh_type = show_all; | |
12485 | ||
12486 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12487 | return CMD_SUCCESS; | |
12488 | ||
12489 | ||
36235319 QY |
12490 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12491 | afi, uj); | |
2986cac2 | 12492 | } |
12493 | ||
716b2d8a | 12494 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12495 | DEFUN (show_ip_bgp_neighbors, |
12496 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12497 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12498 | SHOW_STR |
12499 | IP_STR | |
12500 | BGP_STR | |
f2a8972b | 12501 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12502 | "Address Family\n" |
12503 | "Address Family\n" | |
718e3744 | 12504 | "Detailed information on TCP and BGP neighbor connections\n" |
12505 | "Neighbor to display information about\n" | |
a80beece | 12506 | "Neighbor to display information about\n" |
91d37724 | 12507 | "Neighbor on BGP configured interface\n" |
9973d184 | 12508 | JSON_STR) |
718e3744 | 12509 | { |
d62a17ae | 12510 | char *vrf = NULL; |
12511 | char *sh_arg = NULL; | |
12512 | enum show_type sh_type; | |
d1927ebe | 12513 | afi_t afi = AFI_MAX; |
718e3744 | 12514 | |
9f049418 | 12515 | bool uj = use_json(argc, argv); |
718e3744 | 12516 | |
d62a17ae | 12517 | int idx = 0; |
718e3744 | 12518 | |
9a8bdf1c PG |
12519 | /* [<vrf> VIEWVRFNAME] */ |
12520 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12521 | vrf = argv[idx + 1]->arg; | |
12522 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12523 | vrf = NULL; | |
12524 | } else if (argv_find(argv, argc, "view", &idx)) | |
12525 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12526 | vrf = argv[idx + 1]->arg; |
718e3744 | 12527 | |
d62a17ae | 12528 | idx++; |
d1927ebe AS |
12529 | |
12530 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12531 | sh_type = show_ipv4_all; | |
12532 | afi = AFI_IP; | |
12533 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12534 | sh_type = show_ipv6_all; | |
12535 | afi = AFI_IP6; | |
12536 | } else { | |
12537 | sh_type = show_all; | |
12538 | } | |
12539 | ||
d62a17ae | 12540 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12541 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12542 | || argv_find(argv, argc, "WORD", &idx)) { | |
12543 | sh_type = show_peer; | |
12544 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12545 | } |
12546 | ||
12547 | if (sh_type == show_peer && afi == AFI_IP) { | |
12548 | sh_type = show_ipv4_peer; | |
12549 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12550 | sh_type = show_ipv6_peer; | |
12551 | } | |
856ca177 | 12552 | |
d62a17ae | 12553 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12554 | } |
12555 | ||
716b2d8a | 12556 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12557 | paths' and `show ip mbgp paths'. Those functions results are the |
12558 | same.*/ | |
f412b39a | 12559 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12560 | show_ip_bgp_paths_cmd, |
46f296b4 | 12561 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12562 | SHOW_STR |
12563 | IP_STR | |
12564 | BGP_STR | |
46f296b4 | 12565 | BGP_SAFI_HELP_STR |
718e3744 | 12566 | "Path information\n") |
12567 | { | |
d62a17ae | 12568 | vty_out(vty, "Address Refcnt Path\n"); |
12569 | aspath_print_all_vty(vty); | |
12570 | return CMD_SUCCESS; | |
718e3744 | 12571 | } |
12572 | ||
718e3744 | 12573 | #include "hash.h" |
12574 | ||
e3b78da8 | 12575 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12576 | struct vty *vty) |
718e3744 | 12577 | { |
d62a17ae | 12578 | struct community *com; |
718e3744 | 12579 | |
e3b78da8 | 12580 | com = (struct community *)bucket->data; |
3f65c5b1 | 12581 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12582 | community_str(com, false)); |
718e3744 | 12583 | } |
12584 | ||
12585 | /* Show BGP's community internal data. */ | |
f412b39a | 12586 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12587 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12588 | "show [ip] bgp community-info", |
718e3744 | 12589 | SHOW_STR |
12590 | IP_STR | |
12591 | BGP_STR | |
12592 | "List all bgp community information\n") | |
12593 | { | |
d62a17ae | 12594 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12595 | |
d62a17ae | 12596 | hash_iterate(community_hash(), |
e3b78da8 | 12597 | (void (*)(struct hash_bucket *, |
d62a17ae | 12598 | void *))community_show_all_iterator, |
12599 | vty); | |
718e3744 | 12600 | |
d62a17ae | 12601 | return CMD_SUCCESS; |
718e3744 | 12602 | } |
12603 | ||
e3b78da8 | 12604 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12605 | struct vty *vty) |
57d187bc | 12606 | { |
d62a17ae | 12607 | struct lcommunity *lcom; |
57d187bc | 12608 | |
e3b78da8 | 12609 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12610 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12611 | lcommunity_str(lcom, false)); |
57d187bc JS |
12612 | } |
12613 | ||
12614 | /* Show BGP's community internal data. */ | |
12615 | DEFUN (show_ip_bgp_lcommunity_info, | |
12616 | show_ip_bgp_lcommunity_info_cmd, | |
12617 | "show ip bgp large-community-info", | |
12618 | SHOW_STR | |
12619 | IP_STR | |
12620 | BGP_STR | |
12621 | "List all bgp large-community information\n") | |
12622 | { | |
d62a17ae | 12623 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12624 | |
d62a17ae | 12625 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12626 | (void (*)(struct hash_bucket *, |
d62a17ae | 12627 | void *))lcommunity_show_all_iterator, |
12628 | vty); | |
57d187bc | 12629 | |
d62a17ae | 12630 | return CMD_SUCCESS; |
57d187bc | 12631 | } |
2986cac2 | 12632 | /* Graceful Restart */ |
12633 | ||
12634 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
12635 | struct bgp *bgp, |
12636 | bool use_json, | |
12637 | json_object *json) | |
2986cac2 | 12638 | { |
57d187bc JS |
12639 | |
12640 | ||
2986cac2 | 12641 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12642 | ||
7318ae88 | 12643 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 12644 | |
12645 | switch (bgp_global_gr_mode) { | |
12646 | ||
12647 | case GLOBAL_HELPER: | |
13909c4f | 12648 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12649 | break; |
12650 | ||
12651 | case GLOBAL_GR: | |
13909c4f | 12652 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12653 | break; |
12654 | ||
12655 | case GLOBAL_DISABLE: | |
13909c4f | 12656 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12657 | break; |
12658 | ||
12659 | case GLOBAL_INVALID: | |
2986cac2 | 12660 | vty_out(vty, |
2ba1fe69 | 12661 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12662 | break; |
12663 | } | |
12664 | vty_out(vty, "\n"); | |
12665 | } | |
12666 | ||
36235319 QY |
12667 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
12668 | enum show_type type, | |
12669 | const char *ip_str, | |
12670 | afi_t afi, bool use_json) | |
2986cac2 | 12671 | { |
12672 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12673 | afi = AFI_IP; | |
12674 | ||
12675 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12676 | ||
36235319 QY |
12677 | bgp_show_neighbor_graceful_restart_vty( |
12678 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 12679 | afi++; |
12680 | } | |
12681 | } else if (afi != AFI_MAX) { | |
36235319 QY |
12682 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
12683 | use_json); | |
2986cac2 | 12684 | } else { |
12685 | return CMD_ERR_INCOMPLETE; | |
12686 | } | |
12687 | ||
12688 | return CMD_SUCCESS; | |
12689 | } | |
12690 | /* Graceful Restart */ | |
12691 | ||
f412b39a | 12692 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12693 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12694 | "show [ip] bgp attribute-info", |
718e3744 | 12695 | SHOW_STR |
12696 | IP_STR | |
12697 | BGP_STR | |
12698 | "List all bgp attribute information\n") | |
12699 | { | |
d62a17ae | 12700 | attr_show_all(vty); |
12701 | return CMD_SUCCESS; | |
718e3744 | 12702 | } |
6b0655a2 | 12703 | |
03915806 CS |
12704 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12705 | afi_t afi, safi_t safi, | |
12706 | bool use_json, json_object *json) | |
53089bec | 12707 | { |
12708 | struct bgp *bgp; | |
12709 | struct listnode *node; | |
12710 | char *vname; | |
12711 | char buf1[INET6_ADDRSTRLEN]; | |
12712 | char *ecom_str; | |
12713 | vpn_policy_direction_t dir; | |
12714 | ||
03915806 | 12715 | if (json) { |
b46dfd20 DS |
12716 | json_object *json_import_vrfs = NULL; |
12717 | json_object *json_export_vrfs = NULL; | |
12718 | ||
b46dfd20 DS |
12719 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12720 | ||
53089bec | 12721 | if (!bgp) { |
b46dfd20 DS |
12722 | vty_out(vty, "%s\n", |
12723 | json_object_to_json_string_ext( | |
12724 | json, | |
12725 | JSON_C_TO_STRING_PRETTY)); | |
12726 | json_object_free(json); | |
12727 | ||
53089bec | 12728 | return CMD_WARNING; |
12729 | } | |
b46dfd20 | 12730 | |
94d4c685 DS |
12731 | /* Provide context for the block */ |
12732 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12733 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12734 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12735 | |
b46dfd20 DS |
12736 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12737 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12738 | json_object_string_add(json, "importFromVrfs", "none"); | |
12739 | json_object_string_add(json, "importRts", "none"); | |
12740 | } else { | |
6ce24e52 DS |
12741 | json_import_vrfs = json_object_new_array(); |
12742 | ||
b46dfd20 DS |
12743 | for (ALL_LIST_ELEMENTS_RO( |
12744 | bgp->vpn_policy[afi].import_vrf, | |
12745 | node, vname)) | |
12746 | json_object_array_add(json_import_vrfs, | |
12747 | json_object_new_string(vname)); | |
12748 | ||
b20875ea CS |
12749 | json_object_object_add(json, "importFromVrfs", |
12750 | json_import_vrfs); | |
b46dfd20 | 12751 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12752 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12753 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12754 | bgp->vpn_policy[afi].rtlist[dir], |
12755 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12756 | json_object_string_add(json, "importRts", |
12757 | ecom_str); | |
12758 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12759 | } else | |
12760 | json_object_string_add(json, "importRts", | |
12761 | "none"); | |
b46dfd20 DS |
12762 | } |
12763 | ||
12764 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12765 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12766 | json_object_string_add(json, "exportToVrfs", "none"); | |
12767 | json_object_string_add(json, "routeDistinguisher", | |
12768 | "none"); | |
12769 | json_object_string_add(json, "exportRts", "none"); | |
12770 | } else { | |
6ce24e52 DS |
12771 | json_export_vrfs = json_object_new_array(); |
12772 | ||
b46dfd20 DS |
12773 | for (ALL_LIST_ELEMENTS_RO( |
12774 | bgp->vpn_policy[afi].export_vrf, | |
12775 | node, vname)) | |
12776 | json_object_array_add(json_export_vrfs, | |
12777 | json_object_new_string(vname)); | |
12778 | json_object_object_add(json, "exportToVrfs", | |
12779 | json_export_vrfs); | |
12780 | json_object_string_add(json, "routeDistinguisher", | |
12781 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12782 | buf1, RD_ADDRSTRLEN)); | |
12783 | ||
12784 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12785 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12786 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12787 | bgp->vpn_policy[afi].rtlist[dir], |
12788 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12789 | json_object_string_add(json, "exportRts", |
12790 | ecom_str); | |
12791 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12792 | } else | |
12793 | json_object_string_add(json, "exportRts", | |
12794 | "none"); | |
b46dfd20 DS |
12795 | } |
12796 | ||
03915806 CS |
12797 | if (use_json) { |
12798 | vty_out(vty, "%s\n", | |
12799 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12800 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12801 | json_object_free(json); |
12802 | } | |
53089bec | 12803 | } else { |
b46dfd20 DS |
12804 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12805 | ||
53089bec | 12806 | if (!bgp) { |
b46dfd20 | 12807 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12808 | return CMD_WARNING; |
12809 | } | |
53089bec | 12810 | |
b46dfd20 DS |
12811 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12812 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12813 | vty_out(vty, | |
12814 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12815 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12816 | else { |
12817 | vty_out(vty, | |
12818 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 12819 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12820 | |
12821 | for (ALL_LIST_ELEMENTS_RO( | |
12822 | bgp->vpn_policy[afi].import_vrf, | |
12823 | node, vname)) | |
12824 | vty_out(vty, " %s\n", vname); | |
12825 | ||
12826 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
12827 | ecom_str = NULL; |
12828 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
12829 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12830 | bgp->vpn_policy[afi].rtlist[dir], |
12831 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 12832 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 12833 | |
b20875ea CS |
12834 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
12835 | } else | |
12836 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12837 | } |
53089bec | 12838 | |
b46dfd20 DS |
12839 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12840 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12841 | vty_out(vty, | |
12842 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 12843 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12844 | else { |
12845 | vty_out(vty, | |
04c9077f | 12846 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 12847 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12848 | |
12849 | for (ALL_LIST_ELEMENTS_RO( | |
12850 | bgp->vpn_policy[afi].export_vrf, | |
12851 | node, vname)) | |
12852 | vty_out(vty, " %s\n", vname); | |
12853 | ||
12854 | vty_out(vty, "RD: %s\n", | |
12855 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12856 | buf1, RD_ADDRSTRLEN)); | |
12857 | ||
12858 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12859 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12860 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12861 | bgp->vpn_policy[afi].rtlist[dir], |
12862 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12863 | vty_out(vty, "Export RT: %s\n", ecom_str); |
12864 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12865 | } else | |
12866 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12867 | } |
53089bec | 12868 | } |
12869 | ||
12870 | return CMD_SUCCESS; | |
12871 | } | |
12872 | ||
03915806 CS |
12873 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
12874 | safi_t safi, bool use_json) | |
12875 | { | |
12876 | struct listnode *node, *nnode; | |
12877 | struct bgp *bgp; | |
12878 | char *vrf_name = NULL; | |
12879 | json_object *json = NULL; | |
12880 | json_object *json_vrf = NULL; | |
12881 | json_object *json_vrfs = NULL; | |
12882 | ||
12883 | if (use_json) { | |
12884 | json = json_object_new_object(); | |
12885 | json_vrfs = json_object_new_object(); | |
12886 | } | |
12887 | ||
12888 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
12889 | ||
12890 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
12891 | vrf_name = bgp->name; | |
12892 | ||
12893 | if (use_json) { | |
12894 | json_vrf = json_object_new_object(); | |
12895 | } else { | |
12896 | vty_out(vty, "\nInstance %s:\n", | |
12897 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12898 | ? VRF_DEFAULT_NAME : bgp->name); | |
12899 | } | |
12900 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
12901 | if (use_json) { | |
12902 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12903 | json_object_object_add(json_vrfs, | |
12904 | VRF_DEFAULT_NAME, json_vrf); | |
12905 | else | |
12906 | json_object_object_add(json_vrfs, vrf_name, | |
12907 | json_vrf); | |
12908 | } | |
12909 | } | |
12910 | ||
12911 | if (use_json) { | |
12912 | json_object_object_add(json, "vrfs", json_vrfs); | |
12913 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
12914 | JSON_C_TO_STRING_PRETTY)); | |
12915 | json_object_free(json); | |
12916 | } | |
12917 | ||
12918 | return CMD_SUCCESS; | |
12919 | } | |
12920 | ||
53089bec | 12921 | /* "show [ip] bgp route-leak" command. */ |
12922 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
12923 | show_ip_bgp_route_leak_cmd, |
12924 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
12925 | SHOW_STR |
12926 | IP_STR | |
12927 | BGP_STR | |
12928 | BGP_INSTANCE_HELP_STR | |
12929 | BGP_AFI_HELP_STR | |
12930 | BGP_SAFI_HELP_STR | |
12931 | "Route leaking information\n" | |
12932 | JSON_STR) | |
53089bec | 12933 | { |
12934 | char *vrf = NULL; | |
12935 | afi_t afi = AFI_MAX; | |
12936 | safi_t safi = SAFI_MAX; | |
12937 | ||
9f049418 | 12938 | bool uj = use_json(argc, argv); |
53089bec | 12939 | int idx = 0; |
03915806 | 12940 | json_object *json = NULL; |
53089bec | 12941 | |
12942 | /* show [ip] bgp */ | |
12943 | if (argv_find(argv, argc, "ip", &idx)) { | |
12944 | afi = AFI_IP; | |
12945 | safi = SAFI_UNICAST; | |
12946 | } | |
12947 | /* [vrf VIEWVRFNAME] */ | |
12948 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
12949 | vty_out(vty, |
12950 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 12951 | return CMD_WARNING; |
12952 | } | |
12953 | ||
9a8bdf1c PG |
12954 | if (argv_find(argv, argc, "vrf", &idx)) { |
12955 | vrf = argv[idx + 1]->arg; | |
12956 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12957 | vrf = NULL; | |
12958 | } | |
53089bec | 12959 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
12960 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
12961 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
12962 | } | |
12963 | ||
12964 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
12965 | vty_out(vty, |
12966 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 12967 | return CMD_WARNING; |
12968 | } | |
12969 | ||
03915806 CS |
12970 | if (vrf && strmatch(vrf, "all")) |
12971 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
12972 | ||
12973 | if (uj) | |
12974 | json = json_object_new_object(); | |
12975 | ||
12976 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 12977 | } |
12978 | ||
d62a17ae | 12979 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
12980 | safi_t safi) | |
f186de26 | 12981 | { |
d62a17ae | 12982 | struct listnode *node, *nnode; |
12983 | struct bgp *bgp; | |
f186de26 | 12984 | |
d62a17ae | 12985 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
12986 | vty_out(vty, "\nInstance %s:\n", | |
12987 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12988 | ? VRF_DEFAULT_NAME |
d62a17ae | 12989 | : bgp->name); |
12990 | update_group_show(bgp, afi, safi, vty, 0); | |
12991 | } | |
f186de26 | 12992 | } |
12993 | ||
d62a17ae | 12994 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
12995 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 12996 | { |
d62a17ae | 12997 | struct bgp *bgp; |
4fb25c53 | 12998 | |
d62a17ae | 12999 | if (name) { |
13000 | if (strmatch(name, "all")) { | |
13001 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13002 | return CMD_SUCCESS; | |
13003 | } else { | |
13004 | bgp = bgp_lookup_by_name(name); | |
13005 | } | |
13006 | } else { | |
13007 | bgp = bgp_get_default(); | |
13008 | } | |
4fb25c53 | 13009 | |
d62a17ae | 13010 | if (bgp) |
13011 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13012 | return CMD_SUCCESS; | |
4fb25c53 DW |
13013 | } |
13014 | ||
8fe8a7f6 DS |
13015 | DEFUN (show_ip_bgp_updgrps, |
13016 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13017 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13018 | SHOW_STR |
13019 | IP_STR | |
13020 | BGP_STR | |
13021 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13022 | BGP_AFI_HELP_STR |
9bedbb1e | 13023 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13024 | "Detailed info about dynamic update groups\n" |
13025 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13026 | { |
d62a17ae | 13027 | char *vrf = NULL; |
13028 | afi_t afi = AFI_IP6; | |
13029 | safi_t safi = SAFI_UNICAST; | |
13030 | uint64_t subgrp_id = 0; | |
13031 | ||
13032 | int idx = 0; | |
13033 | ||
13034 | /* show [ip] bgp */ | |
13035 | if (argv_find(argv, argc, "ip", &idx)) | |
13036 | afi = AFI_IP; | |
9a8bdf1c PG |
13037 | /* [<vrf> VIEWVRFNAME] */ |
13038 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13039 | vrf = argv[idx + 1]->arg; | |
13040 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13041 | vrf = NULL; | |
13042 | } else if (argv_find(argv, argc, "view", &idx)) | |
13043 | /* [<view> VIEWVRFNAME] */ | |
13044 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13045 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13046 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13047 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13048 | } | |
5bf15956 | 13049 | |
d62a17ae | 13050 | /* get subgroup id, if provided */ |
13051 | idx = argc - 1; | |
13052 | if (argv[idx]->type == VARIABLE_TKN) | |
13053 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13054 | |
d62a17ae | 13055 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13056 | } |
13057 | ||
f186de26 | 13058 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13059 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13060 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13061 | SHOW_STR |
716b2d8a | 13062 | IP_STR |
f186de26 | 13063 | BGP_STR |
13064 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13065 | "Detailed info about dynamic update groups\n") |
f186de26 | 13066 | { |
d62a17ae | 13067 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13068 | return CMD_SUCCESS; | |
f186de26 | 13069 | } |
13070 | ||
43d3f4fc DS |
13071 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13072 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13073 | "show [ip] bgp l2vpn evpn update-groups", | |
13074 | SHOW_STR | |
13075 | IP_STR | |
13076 | BGP_STR | |
13077 | "l2vpn address family\n" | |
13078 | "evpn sub-address family\n" | |
13079 | "Detailed info about dynamic update groups\n") | |
13080 | { | |
13081 | char *vrf = NULL; | |
13082 | uint64_t subgrp_id = 0; | |
13083 | ||
13084 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13085 | return CMD_SUCCESS; | |
13086 | } | |
13087 | ||
5bf15956 DW |
13088 | DEFUN (show_bgp_updgrps_stats, |
13089 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13090 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13091 | SHOW_STR |
716b2d8a | 13092 | IP_STR |
3f9c7369 | 13093 | BGP_STR |
0c7b1b01 | 13094 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13095 | "Statistics\n") |
13096 | { | |
d62a17ae | 13097 | struct bgp *bgp; |
3f9c7369 | 13098 | |
d62a17ae | 13099 | bgp = bgp_get_default(); |
13100 | if (bgp) | |
13101 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13102 | |
d62a17ae | 13103 | return CMD_SUCCESS; |
3f9c7369 DS |
13104 | } |
13105 | ||
8386ac43 | 13106 | DEFUN (show_bgp_instance_updgrps_stats, |
13107 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13108 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13109 | SHOW_STR |
716b2d8a | 13110 | IP_STR |
8386ac43 | 13111 | BGP_STR |
13112 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13113 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13114 | "Statistics\n") |
13115 | { | |
d62a17ae | 13116 | int idx_word = 3; |
13117 | struct bgp *bgp; | |
8386ac43 | 13118 | |
d62a17ae | 13119 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13120 | if (bgp) | |
13121 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13122 | |
d62a17ae | 13123 | return CMD_SUCCESS; |
8386ac43 | 13124 | } |
13125 | ||
d62a17ae | 13126 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13127 | afi_t afi, safi_t safi, | |
13128 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13129 | { |
d62a17ae | 13130 | struct bgp *bgp; |
8386ac43 | 13131 | |
d62a17ae | 13132 | if (name) |
13133 | bgp = bgp_lookup_by_name(name); | |
13134 | else | |
13135 | bgp = bgp_get_default(); | |
8386ac43 | 13136 | |
d62a17ae | 13137 | if (bgp) { |
13138 | if (!strcmp(what, "advertise-queue")) | |
13139 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13140 | subgrp_id); | |
13141 | else if (!strcmp(what, "advertised-routes")) | |
13142 | update_group_show_advertised(bgp, afi, safi, vty, | |
13143 | subgrp_id); | |
13144 | else if (!strcmp(what, "packet-queue")) | |
13145 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13146 | subgrp_id); | |
13147 | } | |
3f9c7369 DS |
13148 | } |
13149 | ||
dc64bdec QY |
13150 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13151 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13152 | "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", | |
13153 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13154 | BGP_SAFI_HELP_STR | |
13155 | "Detailed info about dynamic update groups\n" | |
13156 | "Specific subgroup to display info for\n" | |
13157 | "Advertisement queue\n" | |
13158 | "Announced routes\n" | |
13159 | "Packet queue\n") | |
3f9c7369 | 13160 | { |
dc64bdec QY |
13161 | uint64_t subgrp_id = 0; |
13162 | afi_t afiz; | |
13163 | safi_t safiz; | |
13164 | if (sgid) | |
13165 | subgrp_id = strtoull(sgid, NULL, 10); | |
13166 | ||
13167 | if (!ip && !afi) | |
13168 | afiz = AFI_IP6; | |
13169 | if (!ip && afi) | |
13170 | afiz = bgp_vty_afi_from_str(afi); | |
13171 | if (ip && !afi) | |
13172 | afiz = AFI_IP; | |
13173 | if (ip && afi) { | |
13174 | afiz = bgp_vty_afi_from_str(afi); | |
13175 | if (afiz != AFI_IP) | |
13176 | vty_out(vty, | |
13177 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13178 | return CMD_WARNING; | |
13179 | } | |
d62a17ae | 13180 | |
dc64bdec | 13181 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13182 | |
dc64bdec | 13183 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13184 | return CMD_SUCCESS; |
13185 | } | |
13186 | ||
d62a17ae | 13187 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13188 | { | |
13189 | struct listnode *node, *nnode; | |
13190 | struct prefix *range; | |
13191 | struct peer *conf; | |
13192 | struct peer *peer; | |
13193 | char buf[PREFIX2STR_BUFFER]; | |
13194 | afi_t afi; | |
13195 | safi_t safi; | |
13196 | const char *peer_status; | |
13197 | const char *af_str; | |
13198 | int lr_count; | |
13199 | int dynamic; | |
13200 | int af_cfgd; | |
13201 | ||
13202 | conf = group->conf; | |
13203 | ||
13204 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13205 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13206 | group->name, conf->as); | |
d62a17ae | 13207 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13208 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13209 | group->name, group->bgp->as); | |
d62a17ae | 13210 | } else { |
13211 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13212 | } | |
f14e6fdb | 13213 | |
d62a17ae | 13214 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13215 | vty_out(vty, " Peer-group type is internal\n"); | |
13216 | else | |
13217 | vty_out(vty, " Peer-group type is external\n"); | |
13218 | ||
13219 | /* Display AFs configured. */ | |
13220 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13221 | FOREACH_AFI_SAFI (afi, safi) { |
13222 | if (conf->afc[afi][safi]) { | |
13223 | af_cfgd = 1; | |
5cb5f4d0 | 13224 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13225 | } |
05c7a1cc | 13226 | } |
d62a17ae | 13227 | if (!af_cfgd) |
13228 | vty_out(vty, " none\n"); | |
13229 | else | |
13230 | vty_out(vty, "\n"); | |
13231 | ||
13232 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13233 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13234 | if (afi == AFI_IP) | |
13235 | af_str = "IPv4"; | |
13236 | else if (afi == AFI_IP6) | |
13237 | af_str = "IPv6"; | |
13238 | else | |
13239 | af_str = "???"; | |
13240 | lr_count = listcount(group->listen_range[afi]); | |
13241 | if (lr_count) { | |
13242 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13243 | af_str); | |
13244 | ||
13245 | ||
13246 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13247 | nnode, range)) { | |
13248 | prefix2str(range, buf, sizeof(buf)); | |
13249 | vty_out(vty, " %s\n", buf); | |
13250 | } | |
13251 | } | |
13252 | } | |
f14e6fdb | 13253 | |
d62a17ae | 13254 | /* Display group members and their status */ |
13255 | if (listcount(group->peer)) { | |
13256 | vty_out(vty, " Peer-group members:\n"); | |
13257 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13258 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13259 | peer_status = "Idle (Admin)"; | |
13260 | else if (CHECK_FLAG(peer->sflags, | |
13261 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13262 | peer_status = "Idle (PfxCt)"; | |
13263 | else | |
13264 | peer_status = lookup_msg(bgp_status_msg, | |
13265 | peer->status, NULL); | |
13266 | ||
13267 | dynamic = peer_dynamic_neighbor(peer); | |
13268 | vty_out(vty, " %s %s %s \n", peer->host, | |
13269 | dynamic ? "(dynamic)" : "", peer_status); | |
13270 | } | |
13271 | } | |
f14e6fdb | 13272 | |
d62a17ae | 13273 | return CMD_SUCCESS; |
13274 | } | |
13275 | ||
ff9959b0 QY |
13276 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13277 | const char *group_name) | |
d62a17ae | 13278 | { |
ff9959b0 | 13279 | struct bgp *bgp; |
d62a17ae | 13280 | struct listnode *node, *nnode; |
13281 | struct peer_group *group; | |
ff9959b0 QY |
13282 | bool found = false; |
13283 | ||
13284 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13285 | ||
13286 | if (!bgp) { | |
9f049418 | 13287 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13288 | return CMD_WARNING; |
13289 | } | |
d62a17ae | 13290 | |
13291 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13292 | if (group_name) { |
13293 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13294 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13295 | found = true; |
13296 | break; | |
d62a17ae | 13297 | } |
ff9959b0 QY |
13298 | } else { |
13299 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13300 | } |
f14e6fdb | 13301 | } |
f14e6fdb | 13302 | |
ff9959b0 | 13303 | if (group_name && !found) |
d62a17ae | 13304 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13305 | |
d62a17ae | 13306 | return CMD_SUCCESS; |
f14e6fdb DS |
13307 | } |
13308 | ||
f14e6fdb DS |
13309 | DEFUN (show_ip_bgp_peer_groups, |
13310 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13311 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13312 | SHOW_STR |
13313 | IP_STR | |
13314 | BGP_STR | |
8386ac43 | 13315 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13316 | "Detailed information on BGP peer groups\n" |
13317 | "Peer group name\n") | |
f14e6fdb | 13318 | { |
d62a17ae | 13319 | char *vrf, *pg; |
d62a17ae | 13320 | int idx = 0; |
f14e6fdb | 13321 | |
a4d82a8a PZ |
13322 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13323 | : NULL; | |
d62a17ae | 13324 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13325 | |
ff9959b0 | 13326 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13327 | } |
3f9c7369 | 13328 | |
d6e3c605 | 13329 | |
718e3744 | 13330 | /* Redistribute VTY commands. */ |
13331 | ||
718e3744 | 13332 | DEFUN (bgp_redistribute_ipv4, |
13333 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13334 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13335 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13336 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13337 | { |
d62a17ae | 13338 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13339 | int idx_protocol = 1; | |
13340 | int type; | |
718e3744 | 13341 | |
d62a17ae | 13342 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13343 | if (type < 0) { | |
13344 | vty_out(vty, "%% Invalid route type\n"); | |
13345 | return CMD_WARNING_CONFIG_FAILED; | |
13346 | } | |
7f323236 | 13347 | |
d62a17ae | 13348 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13349 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13350 | } |
13351 | ||
d62a17ae | 13352 | ALIAS_HIDDEN( |
13353 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13354 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13355 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13356 | |
718e3744 | 13357 | DEFUN (bgp_redistribute_ipv4_rmap, |
13358 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13359 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13360 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13361 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13362 | "Route map reference\n" |
13363 | "Pointer to route-map entries\n") | |
13364 | { | |
d62a17ae | 13365 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13366 | int idx_protocol = 1; | |
13367 | int idx_word = 3; | |
13368 | int type; | |
13369 | struct bgp_redist *red; | |
e923dd62 | 13370 | bool changed; |
1de27621 DA |
13371 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13372 | vty, argv[idx_word]->arg); | |
718e3744 | 13373 | |
d62a17ae | 13374 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13375 | if (type < 0) { | |
13376 | vty_out(vty, "%% Invalid route type\n"); | |
13377 | return CMD_WARNING_CONFIG_FAILED; | |
13378 | } | |
718e3744 | 13379 | |
d62a17ae | 13380 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13381 | changed = |
13382 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13383 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13384 | } |
13385 | ||
d62a17ae | 13386 | ALIAS_HIDDEN( |
13387 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13388 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13389 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13390 | "Route map reference\n" | |
13391 | "Pointer to route-map entries\n") | |
596c17ba | 13392 | |
718e3744 | 13393 | DEFUN (bgp_redistribute_ipv4_metric, |
13394 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13395 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13396 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13397 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13398 | "Metric for redistributed routes\n" |
13399 | "Default metric\n") | |
13400 | { | |
d62a17ae | 13401 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13402 | int idx_protocol = 1; | |
13403 | int idx_number = 3; | |
13404 | int type; | |
d7c0a89a | 13405 | uint32_t metric; |
d62a17ae | 13406 | struct bgp_redist *red; |
e923dd62 | 13407 | bool changed; |
d62a17ae | 13408 | |
13409 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13410 | if (type < 0) { | |
13411 | vty_out(vty, "%% Invalid route type\n"); | |
13412 | return CMD_WARNING_CONFIG_FAILED; | |
13413 | } | |
13414 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13415 | ||
13416 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13417 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13418 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13419 | } |
13420 | ||
13421 | ALIAS_HIDDEN( | |
13422 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13423 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13424 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13425 | "Metric for redistributed routes\n" | |
13426 | "Default metric\n") | |
596c17ba | 13427 | |
718e3744 | 13428 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13429 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13430 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13431 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13432 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13433 | "Route map reference\n" |
13434 | "Pointer to route-map entries\n" | |
13435 | "Metric for redistributed routes\n" | |
13436 | "Default metric\n") | |
13437 | { | |
d62a17ae | 13438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13439 | int idx_protocol = 1; | |
13440 | int idx_word = 3; | |
13441 | int idx_number = 5; | |
13442 | int type; | |
d7c0a89a | 13443 | uint32_t metric; |
d62a17ae | 13444 | struct bgp_redist *red; |
e923dd62 | 13445 | bool changed; |
1de27621 DA |
13446 | struct route_map *route_map = |
13447 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13448 | |
13449 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13450 | if (type < 0) { | |
13451 | vty_out(vty, "%% Invalid route type\n"); | |
13452 | return CMD_WARNING_CONFIG_FAILED; | |
13453 | } | |
13454 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13455 | ||
13456 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13457 | changed = |
13458 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13459 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13460 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13461 | } |
13462 | ||
13463 | ALIAS_HIDDEN( | |
13464 | bgp_redistribute_ipv4_rmap_metric, | |
13465 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13466 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13467 | " route-map WORD metric (0-4294967295)", | |
13468 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13469 | "Route map reference\n" | |
13470 | "Pointer to route-map entries\n" | |
13471 | "Metric for redistributed routes\n" | |
13472 | "Default metric\n") | |
596c17ba | 13473 | |
718e3744 | 13474 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13475 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13476 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13477 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13478 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13479 | "Metric for redistributed routes\n" |
13480 | "Default metric\n" | |
13481 | "Route map reference\n" | |
13482 | "Pointer to route-map entries\n") | |
13483 | { | |
d62a17ae | 13484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13485 | int idx_protocol = 1; | |
13486 | int idx_number = 3; | |
13487 | int idx_word = 5; | |
13488 | int type; | |
d7c0a89a | 13489 | uint32_t metric; |
d62a17ae | 13490 | struct bgp_redist *red; |
e923dd62 | 13491 | bool changed; |
1de27621 DA |
13492 | struct route_map *route_map = |
13493 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13494 | |
13495 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13496 | if (type < 0) { | |
13497 | vty_out(vty, "%% Invalid route type\n"); | |
13498 | return CMD_WARNING_CONFIG_FAILED; | |
13499 | } | |
13500 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13501 | ||
13502 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13503 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13504 | changed |= |
13505 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13506 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13507 | } |
13508 | ||
13509 | ALIAS_HIDDEN( | |
13510 | bgp_redistribute_ipv4_metric_rmap, | |
13511 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13512 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13513 | " metric (0-4294967295) route-map WORD", | |
13514 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13515 | "Metric for redistributed routes\n" | |
13516 | "Default metric\n" | |
13517 | "Route map reference\n" | |
13518 | "Pointer to route-map entries\n") | |
596c17ba | 13519 | |
7c8ff89e DS |
13520 | DEFUN (bgp_redistribute_ipv4_ospf, |
13521 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13522 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13523 | "Redistribute information from another routing protocol\n" |
13524 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13525 | "Non-main Kernel Routing Table\n" |
13526 | "Instance ID/Table ID\n") | |
7c8ff89e | 13527 | { |
d62a17ae | 13528 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13529 | int idx_ospf_table = 1; | |
13530 | int idx_number = 2; | |
d7c0a89a QY |
13531 | unsigned short instance; |
13532 | unsigned short protocol; | |
7c8ff89e | 13533 | |
d62a17ae | 13534 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13535 | |
d62a17ae | 13536 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13537 | protocol = ZEBRA_ROUTE_OSPF; | |
13538 | else | |
13539 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13540 | |
d62a17ae | 13541 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13542 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13543 | } |
13544 | ||
d62a17ae | 13545 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13546 | "redistribute <ospf|table> (1-65535)", | |
13547 | "Redistribute information from another routing protocol\n" | |
13548 | "Open Shortest Path First (OSPFv2)\n" | |
13549 | "Non-main Kernel Routing Table\n" | |
13550 | "Instance ID/Table ID\n") | |
596c17ba | 13551 | |
7c8ff89e DS |
13552 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13553 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13554 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13555 | "Redistribute information from another routing protocol\n" |
13556 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13557 | "Non-main Kernel Routing Table\n" |
13558 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13559 | "Route map reference\n" |
13560 | "Pointer to route-map entries\n") | |
13561 | { | |
d62a17ae | 13562 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13563 | int idx_ospf_table = 1; | |
13564 | int idx_number = 2; | |
13565 | int idx_word = 4; | |
13566 | struct bgp_redist *red; | |
d7c0a89a | 13567 | unsigned short instance; |
d62a17ae | 13568 | int protocol; |
e923dd62 | 13569 | bool changed; |
1de27621 DA |
13570 | struct route_map *route_map = |
13571 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13572 | |
13573 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13574 | protocol = ZEBRA_ROUTE_OSPF; | |
13575 | else | |
13576 | protocol = ZEBRA_ROUTE_TABLE; | |
13577 | ||
13578 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13579 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13580 | changed = |
13581 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13582 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13583 | } |
13584 | ||
13585 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13586 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13587 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13588 | "Redistribute information from another routing protocol\n" | |
13589 | "Open Shortest Path First (OSPFv2)\n" | |
13590 | "Non-main Kernel Routing Table\n" | |
13591 | "Instance ID/Table ID\n" | |
13592 | "Route map reference\n" | |
13593 | "Pointer to route-map entries\n") | |
596c17ba | 13594 | |
7c8ff89e DS |
13595 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13596 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13597 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13598 | "Redistribute information from another routing protocol\n" |
13599 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13600 | "Non-main Kernel Routing Table\n" |
13601 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13602 | "Metric for redistributed routes\n" |
13603 | "Default metric\n") | |
13604 | { | |
d62a17ae | 13605 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13606 | int idx_ospf_table = 1; | |
13607 | int idx_number = 2; | |
13608 | int idx_number_2 = 4; | |
d7c0a89a | 13609 | uint32_t metric; |
d62a17ae | 13610 | struct bgp_redist *red; |
d7c0a89a | 13611 | unsigned short instance; |
d62a17ae | 13612 | int protocol; |
e923dd62 | 13613 | bool changed; |
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); | |
e923dd62 | 13624 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13625 | metric); | |
13626 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13627 | } |
13628 | ||
13629 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13630 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13631 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13632 | "Redistribute information from another routing protocol\n" | |
13633 | "Open Shortest Path First (OSPFv2)\n" | |
13634 | "Non-main Kernel Routing Table\n" | |
13635 | "Instance ID/Table ID\n" | |
13636 | "Metric for redistributed routes\n" | |
13637 | "Default metric\n") | |
596c17ba | 13638 | |
7c8ff89e DS |
13639 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13640 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13641 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13642 | "Redistribute information from another routing protocol\n" |
13643 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13644 | "Non-main Kernel Routing Table\n" |
13645 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13646 | "Route map reference\n" |
13647 | "Pointer to route-map entries\n" | |
13648 | "Metric for redistributed routes\n" | |
13649 | "Default metric\n") | |
13650 | { | |
d62a17ae | 13651 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13652 | int idx_ospf_table = 1; | |
13653 | int idx_number = 2; | |
13654 | int idx_word = 4; | |
13655 | int idx_number_2 = 6; | |
d7c0a89a | 13656 | uint32_t metric; |
d62a17ae | 13657 | struct bgp_redist *red; |
d7c0a89a | 13658 | unsigned short instance; |
d62a17ae | 13659 | int protocol; |
e923dd62 | 13660 | bool changed; |
1de27621 DA |
13661 | struct route_map *route_map = |
13662 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13663 | |
13664 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13665 | protocol = ZEBRA_ROUTE_OSPF; | |
13666 | else | |
13667 | protocol = ZEBRA_ROUTE_TABLE; | |
13668 | ||
13669 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13670 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13671 | ||
13672 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13673 | changed = |
13674 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13675 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13676 | metric); | |
13677 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13678 | } |
13679 | ||
13680 | ALIAS_HIDDEN( | |
13681 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13682 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13683 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13684 | "Redistribute information from another routing protocol\n" | |
13685 | "Open Shortest Path First (OSPFv2)\n" | |
13686 | "Non-main Kernel Routing Table\n" | |
13687 | "Instance ID/Table ID\n" | |
13688 | "Route map reference\n" | |
13689 | "Pointer to route-map entries\n" | |
13690 | "Metric for redistributed routes\n" | |
13691 | "Default metric\n") | |
596c17ba | 13692 | |
7c8ff89e DS |
13693 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13694 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13695 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13696 | "Redistribute information from another routing protocol\n" |
13697 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13698 | "Non-main Kernel Routing Table\n" |
13699 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13700 | "Metric for redistributed routes\n" |
13701 | "Default metric\n" | |
13702 | "Route map reference\n" | |
13703 | "Pointer to route-map entries\n") | |
13704 | { | |
d62a17ae | 13705 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13706 | int idx_ospf_table = 1; | |
13707 | int idx_number = 2; | |
13708 | int idx_number_2 = 4; | |
13709 | int idx_word = 6; | |
d7c0a89a | 13710 | uint32_t metric; |
d62a17ae | 13711 | struct bgp_redist *red; |
d7c0a89a | 13712 | unsigned short instance; |
d62a17ae | 13713 | int protocol; |
e923dd62 | 13714 | bool changed; |
1de27621 DA |
13715 | struct route_map *route_map = |
13716 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13717 | |
13718 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13719 | protocol = ZEBRA_ROUTE_OSPF; | |
13720 | else | |
13721 | protocol = ZEBRA_ROUTE_TABLE; | |
13722 | ||
13723 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13724 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13725 | ||
13726 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13727 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13728 | metric); | |
1de27621 DA |
13729 | changed |= |
13730 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13731 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13732 | } |
13733 | ||
13734 | ALIAS_HIDDEN( | |
13735 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13736 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13737 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13738 | "Redistribute information from another routing protocol\n" | |
13739 | "Open Shortest Path First (OSPFv2)\n" | |
13740 | "Non-main Kernel Routing Table\n" | |
13741 | "Instance ID/Table ID\n" | |
13742 | "Metric for redistributed routes\n" | |
13743 | "Default metric\n" | |
13744 | "Route map reference\n" | |
13745 | "Pointer to route-map entries\n") | |
596c17ba | 13746 | |
7c8ff89e DS |
13747 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13748 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13749 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13750 | NO_STR |
13751 | "Redistribute information from another routing protocol\n" | |
13752 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13753 | "Non-main Kernel Routing Table\n" |
31500417 DW |
13754 | "Instance ID/Table ID\n" |
13755 | "Metric for redistributed routes\n" | |
13756 | "Default metric\n" | |
13757 | "Route map reference\n" | |
13758 | "Pointer to route-map entries\n") | |
7c8ff89e | 13759 | { |
d62a17ae | 13760 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13761 | int idx_ospf_table = 2; | |
13762 | int idx_number = 3; | |
d7c0a89a | 13763 | unsigned short instance; |
d62a17ae | 13764 | int protocol; |
13765 | ||
13766 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13767 | protocol = ZEBRA_ROUTE_OSPF; | |
13768 | else | |
13769 | protocol = ZEBRA_ROUTE_TABLE; | |
13770 | ||
13771 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13772 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13773 | } | |
13774 | ||
13775 | ALIAS_HIDDEN( | |
13776 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13777 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13778 | NO_STR |
13779 | "Redistribute information from another routing protocol\n" | |
13780 | "Open Shortest Path First (OSPFv2)\n" | |
13781 | "Non-main Kernel Routing Table\n" | |
13782 | "Instance ID/Table ID\n" | |
13783 | "Metric for redistributed routes\n" | |
13784 | "Default metric\n" | |
13785 | "Route map reference\n" | |
13786 | "Pointer to route-map entries\n") | |
596c17ba | 13787 | |
718e3744 | 13788 | DEFUN (no_bgp_redistribute_ipv4, |
13789 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13790 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13791 | NO_STR |
13792 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13793 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13794 | "Metric for redistributed routes\n" |
13795 | "Default metric\n" | |
13796 | "Route map reference\n" | |
13797 | "Pointer to route-map entries\n") | |
718e3744 | 13798 | { |
d62a17ae | 13799 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13800 | int idx_protocol = 2; | |
13801 | int type; | |
13802 | ||
13803 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13804 | if (type < 0) { | |
13805 | vty_out(vty, "%% Invalid route type\n"); | |
13806 | return CMD_WARNING_CONFIG_FAILED; | |
13807 | } | |
13808 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13809 | } | |
13810 | ||
13811 | ALIAS_HIDDEN( | |
13812 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13813 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13814 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13815 | NO_STR |
13816 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13817 | "Metric for redistributed routes\n" | |
13818 | "Default metric\n" | |
13819 | "Route map reference\n" | |
13820 | "Pointer to route-map entries\n") | |
596c17ba | 13821 | |
718e3744 | 13822 | DEFUN (bgp_redistribute_ipv6, |
13823 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 13824 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 13825 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13826 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 13827 | { |
d62a17ae | 13828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13829 | int idx_protocol = 1; | |
13830 | int type; | |
718e3744 | 13831 | |
d62a17ae | 13832 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13833 | if (type < 0) { | |
13834 | vty_out(vty, "%% Invalid route type\n"); | |
13835 | return CMD_WARNING_CONFIG_FAILED; | |
13836 | } | |
718e3744 | 13837 | |
d62a17ae | 13838 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13839 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 13840 | } |
13841 | ||
13842 | DEFUN (bgp_redistribute_ipv6_rmap, | |
13843 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 13844 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13845 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13846 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13847 | "Route map reference\n" |
13848 | "Pointer to route-map entries\n") | |
13849 | { | |
d62a17ae | 13850 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13851 | int idx_protocol = 1; | |
13852 | int idx_word = 3; | |
13853 | int type; | |
13854 | struct bgp_redist *red; | |
e923dd62 | 13855 | bool changed; |
1de27621 DA |
13856 | struct route_map *route_map = |
13857 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 13858 | |
d62a17ae | 13859 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13860 | if (type < 0) { | |
13861 | vty_out(vty, "%% Invalid route type\n"); | |
13862 | return CMD_WARNING_CONFIG_FAILED; | |
13863 | } | |
718e3744 | 13864 | |
d62a17ae | 13865 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13866 | changed = |
13867 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13868 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13869 | } |
13870 | ||
13871 | DEFUN (bgp_redistribute_ipv6_metric, | |
13872 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 13873 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13874 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13875 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13876 | "Metric for redistributed routes\n" |
13877 | "Default metric\n") | |
13878 | { | |
d62a17ae | 13879 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13880 | int idx_protocol = 1; | |
13881 | int idx_number = 3; | |
13882 | int type; | |
d7c0a89a | 13883 | uint32_t metric; |
d62a17ae | 13884 | struct bgp_redist *red; |
e923dd62 | 13885 | bool changed; |
d62a17ae | 13886 | |
13887 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13888 | if (type < 0) { | |
13889 | vty_out(vty, "%% Invalid route type\n"); | |
13890 | return CMD_WARNING_CONFIG_FAILED; | |
13891 | } | |
13892 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13893 | |
d62a17ae | 13894 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13895 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
13896 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13897 | } |
13898 | ||
13899 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
13900 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 13901 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13902 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13903 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13904 | "Route map reference\n" |
13905 | "Pointer to route-map entries\n" | |
13906 | "Metric for redistributed routes\n" | |
13907 | "Default metric\n") | |
13908 | { | |
d62a17ae | 13909 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13910 | int idx_protocol = 1; | |
13911 | int idx_word = 3; | |
13912 | int idx_number = 5; | |
13913 | int type; | |
d7c0a89a | 13914 | uint32_t metric; |
d62a17ae | 13915 | struct bgp_redist *red; |
e923dd62 | 13916 | bool changed; |
1de27621 DA |
13917 | struct route_map *route_map = |
13918 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13919 | |
13920 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13921 | if (type < 0) { | |
13922 | vty_out(vty, "%% Invalid route type\n"); | |
13923 | return CMD_WARNING_CONFIG_FAILED; | |
13924 | } | |
13925 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13926 | |
d62a17ae | 13927 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13928 | changed = |
13929 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13930 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
13931 | metric); | |
13932 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13933 | } |
13934 | ||
13935 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
13936 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 13937 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13938 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13939 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13940 | "Metric for redistributed routes\n" |
13941 | "Default metric\n" | |
13942 | "Route map reference\n" | |
13943 | "Pointer to route-map entries\n") | |
13944 | { | |
d62a17ae | 13945 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13946 | int idx_protocol = 1; | |
13947 | int idx_number = 3; | |
13948 | int idx_word = 5; | |
13949 | int type; | |
d7c0a89a | 13950 | uint32_t metric; |
d62a17ae | 13951 | struct bgp_redist *red; |
e923dd62 | 13952 | bool changed; |
1de27621 DA |
13953 | struct route_map *route_map = |
13954 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13955 | |
13956 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13957 | if (type < 0) { | |
13958 | vty_out(vty, "%% Invalid route type\n"); | |
13959 | return CMD_WARNING_CONFIG_FAILED; | |
13960 | } | |
13961 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13962 | |
d62a17ae | 13963 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13964 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
13965 | metric); | |
1de27621 DA |
13966 | changed |= |
13967 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13968 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13969 | } |
13970 | ||
13971 | DEFUN (no_bgp_redistribute_ipv6, | |
13972 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 13973 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13974 | NO_STR |
13975 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13976 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
13977 | "Metric for redistributed routes\n" |
13978 | "Default metric\n" | |
13979 | "Route map reference\n" | |
13980 | "Pointer to route-map entries\n") | |
718e3744 | 13981 | { |
d62a17ae | 13982 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13983 | int idx_protocol = 2; | |
13984 | int type; | |
718e3744 | 13985 | |
d62a17ae | 13986 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13987 | if (type < 0) { | |
13988 | vty_out(vty, "%% Invalid route type\n"); | |
13989 | return CMD_WARNING_CONFIG_FAILED; | |
13990 | } | |
718e3744 | 13991 | |
d62a17ae | 13992 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
13993 | } | |
13994 | ||
dd65f45e DL |
13995 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
13996 | afi_t afi, safi_t safi) | |
d62a17ae | 13997 | { |
13998 | int i; | |
13999 | ||
14000 | /* Unicast redistribution only. */ | |
14001 | if (safi != SAFI_UNICAST) | |
2b791107 | 14002 | return; |
d62a17ae | 14003 | |
14004 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14005 | /* Redistribute BGP does not make sense. */ | |
14006 | if (i != ZEBRA_ROUTE_BGP) { | |
14007 | struct list *red_list; | |
14008 | struct listnode *node; | |
14009 | struct bgp_redist *red; | |
14010 | ||
14011 | red_list = bgp->redist[afi][i]; | |
14012 | if (!red_list) | |
14013 | continue; | |
14014 | ||
14015 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14016 | /* "redistribute" configuration. */ |
14017 | vty_out(vty, " redistribute %s", | |
14018 | zebra_route_string(i)); | |
14019 | if (red->instance) | |
14020 | vty_out(vty, " %d", red->instance); | |
14021 | if (red->redist_metric_flag) | |
14022 | vty_out(vty, " metric %u", | |
14023 | red->redist_metric); | |
14024 | if (red->rmap.name) | |
14025 | vty_out(vty, " route-map %s", | |
14026 | red->rmap.name); | |
14027 | vty_out(vty, "\n"); | |
14028 | } | |
14029 | } | |
14030 | } | |
718e3744 | 14031 | } |
6b0655a2 | 14032 | |
dd65f45e DL |
14033 | /* peer-group helpers for config-write */ |
14034 | ||
14035 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14036 | { | |
14037 | if (!peer_group_active(peer)) { | |
14038 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14039 | return !CHECK_FLAG(peer->flags, flag); | |
14040 | else | |
14041 | return !!CHECK_FLAG(peer->flags, flag); | |
14042 | } | |
14043 | ||
14044 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14045 | } | |
14046 | ||
14047 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14048 | uint32_t flag) | |
14049 | { | |
14050 | if (!peer_group_active(peer)) { | |
14051 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14052 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14053 | else | |
14054 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14055 | } | |
14056 | ||
14057 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14058 | } | |
14059 | ||
14060 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14061 | uint8_t type, int direct) | |
14062 | { | |
14063 | struct bgp_filter *filter; | |
14064 | ||
14065 | if (peer_group_active(peer)) | |
14066 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14067 | type); | |
14068 | ||
14069 | filter = &peer->filter[afi][safi]; | |
14070 | switch (type) { | |
14071 | case PEER_FT_DISTRIBUTE_LIST: | |
14072 | return !!(filter->dlist[direct].name); | |
14073 | case PEER_FT_FILTER_LIST: | |
14074 | return !!(filter->aslist[direct].name); | |
14075 | case PEER_FT_PREFIX_LIST: | |
14076 | return !!(filter->plist[direct].name); | |
14077 | case PEER_FT_ROUTE_MAP: | |
14078 | return !!(filter->map[direct].name); | |
14079 | case PEER_FT_UNSUPPRESS_MAP: | |
14080 | return !!(filter->usmap.name); | |
14081 | default: | |
14082 | return false; | |
14083 | } | |
14084 | } | |
14085 | ||
14086 | /* Return true if the addpath type is set for peer and different from | |
14087 | * peer-group. | |
14088 | */ | |
14089 | static int peergroup_af_addpath_check(struct peer *peer, afi_t afi, safi_t safi) | |
14090 | { | |
14091 | enum bgp_addpath_strat type, g_type; | |
14092 | ||
14093 | type = peer->addpath_type[afi][safi]; | |
14094 | ||
14095 | if (type != BGP_ADDPATH_NONE) { | |
14096 | if (peer_group_active(peer)) { | |
14097 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14098 | ||
14099 | if (type != g_type) | |
14100 | return 1; | |
14101 | else | |
14102 | return 0; | |
14103 | } | |
14104 | ||
14105 | return 1; | |
14106 | } | |
14107 | ||
14108 | return 0; | |
14109 | } | |
14110 | ||
b9c7bc5a | 14111 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14112 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14113 | afi_t afi) |
14114 | { | |
b9c7bc5a | 14115 | int indent = 2; |
ddb5b488 | 14116 | |
8a066a70 PG |
14117 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
14118 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
14119 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
14120 | bgp->vpn_policy[afi] | |
bb4f6190 | 14121 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14122 | else |
14123 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14124 | bgp->vpn_policy[afi] | |
14125 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14126 | } | |
12a844a5 DS |
14127 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14128 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14129 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14130 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14131 | return; | |
14132 | ||
e70e9f8e PZ |
14133 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14134 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14135 | ||
14136 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14137 | ||
14138 | } else { | |
14139 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14140 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14141 | bgp->vpn_policy[afi].tovpn_label); | |
14142 | } | |
ddb5b488 PZ |
14143 | } |
14144 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14145 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14146 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14147 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14148 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14149 | sizeof(buf))); | |
14150 | } | |
14151 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14152 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14153 | ||
14154 | char buf[PREFIX_STRLEN]; | |
14155 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14156 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14157 | sizeof(buf))) { | |
14158 | ||
b9c7bc5a PZ |
14159 | vty_out(vty, "%*snexthop vpn export %s\n", |
14160 | indent, "", buf); | |
ddb5b488 PZ |
14161 | } |
14162 | } | |
14163 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14164 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14165 | && ecommunity_cmp( | |
14166 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14167 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14168 | ||
14169 | char *b = ecommunity_ecom2str( | |
14170 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14171 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14172 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14173 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14174 | } else { | |
14175 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14176 | char *b = ecommunity_ecom2str( | |
14177 | bgp->vpn_policy[afi] | |
14178 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14179 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14180 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14181 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14182 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14183 | } | |
14184 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14185 | char *b = ecommunity_ecom2str( | |
14186 | bgp->vpn_policy[afi] | |
14187 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14188 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14189 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14190 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14191 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14192 | } | |
14193 | } | |
bb4f6190 DS |
14194 | |
14195 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14196 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14197 | bgp->vpn_policy[afi] |
14198 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14199 | |
301ad80a PG |
14200 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14201 | char *b = ecommunity_ecom2str( | |
14202 | bgp->vpn_policy[afi] | |
14203 | .import_redirect_rtlist, | |
14204 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14205 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14206 | |
301ad80a PG |
14207 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14208 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14209 | } | |
ddb5b488 PZ |
14210 | } |
14211 | ||
dd65f45e DL |
14212 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14213 | afi_t afi, safi_t safi) | |
14214 | { | |
14215 | struct bgp_filter *filter; | |
14216 | char *addr; | |
14217 | ||
14218 | addr = peer->host; | |
14219 | filter = &peer->filter[afi][safi]; | |
14220 | ||
14221 | /* distribute-list. */ | |
14222 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14223 | FILTER_IN)) | |
14224 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14225 | filter->dlist[FILTER_IN].name); | |
14226 | ||
14227 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14228 | FILTER_OUT)) | |
14229 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14230 | filter->dlist[FILTER_OUT].name); | |
14231 | ||
14232 | /* prefix-list. */ | |
14233 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14234 | FILTER_IN)) | |
14235 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14236 | filter->plist[FILTER_IN].name); | |
14237 | ||
14238 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14239 | FILTER_OUT)) | |
14240 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14241 | filter->plist[FILTER_OUT].name); | |
14242 | ||
14243 | /* route-map. */ | |
14244 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14245 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14246 | filter->map[RMAP_IN].name); | |
14247 | ||
14248 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14249 | RMAP_OUT)) | |
14250 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14251 | filter->map[RMAP_OUT].name); | |
14252 | ||
14253 | /* unsuppress-map */ | |
14254 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14255 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14256 | filter->usmap.name); | |
14257 | ||
14258 | /* filter-list. */ | |
14259 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14260 | FILTER_IN)) | |
14261 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14262 | filter->aslist[FILTER_IN].name); | |
14263 | ||
14264 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14265 | FILTER_OUT)) | |
14266 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14267 | filter->aslist[FILTER_OUT].name); | |
14268 | } | |
14269 | ||
14270 | /* BGP peer configuration display function. */ | |
14271 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14272 | struct peer *peer) | |
14273 | { | |
14274 | struct peer *g_peer = NULL; | |
14275 | char buf[SU_ADDRSTRLEN]; | |
14276 | char *addr; | |
14277 | int if_pg_printed = false; | |
14278 | int if_ras_printed = false; | |
14279 | ||
14280 | /* Skip dynamic neighbors. */ | |
14281 | if (peer_dynamic_neighbor(peer)) | |
14282 | return; | |
14283 | ||
14284 | if (peer->conf_if) | |
14285 | addr = peer->conf_if; | |
14286 | else | |
14287 | addr = peer->host; | |
14288 | ||
14289 | /************************************ | |
14290 | ****** Global to the neighbor ****** | |
14291 | ************************************/ | |
14292 | if (peer->conf_if) { | |
14293 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14294 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14295 | else | |
14296 | vty_out(vty, " neighbor %s interface", addr); | |
14297 | ||
14298 | if (peer_group_active(peer)) { | |
14299 | vty_out(vty, " peer-group %s", peer->group->name); | |
14300 | if_pg_printed = true; | |
14301 | } else if (peer->as_type == AS_SPECIFIED) { | |
14302 | vty_out(vty, " remote-as %u", peer->as); | |
14303 | if_ras_printed = true; | |
14304 | } else if (peer->as_type == AS_INTERNAL) { | |
14305 | vty_out(vty, " remote-as internal"); | |
14306 | if_ras_printed = true; | |
14307 | } else if (peer->as_type == AS_EXTERNAL) { | |
14308 | vty_out(vty, " remote-as external"); | |
14309 | if_ras_printed = true; | |
14310 | } | |
14311 | ||
14312 | vty_out(vty, "\n"); | |
14313 | } | |
14314 | ||
14315 | /* remote-as and peer-group */ | |
14316 | /* peer is a member of a peer-group */ | |
14317 | if (peer_group_active(peer)) { | |
14318 | g_peer = peer->group->conf; | |
14319 | ||
14320 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14321 | if (peer->as_type == AS_SPECIFIED) { | |
14322 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14323 | addr, peer->as); | |
14324 | } else if (peer->as_type == AS_INTERNAL) { | |
14325 | vty_out(vty, | |
14326 | " neighbor %s remote-as internal\n", | |
14327 | addr); | |
14328 | } else if (peer->as_type == AS_EXTERNAL) { | |
14329 | vty_out(vty, | |
14330 | " neighbor %s remote-as external\n", | |
14331 | addr); | |
14332 | } | |
14333 | } | |
14334 | ||
14335 | /* For swpX peers we displayed the peer-group | |
14336 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14337 | if (!if_pg_printed) | |
14338 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14339 | peer->group->name); | |
14340 | } | |
14341 | ||
14342 | /* peer is NOT a member of a peer-group */ | |
14343 | else { | |
14344 | /* peer is a peer-group, declare the peer-group */ | |
14345 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14346 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14347 | } | |
14348 | ||
14349 | if (!if_ras_printed) { | |
14350 | if (peer->as_type == AS_SPECIFIED) { | |
14351 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14352 | addr, peer->as); | |
14353 | } else if (peer->as_type == AS_INTERNAL) { | |
14354 | vty_out(vty, | |
14355 | " neighbor %s remote-as internal\n", | |
14356 | addr); | |
14357 | } else if (peer->as_type == AS_EXTERNAL) { | |
14358 | vty_out(vty, | |
14359 | " neighbor %s remote-as external\n", | |
14360 | addr); | |
14361 | } | |
14362 | } | |
14363 | } | |
14364 | ||
14365 | /* local-as */ | |
14366 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14367 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14368 | peer->change_local_as); | |
14369 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14370 | vty_out(vty, " no-prepend"); | |
14371 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14372 | vty_out(vty, " replace-as"); | |
14373 | vty_out(vty, "\n"); | |
14374 | } | |
14375 | ||
14376 | /* description */ | |
14377 | if (peer->desc) { | |
14378 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14379 | } | |
14380 | ||
14381 | /* shutdown */ | |
14382 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14383 | if (peer->tx_shutdown_message) | |
14384 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14385 | peer->tx_shutdown_message); | |
14386 | else | |
14387 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14388 | } | |
14389 | ||
14390 | /* bfd */ | |
14391 | if (peer->bfd_info) { | |
14392 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14393 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14394 | } | |
14395 | } | |
14396 | ||
14397 | /* password */ | |
14398 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14399 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14400 | peer->password); | |
14401 | ||
14402 | /* neighbor solo */ | |
14403 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14404 | if (!peer_group_active(peer)) { | |
14405 | vty_out(vty, " neighbor %s solo\n", addr); | |
14406 | } | |
14407 | } | |
14408 | ||
14409 | /* BGP port */ | |
14410 | if (peer->port != BGP_PORT_DEFAULT) { | |
14411 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14412 | } | |
14413 | ||
14414 | /* Local interface name */ | |
14415 | if (peer->ifname) { | |
14416 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14417 | } | |
14418 | ||
14419 | /* passive */ | |
14420 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14421 | vty_out(vty, " neighbor %s passive\n", addr); | |
14422 | ||
14423 | /* ebgp-multihop */ | |
14424 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14425 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14426 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14427 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14428 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14429 | peer->ttl); | |
14430 | } | |
14431 | } | |
14432 | ||
14433 | /* ttl-security hops */ | |
e2521429 | 14434 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14435 | if (!peer_group_active(peer) |
14436 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14437 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14438 | addr, peer->gtsm_hops); | |
14439 | } | |
14440 | } | |
14441 | ||
14442 | /* disable-connected-check */ | |
14443 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14444 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14445 | ||
14446 | /* enforce-first-as */ | |
14447 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14448 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14449 | ||
14450 | /* update-source */ | |
14451 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14452 | if (peer->update_source) | |
14453 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14454 | sockunion2str(peer->update_source, buf, | |
14455 | SU_ADDRSTRLEN)); | |
14456 | else if (peer->update_if) | |
14457 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14458 | peer->update_if); | |
14459 | } | |
14460 | ||
14461 | /* advertisement-interval */ | |
14462 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14463 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14464 | peer->routeadv); | |
14465 | ||
14466 | /* timers */ | |
14467 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14468 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14469 | peer->keepalive, peer->holdtime); | |
14470 | ||
14471 | /* timers connect */ | |
14472 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14473 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14474 | peer->connect); | |
5d5393b9 DL |
14475 | /* need special-case handling for changed default values due to |
14476 | * config profile / version (because there is no "timers bgp connect" | |
14477 | * command, we need to save this per-peer :/) | |
14478 | */ | |
14479 | else if (!peer_group_active(peer) && !peer->connect && | |
14480 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14481 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14482 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14483 | |
14484 | /* capability dynamic */ | |
14485 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14486 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14487 | ||
14488 | /* capability extended-nexthop */ | |
14489 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14490 | if (!peer->conf_if) { | |
14491 | if (CHECK_FLAG(peer->flags_invert, | |
14492 | PEER_FLAG_CAPABILITY_ENHE)) | |
14493 | vty_out(vty, | |
14494 | " no neighbor %s capability extended-nexthop\n", | |
14495 | addr); | |
14496 | else | |
14497 | vty_out(vty, | |
14498 | " neighbor %s capability extended-nexthop\n", | |
14499 | addr); | |
14500 | } | |
14501 | } | |
14502 | ||
14503 | /* dont-capability-negotiation */ | |
14504 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14505 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14506 | ||
14507 | /* override-capability */ | |
14508 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14509 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14510 | ||
14511 | /* strict-capability-match */ | |
14512 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14513 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14514 | ||
14515 | /* Sender side AS path loop detection. */ | |
14516 | if (peer->as_path_loop_detection) | |
14517 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14518 | addr); | |
cfd47646 | 14519 | |
14520 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14521 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14522 | |
14523 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14524 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14525 | vty_out(vty, |
14526 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14527 | } else if (CHECK_FLAG( |
14528 | peer->peer_gr_new_status_flag, | |
14529 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14530 | vty_out(vty, |
14531 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14532 | } else if ( |
14533 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14534 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14535 | && !(CHECK_FLAG( | |
14536 | peer->peer_gr_new_status_flag, | |
14537 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14538 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14539 | addr); | |
cfd47646 | 14540 | } |
14541 | } | |
dd65f45e DL |
14542 | } |
14543 | ||
14544 | /* BGP peer configuration display function. */ | |
14545 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14546 | struct peer *peer, afi_t afi, safi_t safi) | |
14547 | { | |
14548 | struct peer *g_peer = NULL; | |
14549 | char *addr; | |
14550 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14551 | ||
14552 | /* Skip dynamic neighbors. */ | |
14553 | if (peer_dynamic_neighbor(peer)) | |
14554 | return; | |
14555 | ||
14556 | if (peer->conf_if) | |
14557 | addr = peer->conf_if; | |
14558 | else | |
14559 | addr = peer->host; | |
14560 | ||
14561 | /************************************ | |
14562 | ****** Per AF to the neighbor ****** | |
14563 | ************************************/ | |
14564 | if (peer_group_active(peer)) { | |
14565 | g_peer = peer->group->conf; | |
14566 | ||
14567 | /* If the peer-group is active but peer is not, print a 'no | |
14568 | * activate' */ | |
14569 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14570 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14571 | } | |
14572 | ||
14573 | /* If the peer-group is not active but peer is, print an | |
14574 | 'activate' */ | |
14575 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14576 | vty_out(vty, " neighbor %s activate\n", addr); | |
14577 | } | |
14578 | } else { | |
14579 | if (peer->afc[afi][safi]) { | |
14580 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14581 | if (CHECK_FLAG(bgp->flags, |
14582 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14583 | vty_out(vty, " neighbor %s activate\n", |
14584 | addr); | |
14585 | } | |
14586 | } else | |
14587 | vty_out(vty, " neighbor %s activate\n", addr); | |
14588 | } else { | |
14589 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14590 | if (!CHECK_FLAG(bgp->flags, |
14591 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14592 | vty_out(vty, |
14593 | " no neighbor %s activate\n", | |
14594 | addr); | |
14595 | } | |
14596 | } | |
14597 | } | |
14598 | } | |
14599 | ||
14600 | /* addpath TX knobs */ | |
14601 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14602 | switch (peer->addpath_type[afi][safi]) { | |
14603 | case BGP_ADDPATH_ALL: | |
14604 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14605 | addr); | |
14606 | break; | |
14607 | case BGP_ADDPATH_BEST_PER_AS: | |
14608 | vty_out(vty, | |
14609 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14610 | addr); | |
14611 | break; | |
14612 | case BGP_ADDPATH_MAX: | |
14613 | case BGP_ADDPATH_NONE: | |
14614 | break; | |
14615 | } | |
14616 | } | |
14617 | ||
14618 | /* ORF capability. */ | |
14619 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14620 | || peergroup_af_flag_check(peer, afi, safi, | |
14621 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14622 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14623 | ||
14624 | if (peergroup_af_flag_check(peer, afi, safi, | |
14625 | PEER_FLAG_ORF_PREFIX_SM) | |
14626 | && peergroup_af_flag_check(peer, afi, safi, | |
14627 | PEER_FLAG_ORF_PREFIX_RM)) | |
14628 | vty_out(vty, " both"); | |
14629 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14630 | PEER_FLAG_ORF_PREFIX_SM)) | |
14631 | vty_out(vty, " send"); | |
14632 | else | |
14633 | vty_out(vty, " receive"); | |
14634 | vty_out(vty, "\n"); | |
14635 | } | |
14636 | ||
14637 | /* BGP flag dampening. */ | |
14638 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14639 | BGP_CONFIG_DAMPENING)) | |
14640 | bgp_config_write_damp(vty, afi, safi); | |
14641 | ||
14642 | /* Route reflector client. */ | |
14643 | if (peergroup_af_flag_check(peer, afi, safi, | |
14644 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14645 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14646 | } | |
14647 | ||
14648 | /* next-hop-self force */ | |
14649 | if (peergroup_af_flag_check(peer, afi, safi, | |
14650 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14651 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14652 | } | |
14653 | ||
14654 | /* next-hop-self */ | |
14655 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14656 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14657 | } | |
14658 | ||
14659 | /* remove-private-AS */ | |
14660 | if (peergroup_af_flag_check(peer, afi, safi, | |
14661 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14662 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14663 | addr); | |
14664 | } | |
14665 | ||
14666 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14667 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14668 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14669 | addr); | |
14670 | } | |
14671 | ||
14672 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14673 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14674 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14675 | } | |
14676 | ||
14677 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14678 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14679 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14680 | } | |
14681 | ||
14682 | /* as-override */ | |
14683 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14684 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14685 | } | |
14686 | ||
14687 | /* send-community print. */ | |
14688 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14689 | PEER_FLAG_SEND_COMMUNITY); | |
14690 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14691 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14692 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14693 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14694 | ||
14695 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14696 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14697 | } else { | |
14698 | if (flag_scomm) | |
14699 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14700 | if (flag_secomm) | |
14701 | vty_out(vty, | |
14702 | " no neighbor %s send-community extended\n", | |
14703 | addr); | |
14704 | ||
14705 | if (flag_slcomm) | |
14706 | vty_out(vty, " no neighbor %s send-community large\n", | |
14707 | addr); | |
14708 | } | |
14709 | ||
14710 | /* Default information */ | |
14711 | if (peergroup_af_flag_check(peer, afi, safi, | |
14712 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14713 | vty_out(vty, " neighbor %s default-originate", addr); | |
14714 | ||
14715 | if (peer->default_rmap[afi][safi].name) | |
14716 | vty_out(vty, " route-map %s", | |
14717 | peer->default_rmap[afi][safi].name); | |
14718 | ||
14719 | vty_out(vty, "\n"); | |
14720 | } | |
14721 | ||
14722 | /* Soft reconfiguration inbound. */ | |
14723 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14724 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14725 | addr); | |
14726 | } | |
14727 | ||
14728 | /* maximum-prefix. */ | |
14729 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14730 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14731 | peer->pmax[afi][safi]); | |
14732 | ||
14733 | if (peer->pmax_threshold[afi][safi] | |
14734 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14735 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14736 | if (peer_af_flag_check(peer, afi, safi, | |
14737 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14738 | vty_out(vty, " warning-only"); | |
14739 | if (peer->pmax_restart[afi][safi]) | |
14740 | vty_out(vty, " restart %u", | |
14741 | peer->pmax_restart[afi][safi]); | |
14742 | ||
14743 | vty_out(vty, "\n"); | |
14744 | } | |
14745 | ||
fde246e8 DA |
14746 | /* maximum-prefix-out */ |
14747 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14748 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14749 | addr, peer->pmax_out[afi][safi]); | |
14750 | ||
dd65f45e DL |
14751 | /* Route server client. */ |
14752 | if (peergroup_af_flag_check(peer, afi, safi, | |
14753 | PEER_FLAG_RSERVER_CLIENT)) { | |
14754 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14755 | } | |
14756 | ||
14757 | /* Nexthop-local unchanged. */ | |
14758 | if (peergroup_af_flag_check(peer, afi, safi, | |
14759 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14760 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14761 | } | |
14762 | ||
14763 | /* allowas-in <1-10> */ | |
14764 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14765 | if (peer_af_flag_check(peer, afi, safi, | |
14766 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14767 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14768 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14769 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14770 | } else { | |
14771 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14772 | peer->allowas_in[afi][safi]); | |
14773 | } | |
14774 | } | |
14775 | ||
14776 | /* weight */ | |
14777 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14778 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14779 | peer->weight[afi][safi]); | |
14780 | ||
14781 | /* Filter. */ | |
14782 | bgp_config_write_filter(vty, peer, afi, safi); | |
14783 | ||
14784 | /* atribute-unchanged. */ | |
14785 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14786 | || (safi != SAFI_EVPN | |
14787 | && peer_af_flag_check(peer, afi, safi, | |
14788 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14789 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14790 | ||
14791 | if (!peer_group_active(peer) | |
14792 | || peergroup_af_flag_check(peer, afi, safi, | |
14793 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14794 | || peergroup_af_flag_check(peer, afi, safi, | |
14795 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14796 | || peergroup_af_flag_check(peer, afi, safi, | |
14797 | PEER_FLAG_MED_UNCHANGED)) { | |
14798 | ||
14799 | vty_out(vty, | |
14800 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14801 | addr, | |
14802 | peer_af_flag_check(peer, afi, safi, | |
14803 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14804 | ? " as-path" | |
14805 | : "", | |
14806 | peer_af_flag_check(peer, afi, safi, | |
14807 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14808 | ? " next-hop" | |
14809 | : "", | |
14810 | peer_af_flag_check(peer, afi, safi, | |
14811 | PEER_FLAG_MED_UNCHANGED) | |
14812 | ? " med" | |
14813 | : ""); | |
14814 | } | |
14815 | } | |
14816 | } | |
14817 | ||
14818 | /* Address family based peer configuration display. */ | |
14819 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14820 | safi_t safi) | |
14821 | { | |
14822 | struct peer *peer; | |
14823 | struct peer_group *group; | |
14824 | struct listnode *node, *nnode; | |
14825 | ||
14826 | ||
14827 | vty_frame(vty, " !\n address-family "); | |
14828 | if (afi == AFI_IP) { | |
14829 | if (safi == SAFI_UNICAST) | |
14830 | vty_frame(vty, "ipv4 unicast"); | |
14831 | else if (safi == SAFI_LABELED_UNICAST) | |
14832 | vty_frame(vty, "ipv4 labeled-unicast"); | |
14833 | else if (safi == SAFI_MULTICAST) | |
14834 | vty_frame(vty, "ipv4 multicast"); | |
14835 | else if (safi == SAFI_MPLS_VPN) | |
14836 | vty_frame(vty, "ipv4 vpn"); | |
14837 | else if (safi == SAFI_ENCAP) | |
14838 | vty_frame(vty, "ipv4 encap"); | |
14839 | else if (safi == SAFI_FLOWSPEC) | |
14840 | vty_frame(vty, "ipv4 flowspec"); | |
14841 | } else if (afi == AFI_IP6) { | |
14842 | if (safi == SAFI_UNICAST) | |
14843 | vty_frame(vty, "ipv6 unicast"); | |
14844 | else if (safi == SAFI_LABELED_UNICAST) | |
14845 | vty_frame(vty, "ipv6 labeled-unicast"); | |
14846 | else if (safi == SAFI_MULTICAST) | |
14847 | vty_frame(vty, "ipv6 multicast"); | |
14848 | else if (safi == SAFI_MPLS_VPN) | |
14849 | vty_frame(vty, "ipv6 vpn"); | |
14850 | else if (safi == SAFI_ENCAP) | |
14851 | vty_frame(vty, "ipv6 encap"); | |
14852 | else if (safi == SAFI_FLOWSPEC) | |
14853 | vty_frame(vty, "ipv6 flowspec"); | |
14854 | } else if (afi == AFI_L2VPN) { | |
14855 | if (safi == SAFI_EVPN) | |
14856 | vty_frame(vty, "l2vpn evpn"); | |
14857 | } | |
14858 | vty_frame(vty, "\n"); | |
14859 | ||
14860 | bgp_config_write_distance(vty, bgp, afi, safi); | |
14861 | ||
14862 | bgp_config_write_network(vty, bgp, afi, safi); | |
14863 | ||
14864 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
14865 | ||
14866 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
14867 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
14868 | ||
14869 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14870 | /* Skip dynamic neighbors. */ | |
14871 | if (peer_dynamic_neighbor(peer)) | |
14872 | continue; | |
14873 | ||
14874 | /* Do not display doppelganger peers */ | |
14875 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14876 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
14877 | } | |
14878 | ||
14879 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
14880 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
14881 | ||
14882 | if (safi == SAFI_EVPN) | |
14883 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
14884 | ||
14885 | if (safi == SAFI_FLOWSPEC) | |
14886 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
14887 | ||
14888 | if (safi == SAFI_UNICAST) { | |
14889 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
14890 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14891 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
14892 | ||
14893 | vty_out(vty, " export vpn\n"); | |
14894 | } | |
14895 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14896 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
14897 | ||
14898 | vty_out(vty, " import vpn\n"); | |
14899 | } | |
14900 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14901 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14902 | char *name; | |
14903 | ||
14904 | for (ALL_LIST_ELEMENTS_RO( | |
14905 | bgp->vpn_policy[afi].import_vrf, node, | |
14906 | name)) | |
14907 | vty_out(vty, " import vrf %s\n", name); | |
14908 | } | |
14909 | } | |
14910 | ||
14911 | vty_endframe(vty, " exit-address-family\n"); | |
14912 | } | |
14913 | ||
14914 | int bgp_config_write(struct vty *vty) | |
14915 | { | |
14916 | struct bgp *bgp; | |
14917 | struct peer_group *group; | |
14918 | struct peer *peer; | |
14919 | struct listnode *node, *nnode; | |
14920 | struct listnode *mnode, *mnnode; | |
14921 | ||
14922 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
14923 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
14924 | bm->rmap_update_timer); | |
14925 | ||
14926 | /* BGP configuration. */ | |
14927 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
14928 | ||
14929 | /* skip all auto created vrf as they dont have user config */ | |
14930 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
14931 | continue; | |
14932 | ||
14933 | /* Router bgp ASN */ | |
14934 | vty_out(vty, "router bgp %u", bgp->as); | |
14935 | ||
14936 | if (bgp->name) | |
14937 | vty_out(vty, " %s %s", | |
14938 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
14939 | ? "view" : "vrf", bgp->name); | |
14940 | vty_out(vty, "\n"); | |
14941 | ||
14942 | /* BGP fast-external-failover. */ | |
14943 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
14944 | vty_out(vty, " no bgp fast-external-failover\n"); | |
14945 | ||
14946 | /* BGP router ID. */ | |
14947 | if (bgp->router_id_static.s_addr != 0) | |
14948 | vty_out(vty, " bgp router-id %s\n", | |
14949 | inet_ntoa(bgp->router_id_static)); | |
14950 | ||
14951 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 14952 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 14953 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 14954 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
14955 | CHECK_FLAG(bgp->flags, |
14956 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
14957 | ? "" |
14958 | : "no "); | |
14959 | ||
14960 | /* BGP configuration. */ | |
892fedb6 | 14961 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
14962 | vty_out(vty, " bgp always-compare-med\n"); |
14963 | ||
14964 | /* RFC8212 default eBGP policy. */ | |
14965 | if (bgp->ebgp_requires_policy | |
14966 | == DEFAULT_EBGP_POLICY_ENABLED) | |
14967 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
14968 | ||
14969 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
14970 | if (bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) | |
14971 | vty_out(vty, " bgp reject-as-sets\n"); | |
14972 | ||
14973 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 14974 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
14975 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
14976 | ||
14977 | /* BGP default local-preference. */ | |
14978 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
14979 | vty_out(vty, " bgp default local-preference %u\n", | |
14980 | bgp->default_local_pref); | |
14981 | ||
14982 | /* BGP default show-hostname */ | |
892fedb6 | 14983 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 14984 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 14985 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 14986 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
14987 | ? "" |
14988 | : "no "); | |
14989 | ||
14990 | /* BGP default subgroup-pkt-queue-max. */ | |
14991 | if (bgp->default_subgroup_pkt_queue_max | |
14992 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
14993 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
14994 | bgp->default_subgroup_pkt_queue_max); | |
14995 | ||
14996 | /* BGP client-to-client reflection. */ | |
892fedb6 | 14997 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
14998 | vty_out(vty, " no bgp client-to-client reflection\n"); |
14999 | ||
15000 | /* BGP cluster ID. */ | |
15001 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15002 | vty_out(vty, " bgp cluster-id %s\n", | |
15003 | inet_ntoa(bgp->cluster_id)); | |
15004 | ||
15005 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15006 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15007 | vty_out(vty, |
15008 | " bgp disable-ebgp-connected-route-check\n"); | |
15009 | ||
15010 | /* Confederation identifier*/ | |
15011 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15012 | vty_out(vty, " bgp confederation identifier %u\n", | |
15013 | bgp->confed_id); | |
15014 | ||
15015 | /* Confederation peer */ | |
15016 | if (bgp->confed_peers_cnt > 0) { | |
15017 | int i; | |
15018 | ||
15019 | vty_out(vty, " bgp confederation peers"); | |
15020 | ||
15021 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15022 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15023 | ||
15024 | vty_out(vty, "\n"); | |
15025 | } | |
15026 | ||
15027 | /* BGP deterministic-med. */ | |
892fedb6 | 15028 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15029 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15030 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15031 | CHECK_FLAG(bgp->flags, |
15032 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15033 | ? "" |
15034 | : "no "); | |
15035 | ||
15036 | /* BGP update-delay. */ | |
15037 | bgp_config_write_update_delay(vty, bgp); | |
15038 | ||
15039 | if (bgp->v_maxmed_onstartup | |
15040 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15041 | vty_out(vty, " bgp max-med on-startup %u", | |
15042 | bgp->v_maxmed_onstartup); | |
15043 | if (bgp->maxmed_onstartup_value | |
15044 | != BGP_MAXMED_VALUE_DEFAULT) | |
15045 | vty_out(vty, " %u", | |
15046 | bgp->maxmed_onstartup_value); | |
15047 | vty_out(vty, "\n"); | |
15048 | } | |
15049 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15050 | vty_out(vty, " bgp max-med administrative"); | |
15051 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15052 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15053 | vty_out(vty, "\n"); | |
15054 | } | |
15055 | ||
15056 | /* write quanta */ | |
15057 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15058 | /* read quanta */ | |
15059 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15060 | ||
15061 | /* coalesce time */ | |
15062 | bgp_config_write_coalesce_time(vty, bgp); | |
15063 | ||
15064 | /* BGP graceful-restart. */ | |
15065 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15066 | vty_out(vty, | |
15067 | " bgp graceful-restart stalepath-time %u\n", | |
15068 | bgp->stalepath_time); | |
cfd47646 | 15069 | |
dd65f45e DL |
15070 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15071 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15072 | bgp->restart_time); | |
cfd47646 | 15073 | |
15074 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15075 | vty_out(vty, | |
15076 | " bgp graceful-restart select-defer-time %u\n", | |
15077 | bgp->select_defer_time); | |
15078 | ||
15079 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15080 | vty_out(vty, " bgp graceful-restart\n"); |
15081 | ||
cfd47646 | 15082 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15083 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15084 | ||
dd65f45e | 15085 | /* BGP graceful-shutdown */ |
892fedb6 | 15086 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15087 | vty_out(vty, " bgp graceful-shutdown\n"); |
15088 | ||
15089 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15090 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15091 | vty_out(vty, |
15092 | " bgp graceful-restart preserve-fw-state\n"); | |
15093 | ||
dc95985f | 15094 | /* Stale timer for RIB */ |
15095 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15096 | vty_out(vty, | |
15097 | " bgp graceful-restart rib-stale-time %u\n", | |
15098 | bgp->rib_stale_time); | |
15099 | ||
dd65f45e | 15100 | /* BGP bestpath method. */ |
892fedb6 | 15101 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15102 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15103 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15104 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15105 | ||
892fedb6 DA |
15106 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15107 | if (CHECK_FLAG(bgp->flags, | |
15108 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15109 | vty_out(vty, |
15110 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15111 | } else { | |
15112 | vty_out(vty, | |
15113 | " bgp bestpath as-path multipath-relax\n"); | |
15114 | } | |
15115 | } | |
15116 | ||
892fedb6 | 15117 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15118 | vty_out(vty, |
15119 | " bgp route-reflector allow-outbound-policy\n"); | |
15120 | } | |
892fedb6 | 15121 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15122 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15123 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15124 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15125 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15126 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15127 | vty_out(vty, " confed"); |
892fedb6 DA |
15128 | if (CHECK_FLAG(bgp->flags, |
15129 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15130 | vty_out(vty, " missing-as-worst"); |
15131 | vty_out(vty, "\n"); | |
15132 | } | |
15133 | ||
15134 | /* BGP network import check. */ | |
892fedb6 | 15135 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15136 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15137 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15138 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15139 | ? "" |
15140 | : "no "); | |
15141 | ||
15142 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15143 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15144 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15145 | vty_out(vty, " timers bgp %u %u\n", |
15146 | bgp->default_keepalive, bgp->default_holdtime); | |
15147 | ||
15148 | /* peer-group */ | |
15149 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15150 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15151 | } | |
15152 | ||
15153 | /* Normal neighbor configuration. */ | |
15154 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15155 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15156 | bgp_config_write_peer_global(vty, bgp, peer); | |
15157 | } | |
15158 | ||
15159 | /* listen range and limit for dynamic BGP neighbors */ | |
15160 | bgp_config_write_listen(vty, bgp); | |
15161 | ||
15162 | /* | |
15163 | * BGP default autoshutdown neighbors | |
15164 | * | |
15165 | * This must be placed after any peer and peer-group | |
15166 | * configuration, to avoid setting all peers to shutdown after | |
15167 | * a daemon restart, which is undesired behavior. (see #2286) | |
15168 | */ | |
15169 | if (bgp->autoshutdown) | |
15170 | vty_out(vty, " bgp default shutdown\n"); | |
15171 | ||
15172 | /* IPv4 unicast configuration. */ | |
15173 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15174 | ||
15175 | /* IPv4 multicast configuration. */ | |
15176 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15177 | ||
15178 | /* IPv4 labeled-unicast configuration. */ | |
15179 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15180 | ||
15181 | /* IPv4 VPN configuration. */ | |
15182 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15183 | ||
15184 | /* ENCAPv4 configuration. */ | |
15185 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15186 | ||
15187 | /* FLOWSPEC v4 configuration. */ | |
15188 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15189 | ||
15190 | /* IPv6 unicast configuration. */ | |
15191 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15192 | ||
15193 | /* IPv6 multicast configuration. */ | |
15194 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15195 | ||
15196 | /* IPv6 labeled-unicast configuration. */ | |
15197 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15198 | SAFI_LABELED_UNICAST); | |
15199 | ||
15200 | /* IPv6 VPN configuration. */ | |
15201 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15202 | ||
15203 | /* ENCAPv6 configuration. */ | |
15204 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15205 | ||
15206 | /* FLOWSPEC v6 configuration. */ | |
15207 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15208 | ||
15209 | /* EVPN configuration. */ | |
15210 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15211 | ||
15212 | hook_call(bgp_inst_config_write, bgp, vty); | |
15213 | ||
15214 | #if ENABLE_BGP_VNC | |
15215 | bgp_rfapi_cfg_write(vty, bgp); | |
15216 | #endif | |
15217 | ||
15218 | vty_out(vty, "!\n"); | |
15219 | } | |
15220 | return 0; | |
15221 | } | |
15222 | ||
ddb5b488 | 15223 | |
718e3744 | 15224 | /* BGP node structure. */ |
d62a17ae | 15225 | static struct cmd_node bgp_node = { |
9d303b37 | 15226 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 15227 | }; |
15228 | ||
d62a17ae | 15229 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 15230 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15231 | }; |
15232 | ||
d62a17ae | 15233 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 15234 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15235 | }; |
15236 | ||
d62a17ae | 15237 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 15238 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15239 | }; |
15240 | ||
d62a17ae | 15241 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 15242 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15243 | }; |
15244 | ||
d62a17ae | 15245 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 15246 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 15247 | }; |
15248 | ||
d62a17ae | 15249 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 15250 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15251 | }; |
15252 | ||
d62a17ae | 15253 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
15254 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 15255 | |
d62a17ae | 15256 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
15257 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 15258 | |
d62a17ae | 15259 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
15260 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 15261 | |
d62a17ae | 15262 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
15263 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 15264 | |
7c40bf39 | 15265 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
15266 | "%s(config-router-af)# ", 1}; | |
15267 | ||
15268 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
15269 | "%s(config-router-af-vpnv6)# ", 1}; | |
15270 | ||
d62a17ae | 15271 | static void community_list_vty(void); |
1f8ae70b | 15272 | |
d62a17ae | 15273 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15274 | { |
d62a17ae | 15275 | struct bgp *bgp; |
15276 | struct peer *peer; | |
d62a17ae | 15277 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15278 | |
d62a17ae | 15279 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15280 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15281 | /* only provide suggestions on the appropriate input | |
15282 | * token type, | |
15283 | * they'll otherwise show up multiple times */ | |
15284 | enum cmd_token_type match_type; | |
15285 | char *name = peer->host; | |
d48ed3e0 | 15286 | |
d62a17ae | 15287 | if (peer->conf_if) { |
15288 | match_type = VARIABLE_TKN; | |
15289 | name = peer->conf_if; | |
15290 | } else if (strchr(peer->host, ':')) | |
15291 | match_type = IPV6_TKN; | |
15292 | else | |
15293 | match_type = IPV4_TKN; | |
d48ed3e0 | 15294 | |
d62a17ae | 15295 | if (token->type != match_type) |
15296 | continue; | |
d48ed3e0 | 15297 | |
d62a17ae | 15298 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15299 | } | |
d62a17ae | 15300 | } |
b8a815e5 DL |
15301 | } |
15302 | ||
15303 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15304 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15305 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15306 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15307 | {.completions = NULL}}; |
15308 | ||
47a306a0 DS |
15309 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15310 | { | |
15311 | struct bgp *bgp; | |
15312 | struct peer_group *group; | |
15313 | struct listnode *lnbgp, *lnpeer; | |
15314 | ||
15315 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15316 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15317 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15318 | group->name)); | |
15319 | } | |
15320 | } | |
15321 | ||
15322 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15323 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15324 | {.completions = NULL} }; | |
15325 | ||
d62a17ae | 15326 | void bgp_vty_init(void) |
15327 | { | |
15328 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15329 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15330 | |
15331 | /* Install bgp top node. */ | |
15332 | install_node(&bgp_node, bgp_config_write); | |
15333 | install_node(&bgp_ipv4_unicast_node, NULL); | |
15334 | install_node(&bgp_ipv4_multicast_node, NULL); | |
15335 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
15336 | install_node(&bgp_ipv6_unicast_node, NULL); | |
15337 | install_node(&bgp_ipv6_multicast_node, NULL); | |
15338 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
15339 | install_node(&bgp_vpnv4_node, NULL); | |
15340 | install_node(&bgp_vpnv6_node, NULL); | |
15341 | install_node(&bgp_evpn_node, NULL); | |
15342 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 15343 | install_node(&bgp_flowspecv4_node, NULL); |
15344 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 15345 | |
15346 | /* Install default VTY commands to new nodes. */ | |
15347 | install_default(BGP_NODE); | |
15348 | install_default(BGP_IPV4_NODE); | |
15349 | install_default(BGP_IPV4M_NODE); | |
15350 | install_default(BGP_IPV4L_NODE); | |
15351 | install_default(BGP_IPV6_NODE); | |
15352 | install_default(BGP_IPV6M_NODE); | |
15353 | install_default(BGP_IPV6L_NODE); | |
15354 | install_default(BGP_VPNV4_NODE); | |
15355 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15356 | install_default(BGP_FLOWSPECV4_NODE); |
15357 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15358 | install_default(BGP_EVPN_NODE); |
15359 | install_default(BGP_EVPN_VNI_NODE); | |
15360 | ||
8029b216 AK |
15361 | /* "bgp local-mac" hidden commands. */ |
15362 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15363 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15364 | ||
d62a17ae | 15365 | /* bgp route-map delay-timer commands. */ |
15366 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15367 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15368 | ||
15369 | /* Dummy commands (Currently not supported) */ | |
15370 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15371 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15372 | ||
15373 | /* "router bgp" commands. */ | |
15374 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15375 | ||
15376 | /* "no router bgp" commands. */ | |
15377 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15378 | ||
15379 | /* "bgp router-id" commands. */ | |
15380 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15381 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15382 | ||
15383 | /* "bgp cluster-id" commands. */ | |
15384 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15385 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15386 | ||
15387 | /* "bgp confederation" commands. */ | |
15388 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15389 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15390 | ||
15391 | /* "bgp confederation peers" commands. */ | |
15392 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15393 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15394 | ||
15395 | /* bgp max-med command */ | |
15396 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15397 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15398 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15399 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15400 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15401 | ||
15402 | /* bgp disable-ebgp-connected-nh-check */ | |
15403 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15404 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15405 | ||
15406 | /* bgp update-delay command */ | |
15407 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15408 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15409 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15410 | ||
15411 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15412 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15413 | |
15414 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15415 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15416 | ||
15417 | /* "maximum-paths" commands. */ | |
15418 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15419 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15420 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15421 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15422 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15423 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15424 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15425 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15426 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15427 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15428 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15429 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15430 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15431 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15432 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15433 | ||
15434 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15435 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15436 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15437 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15438 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15439 | ||
15440 | /* "timers bgp" commands. */ | |
15441 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15442 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15443 | ||
15444 | /* route-map delay-timer commands - per instance for backwards compat. | |
15445 | */ | |
15446 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15447 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15448 | ||
15449 | /* "bgp client-to-client reflection" commands */ | |
15450 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15451 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15452 | ||
15453 | /* "bgp always-compare-med" commands */ | |
15454 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15455 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15456 | ||
9dac9fc8 DA |
15457 | /* bgp ebgp-requires-policy */ |
15458 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15459 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15460 | ||
fb29348a DA |
15461 | /* bgp reject-as-sets */ |
15462 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15463 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15464 | ||
d62a17ae | 15465 | /* "bgp deterministic-med" commands */ |
15466 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15467 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15468 | ||
055679e9 | 15469 | /* "bgp graceful-restart" command */ |
36235319 QY |
15470 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15471 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15472 | |
15473 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15474 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15475 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15476 | |
15477 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15478 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15479 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15480 | |
15481 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15482 | install_element(BGP_NODE, | |
15483 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15484 | install_element(BGP_NODE, | |
15485 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15486 | ||
15487 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15488 | install_element(BGP_NODE, | |
15489 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15490 | install_element(BGP_NODE, | |
15491 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15492 | ||
d62a17ae | 15493 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15494 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15495 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15496 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15497 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15498 | install_element(BGP_NODE, |
15499 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15500 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15501 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15502 | ||
d6e3c15b | 15503 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15504 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15505 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15506 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15507 | |
7f323236 DW |
15508 | /* "bgp graceful-shutdown" commands */ |
15509 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15510 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15511 | ||
d62a17ae | 15512 | /* "bgp fast-external-failover" commands */ |
15513 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15514 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15515 | ||
d62a17ae | 15516 | /* "bgp bestpath compare-routerid" commands */ |
15517 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15518 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15519 | ||
15520 | /* "bgp bestpath as-path ignore" commands */ | |
15521 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15522 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15523 | ||
15524 | /* "bgp bestpath as-path confed" commands */ | |
15525 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15526 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15527 | ||
15528 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15529 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15530 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15531 | ||
15532 | /* "bgp log-neighbor-changes" commands */ | |
15533 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15534 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15535 | ||
15536 | /* "bgp bestpath med" commands */ | |
15537 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15538 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15539 | ||
15540 | /* "no bgp default ipv4-unicast" commands. */ | |
15541 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15542 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15543 | ||
15544 | /* "bgp network import-check" commands. */ | |
15545 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15546 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15547 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15548 | ||
15549 | /* "bgp default local-preference" commands. */ | |
15550 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15551 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15552 | ||
15553 | /* bgp default show-hostname */ | |
15554 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15555 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15556 | ||
15557 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15558 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15559 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15560 | ||
15561 | /* bgp ibgp-allow-policy-mods command */ | |
15562 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15563 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15564 | ||
15565 | /* "bgp listen limit" commands. */ | |
15566 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15567 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15568 | ||
15569 | /* "bgp listen range" commands. */ | |
15570 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15571 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15572 | ||
8175f54a | 15573 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15574 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15575 | ||
d62a17ae | 15576 | /* "neighbor remote-as" commands. */ |
15577 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15578 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15579 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15580 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15581 | install_element(BGP_NODE, | |
15582 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15583 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15584 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15585 | ||
15586 | /* "neighbor peer-group" commands. */ | |
15587 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15588 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15589 | install_element(BGP_NODE, | |
15590 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15591 | ||
15592 | /* "neighbor local-as" commands. */ | |
15593 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15594 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15595 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15596 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15597 | ||
15598 | /* "neighbor solo" commands. */ | |
15599 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15600 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15601 | ||
15602 | /* "neighbor password" commands. */ | |
15603 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15604 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15605 | ||
15606 | /* "neighbor activate" commands. */ | |
15607 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15608 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15609 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15610 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15611 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15612 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15613 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15614 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15615 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15616 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15617 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15618 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15619 | ||
15620 | /* "no neighbor activate" commands. */ | |
15621 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15622 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15623 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15624 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15625 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15626 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15627 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15628 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15629 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15630 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15631 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15632 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15633 | ||
15634 | /* "neighbor peer-group" set commands. */ | |
15635 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15636 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15637 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15638 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15639 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15640 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15641 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15642 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15643 | install_element(BGP_FLOWSPECV4_NODE, |
15644 | &neighbor_set_peer_group_hidden_cmd); | |
15645 | install_element(BGP_FLOWSPECV6_NODE, | |
15646 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15647 | |
15648 | /* "no neighbor peer-group unset" commands. */ | |
15649 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15650 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15651 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15652 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15653 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15654 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15655 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15656 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15657 | install_element(BGP_FLOWSPECV4_NODE, |
15658 | &no_neighbor_set_peer_group_hidden_cmd); | |
15659 | install_element(BGP_FLOWSPECV6_NODE, | |
15660 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15661 | |
15662 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15663 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15664 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15665 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15666 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15667 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15668 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15669 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15670 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15671 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15672 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15673 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15674 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15675 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15676 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15677 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15678 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15679 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15680 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15681 | install_element(BGP_FLOWSPECV4_NODE, |
15682 | &neighbor_soft_reconfiguration_cmd); | |
15683 | install_element(BGP_FLOWSPECV4_NODE, | |
15684 | &no_neighbor_soft_reconfiguration_cmd); | |
15685 | install_element(BGP_FLOWSPECV6_NODE, | |
15686 | &neighbor_soft_reconfiguration_cmd); | |
15687 | install_element(BGP_FLOWSPECV6_NODE, | |
15688 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15689 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15690 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15691 | |
15692 | /* "neighbor attribute-unchanged" commands. */ | |
15693 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15694 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15695 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15696 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15697 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15698 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15699 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15700 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15701 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15702 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15703 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15704 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15705 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15706 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15707 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15708 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15709 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15710 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15711 | ||
15712 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15713 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15714 | ||
15715 | /* "nexthop-local unchanged" commands */ | |
15716 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15717 | install_element(BGP_IPV6_NODE, | |
15718 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15719 | ||
15720 | /* "neighbor next-hop-self" commands. */ | |
15721 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15722 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15723 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15724 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15725 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15726 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15727 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15728 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15729 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15730 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15731 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15732 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15733 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15734 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15735 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15736 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15737 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15738 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15739 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15740 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15741 | |
15742 | /* "neighbor next-hop-self force" commands. */ | |
15743 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15744 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15745 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15746 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15747 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15748 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15749 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15750 | install_element(BGP_IPV4_NODE, | |
15751 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15752 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15753 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15754 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15755 | install_element(BGP_IPV4M_NODE, | |
15756 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15757 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
15758 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15759 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15760 | install_element(BGP_IPV4L_NODE, | |
15761 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15762 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
15763 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15764 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15765 | install_element(BGP_IPV6_NODE, | |
15766 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15767 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
15768 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15769 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15770 | install_element(BGP_IPV6M_NODE, | |
15771 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15772 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
15773 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15774 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15775 | install_element(BGP_IPV6L_NODE, | |
15776 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15777 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
15778 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15779 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15780 | install_element(BGP_VPNV4_NODE, | |
15781 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15782 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
15783 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15784 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15785 | install_element(BGP_VPNV6_NODE, | |
15786 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15787 | |
15788 | /* "neighbor as-override" commands. */ | |
15789 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
15790 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
15791 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
15792 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
15793 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
15794 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
15795 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
15796 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
15797 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
15798 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
15799 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
15800 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
15801 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
15802 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
15803 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
15804 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
15805 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
15806 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
15807 | ||
15808 | /* "neighbor remove-private-AS" commands. */ | |
15809 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
15810 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
15811 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
15812 | install_element(BGP_NODE, | |
15813 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
15814 | install_element(BGP_NODE, | |
15815 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
15816 | install_element(BGP_NODE, | |
15817 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
15818 | install_element(BGP_NODE, | |
15819 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15820 | install_element( | |
15821 | BGP_NODE, | |
15822 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15823 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
15824 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15825 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15826 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15827 | install_element(BGP_IPV4_NODE, | |
15828 | &neighbor_remove_private_as_replace_as_cmd); | |
15829 | install_element(BGP_IPV4_NODE, | |
15830 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15831 | install_element(BGP_IPV4_NODE, | |
15832 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15833 | install_element(BGP_IPV4_NODE, | |
15834 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15835 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
15836 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
15837 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
15838 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15839 | install_element(BGP_IPV4M_NODE, | |
15840 | &neighbor_remove_private_as_replace_as_cmd); | |
15841 | install_element(BGP_IPV4M_NODE, | |
15842 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15843 | install_element(BGP_IPV4M_NODE, | |
15844 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15845 | install_element(BGP_IPV4M_NODE, | |
15846 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15847 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
15848 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
15849 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
15850 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15851 | install_element(BGP_IPV4L_NODE, | |
15852 | &neighbor_remove_private_as_replace_as_cmd); | |
15853 | install_element(BGP_IPV4L_NODE, | |
15854 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15855 | install_element(BGP_IPV4L_NODE, | |
15856 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15857 | install_element(BGP_IPV4L_NODE, | |
15858 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15859 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
15860 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15861 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15862 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15863 | install_element(BGP_IPV6_NODE, | |
15864 | &neighbor_remove_private_as_replace_as_cmd); | |
15865 | install_element(BGP_IPV6_NODE, | |
15866 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15867 | install_element(BGP_IPV6_NODE, | |
15868 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15869 | install_element(BGP_IPV6_NODE, | |
15870 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15871 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
15872 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
15873 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
15874 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15875 | install_element(BGP_IPV6M_NODE, | |
15876 | &neighbor_remove_private_as_replace_as_cmd); | |
15877 | install_element(BGP_IPV6M_NODE, | |
15878 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15879 | install_element(BGP_IPV6M_NODE, | |
15880 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15881 | install_element(BGP_IPV6M_NODE, | |
15882 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15883 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
15884 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
15885 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
15886 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15887 | install_element(BGP_IPV6L_NODE, | |
15888 | &neighbor_remove_private_as_replace_as_cmd); | |
15889 | install_element(BGP_IPV6L_NODE, | |
15890 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15891 | install_element(BGP_IPV6L_NODE, | |
15892 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15893 | install_element(BGP_IPV6L_NODE, | |
15894 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15895 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
15896 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15897 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15898 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15899 | install_element(BGP_VPNV4_NODE, | |
15900 | &neighbor_remove_private_as_replace_as_cmd); | |
15901 | install_element(BGP_VPNV4_NODE, | |
15902 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15903 | install_element(BGP_VPNV4_NODE, | |
15904 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15905 | install_element(BGP_VPNV4_NODE, | |
15906 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15907 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
15908 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15909 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15910 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15911 | install_element(BGP_VPNV6_NODE, | |
15912 | &neighbor_remove_private_as_replace_as_cmd); | |
15913 | install_element(BGP_VPNV6_NODE, | |
15914 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15915 | install_element(BGP_VPNV6_NODE, | |
15916 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15917 | install_element(BGP_VPNV6_NODE, | |
15918 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15919 | ||
15920 | /* "neighbor send-community" commands.*/ | |
15921 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
15922 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
15923 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
15924 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
15925 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
15926 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
15927 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
15928 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
15929 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
15930 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
15931 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
15932 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
15933 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
15934 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
15935 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
15936 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
15937 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
15938 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
15939 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
15940 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
15941 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
15942 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
15943 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
15944 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
15945 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
15946 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
15947 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
15948 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
15949 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
15950 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
15951 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
15952 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
15953 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
15954 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
15955 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
15956 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
15957 | ||
15958 | /* "neighbor route-reflector" commands.*/ | |
15959 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
15960 | install_element(BGP_NODE, | |
15961 | &no_neighbor_route_reflector_client_hidden_cmd); | |
15962 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
15963 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
15964 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
15965 | install_element(BGP_IPV4M_NODE, | |
15966 | &no_neighbor_route_reflector_client_cmd); | |
15967 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
15968 | install_element(BGP_IPV4L_NODE, | |
15969 | &no_neighbor_route_reflector_client_cmd); | |
15970 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
15971 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
15972 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
15973 | install_element(BGP_IPV6M_NODE, | |
15974 | &no_neighbor_route_reflector_client_cmd); | |
15975 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
15976 | install_element(BGP_IPV6L_NODE, | |
15977 | &no_neighbor_route_reflector_client_cmd); | |
15978 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
15979 | install_element(BGP_VPNV4_NODE, | |
15980 | &no_neighbor_route_reflector_client_cmd); | |
15981 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
15982 | install_element(BGP_VPNV6_NODE, | |
15983 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 15984 | install_element(BGP_FLOWSPECV4_NODE, |
15985 | &neighbor_route_reflector_client_cmd); | |
15986 | install_element(BGP_FLOWSPECV4_NODE, | |
15987 | &no_neighbor_route_reflector_client_cmd); | |
15988 | install_element(BGP_FLOWSPECV6_NODE, | |
15989 | &neighbor_route_reflector_client_cmd); | |
15990 | install_element(BGP_FLOWSPECV6_NODE, | |
15991 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 15992 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
15993 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
15994 | ||
15995 | /* "neighbor route-server" commands.*/ | |
15996 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
15997 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
15998 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
15999 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16000 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16001 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16002 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16003 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16004 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16005 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16006 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16007 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16008 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16009 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16010 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16011 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16012 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16013 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16014 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16015 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16016 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16017 | install_element(BGP_FLOWSPECV4_NODE, | |
16018 | &no_neighbor_route_server_client_cmd); | |
16019 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16020 | install_element(BGP_FLOWSPECV6_NODE, | |
16021 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16022 | |
16023 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16024 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16025 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16026 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16027 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16028 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16029 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16030 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16031 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16032 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16033 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16034 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16035 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16036 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16037 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16038 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16039 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16040 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16041 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16042 | ||
16043 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16044 | install_element(BGP_NODE, | |
16045 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16046 | install_element(BGP_NODE, | |
16047 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16048 | install_element(BGP_IPV4_NODE, | |
16049 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16050 | install_element(BGP_IPV4_NODE, | |
16051 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16052 | install_element(BGP_IPV4M_NODE, | |
16053 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16054 | install_element(BGP_IPV4M_NODE, | |
16055 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16056 | install_element(BGP_IPV4L_NODE, | |
16057 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16058 | install_element(BGP_IPV4L_NODE, | |
16059 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16060 | install_element(BGP_IPV6_NODE, | |
16061 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16062 | install_element(BGP_IPV6_NODE, | |
16063 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16064 | install_element(BGP_IPV6M_NODE, | |
16065 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16066 | install_element(BGP_IPV6M_NODE, | |
16067 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16068 | install_element(BGP_IPV6L_NODE, | |
16069 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16070 | install_element(BGP_IPV6L_NODE, | |
16071 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16072 | install_element(BGP_VPNV4_NODE, | |
16073 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16074 | install_element(BGP_VPNV4_NODE, | |
16075 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16076 | install_element(BGP_VPNV6_NODE, | |
16077 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16078 | install_element(BGP_VPNV6_NODE, | |
16079 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16080 | ||
2b31007c RZ |
16081 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16082 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16083 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16084 | ||
d62a17ae | 16085 | /* "neighbor passive" commands. */ |
16086 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16087 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16088 | ||
16089 | ||
16090 | /* "neighbor shutdown" commands. */ | |
16091 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16092 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16093 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16094 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16095 | ||
16096 | /* "neighbor capability extended-nexthop" commands.*/ | |
16097 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16098 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16099 | ||
16100 | /* "neighbor capability orf prefix-list" commands.*/ | |
16101 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16102 | install_element(BGP_NODE, | |
16103 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16104 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16105 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16106 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16107 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16108 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16109 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16110 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16111 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16112 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16113 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16114 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16115 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16116 | ||
16117 | /* "neighbor capability dynamic" commands.*/ | |
16118 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16119 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16120 | ||
16121 | /* "neighbor dont-capability-negotiate" commands. */ | |
16122 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16123 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16124 | ||
16125 | /* "neighbor ebgp-multihop" commands. */ | |
16126 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16127 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16128 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16129 | ||
16130 | /* "neighbor disable-connected-check" commands. */ | |
16131 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16132 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16133 | ||
47cbc09b PM |
16134 | /* "neighbor enforce-first-as" commands. */ |
16135 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16136 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16137 | ||
d62a17ae | 16138 | /* "neighbor description" commands. */ |
16139 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16140 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16141 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16142 | |
16143 | /* "neighbor update-source" commands. "*/ | |
16144 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16145 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16146 | ||
16147 | /* "neighbor default-originate" commands. */ | |
16148 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16149 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16150 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16151 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16152 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16153 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16154 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16155 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16156 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16157 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16158 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16159 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16160 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16161 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16162 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16163 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16164 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16165 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16166 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16167 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16168 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16169 | ||
16170 | /* "neighbor port" commands. */ | |
16171 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16172 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16173 | ||
16174 | /* "neighbor weight" commands. */ | |
16175 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16176 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16177 | ||
16178 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16179 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16180 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16181 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16182 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16183 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16184 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16185 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16186 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16187 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16188 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16189 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16190 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16191 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16192 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16193 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16194 | ||
16195 | /* "neighbor override-capability" commands. */ | |
16196 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16197 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16198 | ||
16199 | /* "neighbor strict-capability-match" commands. */ | |
16200 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16201 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16202 | ||
16203 | /* "neighbor timers" commands. */ | |
16204 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16205 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16206 | ||
16207 | /* "neighbor timers connect" commands. */ | |
16208 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16209 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16210 | ||
16211 | /* "neighbor advertisement-interval" commands. */ | |
16212 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16213 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16214 | ||
16215 | /* "neighbor interface" commands. */ | |
16216 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16217 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16218 | ||
16219 | /* "neighbor distribute" commands. */ | |
16220 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16221 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16222 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16223 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16224 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16225 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16226 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16227 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16228 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16229 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16230 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16231 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16232 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16233 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16234 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16235 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16236 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16237 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16238 | ||
16239 | /* "neighbor prefix-list" commands. */ | |
16240 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16241 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16242 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16243 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16244 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16245 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16246 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16247 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16248 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16249 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16250 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16251 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16252 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16253 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16254 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16255 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16256 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16257 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16258 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16259 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16260 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16261 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16262 | |
16263 | /* "neighbor filter-list" commands. */ | |
16264 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16265 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16266 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16267 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16268 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16269 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16270 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16271 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16272 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16273 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16274 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16275 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16276 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16277 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16278 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16279 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16280 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16281 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16282 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16283 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16284 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16285 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16286 | |
16287 | /* "neighbor route-map" commands. */ | |
16288 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16289 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16290 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16291 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16292 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16293 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16294 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16295 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16296 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16297 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16298 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16299 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16300 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16301 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16302 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16303 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16304 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16305 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16306 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16307 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16308 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16309 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16310 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16311 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16312 | |
16313 | /* "neighbor unsuppress-map" commands. */ | |
16314 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16315 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16316 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16317 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16318 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16319 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16320 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16321 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16322 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16323 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16324 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16325 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16326 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16327 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16328 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16329 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16330 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16331 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16332 | ||
fde246e8 DA |
16333 | /* neighbor maximum-prefix-out commands. */ |
16334 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16335 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16336 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16337 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16338 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16339 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16340 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16341 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16342 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16343 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16344 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16345 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16346 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16347 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16348 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16349 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16350 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16351 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16352 | ||
d62a17ae | 16353 | /* "neighbor maximum-prefix" commands. */ |
16354 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16355 | install_element(BGP_NODE, | |
16356 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16357 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16358 | install_element(BGP_NODE, | |
16359 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16360 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16361 | install_element(BGP_NODE, | |
16362 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16363 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16364 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16365 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16366 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16367 | install_element(BGP_IPV4_NODE, | |
16368 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16369 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16370 | install_element(BGP_IPV4_NODE, | |
16371 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16372 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16373 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16374 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16375 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16376 | install_element(BGP_IPV4M_NODE, | |
16377 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16378 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16379 | install_element(BGP_IPV4M_NODE, | |
16380 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16381 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16382 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16383 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16384 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16385 | install_element(BGP_IPV4L_NODE, | |
16386 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16387 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16388 | install_element(BGP_IPV4L_NODE, | |
16389 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16390 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16391 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16392 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16393 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16394 | install_element(BGP_IPV6_NODE, | |
16395 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16396 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16397 | install_element(BGP_IPV6_NODE, | |
16398 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16399 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16400 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16401 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16402 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16403 | install_element(BGP_IPV6M_NODE, | |
16404 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16405 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16406 | install_element(BGP_IPV6M_NODE, | |
16407 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16408 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16409 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16410 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16411 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16412 | install_element(BGP_IPV6L_NODE, | |
16413 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16414 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16415 | install_element(BGP_IPV6L_NODE, | |
16416 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16417 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16418 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16419 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16420 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16421 | install_element(BGP_VPNV4_NODE, | |
16422 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16423 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16424 | install_element(BGP_VPNV4_NODE, | |
16425 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16426 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16427 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16428 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16429 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16430 | install_element(BGP_VPNV6_NODE, | |
16431 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16432 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16433 | install_element(BGP_VPNV6_NODE, | |
16434 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16435 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16436 | ||
16437 | /* "neighbor allowas-in" */ | |
16438 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16439 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16440 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16441 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16442 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16443 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16444 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16445 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16446 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16447 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16448 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16449 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16450 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16451 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16452 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16453 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16454 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16455 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16456 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16457 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16458 | ||
16459 | /* address-family commands. */ | |
16460 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16461 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16462 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16463 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16464 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16465 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16466 | |
d62a17ae | 16467 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16468 | ||
16469 | /* "exit-address-family" command. */ | |
16470 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16471 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16472 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16473 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16474 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16475 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16476 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16477 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16478 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16479 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16480 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16481 | ||
16482 | /* "clear ip bgp commands" */ | |
16483 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16484 | ||
16485 | /* clear ip bgp prefix */ | |
16486 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16487 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16488 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16489 | ||
16490 | /* "show [ip] bgp summary" commands. */ | |
16491 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16492 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16493 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16494 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16495 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16496 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16497 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16498 | ||
16499 | /* "show [ip] bgp neighbors" commands. */ | |
16500 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16501 | ||
36235319 | 16502 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16503 | |
d62a17ae | 16504 | /* "show [ip] bgp peer-group" commands. */ |
16505 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16506 | ||
16507 | /* "show [ip] bgp paths" commands. */ | |
16508 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16509 | ||
16510 | /* "show [ip] bgp community" commands. */ | |
16511 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16512 | ||
16513 | /* "show ip bgp large-community" commands. */ | |
16514 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16515 | /* "show [ip] bgp attribute-info" commands. */ | |
16516 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16517 | /* "show [ip] bgp route-leak" command */ |
16518 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16519 | |
16520 | /* "redistribute" commands. */ | |
16521 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16522 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16523 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16524 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16525 | install_element(BGP_NODE, | |
16526 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16527 | install_element(BGP_NODE, | |
16528 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16529 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16530 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16531 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16532 | install_element(BGP_NODE, | |
16533 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16534 | install_element(BGP_NODE, | |
16535 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16536 | install_element(BGP_NODE, | |
16537 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16538 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16539 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16540 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16541 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16542 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16543 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16544 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16545 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16546 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16547 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16548 | install_element(BGP_IPV4_NODE, | |
16549 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16550 | install_element(BGP_IPV4_NODE, | |
16551 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16552 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16553 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16554 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16555 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16556 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16557 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16558 | ||
b9c7bc5a PZ |
16559 | /* import|export vpn [route-map WORD] */ |
16560 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16561 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16562 | |
12a844a5 DS |
16563 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16564 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16565 | ||
d62a17ae | 16566 | /* ttl_security commands */ |
16567 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16568 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16569 | ||
16570 | /* "show [ip] bgp memory" commands. */ | |
16571 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16572 | ||
acf71666 MK |
16573 | /* "show bgp martian next-hop" */ |
16574 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16575 | ||
48ecf8f5 DS |
16576 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16577 | ||
d62a17ae | 16578 | /* "show [ip] bgp views" commands. */ |
16579 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16580 | ||
16581 | /* "show [ip] bgp vrfs" commands. */ | |
16582 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16583 | ||
16584 | /* Community-list. */ | |
16585 | community_list_vty(); | |
ddb5b488 PZ |
16586 | |
16587 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16588 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16589 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16590 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16591 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16592 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16593 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16594 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16595 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16596 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16597 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16598 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16599 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16600 | |
301ad80a PG |
16601 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16602 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16603 | ||
b9c7bc5a PZ |
16604 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16605 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16606 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16607 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
16608 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
16609 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16610 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16611 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16612 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16613 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16614 | } |
6b0655a2 | 16615 | |
718e3744 | 16616 | #include "memory.h" |
16617 | #include "bgp_regex.h" | |
16618 | #include "bgp_clist.h" | |
16619 | #include "bgp_ecommunity.h" | |
16620 | ||
16621 | /* VTY functions. */ | |
16622 | ||
16623 | /* Direction value to string conversion. */ | |
d62a17ae | 16624 | static const char *community_direct_str(int direct) |
16625 | { | |
16626 | switch (direct) { | |
16627 | case COMMUNITY_DENY: | |
16628 | return "deny"; | |
16629 | case COMMUNITY_PERMIT: | |
16630 | return "permit"; | |
16631 | default: | |
16632 | return "unknown"; | |
16633 | } | |
718e3744 | 16634 | } |
16635 | ||
16636 | /* Display error string. */ | |
d62a17ae | 16637 | static void community_list_perror(struct vty *vty, int ret) |
16638 | { | |
16639 | switch (ret) { | |
16640 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16641 | vty_out(vty, "%% Can't find community-list\n"); | |
16642 | break; | |
16643 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16644 | vty_out(vty, "%% Malformed community-list value\n"); | |
16645 | break; | |
16646 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16647 | vty_out(vty, | |
16648 | "%% Community name conflict, previously defined as standard community\n"); | |
16649 | break; | |
16650 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16651 | vty_out(vty, | |
16652 | "%% Community name conflict, previously defined as expanded community\n"); | |
16653 | break; | |
16654 | } | |
718e3744 | 16655 | } |
16656 | ||
5bf15956 DW |
16657 | /* "community-list" keyword help string. */ |
16658 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16659 | ||
7336e101 SP |
16660 | /*community-list standard */ |
16661 | DEFUN (community_list_standard, | |
16662 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 16663 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 16664 | BGP_STR |
718e3744 | 16665 | COMMUNITY_LIST_STR |
16666 | "Community list number (standard)\n" | |
5bf15956 | 16667 | "Add an standard community-list entry\n" |
718e3744 | 16668 | "Community list name\n" |
2f8cc0e5 DA |
16669 | "Sequence number of an entry\n" |
16670 | "Sequence number\n" | |
718e3744 | 16671 | "Specify community to reject\n" |
16672 | "Specify community to accept\n" | |
16673 | COMMUNITY_VAL_STR) | |
16674 | { | |
d62a17ae | 16675 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16676 | char *seq = NULL; |
d62a17ae | 16677 | int direct = 0; |
16678 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16679 | int idx = 0; |
7336e101 | 16680 | |
2f8cc0e5 DA |
16681 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16682 | if (idx) | |
16683 | seq = argv[idx]->arg; | |
16684 | ||
16685 | idx = 0; | |
d62a17ae | 16686 | argv_find(argv, argc, "(1-99)", &idx); |
16687 | argv_find(argv, argc, "WORD", &idx); | |
16688 | cl_name_or_number = argv[idx]->arg; | |
16689 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16690 | : COMMUNITY_DENY; | |
16691 | argv_find(argv, argc, "AA:NN", &idx); | |
16692 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16693 | |
2f8cc0e5 DA |
16694 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16695 | direct, style); | |
42f914d4 | 16696 | |
d62a17ae | 16697 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16698 | |
d62a17ae | 16699 | if (ret < 0) { |
16700 | /* Display error string. */ | |
16701 | community_list_perror(vty, ret); | |
16702 | return CMD_WARNING_CONFIG_FAILED; | |
16703 | } | |
42f914d4 | 16704 | |
d62a17ae | 16705 | return CMD_SUCCESS; |
718e3744 | 16706 | } |
16707 | ||
7336e101 SP |
16708 | DEFUN (no_community_list_standard_all, |
16709 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 16710 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16711 | NO_STR |
16712 | BGP_STR | |
16713 | COMMUNITY_LIST_STR | |
16714 | "Community list number (standard)\n" | |
16715 | "Add an standard community-list entry\n" | |
16716 | "Community list name\n" | |
2f8cc0e5 DA |
16717 | "Sequence number of an entry\n" |
16718 | "Sequence number\n" | |
7336e101 SP |
16719 | "Specify community to reject\n" |
16720 | "Specify community to accept\n" | |
16721 | COMMUNITY_VAL_STR) | |
718e3744 | 16722 | { |
d62a17ae | 16723 | char *cl_name_or_number = NULL; |
174b5cb9 | 16724 | char *str = NULL; |
d62a17ae | 16725 | int direct = 0; |
16726 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 16727 | char *seq = NULL; |
d62a17ae | 16728 | int idx = 0; |
7336e101 | 16729 | |
2f8cc0e5 DA |
16730 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16731 | if (idx) | |
16732 | seq = argv[idx]->arg; | |
16733 | ||
16734 | idx = 0; | |
174b5cb9 DA |
16735 | argv_find(argv, argc, "permit", &idx); |
16736 | argv_find(argv, argc, "deny", &idx); | |
16737 | ||
16738 | if (idx) { | |
16739 | direct = argv_find(argv, argc, "permit", &idx) | |
16740 | ? COMMUNITY_PERMIT | |
16741 | : COMMUNITY_DENY; | |
16742 | ||
16743 | idx = 0; | |
16744 | argv_find(argv, argc, "AA:NN", &idx); | |
16745 | str = argv_concat(argv, argc, idx); | |
16746 | } | |
16747 | ||
16748 | idx = 0; | |
d62a17ae | 16749 | argv_find(argv, argc, "(1-99)", &idx); |
16750 | argv_find(argv, argc, "WORD", &idx); | |
16751 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16752 | |
2f8cc0e5 | 16753 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16754 | direct, style); |
42f914d4 | 16755 | |
d62a17ae | 16756 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16757 | |
d62a17ae | 16758 | if (ret < 0) { |
16759 | community_list_perror(vty, ret); | |
16760 | return CMD_WARNING_CONFIG_FAILED; | |
16761 | } | |
42f914d4 | 16762 | |
d62a17ae | 16763 | return CMD_SUCCESS; |
718e3744 | 16764 | } |
7336e101 | 16765 | |
174b5cb9 DA |
16766 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
16767 | "no bgp community-list <(1-99)|standard WORD>", | |
16768 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
16769 | "Community list number (standard)\n" | |
16770 | "Add an standard community-list entry\n" | |
16771 | "Community list name\n") | |
16772 | ||
7336e101 SP |
16773 | /*community-list expanded */ |
16774 | DEFUN (community_list_expanded_all, | |
16775 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16776 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16777 | BGP_STR |
16778 | COMMUNITY_LIST_STR | |
718e3744 | 16779 | "Community list number (expanded)\n" |
5bf15956 | 16780 | "Add an expanded community-list entry\n" |
718e3744 | 16781 | "Community list name\n" |
2f8cc0e5 DA |
16782 | "Sequence number of an entry\n" |
16783 | "Sequence number\n" | |
718e3744 | 16784 | "Specify community to reject\n" |
16785 | "Specify community to accept\n" | |
16786 | COMMUNITY_VAL_STR) | |
16787 | { | |
d62a17ae | 16788 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16789 | char *seq = NULL; |
d62a17ae | 16790 | int direct = 0; |
16791 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16792 | int idx = 0; |
7b9a4750 | 16793 | |
2f8cc0e5 DA |
16794 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16795 | if (idx) | |
16796 | seq = argv[idx]->arg; | |
16797 | ||
16798 | idx = 0; | |
16799 | ||
d62a17ae | 16800 | argv_find(argv, argc, "(100-500)", &idx); |
16801 | argv_find(argv, argc, "WORD", &idx); | |
16802 | cl_name_or_number = argv[idx]->arg; | |
16803 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16804 | : COMMUNITY_DENY; | |
16805 | argv_find(argv, argc, "AA:NN", &idx); | |
16806 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16807 | |
2f8cc0e5 DA |
16808 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16809 | direct, style); | |
42f914d4 | 16810 | |
d62a17ae | 16811 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16812 | |
d62a17ae | 16813 | if (ret < 0) { |
16814 | /* Display error string. */ | |
16815 | community_list_perror(vty, ret); | |
16816 | return CMD_WARNING_CONFIG_FAILED; | |
16817 | } | |
42f914d4 | 16818 | |
d62a17ae | 16819 | return CMD_SUCCESS; |
718e3744 | 16820 | } |
16821 | ||
7336e101 SP |
16822 | DEFUN (no_community_list_expanded_all, |
16823 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16824 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16825 | NO_STR |
16826 | BGP_STR | |
16827 | COMMUNITY_LIST_STR | |
16828 | "Community list number (expanded)\n" | |
16829 | "Add an expanded community-list entry\n" | |
16830 | "Community list name\n" | |
2f8cc0e5 DA |
16831 | "Sequence number of an entry\n" |
16832 | "Sequence number\n" | |
7336e101 SP |
16833 | "Specify community to reject\n" |
16834 | "Specify community to accept\n" | |
16835 | COMMUNITY_VAL_STR) | |
718e3744 | 16836 | { |
d62a17ae | 16837 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16838 | char *seq = NULL; |
174b5cb9 | 16839 | char *str = NULL; |
d62a17ae | 16840 | int direct = 0; |
16841 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16842 | int idx = 0; |
174b5cb9 | 16843 | |
2f8cc0e5 DA |
16844 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16845 | if (idx) | |
16846 | seq = argv[idx]->arg; | |
16847 | ||
16848 | idx = 0; | |
174b5cb9 DA |
16849 | argv_find(argv, argc, "permit", &idx); |
16850 | argv_find(argv, argc, "deny", &idx); | |
16851 | ||
16852 | if (idx) { | |
16853 | direct = argv_find(argv, argc, "permit", &idx) | |
16854 | ? COMMUNITY_PERMIT | |
16855 | : COMMUNITY_DENY; | |
16856 | ||
16857 | idx = 0; | |
16858 | argv_find(argv, argc, "AA:NN", &idx); | |
16859 | str = argv_concat(argv, argc, idx); | |
7336e101 | 16860 | } |
174b5cb9 DA |
16861 | |
16862 | idx = 0; | |
d62a17ae | 16863 | argv_find(argv, argc, "(100-500)", &idx); |
16864 | argv_find(argv, argc, "WORD", &idx); | |
16865 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16866 | |
2f8cc0e5 | 16867 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16868 | direct, style); |
42f914d4 | 16869 | |
d62a17ae | 16870 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16871 | |
d62a17ae | 16872 | if (ret < 0) { |
16873 | community_list_perror(vty, ret); | |
16874 | return CMD_WARNING_CONFIG_FAILED; | |
16875 | } | |
42f914d4 | 16876 | |
d62a17ae | 16877 | return CMD_SUCCESS; |
718e3744 | 16878 | } |
16879 | ||
174b5cb9 DA |
16880 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
16881 | "no bgp community-list <(100-500)|expanded WORD>", | |
16882 | NO_STR IP_STR COMMUNITY_LIST_STR | |
16883 | "Community list number (expanded)\n" | |
16884 | "Add an expanded community-list entry\n" | |
16885 | "Community list name\n") | |
16886 | ||
8d9b8ed9 PM |
16887 | /* Return configuration string of community-list entry. */ |
16888 | static const char *community_list_config_str(struct community_entry *entry) | |
16889 | { | |
16890 | const char *str; | |
16891 | ||
16892 | if (entry->any) | |
16893 | str = ""; | |
16894 | else { | |
16895 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
16896 | str = community_str(entry->u.com, false); | |
16897 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
16898 | str = lcommunity_str(entry->u.lcom, false); | |
16899 | else | |
16900 | str = entry->config; | |
16901 | } | |
16902 | return str; | |
16903 | } | |
16904 | ||
d62a17ae | 16905 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 16906 | { |
d62a17ae | 16907 | struct community_entry *entry; |
718e3744 | 16908 | |
d62a17ae | 16909 | for (entry = list->head; entry; entry = entry->next) { |
16910 | if (entry == list->head) { | |
16911 | if (all_digit(list->name)) | |
16912 | vty_out(vty, "Community %s list %s\n", | |
16913 | entry->style == COMMUNITY_LIST_STANDARD | |
16914 | ? "standard" | |
16915 | : "(expanded) access", | |
16916 | list->name); | |
16917 | else | |
16918 | vty_out(vty, "Named Community %s list %s\n", | |
16919 | entry->style == COMMUNITY_LIST_STANDARD | |
16920 | ? "standard" | |
16921 | : "expanded", | |
16922 | list->name); | |
16923 | } | |
16924 | if (entry->any) | |
16925 | vty_out(vty, " %s\n", | |
16926 | community_direct_str(entry->direct)); | |
16927 | else | |
16928 | vty_out(vty, " %s %s\n", | |
16929 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16930 | community_list_config_str(entry)); |
d62a17ae | 16931 | } |
718e3744 | 16932 | } |
16933 | ||
7336e101 SP |
16934 | DEFUN (show_community_list, |
16935 | show_bgp_community_list_cmd, | |
16936 | "show bgp community-list", | |
718e3744 | 16937 | SHOW_STR |
7336e101 | 16938 | BGP_STR |
718e3744 | 16939 | "List community-list\n") |
16940 | { | |
d62a17ae | 16941 | struct community_list *list; |
16942 | struct community_list_master *cm; | |
718e3744 | 16943 | |
d62a17ae | 16944 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
16945 | if (!cm) | |
16946 | return CMD_SUCCESS; | |
718e3744 | 16947 | |
d62a17ae | 16948 | for (list = cm->num.head; list; list = list->next) |
16949 | community_list_show(vty, list); | |
718e3744 | 16950 | |
d62a17ae | 16951 | for (list = cm->str.head; list; list = list->next) |
16952 | community_list_show(vty, list); | |
718e3744 | 16953 | |
d62a17ae | 16954 | return CMD_SUCCESS; |
718e3744 | 16955 | } |
16956 | ||
7336e101 SP |
16957 | DEFUN (show_community_list_arg, |
16958 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 16959 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
16960 | SHOW_STR |
16961 | BGP_STR | |
718e3744 | 16962 | "List community-list\n" |
16963 | "Community-list number\n" | |
960b69b9 | 16964 | "Community-list name\n" |
16965 | "Detailed information on community-list\n") | |
718e3744 | 16966 | { |
d62a17ae | 16967 | int idx_comm_list = 3; |
16968 | struct community_list *list; | |
718e3744 | 16969 | |
e237b0d2 | 16970 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 16971 | COMMUNITY_LIST_MASTER); |
16972 | if (!list) { | |
16973 | vty_out(vty, "%% Can't find community-list\n"); | |
16974 | return CMD_WARNING; | |
16975 | } | |
718e3744 | 16976 | |
d62a17ae | 16977 | community_list_show(vty, list); |
718e3744 | 16978 | |
d62a17ae | 16979 | return CMD_SUCCESS; |
718e3744 | 16980 | } |
6b0655a2 | 16981 | |
57d187bc JS |
16982 | /* |
16983 | * Large Community code. | |
16984 | */ | |
d62a17ae | 16985 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
16986 | struct cmd_token **argv, int style, | |
16987 | int reject_all_digit_name) | |
16988 | { | |
16989 | int ret; | |
16990 | int direct; | |
16991 | char *str; | |
16992 | int idx = 0; | |
16993 | char *cl_name; | |
2f8cc0e5 DA |
16994 | char *seq = NULL; |
16995 | ||
16996 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
16997 | if (idx) | |
16998 | seq = argv[idx]->arg; | |
d62a17ae | 16999 | |
2f8cc0e5 | 17000 | idx = 0; |
d62a17ae | 17001 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17002 | : COMMUNITY_DENY; | |
17003 | ||
17004 | /* All digit name check. */ | |
17005 | idx = 0; | |
17006 | argv_find(argv, argc, "WORD", &idx); | |
17007 | argv_find(argv, argc, "(1-99)", &idx); | |
17008 | argv_find(argv, argc, "(100-500)", &idx); | |
17009 | cl_name = argv[idx]->arg; | |
17010 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17011 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17012 | return CMD_WARNING_CONFIG_FAILED; | |
17013 | } | |
17014 | ||
17015 | idx = 0; | |
17016 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17017 | argv_find(argv, argc, "LINE", &idx); | |
17018 | /* Concat community string argument. */ | |
17019 | if (idx) | |
17020 | str = argv_concat(argv, argc, idx); | |
17021 | else | |
17022 | str = NULL; | |
17023 | ||
2f8cc0e5 | 17024 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17025 | |
17026 | /* Free temporary community list string allocated by | |
17027 | argv_concat(). */ | |
0a22ddfb | 17028 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17029 | |
17030 | if (ret < 0) { | |
17031 | community_list_perror(vty, ret); | |
17032 | return CMD_WARNING_CONFIG_FAILED; | |
17033 | } | |
17034 | return CMD_SUCCESS; | |
17035 | } | |
17036 | ||
17037 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17038 | struct cmd_token **argv, int style) | |
17039 | { | |
17040 | int ret; | |
17041 | int direct = 0; | |
17042 | char *str = NULL; | |
17043 | int idx = 0; | |
2f8cc0e5 | 17044 | char *seq = NULL; |
d62a17ae | 17045 | |
2f8cc0e5 DA |
17046 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17047 | if (idx) | |
17048 | seq = argv[idx]->arg; | |
d62a17ae | 17049 | |
2f8cc0e5 | 17050 | idx = 0; |
d62a17ae | 17051 | argv_find(argv, argc, "permit", &idx); |
17052 | argv_find(argv, argc, "deny", &idx); | |
17053 | ||
17054 | if (idx) { | |
17055 | /* Check the list direct. */ | |
17056 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17057 | direct = COMMUNITY_PERMIT; | |
17058 | else | |
17059 | direct = COMMUNITY_DENY; | |
17060 | ||
17061 | idx = 0; | |
17062 | argv_find(argv, argc, "LINE", &idx); | |
17063 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17064 | /* Concat community string argument. */ | |
17065 | str = argv_concat(argv, argc, idx); | |
17066 | } | |
17067 | ||
17068 | idx = 0; | |
17069 | argv_find(argv, argc, "(1-99)", &idx); | |
17070 | argv_find(argv, argc, "(100-500)", &idx); | |
17071 | argv_find(argv, argc, "WORD", &idx); | |
17072 | ||
17073 | /* Unset community list. */ | |
2f8cc0e5 | 17074 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17075 | style); |
17076 | ||
17077 | /* Free temporary community list string allocated by | |
17078 | argv_concat(). */ | |
0a22ddfb | 17079 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17080 | |
17081 | if (ret < 0) { | |
17082 | community_list_perror(vty, ret); | |
17083 | return CMD_WARNING_CONFIG_FAILED; | |
17084 | } | |
17085 | ||
17086 | return CMD_SUCCESS; | |
57d187bc JS |
17087 | } |
17088 | ||
17089 | /* "large-community-list" keyword help string. */ | |
17090 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17091 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17092 | ||
7336e101 SP |
17093 | DEFUN (lcommunity_list_standard, |
17094 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17095 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17096 | BGP_STR |
17097 | LCOMMUNITY_LIST_STR | |
17098 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17099 | "Sequence number of an entry\n" |
17100 | "Sequence number\n" | |
7336e101 SP |
17101 | "Specify large community to reject\n" |
17102 | "Specify large community to accept\n" | |
17103 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17104 | { |
d62a17ae | 17105 | return lcommunity_list_set_vty(vty, argc, argv, |
17106 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17107 | } |
17108 | ||
7336e101 SP |
17109 | DEFUN (lcommunity_list_expanded, |
17110 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17111 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17112 | BGP_STR |
17113 | LCOMMUNITY_LIST_STR | |
17114 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17115 | "Sequence number of an entry\n" |
17116 | "Sequence number\n" | |
7336e101 SP |
17117 | "Specify large community to reject\n" |
17118 | "Specify large community to accept\n" | |
17119 | "An ordered list as a regular-expression\n") | |
57d187bc | 17120 | { |
d62a17ae | 17121 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17122 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17123 | } |
17124 | ||
7336e101 SP |
17125 | DEFUN (lcommunity_list_name_standard, |
17126 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17127 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17128 | BGP_STR |
17129 | LCOMMUNITY_LIST_STR | |
17130 | "Specify standard large-community-list\n" | |
17131 | "Large Community list name\n" | |
2f8cc0e5 DA |
17132 | "Sequence number of an entry\n" |
17133 | "Sequence number\n" | |
7336e101 SP |
17134 | "Specify large community to reject\n" |
17135 | "Specify large community to accept\n" | |
17136 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17137 | { |
d62a17ae | 17138 | return lcommunity_list_set_vty(vty, argc, argv, |
17139 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17140 | } |
17141 | ||
7336e101 SP |
17142 | DEFUN (lcommunity_list_name_expanded, |
17143 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17144 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17145 | BGP_STR |
17146 | LCOMMUNITY_LIST_STR | |
17147 | "Specify expanded large-community-list\n" | |
17148 | "Large Community list name\n" | |
2f8cc0e5 DA |
17149 | "Sequence number of an entry\n" |
17150 | "Sequence number\n" | |
7336e101 SP |
17151 | "Specify large community to reject\n" |
17152 | "Specify large community to accept\n" | |
17153 | "An ordered list as a regular-expression\n") | |
57d187bc | 17154 | { |
d62a17ae | 17155 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17156 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17157 | } |
17158 | ||
4378f57c DA |
17159 | DEFUN (no_lcommunity_list_all, |
17160 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17161 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17162 | NO_STR | |
17163 | BGP_STR | |
17164 | LCOMMUNITY_LIST_STR | |
17165 | "Large Community list number (standard)\n" | |
17166 | "Large Community list number (expanded)\n" | |
17167 | "Large Community list name\n") | |
57d187bc | 17168 | { |
7336e101 SP |
17169 | return lcommunity_list_unset_vty(vty, argc, argv, |
17170 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17171 | } |
17172 | ||
4378f57c DA |
17173 | DEFUN (no_lcommunity_list_name_standard_all, |
17174 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17175 | "no bgp large-community-list standard WORD", | |
17176 | NO_STR | |
17177 | BGP_STR | |
17178 | LCOMMUNITY_LIST_STR | |
17179 | "Specify standard large-community-list\n" | |
17180 | "Large Community list name\n") | |
17181 | { | |
17182 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17183 | LARGE_COMMUNITY_LIST_STANDARD); | |
17184 | } | |
17185 | ||
7336e101 SP |
17186 | DEFUN (no_lcommunity_list_name_expanded_all, |
17187 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17188 | "no bgp large-community-list expanded WORD", | |
17189 | NO_STR | |
17190 | BGP_STR | |
17191 | LCOMMUNITY_LIST_STR | |
17192 | "Specify expanded large-community-list\n" | |
17193 | "Large Community list name\n") | |
57d187bc | 17194 | { |
d62a17ae | 17195 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17196 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17197 | } |
17198 | ||
7336e101 SP |
17199 | DEFUN (no_lcommunity_list_standard, |
17200 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17201 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17202 | NO_STR |
17203 | BGP_STR | |
17204 | LCOMMUNITY_LIST_STR | |
17205 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17206 | "Sequence number of an entry\n" |
17207 | "Sequence number\n" | |
7336e101 SP |
17208 | "Specify large community to reject\n" |
17209 | "Specify large community to accept\n" | |
17210 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17211 | { |
d62a17ae | 17212 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17213 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17214 | } |
17215 | ||
7336e101 SP |
17216 | DEFUN (no_lcommunity_list_expanded, |
17217 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17218 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17219 | NO_STR |
17220 | BGP_STR | |
17221 | LCOMMUNITY_LIST_STR | |
17222 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17223 | "Sequence number of an entry\n" |
17224 | "Sequence number\n" | |
7336e101 SP |
17225 | "Specify large community to reject\n" |
17226 | "Specify large community to accept\n" | |
17227 | "An ordered list as a regular-expression\n") | |
57d187bc | 17228 | { |
d62a17ae | 17229 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17230 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17231 | } |
17232 | ||
7336e101 SP |
17233 | DEFUN (no_lcommunity_list_name_standard, |
17234 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17235 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17236 | NO_STR |
17237 | BGP_STR | |
17238 | LCOMMUNITY_LIST_STR | |
17239 | "Specify standard large-community-list\n" | |
17240 | "Large Community list name\n" | |
2f8cc0e5 DA |
17241 | "Sequence number of an entry\n" |
17242 | "Sequence number\n" | |
7336e101 SP |
17243 | "Specify large community to reject\n" |
17244 | "Specify large community to accept\n" | |
17245 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17246 | { |
d62a17ae | 17247 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17248 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17249 | } |
17250 | ||
7336e101 SP |
17251 | DEFUN (no_lcommunity_list_name_expanded, |
17252 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17253 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17254 | NO_STR |
17255 | BGP_STR | |
17256 | LCOMMUNITY_LIST_STR | |
17257 | "Specify expanded large-community-list\n" | |
17258 | "Large community list name\n" | |
2f8cc0e5 DA |
17259 | "Sequence number of an entry\n" |
17260 | "Sequence number\n" | |
7336e101 SP |
17261 | "Specify large community to reject\n" |
17262 | "Specify large community to accept\n" | |
17263 | "An ordered list as a regular-expression\n") | |
57d187bc | 17264 | { |
d62a17ae | 17265 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17266 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17267 | } |
17268 | ||
d62a17ae | 17269 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17270 | { | |
17271 | struct community_entry *entry; | |
17272 | ||
17273 | for (entry = list->head; entry; entry = entry->next) { | |
17274 | if (entry == list->head) { | |
17275 | if (all_digit(list->name)) | |
17276 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17277 | entry->style == |
17278 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17279 | ? "standard" |
17280 | : "(expanded) access", | |
17281 | list->name); | |
17282 | else | |
17283 | vty_out(vty, | |
17284 | "Named large community %s list %s\n", | |
169b72c8 | 17285 | entry->style == |
17286 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17287 | ? "standard" |
17288 | : "expanded", | |
17289 | list->name); | |
17290 | } | |
17291 | if (entry->any) | |
17292 | vty_out(vty, " %s\n", | |
17293 | community_direct_str(entry->direct)); | |
17294 | else | |
17295 | vty_out(vty, " %s %s\n", | |
17296 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17297 | community_list_config_str(entry)); |
d62a17ae | 17298 | } |
57d187bc JS |
17299 | } |
17300 | ||
7336e101 SP |
17301 | DEFUN (show_lcommunity_list, |
17302 | show_bgp_lcommunity_list_cmd, | |
17303 | "show bgp large-community-list", | |
57d187bc | 17304 | SHOW_STR |
7336e101 | 17305 | BGP_STR |
57d187bc JS |
17306 | "List large-community list\n") |
17307 | { | |
d62a17ae | 17308 | struct community_list *list; |
17309 | struct community_list_master *cm; | |
57d187bc | 17310 | |
d62a17ae | 17311 | cm = community_list_master_lookup(bgp_clist, |
17312 | LARGE_COMMUNITY_LIST_MASTER); | |
17313 | if (!cm) | |
17314 | return CMD_SUCCESS; | |
57d187bc | 17315 | |
d62a17ae | 17316 | for (list = cm->num.head; list; list = list->next) |
17317 | lcommunity_list_show(vty, list); | |
57d187bc | 17318 | |
d62a17ae | 17319 | for (list = cm->str.head; list; list = list->next) |
17320 | lcommunity_list_show(vty, list); | |
57d187bc | 17321 | |
d62a17ae | 17322 | return CMD_SUCCESS; |
57d187bc JS |
17323 | } |
17324 | ||
7336e101 SP |
17325 | DEFUN (show_lcommunity_list_arg, |
17326 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17327 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17328 | SHOW_STR |
17329 | BGP_STR | |
57d187bc | 17330 | "List large-community list\n" |
960b69b9 | 17331 | "Large-community-list number\n" |
17332 | "Large-community-list name\n" | |
17333 | "Detailed information on large-community-list\n") | |
57d187bc | 17334 | { |
d62a17ae | 17335 | struct community_list *list; |
57d187bc | 17336 | |
e237b0d2 | 17337 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17338 | LARGE_COMMUNITY_LIST_MASTER); |
17339 | if (!list) { | |
960b69b9 | 17340 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17341 | return CMD_WARNING; |
17342 | } | |
57d187bc | 17343 | |
d62a17ae | 17344 | lcommunity_list_show(vty, list); |
57d187bc | 17345 | |
d62a17ae | 17346 | return CMD_SUCCESS; |
57d187bc JS |
17347 | } |
17348 | ||
718e3744 | 17349 | /* "extcommunity-list" keyword help string. */ |
17350 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17351 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17352 | ||
7336e101 SP |
17353 | DEFUN (extcommunity_list_standard, |
17354 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17355 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17356 | BGP_STR |
718e3744 | 17357 | EXTCOMMUNITY_LIST_STR |
17358 | "Extended Community list number (standard)\n" | |
718e3744 | 17359 | "Specify standard extcommunity-list\n" |
5bf15956 | 17360 | "Community list name\n" |
2f8cc0e5 DA |
17361 | "Sequence number of an entry\n" |
17362 | "Sequence number\n" | |
718e3744 | 17363 | "Specify community to reject\n" |
17364 | "Specify community to accept\n" | |
17365 | EXTCOMMUNITY_VAL_STR) | |
17366 | { | |
d62a17ae | 17367 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17368 | int direct = 0; | |
17369 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17370 | char *seq = NULL; |
42f914d4 | 17371 | |
d62a17ae | 17372 | int idx = 0; |
7b9a4750 | 17373 | |
d62a17ae | 17374 | argv_find(argv, argc, "(1-99)", &idx); |
17375 | argv_find(argv, argc, "WORD", &idx); | |
17376 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17377 | |
17378 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17379 | if (idx) | |
17380 | seq = argv[idx]->arg; | |
17381 | ||
d62a17ae | 17382 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17383 | : COMMUNITY_DENY; | |
17384 | argv_find(argv, argc, "AA:NN", &idx); | |
17385 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17386 | |
2f8cc0e5 | 17387 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17388 | direct, style); |
42f914d4 | 17389 | |
d62a17ae | 17390 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17391 | |
d62a17ae | 17392 | if (ret < 0) { |
17393 | community_list_perror(vty, ret); | |
17394 | return CMD_WARNING_CONFIG_FAILED; | |
17395 | } | |
42f914d4 | 17396 | |
d62a17ae | 17397 | return CMD_SUCCESS; |
718e3744 | 17398 | } |
17399 | ||
7336e101 SP |
17400 | DEFUN (extcommunity_list_name_expanded, |
17401 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17402 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17403 | BGP_STR |
17404 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17405 | "Extended Community list number (expanded)\n" |
718e3744 | 17406 | "Specify expanded extcommunity-list\n" |
17407 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17408 | "Sequence number of an entry\n" |
17409 | "Sequence number\n" | |
718e3744 | 17410 | "Specify community to reject\n" |
17411 | "Specify community to accept\n" | |
17412 | "An ordered list as a regular-expression\n") | |
17413 | { | |
d62a17ae | 17414 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17415 | int direct = 0; | |
17416 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17417 | char *seq = NULL; |
d62a17ae | 17418 | int idx = 0; |
7336e101 | 17419 | |
d62a17ae | 17420 | argv_find(argv, argc, "(100-500)", &idx); |
17421 | argv_find(argv, argc, "WORD", &idx); | |
17422 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17423 | |
17424 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17425 | if (idx) | |
17426 | seq = argv[idx]->arg; | |
17427 | ||
d62a17ae | 17428 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17429 | : COMMUNITY_DENY; | |
17430 | argv_find(argv, argc, "LINE", &idx); | |
17431 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17432 | |
2f8cc0e5 | 17433 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17434 | direct, style); |
42f914d4 | 17435 | |
d62a17ae | 17436 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17437 | |
d62a17ae | 17438 | if (ret < 0) { |
17439 | community_list_perror(vty, ret); | |
17440 | return CMD_WARNING_CONFIG_FAILED; | |
17441 | } | |
42f914d4 | 17442 | |
d62a17ae | 17443 | return CMD_SUCCESS; |
718e3744 | 17444 | } |
17445 | ||
7336e101 SP |
17446 | DEFUN (no_extcommunity_list_standard_all, |
17447 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17448 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17449 | NO_STR |
17450 | BGP_STR | |
17451 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17452 | "Extended Community list number (standard)\n" |
718e3744 | 17453 | "Specify standard extcommunity-list\n" |
5bf15956 | 17454 | "Community list name\n" |
2f8cc0e5 DA |
17455 | "Sequence number of an entry\n" |
17456 | "Sequence number\n" | |
718e3744 | 17457 | "Specify community to reject\n" |
17458 | "Specify community to accept\n" | |
17459 | EXTCOMMUNITY_VAL_STR) | |
17460 | { | |
d62a17ae | 17461 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17462 | int direct = 0; | |
17463 | char *cl_number_or_name = NULL; | |
d4455c89 | 17464 | char *str = NULL; |
2f8cc0e5 | 17465 | char *seq = NULL; |
d62a17ae | 17466 | int idx = 0; |
d4455c89 | 17467 | |
2f8cc0e5 DA |
17468 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17469 | if (idx) | |
17470 | seq = argv[idx]->arg; | |
17471 | ||
17472 | idx = 0; | |
d4455c89 DA |
17473 | argv_find(argv, argc, "permit", &idx); |
17474 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17475 | if (idx) { |
17476 | direct = argv_find(argv, argc, "permit", &idx) | |
17477 | ? COMMUNITY_PERMIT | |
17478 | : COMMUNITY_DENY; | |
17479 | ||
17480 | idx = 0; | |
17481 | argv_find(argv, argc, "AA:NN", &idx); | |
17482 | str = argv_concat(argv, argc, idx); | |
17483 | } | |
17484 | ||
17485 | idx = 0; | |
d62a17ae | 17486 | argv_find(argv, argc, "(1-99)", &idx); |
17487 | argv_find(argv, argc, "WORD", &idx); | |
17488 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17489 | |
d62a17ae | 17490 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17491 | seq, direct, style); |
42f914d4 | 17492 | |
d62a17ae | 17493 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17494 | |
d62a17ae | 17495 | if (ret < 0) { |
17496 | community_list_perror(vty, ret); | |
17497 | return CMD_WARNING_CONFIG_FAILED; | |
17498 | } | |
42f914d4 | 17499 | |
d62a17ae | 17500 | return CMD_SUCCESS; |
718e3744 | 17501 | } |
17502 | ||
d4455c89 DA |
17503 | ALIAS(no_extcommunity_list_standard_all, |
17504 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17505 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17506 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17507 | "Extended Community list number (standard)\n" | |
17508 | "Specify standard extcommunity-list\n" | |
17509 | "Community list name\n") | |
17510 | ||
7336e101 SP |
17511 | DEFUN (no_extcommunity_list_expanded_all, |
17512 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17513 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17514 | NO_STR |
17515 | BGP_STR | |
17516 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17517 | "Extended Community list number (expanded)\n" |
718e3744 | 17518 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17519 | "Extended Community list name\n" |
2f8cc0e5 DA |
17520 | "Sequence number of an entry\n" |
17521 | "Sequence number\n" | |
718e3744 | 17522 | "Specify community to reject\n" |
17523 | "Specify community to accept\n" | |
17524 | "An ordered list as a regular-expression\n") | |
17525 | { | |
d62a17ae | 17526 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17527 | int direct = 0; | |
17528 | char *cl_number_or_name = NULL; | |
d4455c89 | 17529 | char *str = NULL; |
2f8cc0e5 | 17530 | char *seq = NULL; |
d62a17ae | 17531 | int idx = 0; |
d4455c89 | 17532 | |
2f8cc0e5 DA |
17533 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17534 | if (idx) | |
17535 | seq = argv[idx]->arg; | |
17536 | ||
17537 | idx = 0; | |
d4455c89 DA |
17538 | argv_find(argv, argc, "permit", &idx); |
17539 | argv_find(argv, argc, "deny", &idx); | |
17540 | ||
17541 | if (idx) { | |
17542 | direct = argv_find(argv, argc, "permit", &idx) | |
17543 | ? COMMUNITY_PERMIT | |
17544 | : COMMUNITY_DENY; | |
17545 | ||
17546 | idx = 0; | |
17547 | argv_find(argv, argc, "LINE", &idx); | |
17548 | str = argv_concat(argv, argc, idx); | |
17549 | } | |
17550 | ||
17551 | idx = 0; | |
d62a17ae | 17552 | argv_find(argv, argc, "(100-500)", &idx); |
17553 | argv_find(argv, argc, "WORD", &idx); | |
17554 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17555 | |
d62a17ae | 17556 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17557 | seq, direct, style); |
42f914d4 | 17558 | |
d62a17ae | 17559 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17560 | |
d62a17ae | 17561 | if (ret < 0) { |
17562 | community_list_perror(vty, ret); | |
17563 | return CMD_WARNING_CONFIG_FAILED; | |
17564 | } | |
42f914d4 | 17565 | |
d62a17ae | 17566 | return CMD_SUCCESS; |
718e3744 | 17567 | } |
17568 | ||
d4455c89 DA |
17569 | ALIAS(no_extcommunity_list_expanded_all, |
17570 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17571 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17572 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17573 | "Extended Community list number (expanded)\n" | |
17574 | "Specify expanded extcommunity-list\n" | |
17575 | "Extended Community list name\n") | |
17576 | ||
d62a17ae | 17577 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17578 | { |
d62a17ae | 17579 | struct community_entry *entry; |
718e3744 | 17580 | |
d62a17ae | 17581 | for (entry = list->head; entry; entry = entry->next) { |
17582 | if (entry == list->head) { | |
17583 | if (all_digit(list->name)) | |
17584 | vty_out(vty, "Extended community %s list %s\n", | |
17585 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17586 | ? "standard" | |
17587 | : "(expanded) access", | |
17588 | list->name); | |
17589 | else | |
17590 | vty_out(vty, | |
17591 | "Named extended community %s list %s\n", | |
17592 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17593 | ? "standard" | |
17594 | : "expanded", | |
17595 | list->name); | |
17596 | } | |
17597 | if (entry->any) | |
17598 | vty_out(vty, " %s\n", | |
17599 | community_direct_str(entry->direct)); | |
17600 | else | |
17601 | vty_out(vty, " %s %s\n", | |
17602 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17603 | community_list_config_str(entry)); |
d62a17ae | 17604 | } |
718e3744 | 17605 | } |
17606 | ||
7336e101 SP |
17607 | DEFUN (show_extcommunity_list, |
17608 | show_bgp_extcommunity_list_cmd, | |
17609 | "show bgp extcommunity-list", | |
718e3744 | 17610 | SHOW_STR |
7336e101 | 17611 | BGP_STR |
718e3744 | 17612 | "List extended-community list\n") |
17613 | { | |
d62a17ae | 17614 | struct community_list *list; |
17615 | struct community_list_master *cm; | |
718e3744 | 17616 | |
d62a17ae | 17617 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17618 | if (!cm) | |
17619 | return CMD_SUCCESS; | |
718e3744 | 17620 | |
d62a17ae | 17621 | for (list = cm->num.head; list; list = list->next) |
17622 | extcommunity_list_show(vty, list); | |
718e3744 | 17623 | |
d62a17ae | 17624 | for (list = cm->str.head; list; list = list->next) |
17625 | extcommunity_list_show(vty, list); | |
718e3744 | 17626 | |
d62a17ae | 17627 | return CMD_SUCCESS; |
718e3744 | 17628 | } |
17629 | ||
7336e101 SP |
17630 | DEFUN (show_extcommunity_list_arg, |
17631 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17632 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17633 | SHOW_STR |
17634 | BGP_STR | |
718e3744 | 17635 | "List extended-community list\n" |
17636 | "Extcommunity-list number\n" | |
960b69b9 | 17637 | "Extcommunity-list name\n" |
17638 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17639 | { |
d62a17ae | 17640 | int idx_comm_list = 3; |
17641 | struct community_list *list; | |
718e3744 | 17642 | |
e237b0d2 | 17643 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17644 | EXTCOMMUNITY_LIST_MASTER); |
17645 | if (!list) { | |
17646 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17647 | return CMD_WARNING; | |
17648 | } | |
718e3744 | 17649 | |
d62a17ae | 17650 | extcommunity_list_show(vty, list); |
718e3744 | 17651 | |
d62a17ae | 17652 | return CMD_SUCCESS; |
718e3744 | 17653 | } |
6b0655a2 | 17654 | |
718e3744 | 17655 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17656 | static int community_list_config_write(struct vty *vty) |
17657 | { | |
17658 | struct community_list *list; | |
17659 | struct community_entry *entry; | |
17660 | struct community_list_master *cm; | |
17661 | int write = 0; | |
17662 | ||
17663 | /* Community-list. */ | |
17664 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17665 | ||
17666 | for (list = cm->num.head; list; list = list->next) | |
17667 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17668 | vty_out(vty, |
17669 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
17670 | list->name, entry->seq, | |
d62a17ae | 17671 | community_direct_str(entry->direct), |
17672 | community_list_config_str(entry)); | |
17673 | write++; | |
17674 | } | |
17675 | for (list = cm->str.head; list; list = list->next) | |
17676 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17677 | vty_out(vty, |
17678 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 17679 | entry->style == COMMUNITY_LIST_STANDARD |
17680 | ? "standard" | |
17681 | : "expanded", | |
2f8cc0e5 DA |
17682 | list->name, entry->seq, |
17683 | community_direct_str(entry->direct), | |
d62a17ae | 17684 | community_list_config_str(entry)); |
17685 | write++; | |
17686 | } | |
17687 | ||
17688 | /* Extcommunity-list. */ | |
17689 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17690 | ||
17691 | for (list = cm->num.head; list; list = list->next) | |
17692 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17693 | vty_out(vty, |
17694 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
17695 | list->name, entry->seq, | |
17696 | community_direct_str(entry->direct), | |
d62a17ae | 17697 | community_list_config_str(entry)); |
17698 | write++; | |
17699 | } | |
17700 | for (list = cm->str.head; list; list = list->next) | |
17701 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17702 | vty_out(vty, |
17703 | "bgp extcommunity-list %s %s seq %" PRId64 | |
17704 | " %s %s\n", | |
d62a17ae | 17705 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17706 | ? "standard" | |
17707 | : "expanded", | |
2f8cc0e5 DA |
17708 | list->name, entry->seq, |
17709 | community_direct_str(entry->direct), | |
d62a17ae | 17710 | community_list_config_str(entry)); |
17711 | write++; | |
17712 | } | |
17713 | ||
17714 | ||
17715 | /* lcommunity-list. */ | |
17716 | cm = community_list_master_lookup(bgp_clist, | |
17717 | LARGE_COMMUNITY_LIST_MASTER); | |
17718 | ||
17719 | for (list = cm->num.head; list; list = list->next) | |
17720 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17721 | vty_out(vty, |
17722 | "bgp large-community-list %s seq %" PRId64 | |
17723 | " %s %s\n", | |
17724 | list->name, entry->seq, | |
17725 | community_direct_str(entry->direct), | |
d62a17ae | 17726 | community_list_config_str(entry)); |
17727 | write++; | |
17728 | } | |
17729 | for (list = cm->str.head; list; list = list->next) | |
17730 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17731 | vty_out(vty, |
17732 | "bgp large-community-list %s %s seq %" PRId64 | |
17733 | " %s %s\n", | |
17734 | ||
d62a17ae | 17735 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17736 | ? "standard" | |
17737 | : "expanded", | |
2f8cc0e5 | 17738 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 17739 | community_list_config_str(entry)); |
17740 | write++; | |
17741 | } | |
17742 | ||
17743 | return write; | |
17744 | } | |
17745 | ||
17746 | static struct cmd_node community_list_node = { | |
17747 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 17748 | }; |
17749 | ||
d62a17ae | 17750 | static void community_list_vty(void) |
17751 | { | |
17752 | install_node(&community_list_node, community_list_config_write); | |
17753 | ||
17754 | /* Community-list. */ | |
7336e101 SP |
17755 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
17756 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
17757 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 17758 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 17759 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 17760 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
17761 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
17762 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 17763 | |
17764 | /* Extcommunity-list. */ | |
7336e101 SP |
17765 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
17766 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
17767 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
17768 | install_element(CONFIG_NODE, |
17769 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 17770 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
17771 | install_element(CONFIG_NODE, |
17772 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
17773 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
17774 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 17775 | |
17776 | /* Large Community List */ | |
7336e101 | 17777 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
17778 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
17779 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 17780 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
17781 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
17782 | install_element(CONFIG_NODE, | |
17783 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
17784 | install_element(CONFIG_NODE, |
17785 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
17786 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
17787 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
17788 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
17789 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
17790 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
17791 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 17792 | } |