]>
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 | ||
3dc339cd | 536 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 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) | |
3dc339cd | 548 | return true; |
d62a17ae | 549 | |
3dc339cd | 550 | return false; |
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 | ||
ae00326a | 6593 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
6594 | peer->pmax_out[afi][safi] = 0; |
6595 | ||
6596 | return CMD_SUCCESS; | |
6597 | } | |
6598 | ||
718e3744 | 6599 | /* Maximum number of prefix configuration. prefix count is different |
6600 | for each peer configuration. So this configuration can be set for | |
6601 | each peer configuration. */ | |
6602 | DEFUN (neighbor_maximum_prefix, | |
6603 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6604 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6605 | NEIGHBOR_STR |
6606 | NEIGHBOR_ADDR_STR2 | |
6607 | "Maximum number of prefix accept from this peer\n" | |
6608 | "maximum no. of prefix limit\n") | |
6609 | { | |
d62a17ae | 6610 | int idx_peer = 1; |
6611 | int idx_number = 3; | |
6612 | return peer_maximum_prefix_set_vty( | |
6613 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6614 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6615 | } |
6616 | ||
d62a17ae | 6617 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6618 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6619 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6620 | "Maximum number of prefix accept from this peer\n" | |
6621 | "maximum no. of prefix limit\n") | |
596c17ba | 6622 | |
e0701b79 | 6623 | DEFUN (neighbor_maximum_prefix_threshold, |
6624 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6625 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6626 | NEIGHBOR_STR |
6627 | NEIGHBOR_ADDR_STR2 | |
6628 | "Maximum number of prefix accept from this peer\n" | |
6629 | "maximum no. of prefix limit\n" | |
6630 | "Threshold value (%) at which to generate a warning msg\n") | |
6631 | { | |
d62a17ae | 6632 | int idx_peer = 1; |
6633 | int idx_number = 3; | |
6634 | int idx_number_2 = 4; | |
6635 | return peer_maximum_prefix_set_vty( | |
6636 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6637 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6638 | } |
e0701b79 | 6639 | |
d62a17ae | 6640 | ALIAS_HIDDEN( |
6641 | neighbor_maximum_prefix_threshold, | |
6642 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6643 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6644 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6645 | "Maximum number of prefix accept from this peer\n" | |
6646 | "maximum no. of prefix limit\n" | |
6647 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6648 | |
718e3744 | 6649 | DEFUN (neighbor_maximum_prefix_warning, |
6650 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6651 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6652 | NEIGHBOR_STR |
6653 | NEIGHBOR_ADDR_STR2 | |
6654 | "Maximum number of prefix accept from this peer\n" | |
6655 | "maximum no. of prefix limit\n" | |
6656 | "Only give warning message when limit is exceeded\n") | |
6657 | { | |
d62a17ae | 6658 | int idx_peer = 1; |
6659 | int idx_number = 3; | |
6660 | return peer_maximum_prefix_set_vty( | |
6661 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6662 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6663 | } |
6664 | ||
d62a17ae | 6665 | ALIAS_HIDDEN( |
6666 | neighbor_maximum_prefix_warning, | |
6667 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6668 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6669 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6670 | "Maximum number of prefix accept from this peer\n" | |
6671 | "maximum no. of prefix limit\n" | |
6672 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6673 | |
e0701b79 | 6674 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6675 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6676 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6677 | NEIGHBOR_STR |
6678 | NEIGHBOR_ADDR_STR2 | |
6679 | "Maximum number of prefix accept from this peer\n" | |
6680 | "maximum no. of prefix limit\n" | |
6681 | "Threshold value (%) at which to generate a warning msg\n" | |
6682 | "Only give warning message when limit is exceeded\n") | |
6683 | { | |
d62a17ae | 6684 | int idx_peer = 1; |
6685 | int idx_number = 3; | |
6686 | int idx_number_2 = 4; | |
6687 | return peer_maximum_prefix_set_vty( | |
6688 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6689 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6690 | } |
6691 | ||
d62a17ae | 6692 | ALIAS_HIDDEN( |
6693 | neighbor_maximum_prefix_threshold_warning, | |
6694 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6695 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6696 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6697 | "Maximum number of prefix accept from this peer\n" | |
6698 | "maximum no. of prefix limit\n" | |
6699 | "Threshold value (%) at which to generate a warning msg\n" | |
6700 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6701 | |
0a486e5f | 6702 | DEFUN (neighbor_maximum_prefix_restart, |
6703 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6704 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6705 | NEIGHBOR_STR |
6706 | NEIGHBOR_ADDR_STR2 | |
6707 | "Maximum number of prefix accept from this peer\n" | |
6708 | "maximum no. of prefix limit\n" | |
6709 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6710 | "Restart interval in minutes\n") |
0a486e5f | 6711 | { |
d62a17ae | 6712 | int idx_peer = 1; |
6713 | int idx_number = 3; | |
6714 | int idx_number_2 = 5; | |
6715 | return peer_maximum_prefix_set_vty( | |
6716 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6717 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6718 | } |
6719 | ||
d62a17ae | 6720 | ALIAS_HIDDEN( |
6721 | neighbor_maximum_prefix_restart, | |
6722 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6723 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6724 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6725 | "Maximum number of prefix accept from this peer\n" | |
6726 | "maximum no. of prefix limit\n" | |
6727 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6728 | "Restart interval in minutes\n") |
596c17ba | 6729 | |
0a486e5f | 6730 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6731 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6732 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6733 | NEIGHBOR_STR |
6734 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6735 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6736 | "maximum no. of prefix limit\n" |
6737 | "Threshold value (%) at which to generate a warning msg\n" | |
6738 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6739 | "Restart interval in minutes\n") |
0a486e5f | 6740 | { |
d62a17ae | 6741 | int idx_peer = 1; |
6742 | int idx_number = 3; | |
6743 | int idx_number_2 = 4; | |
6744 | int idx_number_3 = 6; | |
6745 | return peer_maximum_prefix_set_vty( | |
6746 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6747 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6748 | argv[idx_number_3]->arg); | |
6749 | } | |
6750 | ||
6751 | ALIAS_HIDDEN( | |
6752 | neighbor_maximum_prefix_threshold_restart, | |
6753 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6754 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6755 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6756 | "Maximum number of prefixes to accept from this peer\n" | |
6757 | "maximum no. of prefix limit\n" | |
6758 | "Threshold value (%) at which to generate a warning msg\n" | |
6759 | "Restart bgp connection after limit is exceeded\n" | |
6760 | "Restart interval in minutes\n") | |
596c17ba | 6761 | |
718e3744 | 6762 | DEFUN (no_neighbor_maximum_prefix, |
6763 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6765 | NO_STR |
6766 | NEIGHBOR_STR | |
6767 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6768 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6769 | "maximum no. of prefix limit\n" |
6770 | "Threshold value (%) at which to generate a warning msg\n" | |
6771 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6772 | "Restart interval in minutes\n" |
31500417 | 6773 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6774 | { |
d62a17ae | 6775 | int idx_peer = 2; |
6776 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6777 | bgp_node_afi(vty), | |
6778 | bgp_node_safi(vty)); | |
718e3744 | 6779 | } |
e52702f2 | 6780 | |
d62a17ae | 6781 | ALIAS_HIDDEN( |
6782 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6783 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6784 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6785 | "Maximum number of prefixes to accept from this peer\n" | |
6786 | "maximum no. of prefix limit\n" | |
6787 | "Threshold value (%) at which to generate a warning msg\n" | |
6788 | "Restart bgp connection after limit is exceeded\n" | |
6789 | "Restart interval in minutes\n" | |
6790 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6791 | |
718e3744 | 6792 | |
718e3744 | 6793 | /* "neighbor allowas-in" */ |
6794 | DEFUN (neighbor_allowas_in, | |
6795 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6796 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6797 | NEIGHBOR_STR |
6798 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6799 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6800 | "Number of occurrences of AS number\n" |
fd8503f5 | 6801 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6802 | { |
d62a17ae | 6803 | int idx_peer = 1; |
6804 | int idx_number_origin = 3; | |
6805 | int ret; | |
6806 | int origin = 0; | |
6807 | struct peer *peer; | |
6808 | int allow_num = 0; | |
6809 | ||
6810 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6811 | if (!peer) | |
6812 | return CMD_WARNING_CONFIG_FAILED; | |
6813 | ||
6814 | if (argc <= idx_number_origin) | |
6815 | allow_num = 3; | |
6816 | else { | |
6817 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6818 | origin = 1; | |
6819 | else | |
6820 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6821 | } | |
6822 | ||
6823 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6824 | allow_num, origin); | |
6825 | ||
6826 | return bgp_vty_return(vty, ret); | |
6827 | } | |
6828 | ||
6829 | ALIAS_HIDDEN( | |
6830 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6831 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6832 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6833 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6834 | "Number of occurrences of AS number\n" |
d62a17ae | 6835 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6836 | |
718e3744 | 6837 | DEFUN (no_neighbor_allowas_in, |
6838 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6839 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6840 | NO_STR |
6841 | NEIGHBOR_STR | |
6842 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6843 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6844 | "Number of occurrences of AS number\n" |
fd8503f5 | 6845 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6846 | { |
d62a17ae | 6847 | int idx_peer = 2; |
6848 | int ret; | |
6849 | struct peer *peer; | |
718e3744 | 6850 | |
d62a17ae | 6851 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6852 | if (!peer) | |
6853 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6854 | |
d62a17ae | 6855 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6856 | bgp_node_safi(vty)); | |
718e3744 | 6857 | |
d62a17ae | 6858 | return bgp_vty_return(vty, ret); |
718e3744 | 6859 | } |
6b0655a2 | 6860 | |
d62a17ae | 6861 | ALIAS_HIDDEN( |
6862 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6864 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6865 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6866 | "Number of occurrences of AS number\n" |
d62a17ae | 6867 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6868 | |
fa411a21 NH |
6869 | DEFUN (neighbor_ttl_security, |
6870 | neighbor_ttl_security_cmd, | |
7ebe625c | 6871 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6872 | NEIGHBOR_STR |
7ebe625c | 6873 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6874 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6875 | "Specify the maximum number of hops to the BGP peer\n" |
6876 | "Number of hops to BGP peer\n") | |
fa411a21 | 6877 | { |
d62a17ae | 6878 | int idx_peer = 1; |
6879 | int idx_number = 4; | |
6880 | struct peer *peer; | |
6881 | int gtsm_hops; | |
6882 | ||
6883 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6884 | if (!peer) | |
6885 | return CMD_WARNING_CONFIG_FAILED; | |
6886 | ||
6887 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6888 | ||
7ebe625c QY |
6889 | /* |
6890 | * If 'neighbor swpX', then this is for directly connected peers, | |
6891 | * we should not accept a ttl-security hops value greater than 1. | |
6892 | */ | |
e2521429 | 6893 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
6894 | vty_out(vty, |
6895 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6896 | argv[idx_peer]->arg); | |
6897 | return CMD_WARNING_CONFIG_FAILED; | |
6898 | } | |
6899 | ||
d62a17ae | 6900 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6901 | } |
6902 | ||
6903 | DEFUN (no_neighbor_ttl_security, | |
6904 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6906 | NO_STR |
6907 | NEIGHBOR_STR | |
7ebe625c | 6908 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6909 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6910 | "Specify the maximum number of hops to the BGP peer\n" |
6911 | "Number of hops to BGP peer\n") | |
fa411a21 | 6912 | { |
d62a17ae | 6913 | int idx_peer = 2; |
6914 | struct peer *peer; | |
fa411a21 | 6915 | |
d62a17ae | 6916 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6917 | if (!peer) | |
6918 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6919 | |
d62a17ae | 6920 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6921 | } |
6b0655a2 | 6922 | |
adbac85e DW |
6923 | DEFUN (neighbor_addpath_tx_all_paths, |
6924 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6925 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6926 | NEIGHBOR_STR |
6927 | NEIGHBOR_ADDR_STR2 | |
6928 | "Use addpath to advertise all paths to a neighbor\n") | |
6929 | { | |
d62a17ae | 6930 | int idx_peer = 1; |
6931 | struct peer *peer; | |
adbac85e | 6932 | |
d62a17ae | 6933 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6934 | if (!peer) | |
6935 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6936 | |
dcc68b5e MS |
6937 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6938 | BGP_ADDPATH_ALL); | |
6939 | return CMD_SUCCESS; | |
adbac85e DW |
6940 | } |
6941 | ||
d62a17ae | 6942 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6943 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6944 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6945 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6946 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6947 | |
adbac85e DW |
6948 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6949 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6950 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6951 | NO_STR |
6952 | NEIGHBOR_STR | |
6953 | NEIGHBOR_ADDR_STR2 | |
6954 | "Use addpath to advertise all paths to a neighbor\n") | |
6955 | { | |
d62a17ae | 6956 | int idx_peer = 2; |
dcc68b5e MS |
6957 | struct peer *peer; |
6958 | ||
6959 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6960 | if (!peer) | |
6961 | return CMD_WARNING_CONFIG_FAILED; | |
6962 | ||
6963 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6964 | != BGP_ADDPATH_ALL) { | |
6965 | vty_out(vty, | |
6966 | "%% Peer not currently configured to transmit all paths."); | |
6967 | return CMD_WARNING_CONFIG_FAILED; | |
6968 | } | |
6969 | ||
6970 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6971 | BGP_ADDPATH_NONE); | |
6972 | ||
6973 | return CMD_SUCCESS; | |
adbac85e DW |
6974 | } |
6975 | ||
d62a17ae | 6976 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6977 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6978 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6979 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6980 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6981 | |
06370dac DW |
6982 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6983 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6984 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6985 | NEIGHBOR_STR |
6986 | NEIGHBOR_ADDR_STR2 | |
6987 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6988 | { | |
d62a17ae | 6989 | int idx_peer = 1; |
6990 | struct peer *peer; | |
06370dac | 6991 | |
d62a17ae | 6992 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6993 | if (!peer) | |
6994 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6995 | |
dcc68b5e MS |
6996 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6997 | BGP_ADDPATH_BEST_PER_AS); | |
6998 | ||
6999 | return CMD_SUCCESS; | |
06370dac DW |
7000 | } |
7001 | ||
d62a17ae | 7002 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7003 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7004 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7005 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7006 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7007 | |
06370dac DW |
7008 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7009 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7011 | NO_STR |
7012 | NEIGHBOR_STR | |
7013 | NEIGHBOR_ADDR_STR2 | |
7014 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7015 | { | |
d62a17ae | 7016 | int idx_peer = 2; |
dcc68b5e MS |
7017 | struct peer *peer; |
7018 | ||
7019 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7020 | if (!peer) | |
7021 | return CMD_WARNING_CONFIG_FAILED; | |
7022 | ||
7023 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7024 | != BGP_ADDPATH_BEST_PER_AS) { | |
7025 | vty_out(vty, | |
7026 | "%% Peer not currently configured to transmit all best path per as."); | |
7027 | return CMD_WARNING_CONFIG_FAILED; | |
7028 | } | |
7029 | ||
7030 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7031 | BGP_ADDPATH_NONE); | |
7032 | ||
7033 | return CMD_SUCCESS; | |
06370dac DW |
7034 | } |
7035 | ||
d62a17ae | 7036 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7037 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7038 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7039 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7040 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7041 | |
2b31007c RZ |
7042 | DEFPY( |
7043 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7044 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7045 | NEIGHBOR_STR | |
7046 | NEIGHBOR_ADDR_STR2 | |
7047 | "Detect AS loops before sending to neighbor\n") | |
7048 | { | |
7049 | struct peer *peer; | |
7050 | ||
7051 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7052 | if (!peer) | |
7053 | return CMD_WARNING_CONFIG_FAILED; | |
7054 | ||
7055 | peer->as_path_loop_detection = true; | |
7056 | ||
7057 | return CMD_SUCCESS; | |
7058 | } | |
7059 | ||
7060 | DEFPY( | |
7061 | no_neighbor_aspath_loop_detection, | |
7062 | no_neighbor_aspath_loop_detection_cmd, | |
7063 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7064 | NO_STR | |
7065 | NEIGHBOR_STR | |
7066 | NEIGHBOR_ADDR_STR2 | |
7067 | "Detect AS loops before sending to neighbor\n") | |
7068 | { | |
7069 | struct peer *peer; | |
7070 | ||
7071 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7072 | if (!peer) | |
7073 | return CMD_WARNING_CONFIG_FAILED; | |
7074 | ||
7075 | peer->as_path_loop_detection = false; | |
7076 | ||
7077 | return CMD_SUCCESS; | |
7078 | } | |
7079 | ||
b9c7bc5a PZ |
7080 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7081 | struct ecommunity **list) | |
ddb5b488 | 7082 | { |
b9c7bc5a PZ |
7083 | struct ecommunity *ecom = NULL; |
7084 | struct ecommunity *ecomadd; | |
ddb5b488 | 7085 | |
b9c7bc5a | 7086 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7087 | |
b9c7bc5a PZ |
7088 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7089 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7090 | if (!ecomadd) { | |
7091 | vty_out(vty, "Malformed community-list value\n"); | |
7092 | if (ecom) | |
7093 | ecommunity_free(&ecom); | |
7094 | return CMD_WARNING_CONFIG_FAILED; | |
7095 | } | |
ddb5b488 | 7096 | |
b9c7bc5a PZ |
7097 | if (ecom) { |
7098 | ecommunity_merge(ecom, ecomadd); | |
7099 | ecommunity_free(&ecomadd); | |
7100 | } else { | |
7101 | ecom = ecomadd; | |
7102 | } | |
7103 | } | |
7104 | ||
7105 | if (*list) { | |
7106 | ecommunity_free(&*list); | |
ddb5b488 | 7107 | } |
b9c7bc5a PZ |
7108 | *list = ecom; |
7109 | ||
7110 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7111 | } |
7112 | ||
0ca70ba5 DS |
7113 | /* |
7114 | * v2vimport is true if we are handling a `import vrf ...` command | |
7115 | */ | |
7116 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7117 | { |
0ca70ba5 DS |
7118 | afi_t afi; |
7119 | ||
ddb5b488 | 7120 | switch (vty->node) { |
b9c7bc5a | 7121 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7122 | afi = AFI_IP; |
7123 | break; | |
b9c7bc5a | 7124 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7125 | afi = AFI_IP6; |
7126 | break; | |
ddb5b488 PZ |
7127 | default: |
7128 | vty_out(vty, | |
b9c7bc5a | 7129 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7130 | return AFI_MAX; |
ddb5b488 | 7131 | } |
69b07479 | 7132 | |
0ca70ba5 DS |
7133 | if (!v2vimport) { |
7134 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7135 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7136 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7137 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7138 | vty_out(vty, | |
7139 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7140 | return AFI_MAX; | |
7141 | } | |
7142 | } else { | |
7143 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7144 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7145 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7146 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7147 | vty_out(vty, | |
7148 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7149 | return AFI_MAX; | |
7150 | } | |
7151 | } | |
7152 | return afi; | |
ddb5b488 PZ |
7153 | } |
7154 | ||
b9c7bc5a PZ |
7155 | DEFPY (af_rd_vpn_export, |
7156 | af_rd_vpn_export_cmd, | |
7157 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7158 | NO_STR | |
ddb5b488 | 7159 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7160 | "Between current address-family and vpn\n" |
7161 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7162 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7163 | { | |
7164 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7165 | struct prefix_rd prd; | |
7166 | int ret; | |
ddb5b488 | 7167 | afi_t afi; |
b9c7bc5a PZ |
7168 | int idx = 0; |
7169 | int yes = 1; | |
ddb5b488 | 7170 | |
b9c7bc5a | 7171 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7172 | yes = 0; |
b9c7bc5a PZ |
7173 | |
7174 | if (yes) { | |
7175 | ret = str2prefix_rd(rd_str, &prd); | |
7176 | if (!ret) { | |
7177 | vty_out(vty, "%% Malformed rd\n"); | |
7178 | return CMD_WARNING_CONFIG_FAILED; | |
7179 | } | |
ddb5b488 PZ |
7180 | } |
7181 | ||
0ca70ba5 | 7182 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7183 | if (afi == AFI_MAX) |
7184 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7185 | |
69b07479 DS |
7186 | /* |
7187 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7188 | */ | |
7189 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7190 | bgp_get_default(), bgp); | |
ddb5b488 | 7191 | |
69b07479 DS |
7192 | if (yes) { |
7193 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7194 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7195 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7196 | } else { | |
7197 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7198 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7199 | } |
7200 | ||
69b07479 DS |
7201 | /* post-change: re-export vpn routes */ |
7202 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7203 | bgp_get_default(), bgp); | |
7204 | ||
ddb5b488 PZ |
7205 | return CMD_SUCCESS; |
7206 | } | |
7207 | ||
b9c7bc5a PZ |
7208 | ALIAS (af_rd_vpn_export, |
7209 | af_no_rd_vpn_export_cmd, | |
7210 | "no rd vpn export", | |
ddb5b488 | 7211 | NO_STR |
b9c7bc5a PZ |
7212 | "Specify route distinguisher\n" |
7213 | "Between current address-family and vpn\n" | |
7214 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7215 | |
b9c7bc5a PZ |
7216 | DEFPY (af_label_vpn_export, |
7217 | af_label_vpn_export_cmd, | |
e70e9f8e | 7218 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7219 | NO_STR |
ddb5b488 | 7220 | "label value for VRF\n" |
b9c7bc5a PZ |
7221 | "Between current address-family and vpn\n" |
7222 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7223 | "Label Value <0-1048575>\n" |
7224 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7225 | { |
7226 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7227 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7228 | afi_t afi; |
b9c7bc5a PZ |
7229 | int idx = 0; |
7230 | int yes = 1; | |
7231 | ||
7232 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7233 | yes = 0; |
ddb5b488 | 7234 | |
21a16cc2 PZ |
7235 | /* If "no ...", squash trailing parameter */ |
7236 | if (!yes) | |
7237 | label_auto = NULL; | |
7238 | ||
e70e9f8e PZ |
7239 | if (yes) { |
7240 | if (!label_auto) | |
7241 | label = label_val; /* parser should force unsigned */ | |
7242 | } | |
ddb5b488 | 7243 | |
0ca70ba5 | 7244 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7245 | if (afi == AFI_MAX) |
7246 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7247 | |
e70e9f8e | 7248 | |
69b07479 DS |
7249 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7250 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7251 | /* no change */ | |
7252 | return CMD_SUCCESS; | |
e70e9f8e | 7253 | |
69b07479 DS |
7254 | /* |
7255 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7256 | */ | |
7257 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7258 | bgp_get_default(), bgp); | |
7259 | ||
7260 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7261 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7262 | ||
7263 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7264 | ||
7265 | /* | |
7266 | * label has previously been automatically | |
7267 | * assigned by labelpool: release it | |
7268 | * | |
7269 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7270 | * means the automatic assignment is in flight | |
7271 | * and therefore the labelpool callback must | |
7272 | * detect that the auto label is not needed. | |
7273 | */ | |
7274 | ||
7275 | bgp_lp_release(LP_TYPE_VRF, | |
7276 | &bgp->vpn_policy[afi], | |
7277 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7278 | } |
69b07479 DS |
7279 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7280 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7281 | } | |
ddb5b488 | 7282 | |
69b07479 DS |
7283 | bgp->vpn_policy[afi].tovpn_label = label; |
7284 | if (label_auto) { | |
7285 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7286 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7287 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7288 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7289 | } |
7290 | ||
69b07479 DS |
7291 | /* post-change: re-export vpn routes */ |
7292 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7293 | bgp_get_default(), bgp); | |
7294 | ||
ddb5b488 PZ |
7295 | return CMD_SUCCESS; |
7296 | } | |
7297 | ||
b9c7bc5a PZ |
7298 | ALIAS (af_label_vpn_export, |
7299 | af_no_label_vpn_export_cmd, | |
7300 | "no label vpn export", | |
7301 | NO_STR | |
7302 | "label value for VRF\n" | |
7303 | "Between current address-family and vpn\n" | |
7304 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7305 | |
b9c7bc5a PZ |
7306 | DEFPY (af_nexthop_vpn_export, |
7307 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7308 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7309 | NO_STR |
ddb5b488 | 7310 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7311 | "Between current address-family and vpn\n" |
7312 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7313 | "IPv4 prefix\n" |
7314 | "IPv6 prefix\n") | |
7315 | { | |
7316 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7317 | afi_t afi; |
ddb5b488 PZ |
7318 | struct prefix p; |
7319 | ||
8c85ca28 QY |
7320 | if (!no) { |
7321 | if (!nexthop_su) { | |
7322 | vty_out(vty, "%% Nexthop required\n"); | |
7323 | return CMD_WARNING_CONFIG_FAILED; | |
7324 | } | |
b9c7bc5a | 7325 | |
8c85ca28 | 7326 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7327 | return CMD_WARNING_CONFIG_FAILED; |
7328 | } | |
ddb5b488 | 7329 | |
0ca70ba5 | 7330 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7331 | if (afi == AFI_MAX) |
7332 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7333 | |
69b07479 DS |
7334 | /* |
7335 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7336 | */ | |
7337 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7338 | bgp_get_default(), bgp); | |
ddb5b488 | 7339 | |
8c85ca28 | 7340 | if (!no) { |
69b07479 DS |
7341 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7342 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7343 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7344 | } else { | |
7345 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7346 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7347 | } |
7348 | ||
69b07479 DS |
7349 | /* post-change: re-export vpn routes */ |
7350 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7351 | bgp_get_default(), bgp); | |
7352 | ||
ddb5b488 PZ |
7353 | return CMD_SUCCESS; |
7354 | } | |
7355 | ||
b9c7bc5a | 7356 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7357 | { |
b9c7bc5a PZ |
7358 | if (!strcmp(dstr, "import")) { |
7359 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7360 | } else if (!strcmp(dstr, "export")) { | |
7361 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7362 | } else if (!strcmp(dstr, "both")) { | |
7363 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7364 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7365 | } else { | |
7366 | vty_out(vty, "%% direction parse error\n"); | |
7367 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7368 | } |
ddb5b488 PZ |
7369 | return CMD_SUCCESS; |
7370 | } | |
7371 | ||
b9c7bc5a PZ |
7372 | DEFPY (af_rt_vpn_imexport, |
7373 | af_rt_vpn_imexport_cmd, | |
7374 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7375 | NO_STR | |
7376 | "Specify route target list\n" | |
ddb5b488 | 7377 | "Specify route target list\n" |
b9c7bc5a PZ |
7378 | "Between current address-family and vpn\n" |
7379 | "For routes leaked from vpn to current address-family: match any\n" | |
7380 | "For routes leaked from current address-family to vpn: set\n" | |
7381 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7382 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7383 | { | |
7384 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7385 | int ret; | |
7386 | struct ecommunity *ecom = NULL; | |
7387 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7388 | vpn_policy_direction_t dir; |
7389 | afi_t afi; | |
7390 | int idx = 0; | |
b9c7bc5a | 7391 | int yes = 1; |
ddb5b488 | 7392 | |
b9c7bc5a | 7393 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7394 | yes = 0; |
b9c7bc5a | 7395 | |
0ca70ba5 | 7396 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7397 | if (afi == AFI_MAX) |
7398 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7399 | |
b9c7bc5a | 7400 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7401 | if (ret != CMD_SUCCESS) |
7402 | return ret; | |
7403 | ||
b9c7bc5a PZ |
7404 | if (yes) { |
7405 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7406 | vty_out(vty, "%% Missing RTLIST\n"); | |
7407 | return CMD_WARNING_CONFIG_FAILED; | |
7408 | } | |
7409 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7410 | if (ret != CMD_SUCCESS) { | |
7411 | return ret; | |
7412 | } | |
ddb5b488 PZ |
7413 | } |
7414 | ||
69b07479 DS |
7415 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7416 | if (!dodir[dir]) | |
ddb5b488 | 7417 | continue; |
ddb5b488 | 7418 | |
69b07479 | 7419 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7420 | |
69b07479 DS |
7421 | if (yes) { |
7422 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7423 | ecommunity_free( | |
7424 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7425 | bgp->vpn_policy[afi].rtlist[dir] = | |
7426 | ecommunity_dup(ecom); | |
7427 | } else { | |
7428 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7429 | ecommunity_free( | |
7430 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7431 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7432 | } |
69b07479 DS |
7433 | |
7434 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7435 | } |
69b07479 | 7436 | |
d555f3e9 PZ |
7437 | if (ecom) |
7438 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7439 | |
7440 | return CMD_SUCCESS; | |
7441 | } | |
7442 | ||
b9c7bc5a PZ |
7443 | ALIAS (af_rt_vpn_imexport, |
7444 | af_no_rt_vpn_imexport_cmd, | |
7445 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7446 | NO_STR |
7447 | "Specify route target list\n" | |
b9c7bc5a PZ |
7448 | "Specify route target list\n" |
7449 | "Between current address-family and vpn\n" | |
7450 | "For routes leaked from vpn to current address-family\n" | |
7451 | "For routes leaked from current address-family to vpn\n" | |
7452 | "both import and export\n") | |
7453 | ||
7454 | DEFPY (af_route_map_vpn_imexport, | |
7455 | af_route_map_vpn_imexport_cmd, | |
7456 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7457 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7458 | NO_STR | |
ddb5b488 | 7459 | "Specify route map\n" |
b9c7bc5a PZ |
7460 | "Between current address-family and vpn\n" |
7461 | "For routes leaked from vpn to current address-family\n" | |
7462 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7463 | "name of route-map\n") |
7464 | { | |
7465 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7466 | int ret; | |
7467 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7468 | vpn_policy_direction_t dir; |
7469 | afi_t afi; | |
ddb5b488 | 7470 | int idx = 0; |
b9c7bc5a | 7471 | int yes = 1; |
ddb5b488 | 7472 | |
b9c7bc5a | 7473 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7474 | yes = 0; |
b9c7bc5a | 7475 | |
0ca70ba5 | 7476 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7477 | if (afi == AFI_MAX) |
7478 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7479 | |
b9c7bc5a | 7480 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7481 | if (ret != CMD_SUCCESS) |
7482 | return ret; | |
7483 | ||
69b07479 DS |
7484 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7485 | if (!dodir[dir]) | |
ddb5b488 | 7486 | continue; |
ddb5b488 | 7487 | |
69b07479 | 7488 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7489 | |
69b07479 DS |
7490 | if (yes) { |
7491 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7492 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7493 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7494 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7495 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7496 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7497 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7498 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7499 | return CMD_SUCCESS; | |
7500 | } else { | |
7501 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7502 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7503 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7504 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7505 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7506 | } |
69b07479 DS |
7507 | |
7508 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7509 | } |
7510 | ||
7511 | return CMD_SUCCESS; | |
7512 | } | |
7513 | ||
b9c7bc5a PZ |
7514 | ALIAS (af_route_map_vpn_imexport, |
7515 | af_no_route_map_vpn_imexport_cmd, | |
7516 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7517 | NO_STR |
7518 | "Specify route map\n" | |
b9c7bc5a PZ |
7519 | "Between current address-family and vpn\n" |
7520 | "For routes leaked from vpn to current address-family\n" | |
7521 | "For routes leaked from current address-family to vpn\n") | |
7522 | ||
bb4f6190 | 7523 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 7524 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
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; | |
bb4f6190 DS |
7533 | struct bgp *bgp_default; |
7534 | ||
0ca70ba5 | 7535 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7536 | if (afi == AFI_MAX) |
7537 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7538 | |
7539 | bgp_default = bgp_get_default(); | |
7540 | if (!bgp_default) { | |
7541 | int32_t ret; | |
7542 | as_t as = bgp->as; | |
7543 | ||
7544 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7545 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7546 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7547 | |
7548 | if (ret) { | |
7549 | vty_out(vty, | |
7550 | "VRF default is not configured as a bgp instance\n"); | |
7551 | return CMD_WARNING; | |
7552 | } | |
7553 | } | |
7554 | ||
69b07479 | 7555 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7556 | |
ae6a6fb4 DS |
7557 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
7558 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7559 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7560 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7561 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7562 | bgp->vpn_policy[afi].rmap[dir] = | |
7563 | route_map_lookup_warn_noexist(vty, rmap_str); | |
7564 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
7565 | return CMD_SUCCESS; | |
7566 | ||
7567 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7568 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 7569 | |
69b07479 DS |
7570 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7571 | ||
bb4f6190 DS |
7572 | return CMD_SUCCESS; |
7573 | } | |
7574 | ||
ae6a6fb4 DS |
7575 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
7576 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
7577 | NO_STR |
7578 | "Import routes from another VRF\n" | |
7579 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
7580 | "Specify route map\n" |
7581 | "name of route-map\n") | |
7582 | { | |
7583 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7584 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7585 | afi_t afi; | |
7586 | ||
7587 | afi = vpn_policy_getafi(vty, bgp, true); | |
7588 | if (afi == AFI_MAX) | |
7589 | return CMD_WARNING_CONFIG_FAILED; | |
7590 | ||
7591 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7592 | ||
7593 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7594 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7595 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7596 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7597 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
7598 | ||
7599 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
7600 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7601 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
7602 | ||
7603 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
7604 | ||
7605 | return CMD_SUCCESS; | |
7606 | } | |
bb4f6190 | 7607 | |
4d1b335c DA |
7608 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7609 | "[no] import vrf VIEWVRFNAME$import_name", | |
7610 | NO_STR | |
7611 | "Import routes from another VRF\n" | |
7612 | "VRF to import from\n" | |
7613 | "The name of the VRF\n") | |
12a844a5 DS |
7614 | { |
7615 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7616 | struct listnode *node; | |
79ef8664 DS |
7617 | struct bgp *vrf_bgp, *bgp_default; |
7618 | int32_t ret = 0; | |
7619 | as_t as = bgp->as; | |
12a844a5 DS |
7620 | bool remove = false; |
7621 | int32_t idx = 0; | |
7622 | char *vname; | |
a8dadcf6 | 7623 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7624 | safi_t safi; |
7625 | afi_t afi; | |
7626 | ||
867f0cca | 7627 | if (import_name == NULL) { |
7628 | vty_out(vty, "%% Missing import name\n"); | |
7629 | return CMD_WARNING; | |
7630 | } | |
7631 | ||
ae6a6fb4 DS |
7632 | if (strcmp(import_name, "route-map") == 0) { |
7633 | vty_out(vty, "%% Must include route-map name\n"); | |
7634 | return CMD_WARNING; | |
7635 | } | |
7636 | ||
12a844a5 DS |
7637 | if (argv_find(argv, argc, "no", &idx)) |
7638 | remove = true; | |
7639 | ||
0ca70ba5 DS |
7640 | afi = vpn_policy_getafi(vty, bgp, true); |
7641 | if (afi == AFI_MAX) | |
7642 | return CMD_WARNING_CONFIG_FAILED; | |
7643 | ||
12a844a5 DS |
7644 | safi = bgp_node_safi(vty); |
7645 | ||
25679caa | 7646 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7647 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7648 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7649 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7650 | remove ? "unimport" : "import", import_name); | |
7651 | return CMD_WARNING; | |
7652 | } | |
7653 | ||
79ef8664 DS |
7654 | bgp_default = bgp_get_default(); |
7655 | if (!bgp_default) { | |
7656 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7657 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7658 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7659 | |
7660 | if (ret) { | |
7661 | vty_out(vty, | |
7662 | "VRF default is not configured as a bgp instance\n"); | |
7663 | return CMD_WARNING; | |
7664 | } | |
7665 | } | |
7666 | ||
12a844a5 DS |
7667 | vrf_bgp = bgp_lookup_by_name(import_name); |
7668 | if (!vrf_bgp) { | |
5742e42b | 7669 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7670 | vrf_bgp = bgp_default; |
7671 | else | |
0fb8d6e6 | 7672 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7673 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7674 | |
6e2c7fe6 | 7675 | if (ret) { |
020a3f60 DS |
7676 | vty_out(vty, |
7677 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7678 | import_name); |
7679 | return CMD_WARNING; | |
7680 | } | |
12a844a5 DS |
7681 | } |
7682 | ||
12a844a5 | 7683 | if (remove) { |
44338987 | 7684 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7685 | } else { |
44338987 | 7686 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7687 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7688 | vname)) { | |
7689 | if (strcmp(vname, import_name) == 0) | |
7690 | return CMD_WARNING; | |
7691 | } | |
7692 | ||
44338987 | 7693 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7694 | } |
7695 | ||
7696 | return CMD_SUCCESS; | |
7697 | } | |
7698 | ||
b9c7bc5a PZ |
7699 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7700 | DEFPY (bgp_imexport_vpn, | |
7701 | bgp_imexport_vpn_cmd, | |
7702 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7703 | NO_STR |
7704 | "Import routes to this address-family\n" | |
7705 | "Export routes from this address-family\n" | |
7706 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7707 | { |
7708 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7709 | int previous_state; |
ddb5b488 | 7710 | afi_t afi; |
b9c7bc5a | 7711 | safi_t safi; |
ddb5b488 | 7712 | int idx = 0; |
b9c7bc5a PZ |
7713 | int yes = 1; |
7714 | int flag; | |
7715 | vpn_policy_direction_t dir; | |
ddb5b488 | 7716 | |
b9c7bc5a | 7717 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7718 | yes = 0; |
ddb5b488 | 7719 | |
b9c7bc5a PZ |
7720 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7721 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7722 | |
b9c7bc5a PZ |
7723 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7724 | return CMD_WARNING_CONFIG_FAILED; | |
7725 | } | |
ddb5b488 | 7726 | |
b9c7bc5a PZ |
7727 | afi = bgp_node_afi(vty); |
7728 | safi = bgp_node_safi(vty); | |
7729 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7730 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7731 | return CMD_WARNING_CONFIG_FAILED; | |
7732 | } | |
ddb5b488 | 7733 | |
b9c7bc5a PZ |
7734 | if (!strcmp(direction_str, "import")) { |
7735 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7736 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7737 | } else if (!strcmp(direction_str, "export")) { | |
7738 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7739 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7740 | } else { | |
7741 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7742 | return CMD_WARNING_CONFIG_FAILED; | |
7743 | } | |
7744 | ||
7745 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7746 | |
b9c7bc5a PZ |
7747 | if (yes) { |
7748 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7749 | if (!previous_state) { | |
7750 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7751 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7752 | } | |
b9c7bc5a PZ |
7753 | } else { |
7754 | if (previous_state) { | |
7755 | /* trigger un-export current vrf */ | |
7756 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7757 | } | |
7758 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7759 | } |
7760 | ||
7761 | return CMD_SUCCESS; | |
7762 | } | |
7763 | ||
301ad80a PG |
7764 | DEFPY (af_routetarget_import, |
7765 | af_routetarget_import_cmd, | |
7766 | "[no] <rt|route-target> redirect import RTLIST...", | |
7767 | NO_STR | |
7768 | "Specify route target list\n" | |
7769 | "Specify route target list\n" | |
7770 | "Flow-spec redirect type route target\n" | |
7771 | "Import routes to this address-family\n" | |
7772 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7773 | { | |
7774 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7775 | int ret; | |
7776 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7777 | afi_t afi; |
7778 | int idx = 0; | |
7779 | int yes = 1; | |
7780 | ||
7781 | if (argv_find(argv, argc, "no", &idx)) | |
7782 | yes = 0; | |
7783 | ||
0ca70ba5 | 7784 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7785 | if (afi == AFI_MAX) |
7786 | return CMD_WARNING_CONFIG_FAILED; | |
7787 | ||
301ad80a PG |
7788 | if (yes) { |
7789 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7790 | vty_out(vty, "%% Missing RTLIST\n"); | |
7791 | return CMD_WARNING_CONFIG_FAILED; | |
7792 | } | |
7793 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7794 | if (ret != CMD_SUCCESS) | |
7795 | return ret; | |
7796 | } | |
69b07479 DS |
7797 | |
7798 | if (yes) { | |
7799 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7800 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7801 | .import_redirect_rtlist); |
69b07479 DS |
7802 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7803 | ecommunity_dup(ecom); | |
7804 | } else { | |
7805 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7806 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7807 | .import_redirect_rtlist); |
69b07479 | 7808 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7809 | } |
69b07479 | 7810 | |
301ad80a PG |
7811 | if (ecom) |
7812 | ecommunity_free(&ecom); | |
7813 | ||
7814 | return CMD_SUCCESS; | |
7815 | } | |
7816 | ||
505e5056 | 7817 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7818 | address_family_ipv4_safi_cmd, |
7819 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7820 | "Enter Address Family command mode\n" | |
7821 | "Address Family\n" | |
7822 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7823 | { |
f51bae9c | 7824 | |
d62a17ae | 7825 | if (argc == 3) { |
2131d5cf | 7826 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7827 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7828 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7829 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7830 | && safi != SAFI_EVPN) { |
31947174 MK |
7831 | vty_out(vty, |
7832 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7833 | return CMD_WARNING_CONFIG_FAILED; |
7834 | } | |
d62a17ae | 7835 | vty->node = bgp_node_type(AFI_IP, safi); |
7836 | } else | |
7837 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7838 | |
d62a17ae | 7839 | return CMD_SUCCESS; |
718e3744 | 7840 | } |
7841 | ||
505e5056 | 7842 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7843 | address_family_ipv6_safi_cmd, |
7844 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7845 | "Enter Address Family command mode\n" | |
7846 | "Address Family\n" | |
7847 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7848 | { |
d62a17ae | 7849 | if (argc == 3) { |
2131d5cf | 7850 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7851 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7852 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7853 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7854 | && safi != SAFI_EVPN) { |
31947174 MK |
7855 | vty_out(vty, |
7856 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7857 | return CMD_WARNING_CONFIG_FAILED; |
7858 | } | |
d62a17ae | 7859 | vty->node = bgp_node_type(AFI_IP6, safi); |
7860 | } else | |
7861 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7862 | |
d62a17ae | 7863 | return CMD_SUCCESS; |
25ffbdc1 | 7864 | } |
718e3744 | 7865 | |
d6902373 | 7866 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7867 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7868 | address_family_vpnv4_cmd, |
8334fd5a | 7869 | "address-family vpnv4 [unicast]", |
718e3744 | 7870 | "Enter Address Family command mode\n" |
8c3deaae | 7871 | "Address Family\n" |
3a2d747c | 7872 | "Address Family modifier\n") |
718e3744 | 7873 | { |
d62a17ae | 7874 | vty->node = BGP_VPNV4_NODE; |
7875 | return CMD_SUCCESS; | |
718e3744 | 7876 | } |
7877 | ||
505e5056 | 7878 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7879 | address_family_vpnv6_cmd, |
8334fd5a | 7880 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7881 | "Enter Address Family command mode\n" |
8c3deaae | 7882 | "Address Family\n" |
3a2d747c | 7883 | "Address Family modifier\n") |
8ecd3266 | 7884 | { |
d62a17ae | 7885 | vty->node = BGP_VPNV6_NODE; |
7886 | return CMD_SUCCESS; | |
8ecd3266 | 7887 | } |
64e4a6c5 | 7888 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7889 | |
505e5056 | 7890 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7891 | address_family_evpn_cmd, |
7111c1a0 | 7892 | "address-family l2vpn evpn", |
4e0b7b6d | 7893 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7894 | "Address Family\n" |
7895 | "Address Family modifier\n") | |
4e0b7b6d | 7896 | { |
2131d5cf | 7897 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7898 | vty->node = BGP_EVPN_NODE; |
7899 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7900 | } |
7901 | ||
505e5056 | 7902 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7903 | exit_address_family_cmd, |
7904 | "exit-address-family", | |
7905 | "Exit from Address Family configuration mode\n") | |
7906 | { | |
d62a17ae | 7907 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7908 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7909 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7910 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7911 | || vty->node == BGP_EVPN_NODE |
7912 | || vty->node == BGP_FLOWSPECV4_NODE | |
7913 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7914 | vty->node = BGP_NODE; |
7915 | return CMD_SUCCESS; | |
718e3744 | 7916 | } |
6b0655a2 | 7917 | |
8ad7271d | 7918 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7919 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7920 | const char *ip_str, afi_t afi, safi_t safi, | |
7921 | struct prefix_rd *prd) | |
7922 | { | |
7923 | int ret; | |
7924 | struct prefix match; | |
7925 | struct bgp_node *rn; | |
7926 | struct bgp_node *rm; | |
7927 | struct bgp *bgp; | |
7928 | struct bgp_table *table; | |
7929 | struct bgp_table *rib; | |
7930 | ||
7931 | /* BGP structure lookup. */ | |
7932 | if (view_name) { | |
7933 | bgp = bgp_lookup_by_name(view_name); | |
7934 | if (bgp == NULL) { | |
7935 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7936 | view_name); | |
7937 | return CMD_WARNING; | |
7938 | } | |
7939 | } else { | |
7940 | bgp = bgp_get_default(); | |
7941 | if (bgp == NULL) { | |
7942 | vty_out(vty, "%% No BGP process is configured\n"); | |
7943 | return CMD_WARNING; | |
7944 | } | |
7945 | } | |
7946 | ||
7947 | /* Check IP address argument. */ | |
7948 | ret = str2prefix(ip_str, &match); | |
7949 | if (!ret) { | |
7950 | vty_out(vty, "%% address is malformed\n"); | |
7951 | return CMD_WARNING; | |
7952 | } | |
7953 | ||
7954 | match.family = afi2family(afi); | |
7955 | rib = bgp->rib[afi][safi]; | |
7956 | ||
7957 | if (safi == SAFI_MPLS_VPN) { | |
7958 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
b54892e0 DS |
7959 | const struct prefix *rn_p = bgp_node_get_prefix(rn); |
7960 | ||
7961 | if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0) | |
d62a17ae | 7962 | continue; |
7963 | ||
67009e22 | 7964 | table = bgp_node_get_bgp_table_info(rn); |
b54892e0 DS |
7965 | if (table == NULL) |
7966 | continue; | |
7967 | ||
7968 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
7969 | const struct prefix *rm_p = | |
7970 | bgp_node_get_prefix(rm); | |
7971 | ||
7972 | if (rm_p->prefixlen == match.prefixlen) { | |
7973 | SET_FLAG(rm->flags, | |
7974 | BGP_NODE_USER_CLEAR); | |
7975 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 7976 | } |
b54892e0 | 7977 | bgp_unlock_node(rm); |
d62a17ae | 7978 | } |
7979 | } | |
7980 | } else { | |
7981 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
b54892e0 DS |
7982 | const struct prefix *rn_p = bgp_node_get_prefix(rn); |
7983 | ||
7984 | if (rn_p->prefixlen == match.prefixlen) { | |
d62a17ae | 7985 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); |
7986 | bgp_process(bgp, rn, afi, safi); | |
7987 | } | |
7988 | bgp_unlock_node(rn); | |
7989 | } | |
7990 | } | |
7991 | ||
7992 | return CMD_SUCCESS; | |
8ad7271d DS |
7993 | } |
7994 | ||
b09b5ae0 | 7995 | /* one clear bgp command to rule them all */ |
718e3744 | 7996 | DEFUN (clear_ip_bgp_all, |
7997 | clear_ip_bgp_all_cmd, | |
453c92f6 | 7998 | "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 | 7999 | CLEAR_STR |
8000 | IP_STR | |
8001 | BGP_STR | |
838758ac | 8002 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8003 | BGP_AFI_HELP_STR |
fd5e7b70 | 8004 | "Address Family\n" |
510afcd6 | 8005 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8006 | "Address Family modifier\n" |
b09b5ae0 | 8007 | "Clear all peers\n" |
453c92f6 | 8008 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8009 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8010 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8011 | "Clear peers with the AS number\n" |
8012 | "Clear all external peers\n" | |
718e3744 | 8013 | "Clear all members of peer-group\n" |
b09b5ae0 | 8014 | "BGP peer-group name\n" |
b09b5ae0 DW |
8015 | BGP_SOFT_STR |
8016 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8017 | BGP_SOFT_OUT_STR |
8018 | BGP_SOFT_IN_STR | |
8019 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8020 | BGP_SOFT_OUT_STR) |
718e3744 | 8021 | { |
d62a17ae | 8022 | char *vrf = NULL; |
8023 | ||
dc912615 DS |
8024 | afi_t afi = AFI_UNSPEC; |
8025 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8026 | enum clear_sort clr_sort = clear_peer; |
8027 | enum bgp_clear_type clr_type; | |
8028 | char *clr_arg = NULL; | |
8029 | ||
8030 | int idx = 0; | |
8031 | ||
8032 | /* clear [ip] bgp */ | |
8033 | if (argv_find(argv, argc, "ip", &idx)) | |
8034 | afi = AFI_IP; | |
8035 | ||
9a8bdf1c PG |
8036 | /* [<vrf> VIEWVRFNAME] */ |
8037 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8038 | vrf = argv[idx + 1]->arg; | |
8039 | idx += 2; | |
8040 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8041 | vrf = NULL; | |
8042 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8043 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8044 | vrf = argv[idx + 1]->arg; |
8045 | idx += 2; | |
8046 | } | |
d62a17ae | 8047 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8048 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8049 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8050 | ||
d7b9898c | 8051 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8052 | if (argv_find(argv, argc, "*", &idx)) { |
8053 | clr_sort = clear_all; | |
8054 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8055 | clr_sort = clear_peer; | |
8056 | clr_arg = argv[idx]->arg; | |
8057 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8058 | clr_sort = clear_peer; | |
8059 | clr_arg = argv[idx]->arg; | |
8060 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8061 | clr_sort = clear_group; | |
8062 | idx++; | |
8063 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8064 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8065 | clr_sort = clear_peer; |
8066 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8067 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8068 | clr_sort = clear_peer; | |
8069 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8070 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8071 | clr_sort = clear_as; | |
8072 | clr_arg = argv[idx]->arg; | |
8073 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8074 | clr_sort = clear_external; | |
8075 | } | |
8076 | ||
8077 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8078 | if (argv_find(argv, argc, "soft", &idx)) { | |
8079 | if (argv_find(argv, argc, "in", &idx) | |
8080 | || argv_find(argv, argc, "out", &idx)) | |
8081 | clr_type = strmatch(argv[idx]->text, "in") | |
8082 | ? BGP_CLEAR_SOFT_IN | |
8083 | : BGP_CLEAR_SOFT_OUT; | |
8084 | else | |
8085 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8086 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8087 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8088 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8089 | : BGP_CLEAR_SOFT_IN; | |
8090 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8091 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8092 | } else | |
8093 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8094 | ||
8095 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8096 | } |
01080f7c | 8097 | |
8ad7271d DS |
8098 | DEFUN (clear_ip_bgp_prefix, |
8099 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8100 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8101 | CLEAR_STR |
8102 | IP_STR | |
8103 | BGP_STR | |
838758ac | 8104 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8105 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8106 | "IPv4 prefix\n") |
8ad7271d | 8107 | { |
d62a17ae | 8108 | char *vrf = NULL; |
8109 | char *prefix = NULL; | |
8ad7271d | 8110 | |
d62a17ae | 8111 | int idx = 0; |
01080f7c | 8112 | |
d62a17ae | 8113 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8114 | if (argv_find(argv, argc, "vrf", &idx)) { |
8115 | vrf = argv[idx + 1]->arg; | |
8116 | idx += 2; | |
8117 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8118 | vrf = NULL; | |
8119 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8120 | /* [<view> VIEWVRFNAME] */ | |
8121 | vrf = argv[idx + 1]->arg; | |
8122 | idx += 2; | |
8123 | } | |
0c7b1b01 | 8124 | |
d62a17ae | 8125 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8126 | |
d62a17ae | 8127 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8128 | } |
8ad7271d | 8129 | |
b09b5ae0 DW |
8130 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8131 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8132 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8133 | CLEAR_STR |
3a2d747c | 8134 | IP_STR |
718e3744 | 8135 | BGP_STR |
8c3deaae | 8136 | "Address Family\n" |
46f296b4 | 8137 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8138 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8139 | "IPv6 prefix\n") |
718e3744 | 8140 | { |
9b475e76 PG |
8141 | int idx_safi = 0; |
8142 | int idx_ipv6_prefix = 0; | |
8143 | safi_t safi = SAFI_UNICAST; | |
8144 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8145 | argv[idx_ipv6_prefix]->arg : NULL; | |
8146 | ||
8147 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8148 | return bgp_clear_prefix( |
9b475e76 PG |
8149 | vty, NULL, prefix, AFI_IP6, |
8150 | safi, NULL); | |
838758ac | 8151 | } |
01080f7c | 8152 | |
b09b5ae0 DW |
8153 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8154 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8155 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8156 | CLEAR_STR |
3a2d747c | 8157 | IP_STR |
718e3744 | 8158 | BGP_STR |
838758ac | 8159 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8160 | "Address Family\n" |
46f296b4 | 8161 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8162 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8163 | "IPv6 prefix\n") |
718e3744 | 8164 | { |
9b475e76 | 8165 | int idx_safi = 0; |
9a8bdf1c | 8166 | int idx_vrfview = 0; |
9b475e76 PG |
8167 | int idx_ipv6_prefix = 0; |
8168 | safi_t safi = SAFI_UNICAST; | |
8169 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8170 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8171 | char *vrfview = NULL; |
9b475e76 | 8172 | |
9a8bdf1c PG |
8173 | /* [<view|vrf> VIEWVRFNAME] */ |
8174 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8175 | vrfview = argv[idx_vrfview + 1]->arg; | |
8176 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8177 | vrfview = NULL; | |
8178 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8179 | /* [<view> VIEWVRFNAME] */ | |
8180 | vrfview = argv[idx_vrfview + 1]->arg; | |
8181 | } | |
9b475e76 PG |
8182 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8183 | ||
d62a17ae | 8184 | return bgp_clear_prefix( |
9b475e76 PG |
8185 | vty, vrfview, prefix, |
8186 | AFI_IP6, safi, NULL); | |
718e3744 | 8187 | } |
8188 | ||
b09b5ae0 DW |
8189 | DEFUN (show_bgp_views, |
8190 | show_bgp_views_cmd, | |
d6e3c605 | 8191 | "show [ip] bgp views", |
b09b5ae0 | 8192 | SHOW_STR |
d6e3c605 | 8193 | IP_STR |
01080f7c | 8194 | BGP_STR |
b09b5ae0 | 8195 | "Show the defined BGP views\n") |
01080f7c | 8196 | { |
d62a17ae | 8197 | struct list *inst = bm->bgp; |
8198 | struct listnode *node; | |
8199 | struct bgp *bgp; | |
01080f7c | 8200 | |
d62a17ae | 8201 | vty_out(vty, "Defined BGP views:\n"); |
8202 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8203 | /* Skip VRFs. */ | |
8204 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8205 | continue; | |
8206 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8207 | bgp->as); | |
8208 | } | |
e52702f2 | 8209 | |
d62a17ae | 8210 | return CMD_SUCCESS; |
e0081f70 ML |
8211 | } |
8212 | ||
8386ac43 | 8213 | DEFUN (show_bgp_vrfs, |
8214 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8215 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8216 | SHOW_STR |
d6e3c605 | 8217 | IP_STR |
8386ac43 | 8218 | BGP_STR |
8219 | "Show BGP VRFs\n" | |
9973d184 | 8220 | JSON_STR) |
8386ac43 | 8221 | { |
fe1dc5a3 | 8222 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8223 | struct list *inst = bm->bgp; |
8224 | struct listnode *node; | |
8225 | struct bgp *bgp; | |
9f049418 | 8226 | bool uj = use_json(argc, argv); |
d62a17ae | 8227 | json_object *json = NULL; |
8228 | json_object *json_vrfs = NULL; | |
8229 | int count = 0; | |
d62a17ae | 8230 | |
d62a17ae | 8231 | if (uj) { |
8232 | json = json_object_new_object(); | |
8233 | json_vrfs = json_object_new_object(); | |
8234 | } | |
8235 | ||
8236 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8237 | const char *name, *type; | |
8238 | struct peer *peer; | |
7fe96307 | 8239 | struct listnode *node2, *nnode2; |
d62a17ae | 8240 | int peers_cfg, peers_estb; |
8241 | json_object *json_vrf = NULL; | |
d62a17ae | 8242 | |
8243 | /* Skip Views. */ | |
8244 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8245 | continue; | |
8246 | ||
8247 | count++; | |
efb4077a | 8248 | if (!uj && count == 1) { |
fe1dc5a3 | 8249 | vty_out(vty, |
efb4077a | 8250 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8251 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8252 | "#PeersEstb", "Name"); |
8253 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8254 | "L3-VNI", "RouterMAC", "Interface"); | |
8255 | } | |
d62a17ae | 8256 | |
8257 | peers_cfg = peers_estb = 0; | |
8258 | if (uj) | |
8259 | json_vrf = json_object_new_object(); | |
8260 | ||
8261 | ||
7fe96307 | 8262 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8263 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8264 | continue; | |
8265 | peers_cfg++; | |
8266 | if (peer->status == Established) | |
8267 | peers_estb++; | |
8268 | } | |
8269 | ||
8270 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8271 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8272 | type = "DFLT"; |
8273 | } else { | |
8274 | name = bgp->name; | |
8275 | type = "VRF"; | |
8276 | } | |
8277 | ||
a8bf7d9c | 8278 | |
d62a17ae | 8279 | if (uj) { |
a4d82a8a PZ |
8280 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8281 | ? -1 | |
8282 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8283 | json_object_string_add(json_vrf, "type", type); |
8284 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8285 | json_object_string_add(json_vrf, "routerId", | |
8286 | inet_ntoa(bgp->router_id)); | |
8287 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8288 | peers_cfg); | |
8289 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8290 | peers_estb); | |
8291 | ||
fe1dc5a3 | 8292 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8293 | json_object_string_add( |
8294 | json_vrf, "rmac", | |
8295 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8296 | json_object_string_add(json_vrf, "interface", |
8297 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8298 | bgp->vrf_id)); | |
d62a17ae | 8299 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8300 | } else { |
fe1dc5a3 | 8301 | vty_out(vty, |
efb4077a | 8302 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8303 | type, |
8304 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8305 | : (int)bgp->vrf_id, | |
8306 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8307 | peers_estb, name); |
8308 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8309 | bgp->l3vni, | |
8310 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8311 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8312 | bgp->vrf_id)); | |
8313 | } | |
d62a17ae | 8314 | } |
8315 | ||
8316 | if (uj) { | |
8317 | json_object_object_add(json, "vrfs", json_vrfs); | |
8318 | ||
8319 | json_object_int_add(json, "totalVrfs", count); | |
8320 | ||
996c9314 LB |
8321 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8322 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8323 | json_object_free(json); |
8324 | } else { | |
8325 | if (count) | |
8326 | vty_out(vty, | |
8327 | "\nTotal number of VRFs (including default): %d\n", | |
8328 | count); | |
8329 | } | |
8330 | ||
8331 | return CMD_SUCCESS; | |
8386ac43 | 8332 | } |
8333 | ||
48ecf8f5 DS |
8334 | DEFUN (show_bgp_mac_hash, |
8335 | show_bgp_mac_hash_cmd, | |
8336 | "show bgp mac hash", | |
8337 | SHOW_STR | |
8338 | BGP_STR | |
8339 | "Mac Address\n" | |
8340 | "Mac Address database\n") | |
8341 | { | |
8342 | bgp_mac_dump_table(vty); | |
8343 | ||
8344 | return CMD_SUCCESS; | |
8345 | } | |
acf71666 | 8346 | |
e3b78da8 | 8347 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8348 | { |
0291c246 | 8349 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8350 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8351 | |
60466a63 | 8352 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8353 | tip->refcnt); |
8354 | } | |
8355 | ||
8356 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8357 | { | |
8358 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8359 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8360 | |
8361 | vty_out(vty, "Tunnel-ip database:\n"); | |
8362 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8363 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8364 | vty); |
8365 | } | |
8366 | ||
15c81ca4 DS |
8367 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8368 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8369 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8370 | "martian next-hops\n" |
8371 | "martian next-hop database\n") | |
acf71666 | 8372 | { |
0291c246 | 8373 | struct bgp *bgp = NULL; |
15c81ca4 | 8374 | int idx = 0; |
9a8bdf1c PG |
8375 | char *name = NULL; |
8376 | ||
8377 | /* [<vrf> VIEWVRFNAME] */ | |
8378 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8379 | name = argv[idx + 1]->arg; | |
8380 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8381 | name = NULL; | |
8382 | } else if (argv_find(argv, argc, "view", &idx)) | |
8383 | /* [<view> VIEWVRFNAME] */ | |
8384 | name = argv[idx + 1]->arg; | |
8385 | if (name) | |
8386 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8387 | else |
8388 | bgp = bgp_get_default(); | |
acf71666 | 8389 | |
acf71666 MK |
8390 | if (!bgp) { |
8391 | vty_out(vty, "%% No BGP process is configured\n"); | |
8392 | return CMD_WARNING; | |
8393 | } | |
8394 | bgp_show_martian_nexthops(vty, bgp); | |
8395 | ||
8396 | return CMD_SUCCESS; | |
8397 | } | |
8398 | ||
f412b39a | 8399 | DEFUN (show_bgp_memory, |
4bf6a362 | 8400 | show_bgp_memory_cmd, |
7fa12b13 | 8401 | "show [ip] bgp memory", |
4bf6a362 | 8402 | SHOW_STR |
3a2d747c | 8403 | IP_STR |
4bf6a362 PJ |
8404 | BGP_STR |
8405 | "Global BGP memory statistics\n") | |
8406 | { | |
d62a17ae | 8407 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8408 | unsigned long count; | |
8409 | ||
8410 | /* RIB related usage stats */ | |
8411 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8412 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8413 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8414 | count * sizeof(struct bgp_node))); | |
8415 | ||
8416 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8417 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8418 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8419 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8420 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8421 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8422 | count, | |
4b7e6066 DS |
8423 | mtype_memstr( |
8424 | memstrbuf, sizeof(memstrbuf), | |
8425 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8426 | |
8427 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8428 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8429 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8430 | count * sizeof(struct bgp_static))); | |
8431 | ||
8432 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8433 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8434 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8435 | count * sizeof(struct bpacket))); | |
8436 | ||
8437 | /* Adj-In/Out */ | |
8438 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8439 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8440 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8441 | count * sizeof(struct bgp_adj_in))); | |
8442 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8443 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8444 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8445 | count * sizeof(struct bgp_adj_out))); | |
8446 | ||
8447 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8448 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8449 | count, | |
8450 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8451 | count * sizeof(struct bgp_nexthop_cache))); | |
8452 | ||
8453 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8454 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8455 | count, | |
8456 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8457 | count * sizeof(struct bgp_damp_info))); | |
8458 | ||
8459 | /* Attributes */ | |
8460 | count = attr_count(); | |
8461 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8462 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8463 | count * sizeof(struct attr))); | |
8464 | ||
8465 | if ((count = attr_unknown_count())) | |
8466 | vty_out(vty, "%ld unknown attributes\n", count); | |
8467 | ||
8468 | /* AS_PATH attributes */ | |
8469 | count = aspath_count(); | |
8470 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8471 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8472 | count * sizeof(struct aspath))); | |
8473 | ||
8474 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8475 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8476 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8477 | count * sizeof(struct assegment))); | |
8478 | ||
8479 | /* Other attributes */ | |
8480 | if ((count = community_count())) | |
8481 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8482 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8483 | count * sizeof(struct community))); | |
d62a17ae | 8484 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8485 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8486 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8487 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8488 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8489 | vty_out(vty, | |
8490 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8491 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8492 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8493 | |
8494 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8495 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8496 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8497 | count * sizeof(struct cluster_list))); | |
8498 | ||
8499 | /* Peer related usage */ | |
8500 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8501 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8502 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8503 | count * sizeof(struct peer))); | |
8504 | ||
8505 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8506 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8507 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8508 | count * sizeof(struct peer_group))); | |
8509 | ||
8510 | /* Other */ | |
d62a17ae | 8511 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8512 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8513 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8514 | count * sizeof(regex_t))); | |
d62a17ae | 8515 | return CMD_SUCCESS; |
4bf6a362 | 8516 | } |
fee0f4c6 | 8517 | |
57a9c8a8 DS |
8518 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8519 | { | |
8520 | json_object *bestpath = json_object_new_object(); | |
8521 | ||
892fedb6 | 8522 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8523 | json_object_string_add(bestpath, "asPath", "ignore"); |
8524 | ||
892fedb6 | 8525 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8526 | json_object_string_add(bestpath, "asPath", "confed"); |
8527 | ||
892fedb6 DA |
8528 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8529 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8530 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8531 | "as-set"); |
8532 | else | |
a4d82a8a | 8533 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8534 | "true"); |
8535 | } else | |
a4d82a8a | 8536 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8537 | |
892fedb6 | 8538 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8539 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8540 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8541 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8542 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8543 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8544 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8545 | json_object_string_add(bestpath, "med", |
8546 | "missing-as-worst"); | |
8547 | else | |
8548 | json_object_string_add(bestpath, "med", "true"); | |
8549 | } | |
8550 | ||
8551 | json_object_object_add(json, "bestPath", bestpath); | |
8552 | } | |
8553 | ||
3577f1c5 DD |
8554 | /* Print the error code/subcode for why the peer is down */ |
8555 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8556 | json_object *json_peer, bool use_json) | |
8557 | { | |
8558 | const char *code_str; | |
8559 | const char *subcode_str; | |
8560 | ||
8561 | if (use_json) { | |
8562 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8563 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8564 | char errorcodesubcode_hexstr[5]; | |
8565 | char errorcodesubcode_str[256]; | |
8566 | ||
8567 | code_str = bgp_notify_code_str(peer->notify.code); | |
8568 | subcode_str = bgp_notify_subcode_str( | |
8569 | peer->notify.code, | |
8570 | peer->notify.subcode); | |
8571 | ||
8572 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
8573 | peer->notify.code, peer->notify.subcode); | |
8574 | json_object_string_add(json_peer, | |
8575 | "lastErrorCodeSubcode", | |
8576 | errorcodesubcode_hexstr); | |
8577 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8578 | code_str, subcode_str); | |
8579 | json_object_string_add(json_peer, | |
8580 | "lastNotificationReason", | |
8581 | errorcodesubcode_str); | |
8582 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8583 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8584 | && (peer->notify.subcode | |
8585 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8586 | || peer->notify.subcode | |
8587 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8588 | && peer->notify.length) { | |
8589 | char msgbuf[1024]; | |
8590 | const char *msg_str; | |
8591 | ||
8592 | msg_str = bgp_notify_admin_message( | |
8593 | msgbuf, sizeof(msgbuf), | |
8594 | (uint8_t *)peer->notify.data, | |
8595 | peer->notify.length); | |
8596 | if (msg_str) | |
8597 | json_object_string_add( | |
8598 | json_peer, | |
8599 | "lastShutdownDescription", | |
8600 | msg_str); | |
8601 | } | |
8602 | ||
c258527b | 8603 | } |
3577f1c5 DD |
8604 | json_object_string_add(json_peer, "lastResetDueTo", |
8605 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8606 | json_object_int_add(json_peer, "lastResetCode", |
8607 | peer->last_reset); | |
3577f1c5 DD |
8608 | } else { |
8609 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8610 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8611 | code_str = bgp_notify_code_str(peer->notify.code); | |
8612 | subcode_str = | |
8613 | bgp_notify_subcode_str(peer->notify.code, | |
8614 | peer->notify.subcode); | |
8615 | vty_out(vty, " Notification %s (%s%s)\n", | |
8616 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8617 | ? "sent" | |
8618 | : "received", | |
8619 | code_str, subcode_str); | |
8620 | } else { | |
e91c24c8 | 8621 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8622 | peer_down_str[(int)peer->last_reset]); |
8623 | } | |
8624 | } | |
8625 | } | |
8626 | ||
8627 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8628 | safi_t safi) | |
8629 | { | |
8630 | return ((peer->status != Established) || | |
8631 | !peer->afc_recv[afi][safi]); | |
8632 | } | |
8633 | ||
8634 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8635 | struct peer *peer, json_object *json_peer, | |
8636 | int max_neighbor_width, bool use_json) | |
8637 | { | |
8638 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8639 | int len; | |
8640 | ||
8641 | if (use_json) { | |
8642 | if (peer_dynamic_neighbor(peer)) | |
8643 | json_object_boolean_true_add(json_peer, | |
8644 | "dynamicPeer"); | |
8645 | if (peer->hostname) | |
8646 | json_object_string_add(json_peer, "hostname", | |
8647 | peer->hostname); | |
8648 | ||
8649 | if (peer->domainname) | |
8650 | json_object_string_add(json_peer, "domainname", | |
8651 | peer->domainname); | |
8652 | json_object_int_add(json_peer, "connectionsEstablished", | |
8653 | peer->established); | |
8654 | json_object_int_add(json_peer, "connectionsDropped", | |
8655 | peer->dropped); | |
8656 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8657 | use_json, json_peer); | |
8658 | if (peer->status == Established) | |
8659 | json_object_string_add(json_peer, "lastResetDueTo", | |
8660 | "AFI/SAFI Not Negotiated"); | |
8661 | else | |
8662 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8663 | } else { | |
8664 | dn_flag[1] = '\0'; | |
8665 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8666 | if (peer->hostname | |
892fedb6 | 8667 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8668 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8669 | peer->hostname, peer->host); | |
8670 | else | |
8671 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8672 | ||
8673 | /* pad the neighbor column with spaces */ | |
8674 | if (len < max_neighbor_width) | |
8675 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8676 | " "); | |
e91c24c8 | 8677 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8678 | peer->dropped, |
8679 | peer_uptime(peer->uptime, timebuf, | |
8680 | BGP_UPTIME_LEN, 0, NULL)); | |
8681 | if (peer->status == Established) | |
8682 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8683 | else | |
8684 | bgp_show_peer_reset(vty, peer, NULL, | |
8685 | false); | |
8686 | } | |
8687 | } | |
c258527b | 8688 | |
3577f1c5 | 8689 | |
718e3744 | 8690 | /* Show BGP peer's summary information. */ |
d62a17ae | 8691 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8692 | bool show_failed, bool use_json) |
d62a17ae | 8693 | { |
8694 | struct peer *peer; | |
8695 | struct listnode *node, *nnode; | |
8696 | unsigned int count = 0, dn_count = 0; | |
8697 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8698 | char neighbor_buf[VTY_BUFSIZ]; | |
8699 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8700 | int len, failed_count = 0; |
d62a17ae | 8701 | int max_neighbor_width = 0; |
8702 | int pfx_rcd_safi; | |
3c13337d | 8703 | json_object *json = NULL; |
d62a17ae | 8704 | json_object *json_peer = NULL; |
8705 | json_object *json_peers = NULL; | |
50e05855 | 8706 | struct peer_af *paf; |
d62a17ae | 8707 | |
8708 | /* labeled-unicast routes are installed in the unicast table so in order | |
8709 | * to | |
8710 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8711 | */ | |
3577f1c5 | 8712 | |
d62a17ae | 8713 | if (safi == SAFI_LABELED_UNICAST) |
8714 | pfx_rcd_safi = SAFI_UNICAST; | |
8715 | else | |
8716 | pfx_rcd_safi = safi; | |
8717 | ||
8718 | if (use_json) { | |
3c13337d | 8719 | json = json_object_new_object(); |
d62a17ae | 8720 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8721 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8722 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8723 | continue; | |
8724 | ||
8725 | if (peer->afc[afi][safi]) { | |
8726 | /* See if we have at least a single failed peer */ | |
8727 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8728 | failed_count++; | |
8729 | count++; | |
8730 | } | |
8731 | if (peer_dynamic_neighbor(peer)) | |
8732 | dn_count++; | |
8733 | } | |
c258527b | 8734 | |
d62a17ae | 8735 | } else { |
8736 | /* Loop over all neighbors that will be displayed to determine | |
8737 | * how many | |
8738 | * characters are needed for the Neighbor column | |
8739 | */ | |
8740 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8741 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8742 | continue; | |
8743 | ||
8744 | if (peer->afc[afi][safi]) { | |
8745 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8746 | if (peer_dynamic_neighbor(peer)) | |
8747 | dn_flag[0] = '*'; | |
8748 | ||
8749 | if (peer->hostname | |
892fedb6 DA |
8750 | && CHECK_FLAG(bgp->flags, |
8751 | BGP_FLAG_SHOW_HOSTNAME)) | |
d62a17ae | 8752 | sprintf(neighbor_buf, "%s%s(%s) ", |
8753 | dn_flag, peer->hostname, | |
8754 | peer->host); | |
8755 | else | |
8756 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
8757 | peer->host); | |
8758 | ||
8759 | len = strlen(neighbor_buf); | |
8760 | ||
8761 | if (len > max_neighbor_width) | |
8762 | max_neighbor_width = len; | |
c258527b | 8763 | |
3577f1c5 DD |
8764 | /* See if we have at least a single failed peer */ |
8765 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8766 | failed_count++; | |
8767 | count++; | |
d62a17ae | 8768 | } |
8769 | } | |
f933309e | 8770 | |
d62a17ae | 8771 | /* Originally we displayed the Neighbor column as 16 |
8772 | * characters wide so make that the default | |
8773 | */ | |
8774 | if (max_neighbor_width < neighbor_col_default_width) | |
8775 | max_neighbor_width = neighbor_col_default_width; | |
8776 | } | |
f933309e | 8777 | |
3577f1c5 DD |
8778 | if (show_failed && !failed_count) { |
8779 | if (use_json) { | |
8780 | json_object_int_add(json, "failedPeersCount", 0); | |
8781 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8782 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8783 | |
8784 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8785 | json, JSON_C_TO_STRING_PRETTY)); | |
8786 | json_object_free(json); | |
8787 | } else { | |
8788 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8789 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8790 | } | |
8791 | return CMD_SUCCESS; | |
8792 | } | |
c258527b | 8793 | |
3577f1c5 | 8794 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8795 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8796 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8797 | continue; | |
8798 | ||
ea47320b DL |
8799 | if (!peer->afc[afi][safi]) |
8800 | continue; | |
d62a17ae | 8801 | |
ea47320b DL |
8802 | if (!count) { |
8803 | unsigned long ents; | |
8804 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8805 | int64_t vrf_id_ui; |
d62a17ae | 8806 | |
a4d82a8a PZ |
8807 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8808 | ? -1 | |
8809 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8810 | |
8811 | /* Usage summary and header */ | |
8812 | if (use_json) { | |
8813 | json_object_string_add( | |
8814 | json, "routerId", | |
8815 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8816 | json_object_int_add(json, "as", bgp->as); |
8817 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8818 | json_object_string_add( |
8819 | json, "vrfName", | |
8820 | (bgp->inst_type | |
8821 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8822 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8823 | : bgp->name); |
8824 | } else { | |
8825 | vty_out(vty, | |
8826 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8827 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8828 | bgp->vrf_id == VRF_UNKNOWN |
8829 | ? -1 | |
8830 | : (int)bgp->vrf_id); | |
ea47320b DL |
8831 | vty_out(vty, "\n"); |
8832 | } | |
d62a17ae | 8833 | |
ea47320b | 8834 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8835 | if (use_json) { |
ea47320b | 8836 | json_object_int_add( |
60466a63 | 8837 | json, "updateDelayLimit", |
ea47320b | 8838 | bgp->v_update_delay); |
d62a17ae | 8839 | |
ea47320b DL |
8840 | if (bgp->v_update_delay |
8841 | != bgp->v_establish_wait) | |
d62a17ae | 8842 | json_object_int_add( |
8843 | json, | |
ea47320b DL |
8844 | "updateDelayEstablishWait", |
8845 | bgp->v_establish_wait); | |
d62a17ae | 8846 | |
60466a63 | 8847 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8848 | json_object_string_add( |
8849 | json, | |
8850 | "updateDelayFirstNeighbor", | |
8851 | bgp->update_delay_begin_time); | |
8852 | json_object_boolean_true_add( | |
8853 | json, | |
8854 | "updateDelayInProgress"); | |
8855 | } else { | |
8856 | if (bgp->update_delay_over) { | |
d62a17ae | 8857 | json_object_string_add( |
8858 | json, | |
8859 | "updateDelayFirstNeighbor", | |
8860 | bgp->update_delay_begin_time); | |
ea47320b | 8861 | json_object_string_add( |
d62a17ae | 8862 | json, |
ea47320b DL |
8863 | "updateDelayBestpathResumed", |
8864 | bgp->update_delay_end_time); | |
8865 | json_object_string_add( | |
d62a17ae | 8866 | json, |
ea47320b DL |
8867 | "updateDelayZebraUpdateResume", |
8868 | bgp->update_delay_zebra_resume_time); | |
8869 | json_object_string_add( | |
8870 | json, | |
8871 | "updateDelayPeerUpdateResume", | |
8872 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8873 | } |
ea47320b DL |
8874 | } |
8875 | } else { | |
8876 | vty_out(vty, | |
8877 | "Read-only mode update-delay limit: %d seconds\n", | |
8878 | bgp->v_update_delay); | |
8879 | if (bgp->v_update_delay | |
8880 | != bgp->v_establish_wait) | |
d62a17ae | 8881 | vty_out(vty, |
ea47320b DL |
8882 | " Establish wait: %d seconds\n", |
8883 | bgp->v_establish_wait); | |
d62a17ae | 8884 | |
60466a63 | 8885 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8886 | vty_out(vty, |
8887 | " First neighbor established: %s\n", | |
8888 | bgp->update_delay_begin_time); | |
8889 | vty_out(vty, | |
8890 | " Delay in progress\n"); | |
8891 | } else { | |
8892 | if (bgp->update_delay_over) { | |
d62a17ae | 8893 | vty_out(vty, |
8894 | " First neighbor established: %s\n", | |
8895 | bgp->update_delay_begin_time); | |
8896 | vty_out(vty, | |
ea47320b DL |
8897 | " Best-paths resumed: %s\n", |
8898 | bgp->update_delay_end_time); | |
8899 | vty_out(vty, | |
8900 | " zebra update resumed: %s\n", | |
8901 | bgp->update_delay_zebra_resume_time); | |
8902 | vty_out(vty, | |
8903 | " peers update resumed: %s\n", | |
8904 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8905 | } |
8906 | } | |
8907 | } | |
ea47320b | 8908 | } |
d62a17ae | 8909 | |
ea47320b DL |
8910 | if (use_json) { |
8911 | if (bgp_maxmed_onstartup_configured(bgp) | |
8912 | && bgp->maxmed_active) | |
8913 | json_object_boolean_true_add( | |
60466a63 | 8914 | json, "maxMedOnStartup"); |
ea47320b DL |
8915 | if (bgp->v_maxmed_admin) |
8916 | json_object_boolean_true_add( | |
60466a63 | 8917 | json, "maxMedAdministrative"); |
d62a17ae | 8918 | |
ea47320b DL |
8919 | json_object_int_add( |
8920 | json, "tableVersion", | |
60466a63 | 8921 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8922 | |
60466a63 QY |
8923 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8924 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8925 | json_object_int_add( |
8926 | json, "ribMemory", | |
8927 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8928 | |
210ec2a0 | 8929 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8930 | json_object_int_add(json, "peerCount", ents); |
8931 | json_object_int_add(json, "peerMemory", | |
8932 | ents * sizeof(struct peer)); | |
d62a17ae | 8933 | |
ea47320b DL |
8934 | if ((ents = listcount(bgp->group))) { |
8935 | json_object_int_add( | |
60466a63 | 8936 | json, "peerGroupCount", ents); |
ea47320b DL |
8937 | json_object_int_add( |
8938 | json, "peerGroupMemory", | |
996c9314 LB |
8939 | ents * sizeof(struct |
8940 | peer_group)); | |
ea47320b | 8941 | } |
d62a17ae | 8942 | |
ea47320b DL |
8943 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8944 | BGP_CONFIG_DAMPENING)) | |
8945 | json_object_boolean_true_add( | |
60466a63 | 8946 | json, "dampeningEnabled"); |
ea47320b DL |
8947 | } else { |
8948 | if (bgp_maxmed_onstartup_configured(bgp) | |
8949 | && bgp->maxmed_active) | |
d62a17ae | 8950 | vty_out(vty, |
ea47320b DL |
8951 | "Max-med on-startup active\n"); |
8952 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8953 | vty_out(vty, |
ea47320b | 8954 | "Max-med administrative active\n"); |
d62a17ae | 8955 | |
60466a63 QY |
8956 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8957 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8958 | |
60466a63 | 8959 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8960 | vty_out(vty, |
8961 | "RIB entries %ld, using %s of memory\n", | |
8962 | ents, | |
996c9314 LB |
8963 | mtype_memstr(memstrbuf, |
8964 | sizeof(memstrbuf), | |
8965 | ents * sizeof(struct | |
8966 | bgp_node))); | |
ea47320b DL |
8967 | |
8968 | /* Peer related usage */ | |
210ec2a0 | 8969 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8970 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8971 | ents, |
8972 | mtype_memstr( | |
60466a63 QY |
8973 | memstrbuf, sizeof(memstrbuf), |
8974 | ents * sizeof(struct peer))); | |
ea47320b DL |
8975 | |
8976 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8977 | vty_out(vty, |
ea47320b | 8978 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8979 | ents, |
8980 | mtype_memstr( | |
8981 | memstrbuf, | |
8982 | sizeof(memstrbuf), | |
996c9314 LB |
8983 | ents * sizeof(struct |
8984 | peer_group))); | |
d62a17ae | 8985 | |
ea47320b DL |
8986 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8987 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8988 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8989 | vty_out(vty, "\n"); |
d62a17ae | 8990 | |
ea47320b DL |
8991 | /* Subtract 8 here because 'Neighbor' is |
8992 | * 8 characters */ | |
8993 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8994 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8995 | " "); | |
3577f1c5 DD |
8996 | if (show_failed) |
8997 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
8998 | else | |
8999 | vty_out(vty, | |
bed8d78b | 9000 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 9001 | } |
ea47320b | 9002 | } |
d62a17ae | 9003 | |
ea47320b | 9004 | count++; |
3577f1c5 DD |
9005 | /* Works for both failed & successful cases */ |
9006 | if (peer_dynamic_neighbor(peer)) | |
9007 | dn_count++; | |
d62a17ae | 9008 | |
ea47320b | 9009 | if (use_json) { |
3577f1c5 DD |
9010 | json_peer = NULL; |
9011 | ||
9012 | if (show_failed && | |
9013 | bgp_has_peer_failed(peer, afi, safi)) { | |
9014 | json_peer = json_object_new_object(); | |
9015 | bgp_show_failed_summary(vty, bgp, peer, | |
9016 | json_peer, 0, use_json); | |
9017 | } else if (!show_failed) { | |
9018 | json_peer = json_object_new_object(); | |
9019 | if (peer_dynamic_neighbor(peer)) { | |
9020 | json_object_boolean_true_add(json_peer, | |
9021 | "dynamicPeer"); | |
9022 | } | |
d62a17ae | 9023 | |
3577f1c5 DD |
9024 | if (peer->hostname) |
9025 | json_object_string_add(json_peer, "hostname", | |
9026 | peer->hostname); | |
9027 | ||
9028 | if (peer->domainname) | |
9029 | json_object_string_add(json_peer, "domainname", | |
9030 | peer->domainname); | |
9031 | ||
9032 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9033 | json_object_int_add(json_peer, "version", 4); | |
9034 | json_object_int_add(json_peer, "msgRcvd", | |
9035 | PEER_TOTAL_RX(peer)); | |
9036 | json_object_int_add(json_peer, "msgSent", | |
9037 | PEER_TOTAL_TX(peer)); | |
9038 | ||
9039 | json_object_int_add(json_peer, "tableVersion", | |
9040 | peer->version[afi][safi]); | |
9041 | json_object_int_add(json_peer, "outq", | |
9042 | peer->obuf->count); | |
9043 | json_object_int_add(json_peer, "inq", 0); | |
9044 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9045 | use_json, json_peer); | |
9046 | ||
9047 | /* | |
9048 | * Adding "pfxRcd" field to match with the corresponding | |
9049 | * CLI. "prefixReceivedCount" will be deprecated in | |
9050 | * future. | |
9051 | */ | |
9052 | json_object_int_add(json_peer, "prefixReceivedCount", | |
9053 | peer->pcount[afi][pfx_rcd_safi]); | |
9054 | json_object_int_add(json_peer, "pfxRcd", | |
9055 | peer->pcount[afi][pfx_rcd_safi]); | |
9056 | ||
9057 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
9058 | if (paf && PAF_SUBGRP(paf)) | |
9059 | json_object_int_add(json_peer, | |
9060 | "pfxSnt", | |
9061 | (PAF_SUBGRP(paf))->scount); | |
9062 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9063 | json_object_string_add(json_peer, "state", | |
9064 | "Idle (Admin)"); | |
9065 | else if (peer->afc_recv[afi][safi]) | |
9066 | json_object_string_add( | |
9067 | json_peer, "state", | |
9068 | lookup_msg(bgp_status_msg, peer->status, | |
9069 | NULL)); | |
9070 | else if (CHECK_FLAG(peer->sflags, | |
9071 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9072 | json_object_string_add(json_peer, "state", | |
9073 | "Idle (PfxCt)"); | |
9074 | else | |
9075 | json_object_string_add( | |
9076 | json_peer, "state", | |
9077 | lookup_msg(bgp_status_msg, peer->status, | |
9078 | NULL)); | |
200116db DD |
9079 | json_object_int_add(json_peer, "connectionsEstablished", |
9080 | peer->established); | |
9081 | json_object_int_add(json_peer, "connectionsDropped", | |
9082 | peer->dropped); | |
b4e9dcba | 9083 | } |
3577f1c5 DD |
9084 | /* Avoid creating empty peer dicts in JSON */ |
9085 | if (json_peer == NULL) | |
9086 | continue; | |
ea47320b DL |
9087 | |
9088 | if (peer->conf_if) | |
60466a63 | 9089 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9090 | "interface"); |
9091 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9092 | json_object_string_add(json_peer, "idType", |
9093 | "ipv4"); | |
ea47320b | 9094 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9095 | json_object_string_add(json_peer, "idType", |
9096 | "ipv6"); | |
ea47320b DL |
9097 | json_object_object_add(json_peers, peer->host, |
9098 | json_peer); | |
9099 | } else { | |
3577f1c5 DD |
9100 | if (show_failed && |
9101 | bgp_has_peer_failed(peer, afi, safi)) { | |
9102 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9103 | max_neighbor_width, | |
9104 | use_json); | |
9105 | } else if (!show_failed) { | |
9106 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9107 | if (peer_dynamic_neighbor(peer)) { | |
9108 | dn_flag[0] = '*'; | |
9109 | } | |
d62a17ae | 9110 | |
3577f1c5 | 9111 | if (peer->hostname |
892fedb6 DA |
9112 | && CHECK_FLAG(bgp->flags, |
9113 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9114 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9115 | peer->hostname, |
9116 | peer->host); | |
d62a17ae | 9117 | else |
3577f1c5 DD |
9118 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9119 | ||
9120 | /* pad the neighbor column with spaces */ | |
9121 | if (len < max_neighbor_width) | |
9122 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9123 | " "); | |
9124 | ||
566bdaf6 DL |
9125 | vty_out(vty, |
9126 | "4 %10u %9u %9u %8" PRIu64 " %4d %4zu %8s", | |
3577f1c5 | 9127 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 DL |
9128 | PEER_TOTAL_TX(peer), |
9129 | peer->version[afi][safi], 0, | |
9130 | peer->obuf->count, | |
3577f1c5 DD |
9131 | peer_uptime(peer->uptime, timebuf, |
9132 | BGP_UPTIME_LEN, 0, NULL)); | |
9133 | ||
9134 | if (peer->status == Established) | |
9135 | if (peer->afc_recv[afi][safi]) | |
a0a87037 DA |
9136 | vty_out(vty, " %12" PRIu32, |
9137 | peer->pcount | |
9138 | [afi] | |
9139 | [pfx_rcd_safi]); | |
3577f1c5 DD |
9140 | else |
9141 | vty_out(vty, " NoNeg"); | |
9142 | else { | |
9143 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9144 | vty_out(vty, " Idle (Admin)"); | |
9145 | else if (CHECK_FLAG( | |
9146 | peer->sflags, | |
9147 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9148 | vty_out(vty, " Idle (PfxCt)"); | |
9149 | else | |
9150 | vty_out(vty, " %12s", | |
9151 | lookup_msg(bgp_status_msg, | |
9152 | peer->status, NULL)); | |
9153 | } | |
9154 | vty_out(vty, "\n"); | |
d62a17ae | 9155 | } |
3577f1c5 | 9156 | |
d62a17ae | 9157 | } |
9158 | } | |
f933309e | 9159 | |
d62a17ae | 9160 | if (use_json) { |
9161 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9162 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9163 | json_object_int_add(json, "totalPeers", count); |
9164 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9165 | ||
3577f1c5 DD |
9166 | if (!show_failed) |
9167 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9168 | |
996c9314 LB |
9169 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9170 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9171 | json_object_free(json); |
9172 | } else { | |
9173 | if (count) | |
9174 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9175 | else { | |
d6ceaca3 | 9176 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9177 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9178 | } |
b05a1c8b | 9179 | |
d6ceaca3 | 9180 | if (dn_count) { |
d62a17ae | 9181 | vty_out(vty, "* - dynamic neighbor\n"); |
9182 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9183 | dn_count, bgp->dynamic_neighbors_limit); | |
9184 | } | |
9185 | } | |
1ff9a340 | 9186 | |
d62a17ae | 9187 | return CMD_SUCCESS; |
718e3744 | 9188 | } |
9189 | ||
d62a17ae | 9190 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9191 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9192 | { |
9193 | int is_first = 1; | |
9194 | int afi_wildcard = (afi == AFI_MAX); | |
9195 | int safi_wildcard = (safi == SAFI_MAX); | |
9196 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9197 | bool nbr_output = false; |
d62a17ae | 9198 | |
9199 | if (use_json && is_wildcard) | |
9200 | vty_out(vty, "{\n"); | |
9201 | if (afi_wildcard) | |
9202 | afi = 1; /* AFI_IP */ | |
9203 | while (afi < AFI_MAX) { | |
9204 | if (safi_wildcard) | |
9205 | safi = 1; /* SAFI_UNICAST */ | |
9206 | while (safi < SAFI_MAX) { | |
318cac96 | 9207 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9208 | nbr_output = true; |
f86897b9 | 9209 | |
d62a17ae | 9210 | if (is_wildcard) { |
9211 | /* | |
9212 | * So limit output to those afi/safi | |
9213 | * pairs that | |
9214 | * actualy have something interesting in | |
9215 | * them | |
9216 | */ | |
9217 | if (use_json) { | |
d62a17ae | 9218 | if (!is_first) |
9219 | vty_out(vty, ",\n"); | |
9220 | else | |
9221 | is_first = 0; | |
9222 | ||
9223 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9224 | get_afi_safi_str(afi, |
9225 | safi, | |
9226 | true)); | |
d62a17ae | 9227 | } else { |
9228 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9229 | get_afi_safi_str(afi, |
9230 | safi, | |
9231 | false)); | |
d62a17ae | 9232 | } |
9233 | } | |
3577f1c5 DD |
9234 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9235 | use_json); | |
d62a17ae | 9236 | } |
9237 | safi++; | |
d62a17ae | 9238 | if (!safi_wildcard) |
9239 | safi = SAFI_MAX; | |
9240 | } | |
9241 | afi++; | |
ee851c8c | 9242 | if (!afi_wildcard) |
d62a17ae | 9243 | afi = AFI_MAX; |
9244 | } | |
9245 | ||
9246 | if (use_json && is_wildcard) | |
9247 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9248 | else if (!nbr_output) { |
9249 | if (use_json) | |
9250 | vty_out(vty, "{}\n"); | |
9251 | else | |
9252 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9253 | } | |
d62a17ae | 9254 | } |
9255 | ||
9256 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9257 | safi_t safi, bool show_failed, |
9258 | bool use_json) | |
d62a17ae | 9259 | { |
9260 | struct listnode *node, *nnode; | |
9261 | struct bgp *bgp; | |
d62a17ae | 9262 | int is_first = 1; |
9f049418 | 9263 | bool nbr_output = false; |
d62a17ae | 9264 | |
9265 | if (use_json) | |
9266 | vty_out(vty, "{\n"); | |
9267 | ||
9268 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9269 | nbr_output = true; |
d62a17ae | 9270 | if (use_json) { |
d62a17ae | 9271 | if (!is_first) |
9272 | vty_out(vty, ",\n"); | |
9273 | else | |
9274 | is_first = 0; | |
9275 | ||
9276 | vty_out(vty, "\"%s\":", | |
9277 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9278 | ? VRF_DEFAULT_NAME |
d62a17ae | 9279 | : bgp->name); |
9280 | } else { | |
9281 | vty_out(vty, "\nInstance %s:\n", | |
9282 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9283 | ? VRF_DEFAULT_NAME |
d62a17ae | 9284 | : bgp->name); |
9285 | } | |
3577f1c5 DD |
9286 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9287 | use_json); | |
d62a17ae | 9288 | } |
9289 | ||
9290 | if (use_json) | |
9291 | vty_out(vty, "}\n"); | |
9f049418 DS |
9292 | else if (!nbr_output) |
9293 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9294 | } |
9295 | ||
9296 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9297 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9298 | { |
9299 | struct bgp *bgp; | |
9300 | ||
9301 | if (name) { | |
9302 | if (strmatch(name, "all")) { | |
9303 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9304 | show_failed, |
d62a17ae | 9305 | use_json); |
9306 | return CMD_SUCCESS; | |
9307 | } else { | |
9308 | bgp = bgp_lookup_by_name(name); | |
9309 | ||
9310 | if (!bgp) { | |
9311 | if (use_json) | |
9312 | vty_out(vty, "{}\n"); | |
9313 | else | |
9314 | vty_out(vty, | |
ca61fd25 | 9315 | "%% BGP instance not found\n"); |
d62a17ae | 9316 | return CMD_WARNING; |
9317 | } | |
9318 | ||
f86897b9 | 9319 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9320 | show_failed, use_json); |
d62a17ae | 9321 | return CMD_SUCCESS; |
9322 | } | |
9323 | } | |
9324 | ||
9325 | bgp = bgp_get_default(); | |
9326 | ||
9327 | if (bgp) | |
3577f1c5 DD |
9328 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9329 | use_json); | |
9f049418 | 9330 | else { |
ca61fd25 DS |
9331 | if (use_json) |
9332 | vty_out(vty, "{}\n"); | |
9333 | else | |
9334 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9335 | return CMD_WARNING; |
9336 | } | |
d62a17ae | 9337 | |
9338 | return CMD_SUCCESS; | |
4fb25c53 DW |
9339 | } |
9340 | ||
716b2d8a | 9341 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9342 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9343 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9344 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9345 | SHOW_STR |
9346 | IP_STR | |
9347 | BGP_STR | |
8386ac43 | 9348 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9349 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9350 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9351 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9352 | "Show only sessions not in Established state\n" |
9973d184 | 9353 | JSON_STR) |
718e3744 | 9354 | { |
d62a17ae | 9355 | char *vrf = NULL; |
9356 | afi_t afi = AFI_MAX; | |
9357 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9358 | bool show_failed = false; |
d62a17ae | 9359 | |
9360 | int idx = 0; | |
9361 | ||
9362 | /* show [ip] bgp */ | |
9363 | if (argv_find(argv, argc, "ip", &idx)) | |
9364 | afi = AFI_IP; | |
9a8bdf1c PG |
9365 | /* [<vrf> VIEWVRFNAME] */ |
9366 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9367 | vrf = argv[idx + 1]->arg; | |
9368 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9369 | vrf = NULL; | |
9370 | } else if (argv_find(argv, argc, "view", &idx)) | |
9371 | /* [<view> VIEWVRFNAME] */ | |
9372 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9373 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9374 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9375 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9376 | } | |
9377 | ||
3577f1c5 DD |
9378 | if (argv_find(argv, argc, "failed", &idx)) |
9379 | show_failed = true; | |
9380 | ||
9f049418 | 9381 | bool uj = use_json(argc, argv); |
d62a17ae | 9382 | |
3577f1c5 | 9383 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9384 | } |
9385 | ||
5cb5f4d0 | 9386 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9387 | { |
5cb5f4d0 DD |
9388 | if (for_json) |
9389 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9390 | else |
5cb5f4d0 | 9391 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9392 | } |
9393 | ||
d62a17ae | 9394 | |
9395 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9396 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9397 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9398 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9399 | bool use_json, json_object *json_pref) |
d62a17ae | 9400 | { |
9401 | /* Send-Mode */ | |
9402 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9403 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9404 | if (use_json) { | |
9405 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9406 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9407 | json_object_string_add(json_pref, "sendMode", | |
9408 | "advertisedAndReceived"); | |
9409 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9410 | json_object_string_add(json_pref, "sendMode", | |
9411 | "advertised"); | |
9412 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9413 | json_object_string_add(json_pref, "sendMode", | |
9414 | "received"); | |
9415 | } else { | |
9416 | vty_out(vty, " Send-mode: "); | |
9417 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9418 | vty_out(vty, "advertised"); | |
9419 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9420 | vty_out(vty, "%sreceived", | |
9421 | CHECK_FLAG(p->af_cap[afi][safi], | |
9422 | adv_smcap) | |
9423 | ? ", " | |
9424 | : ""); | |
9425 | vty_out(vty, "\n"); | |
9426 | } | |
9427 | } | |
9428 | ||
9429 | /* Receive-Mode */ | |
9430 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9431 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9432 | if (use_json) { | |
9433 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9434 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9435 | json_object_string_add(json_pref, "recvMode", | |
9436 | "advertisedAndReceived"); | |
9437 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9438 | json_object_string_add(json_pref, "recvMode", | |
9439 | "advertised"); | |
9440 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9441 | json_object_string_add(json_pref, "recvMode", | |
9442 | "received"); | |
9443 | } else { | |
9444 | vty_out(vty, " Receive-mode: "); | |
9445 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9446 | vty_out(vty, "advertised"); | |
9447 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9448 | vty_out(vty, "%sreceived", | |
9449 | CHECK_FLAG(p->af_cap[afi][safi], | |
9450 | adv_rmcap) | |
9451 | ? ", " | |
9452 | : ""); | |
9453 | vty_out(vty, "\n"); | |
9454 | } | |
9455 | } | |
9456 | } | |
9457 | ||
13909c4f DS |
9458 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9459 | struct peer *p, | |
9460 | bool use_json, | |
9461 | json_object *json) | |
2986cac2 | 9462 | { |
08c2d52a | 9463 | bool rbit_status = false; |
2986cac2 | 9464 | |
9465 | if (!use_json) | |
a53ca37b | 9466 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9467 | |
13909c4f DS |
9468 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9469 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9470 | && (p->status == Established)) { | |
2986cac2 | 9471 | |
9472 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9473 | rbit_status = true; |
2986cac2 | 9474 | else |
08c2d52a | 9475 | rbit_status = false; |
2986cac2 | 9476 | } |
9477 | ||
9478 | if (rbit_status) { | |
9479 | if (use_json) | |
13909c4f | 9480 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9481 | else |
9482 | vty_out(vty, "True\n"); | |
9483 | } else { | |
9484 | if (use_json) | |
13909c4f | 9485 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9486 | else |
9487 | vty_out(vty, "False\n"); | |
9488 | } | |
9489 | } | |
9490 | ||
13909c4f DS |
9491 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9492 | struct peer *peer, | |
9493 | bool use_json, | |
9494 | json_object *json) | |
2986cac2 | 9495 | { |
2bb5d39b | 9496 | const char *mode = "NotApplicable"; |
2986cac2 | 9497 | |
9498 | if (!use_json) | |
a53ca37b | 9499 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9500 | |
13909c4f DS |
9501 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9502 | && (peer->status == Established)) { | |
2986cac2 | 9503 | |
13909c4f DS |
9504 | if ((peer->nsf_af_count == 0) |
9505 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9506 | |
2986cac2 | 9507 | mode = "Disable"; |
9508 | ||
13909c4f DS |
9509 | } else if (peer->nsf_af_count == 0 |
9510 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9511 | |
2986cac2 | 9512 | mode = "Helper"; |
9513 | ||
13909c4f DS |
9514 | } else if (peer->nsf_af_count != 0 |
9515 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9516 | |
2986cac2 | 9517 | mode = "Restart"; |
2986cac2 | 9518 | } |
9519 | } | |
9520 | ||
9521 | if (use_json) { | |
13909c4f | 9522 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9523 | } else |
9524 | vty_out(vty, mode, "\n"); | |
9525 | } | |
9526 | ||
13909c4f DS |
9527 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9528 | struct peer *p, | |
9529 | bool use_json, | |
9530 | json_object *json) | |
2986cac2 | 9531 | { |
9532 | const char *mode = "Invalid"; | |
9533 | ||
9534 | if (!use_json) | |
a53ca37b | 9535 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9536 | |
9537 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9538 | mode = "Helper"; | |
9539 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9540 | mode = "Restart"; | |
9541 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9542 | mode = "Disable"; | |
2ba1fe69 | 9543 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9544 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9545 | mode = "Helper*"; | |
9546 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9547 | mode = "Restart*"; | |
9548 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9549 | mode = "Disable*"; | |
9550 | else | |
9551 | mode = "Invalid*"; | |
2ba1fe69 | 9552 | } |
2986cac2 | 9553 | |
9554 | if (use_json) { | |
13909c4f | 9555 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9556 | } else { |
9557 | vty_out(vty, mode, "\n"); | |
9558 | } | |
9559 | } | |
9560 | ||
13909c4f DS |
9561 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9562 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9563 | { |
2ba1fe69 | 9564 | afi_t afi; |
9565 | safi_t safi; | |
2986cac2 | 9566 | json_object *json_afi_safi = NULL; |
9567 | json_object *json_timer = NULL; | |
9568 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9569 | bool eor_flag = false; |
2986cac2 | 9570 | |
9571 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9572 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9573 | if (!peer->afc[afi][safi]) |
9574 | continue; | |
2986cac2 | 9575 | |
13909c4f DS |
9576 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9577 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9578 | continue; | |
9e3b51a7 | 9579 | |
13909c4f DS |
9580 | if (use_json) { |
9581 | json_afi_safi = json_object_new_object(); | |
9582 | json_endofrib_status = json_object_new_object(); | |
9583 | json_timer = json_object_new_object(); | |
9584 | } | |
2986cac2 | 9585 | |
13909c4f DS |
9586 | if (peer->eor_stime[afi][safi] |
9587 | >= peer->pkt_stime[afi][safi]) | |
9588 | eor_flag = true; | |
9589 | else | |
9590 | eor_flag = false; | |
2986cac2 | 9591 | |
13909c4f | 9592 | if (!use_json) { |
a53ca37b | 9593 | vty_out(vty, " %s:\n", |
13909c4f | 9594 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9595 | |
a53ca37b | 9596 | vty_out(vty, " F bit: "); |
698ba8d0 | 9597 | } |
2986cac2 | 9598 | |
13909c4f DS |
9599 | if (peer->nsf[afi][safi] |
9600 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9601 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9602 | |
13909c4f DS |
9603 | if (use_json) { |
9604 | json_object_boolean_true_add( | |
2986cac2 | 9605 | json_afi_safi, "fBit"); |
13909c4f DS |
9606 | } else |
9607 | vty_out(vty, "True\n"); | |
9608 | } else { | |
9609 | if (use_json) | |
9610 | json_object_boolean_false_add( | |
9611 | json_afi_safi, "fBit"); | |
9612 | else | |
9613 | vty_out(vty, "False\n"); | |
9614 | } | |
2986cac2 | 9615 | |
13909c4f | 9616 | if (!use_json) |
a53ca37b | 9617 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9618 | |
13909c4f DS |
9619 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9620 | PEER_STATUS_EOR_SEND)) { | |
9621 | if (use_json) { | |
9622 | json_object_boolean_true_add( | |
2986cac2 | 9623 | json_endofrib_status, |
13909c4f | 9624 | "endOfRibSend"); |
9e3b51a7 | 9625 | |
13909c4f DS |
9626 | PRINT_EOR_JSON(eor_flag); |
9627 | } else { | |
9628 | vty_out(vty, "Yes\n"); | |
9629 | vty_out(vty, | |
a53ca37b | 9630 | " End-of-RIB sent after update: "); |
2986cac2 | 9631 | |
13909c4f DS |
9632 | PRINT_EOR(eor_flag); |
9633 | } | |
9634 | } else { | |
9635 | if (use_json) { | |
9636 | json_object_boolean_false_add( | |
2986cac2 | 9637 | json_endofrib_status, |
13909c4f DS |
9638 | "endOfRibSend"); |
9639 | json_object_boolean_false_add( | |
9e3b51a7 | 9640 | json_endofrib_status, |
13909c4f DS |
9641 | "endOfRibSentAfterUpdate"); |
9642 | } else { | |
9643 | vty_out(vty, "No\n"); | |
9644 | vty_out(vty, | |
a53ca37b | 9645 | " End-of-RIB sent after update: "); |
13909c4f | 9646 | vty_out(vty, "No\n"); |
2986cac2 | 9647 | } |
13909c4f | 9648 | } |
2986cac2 | 9649 | |
a53ca37b DA |
9650 | if (!use_json) |
9651 | vty_out(vty, " End-of-RIB received: "); | |
9652 | ||
9653 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9654 | PEER_STATUS_EOR_RECEIVED)) { | |
9655 | if (use_json) | |
9656 | json_object_boolean_true_add( | |
9657 | json_endofrib_status, | |
9658 | "endOfRibRecv"); | |
9659 | else | |
9660 | vty_out(vty, "Yes\n"); | |
9661 | } else { | |
9662 | if (use_json) | |
9663 | json_object_boolean_false_add( | |
9664 | json_endofrib_status, | |
9665 | "endOfRibRecv"); | |
9666 | else | |
9667 | vty_out(vty, "No\n"); | |
9668 | } | |
9669 | ||
13909c4f DS |
9670 | if (use_json) { |
9671 | json_object_int_add(json_timer, | |
9672 | "stalePathTimer", | |
9673 | peer->bgp->stalepath_time); | |
2986cac2 | 9674 | |
13909c4f DS |
9675 | if (peer->t_gr_stale != NULL) { |
9676 | json_object_int_add( | |
2986cac2 | 9677 | json_timer, |
9678 | "stalePathTimerRemaining", | |
9679 | thread_timer_remain_second( | |
13909c4f DS |
9680 | peer->t_gr_stale)); |
9681 | } | |
3a75afa4 | 9682 | |
13909c4f DS |
9683 | /* Display Configured Selection |
9684 | * Deferral only when when | |
9685 | * Gr mode is enabled. | |
9686 | */ | |
9687 | if (CHECK_FLAG(peer->flags, | |
9688 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9689 | json_object_int_add( | |
3a75afa4 | 9690 | json_timer, |
2986cac2 | 9691 | "selectionDeferralTimer", |
9692 | peer->bgp->stalepath_time); | |
13909c4f | 9693 | } |
2986cac2 | 9694 | |
13909c4f DS |
9695 | if (peer->bgp->gr_info[afi][safi] |
9696 | .t_select_deferral | |
9697 | != NULL) { | |
2986cac2 | 9698 | |
13909c4f | 9699 | json_object_int_add( |
2986cac2 | 9700 | json_timer, |
9701 | "selectionDeferralTimerRemaining", | |
9702 | thread_timer_remain_second( | |
13909c4f DS |
9703 | peer->bgp |
9704 | ->gr_info[afi] | |
9705 | [safi] | |
9706 | .t_select_deferral)); | |
9707 | } | |
9708 | } else { | |
a53ca37b | 9709 | vty_out(vty, " Timers:\n"); |
13909c4f | 9710 | vty_out(vty, |
a53ca37b DA |
9711 | " Configured Stale Path Time(sec): %u\n", |
9712 | peer->bgp->stalepath_time); | |
2986cac2 | 9713 | |
a53ca37b | 9714 | if (peer->t_gr_stale != NULL) |
2986cac2 | 9715 | vty_out(vty, |
a53ca37b | 9716 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 9717 | thread_timer_remain_second( |
13909c4f | 9718 | peer->t_gr_stale)); |
13909c4f DS |
9719 | /* Display Configured Selection |
9720 | * Deferral only when when | |
9721 | * Gr mode is enabled. | |
9722 | */ | |
9723 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 9724 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 9725 | vty_out(vty, |
a53ca37b | 9726 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 9727 | peer->bgp->select_defer_time); |
2986cac2 | 9728 | |
13909c4f DS |
9729 | if (peer->bgp->gr_info[afi][safi] |
9730 | .t_select_deferral | |
a53ca37b | 9731 | != NULL) |
13909c4f | 9732 | vty_out(vty, |
a53ca37b | 9733 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 9734 | thread_timer_remain_second( |
13909c4f DS |
9735 | peer->bgp |
9736 | ->gr_info[afi] | |
9737 | [safi] | |
9738 | .t_select_deferral)); | |
2986cac2 | 9739 | } |
13909c4f DS |
9740 | if (use_json) { |
9741 | json_object_object_add(json_afi_safi, | |
9742 | "endOfRibStatus", | |
9743 | json_endofrib_status); | |
9744 | json_object_object_add(json_afi_safi, "timers", | |
9745 | json_timer); | |
9746 | json_object_object_add( | |
9747 | json, get_afi_safi_str(afi, safi, true), | |
9748 | json_afi_safi); | |
9749 | } | |
2986cac2 | 9750 | } |
9751 | } | |
9752 | } | |
9753 | ||
36235319 QY |
9754 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
9755 | struct peer *p, | |
9756 | bool use_json, | |
9757 | json_object *json) | |
2986cac2 | 9758 | { |
9759 | if (use_json) { | |
9760 | json_object *json_timer = NULL; | |
9761 | ||
9762 | json_timer = json_object_new_object(); | |
9763 | ||
13909c4f DS |
9764 | json_object_int_add(json_timer, "configuredRestartTimer", |
9765 | p->bgp->restart_time); | |
2986cac2 | 9766 | |
13909c4f DS |
9767 | json_object_int_add(json_timer, "receivedRestartTimer", |
9768 | p->v_gr_restart); | |
2986cac2 | 9769 | |
13909c4f DS |
9770 | if (p->t_gr_restart != NULL) |
9771 | json_object_int_add( | |
9772 | json_timer, "restartTimerRemaining", | |
9773 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 9774 | |
9775 | json_object_object_add(json, "timers", json_timer); | |
9776 | } else { | |
9777 | ||
a53ca37b DA |
9778 | vty_out(vty, " Timers:\n"); |
9779 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 9780 | p->bgp->restart_time); |
2986cac2 | 9781 | |
a53ca37b | 9782 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
9783 | p->v_gr_restart); |
9784 | if (p->t_gr_restart != NULL) | |
a53ca37b | 9785 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 9786 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 9787 | if (p->t_gr_restart != NULL) { |
a53ca37b | 9788 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
9789 | thread_timer_remain_second(p->t_gr_restart)); |
9790 | } | |
2986cac2 | 9791 | } |
9792 | } | |
9793 | ||
9794 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 9795 | bool use_json, json_object *json) |
2986cac2 | 9796 | { |
9797 | char buf[SU_ADDRSTRLEN] = {0}; | |
9798 | char dn_flag[2] = {0}; | |
9799 | char neighborAddr[INET6_ADDRSTRLEN] = {0}; | |
9800 | ||
2986cac2 | 9801 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
9802 | dn_flag[0] = '*'; | |
9803 | ||
9804 | if (p->conf_if) { | |
9805 | if (use_json) | |
13909c4f DS |
9806 | json_object_string_add( |
9807 | json, "neighborAddr", | |
2986cac2 | 9808 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
9809 | ? "none" |
9810 | : sockunion2str(&p->su, buf, | |
9811 | SU_ADDRSTRLEN)); | |
2986cac2 | 9812 | else |
13909c4f | 9813 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 9814 | BGP_PEER_SU_UNSPEC(p) |
9815 | ? "none" | |
9816 | : sockunion2str(&p->su, buf, | |
9817 | SU_ADDRSTRLEN)); | |
9818 | } else { | |
9819 | sprintf(neighborAddr, "%s%s", dn_flag, p->host); | |
9820 | ||
9821 | if (use_json) | |
36235319 QY |
9822 | json_object_string_add(json, "neighborAddr", |
9823 | neighborAddr); | |
2986cac2 | 9824 | else |
36235319 | 9825 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 9826 | } |
9827 | ||
9828 | /* more gr info in new format */ | |
9829 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9830 | } | |
9831 | ||
d62a17ae | 9832 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9833 | safi_t safi, bool use_json, |
d62a17ae | 9834 | json_object *json_neigh) |
9835 | { | |
0291c246 MK |
9836 | struct bgp_filter *filter; |
9837 | struct peer_af *paf; | |
9838 | char orf_pfx_name[BUFSIZ]; | |
9839 | int orf_pfx_count; | |
9840 | json_object *json_af = NULL; | |
9841 | json_object *json_prefA = NULL; | |
9842 | json_object *json_prefB = NULL; | |
9843 | json_object *json_addr = NULL; | |
d62a17ae | 9844 | |
9845 | if (use_json) { | |
9846 | json_addr = json_object_new_object(); | |
9847 | json_af = json_object_new_object(); | |
9848 | filter = &p->filter[afi][safi]; | |
9849 | ||
9850 | if (peer_group_active(p)) | |
9851 | json_object_string_add(json_addr, "peerGroupMember", | |
9852 | p->group->name); | |
9853 | ||
9854 | paf = peer_af_find(p, afi, safi); | |
9855 | if (paf && PAF_SUBGRP(paf)) { | |
9856 | json_object_int_add(json_addr, "updateGroupId", | |
9857 | PAF_UPDGRP(paf)->id); | |
9858 | json_object_int_add(json_addr, "subGroupId", | |
9859 | PAF_SUBGRP(paf)->id); | |
9860 | json_object_int_add(json_addr, "packetQueueLength", | |
9861 | bpacket_queue_virtual_length(paf)); | |
9862 | } | |
9863 | ||
9864 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9865 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9866 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9867 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9868 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9869 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9870 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9871 | json_object_int_add(json_af, "orfType", | |
9872 | ORF_TYPE_PREFIX); | |
9873 | json_prefA = json_object_new_object(); | |
9874 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
9875 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
9876 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9877 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9878 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
9879 | use_json, json_prefA); | |
9880 | json_object_object_add(json_af, "orfPrefixList", | |
9881 | json_prefA); | |
9882 | } | |
9883 | ||
9884 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9885 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9886 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9887 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9888 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9889 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9890 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9891 | json_object_int_add(json_af, "orfOldType", | |
9892 | ORF_TYPE_PREFIX_OLD); | |
9893 | json_prefB = json_object_new_object(); | |
9894 | bgp_show_peer_afi_orf_cap( | |
9895 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9896 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9897 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9898 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9899 | json_prefB); | |
9900 | json_object_object_add(json_af, "orfOldPrefixList", | |
9901 | json_prefB); | |
9902 | } | |
9903 | ||
9904 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9905 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9906 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9907 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9908 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9909 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9910 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9911 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9912 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9913 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9914 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9915 | json_object_object_add(json_addr, "afDependentCap", | |
9916 | json_af); | |
9917 | else | |
9918 | json_object_free(json_af); | |
9919 | ||
9920 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
9921 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
9922 | NULL, afi, orf_pfx_name, use_json); | |
9923 | ||
9924 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9925 | PEER_STATUS_ORF_PREFIX_SEND) | |
9926 | || orf_pfx_count) { | |
9927 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9928 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9929 | json_object_boolean_true_add(json_neigh, | |
9930 | "orfSent"); | |
9931 | if (orf_pfx_count) | |
9932 | json_object_int_add(json_addr, "orfRecvCounter", | |
9933 | orf_pfx_count); | |
9934 | } | |
9935 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9936 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9937 | json_object_string_add( | |
9938 | json_addr, "orfFirstUpdate", | |
9939 | "deferredUntilORFOrRouteRefreshRecvd"); | |
9940 | ||
9941 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9942 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9943 | json_object_boolean_true_add(json_addr, | |
9944 | "routeReflectorClient"); | |
9945 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9946 | PEER_FLAG_RSERVER_CLIENT)) | |
9947 | json_object_boolean_true_add(json_addr, | |
9948 | "routeServerClient"); | |
9949 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9950 | json_object_boolean_true_add(json_addr, | |
9951 | "inboundSoftConfigPermit"); | |
9952 | ||
9953 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9954 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9955 | json_object_boolean_true_add( | |
9956 | json_addr, | |
9957 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
9958 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9959 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9960 | json_object_boolean_true_add( | |
9961 | json_addr, | |
9962 | "privateAsNumsReplacedInUpdatesToNbr"); | |
9963 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9964 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9965 | json_object_boolean_true_add( | |
9966 | json_addr, | |
9967 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
9968 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9969 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9970 | json_object_boolean_true_add( | |
9971 | json_addr, | |
9972 | "privateAsNumsRemovedInUpdatesToNbr"); | |
9973 | ||
dcc68b5e MS |
9974 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9975 | json_object_boolean_true_add( | |
9976 | json_addr, | |
9977 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9978 | ->type_json_name); | |
d62a17ae | 9979 | |
9980 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9981 | json_object_string_add(json_addr, | |
9982 | "overrideASNsInOutboundUpdates", | |
9983 | "ifAspathEqualRemoteAs"); | |
9984 | ||
9985 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9986 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9987 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9988 | json_object_boolean_true_add(json_addr, | |
9989 | "routerAlwaysNextHop"); | |
9990 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9991 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9992 | json_object_boolean_true_add( | |
9993 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
9994 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9995 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9996 | json_object_boolean_true_add( | |
9997 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
9998 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9999 | json_object_boolean_true_add( | |
10000 | json_addr, "unchangedMedPropogatedToNbr"); | |
10001 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10002 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10003 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10004 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10005 | PEER_FLAG_SEND_COMMUNITY) | |
10006 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10007 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10008 | json_object_string_add(json_addr, | |
10009 | "commAttriSentToNbr", | |
10010 | "extendedAndStandard"); | |
10011 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10012 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10013 | json_object_string_add(json_addr, | |
10014 | "commAttriSentToNbr", | |
10015 | "extended"); | |
10016 | else | |
10017 | json_object_string_add(json_addr, | |
10018 | "commAttriSentToNbr", | |
10019 | "standard"); | |
10020 | } | |
10021 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10022 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10023 | if (p->default_rmap[afi][safi].name) | |
10024 | json_object_string_add( | |
10025 | json_addr, "defaultRouteMap", | |
10026 | p->default_rmap[afi][safi].name); | |
10027 | ||
10028 | if (paf && PAF_SUBGRP(paf) | |
10029 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10030 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10031 | json_object_boolean_true_add(json_addr, | |
10032 | "defaultSent"); | |
10033 | else | |
10034 | json_object_boolean_true_add(json_addr, | |
10035 | "defaultNotSent"); | |
10036 | } | |
10037 | ||
dff8f48d | 10038 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10039 | if (is_evpn_enabled()) |
60466a63 QY |
10040 | json_object_boolean_true_add( |
10041 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10042 | } |
10043 | ||
d62a17ae | 10044 | if (filter->plist[FILTER_IN].name |
10045 | || filter->dlist[FILTER_IN].name | |
10046 | || filter->aslist[FILTER_IN].name | |
10047 | || filter->map[RMAP_IN].name) | |
10048 | json_object_boolean_true_add(json_addr, | |
10049 | "inboundPathPolicyConfig"); | |
10050 | if (filter->plist[FILTER_OUT].name | |
10051 | || filter->dlist[FILTER_OUT].name | |
10052 | || filter->aslist[FILTER_OUT].name | |
10053 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10054 | json_object_boolean_true_add( | |
10055 | json_addr, "outboundPathPolicyConfig"); | |
10056 | ||
10057 | /* prefix-list */ | |
10058 | if (filter->plist[FILTER_IN].name) | |
10059 | json_object_string_add(json_addr, | |
10060 | "incomingUpdatePrefixFilterList", | |
10061 | filter->plist[FILTER_IN].name); | |
10062 | if (filter->plist[FILTER_OUT].name) | |
10063 | json_object_string_add(json_addr, | |
10064 | "outgoingUpdatePrefixFilterList", | |
10065 | filter->plist[FILTER_OUT].name); | |
10066 | ||
10067 | /* distribute-list */ | |
10068 | if (filter->dlist[FILTER_IN].name) | |
10069 | json_object_string_add( | |
10070 | json_addr, "incomingUpdateNetworkFilterList", | |
10071 | filter->dlist[FILTER_IN].name); | |
10072 | if (filter->dlist[FILTER_OUT].name) | |
10073 | json_object_string_add( | |
10074 | json_addr, "outgoingUpdateNetworkFilterList", | |
10075 | filter->dlist[FILTER_OUT].name); | |
10076 | ||
10077 | /* filter-list. */ | |
10078 | if (filter->aslist[FILTER_IN].name) | |
10079 | json_object_string_add(json_addr, | |
10080 | "incomingUpdateAsPathFilterList", | |
10081 | filter->aslist[FILTER_IN].name); | |
10082 | if (filter->aslist[FILTER_OUT].name) | |
10083 | json_object_string_add(json_addr, | |
10084 | "outgoingUpdateAsPathFilterList", | |
10085 | filter->aslist[FILTER_OUT].name); | |
10086 | ||
10087 | /* route-map. */ | |
10088 | if (filter->map[RMAP_IN].name) | |
10089 | json_object_string_add( | |
10090 | json_addr, "routeMapForIncomingAdvertisements", | |
10091 | filter->map[RMAP_IN].name); | |
10092 | if (filter->map[RMAP_OUT].name) | |
10093 | json_object_string_add( | |
10094 | json_addr, "routeMapForOutgoingAdvertisements", | |
10095 | filter->map[RMAP_OUT].name); | |
10096 | ||
9dac9fc8 DA |
10097 | /* ebgp-requires-policy (inbound) */ |
10098 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10099 | && !bgp_inbound_policy_exists(p, filter)) | |
10100 | json_object_string_add( | |
10101 | json_addr, "inboundEbgpRequiresPolicy", | |
10102 | "Inbound updates discarded due to missing policy"); | |
10103 | ||
10104 | /* ebgp-requires-policy (outbound) */ | |
10105 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10106 | && (!bgp_outbound_policy_exists(p, filter))) | |
10107 | json_object_string_add( | |
10108 | json_addr, "outboundEbgpRequiresPolicy", | |
10109 | "Outbound updates discarded due to missing policy"); | |
10110 | ||
d62a17ae | 10111 | /* unsuppress-map */ |
10112 | if (filter->usmap.name) | |
10113 | json_object_string_add(json_addr, | |
10114 | "selectiveUnsuppressRouteMap", | |
10115 | filter->usmap.name); | |
10116 | ||
10117 | /* Receive prefix count */ | |
10118 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10119 | p->pcount[afi][safi]); | |
50e05855 AD |
10120 | if (paf && PAF_SUBGRP(paf)) |
10121 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10122 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10123 | |
fde246e8 DA |
10124 | /* Maximum prefix */ |
10125 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10126 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10127 | p->pmax_out[afi][safi]); | |
10128 | ||
d62a17ae | 10129 | /* Maximum prefix */ |
10130 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10131 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10132 | p->pmax[afi][safi]); | |
10133 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10134 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10135 | json_object_boolean_true_add( | |
10136 | json_addr, "prefixAllowedMaxWarning"); | |
10137 | json_object_int_add(json_addr, | |
10138 | "prefixAllowedWarningThresh", | |
10139 | p->pmax_threshold[afi][safi]); | |
10140 | if (p->pmax_restart[afi][safi]) | |
10141 | json_object_int_add( | |
10142 | json_addr, | |
10143 | "prefixAllowedRestartIntervalMsecs", | |
10144 | p->pmax_restart[afi][safi] * 60000); | |
10145 | } | |
2986cac2 | 10146 | json_object_object_add(json_neigh, |
36235319 | 10147 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10148 | json_addr); |
10149 | ||
10150 | } else { | |
10151 | filter = &p->filter[afi][safi]; | |
10152 | ||
10153 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10154 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10155 | |
10156 | if (peer_group_active(p)) | |
10157 | vty_out(vty, " %s peer-group member\n", | |
10158 | p->group->name); | |
10159 | ||
10160 | paf = peer_af_find(p, afi, safi); | |
10161 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10162 | vty_out(vty, " Update group %" PRIu64 |
10163 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10164 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10165 | vty_out(vty, " Packet Queue length %d\n", | |
10166 | bpacket_queue_virtual_length(paf)); | |
10167 | } else { | |
10168 | vty_out(vty, " Not part of any update group\n"); | |
10169 | } | |
10170 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10171 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10172 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10173 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10174 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10175 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10176 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10177 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10178 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10179 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10180 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10181 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10182 | ||
10183 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10184 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10185 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10186 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10187 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10188 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10189 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10190 | vty_out(vty, | |
10191 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10192 | ORF_TYPE_PREFIX); | |
10193 | bgp_show_peer_afi_orf_cap( | |
10194 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10195 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10196 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10197 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10198 | } | |
10199 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10200 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10201 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10202 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10203 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10204 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10205 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10206 | vty_out(vty, | |
10207 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10208 | ORF_TYPE_PREFIX_OLD); | |
10209 | bgp_show_peer_afi_orf_cap( | |
10210 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10211 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10212 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10213 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10214 | } | |
10215 | ||
10216 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
10217 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
10218 | NULL, afi, orf_pfx_name, use_json); | |
10219 | ||
10220 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10221 | PEER_STATUS_ORF_PREFIX_SEND) | |
10222 | || orf_pfx_count) { | |
10223 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10224 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10225 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10226 | vty_out(vty, " sent;"); | |
10227 | if (orf_pfx_count) | |
10228 | vty_out(vty, " received (%d entries)", | |
10229 | orf_pfx_count); | |
10230 | vty_out(vty, "\n"); | |
10231 | } | |
10232 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10233 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10234 | vty_out(vty, | |
10235 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10236 | ||
10237 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10238 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10239 | vty_out(vty, " Route-Reflector Client\n"); | |
10240 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10241 | PEER_FLAG_RSERVER_CLIENT)) | |
10242 | vty_out(vty, " Route-Server Client\n"); | |
10243 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10244 | vty_out(vty, | |
10245 | " Inbound soft reconfiguration allowed\n"); | |
10246 | ||
10247 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10248 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10249 | vty_out(vty, | |
10250 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10251 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10252 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10253 | vty_out(vty, | |
10254 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10255 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10256 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10257 | vty_out(vty, | |
10258 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10259 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10260 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10261 | vty_out(vty, | |
10262 | " Private AS numbers removed in updates to this neighbor\n"); | |
10263 | ||
dcc68b5e MS |
10264 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10265 | vty_out(vty, " %s\n", | |
10266 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10267 | ->human_description); | |
d62a17ae | 10268 | |
10269 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10270 | vty_out(vty, | |
10271 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10272 | ||
10273 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10274 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10275 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10276 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10277 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10278 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10279 | vty_out(vty, | |
10280 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10281 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10282 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10283 | vty_out(vty, | |
10284 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10285 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10286 | vty_out(vty, | |
10287 | " MED is propagated unchanged to this neighbor\n"); | |
10288 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10289 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10290 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10291 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10292 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10293 | vty_out(vty, | |
10294 | " Community attribute sent to this neighbor"); | |
10295 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10296 | PEER_FLAG_SEND_COMMUNITY) | |
10297 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10298 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10299 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10300 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10301 | vty_out(vty, "(all)\n"); | |
10302 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10303 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10304 | vty_out(vty, "(large)\n"); | |
10305 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10306 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10307 | vty_out(vty, "(extended)\n"); | |
10308 | else | |
10309 | vty_out(vty, "(standard)\n"); | |
10310 | } | |
10311 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10312 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10313 | vty_out(vty, " Default information originate,"); | |
10314 | ||
10315 | if (p->default_rmap[afi][safi].name) | |
10316 | vty_out(vty, " default route-map %s%s,", | |
10317 | p->default_rmap[afi][safi].map ? "*" | |
10318 | : "", | |
10319 | p->default_rmap[afi][safi].name); | |
10320 | if (paf && PAF_SUBGRP(paf) | |
10321 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10322 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10323 | vty_out(vty, " default sent\n"); | |
10324 | else | |
10325 | vty_out(vty, " default not sent\n"); | |
10326 | } | |
10327 | ||
dff8f48d MK |
10328 | /* advertise-vni-all */ |
10329 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10330 | if (is_evpn_enabled()) |
dff8f48d MK |
10331 | vty_out(vty, " advertise-all-vni\n"); |
10332 | } | |
10333 | ||
d62a17ae | 10334 | if (filter->plist[FILTER_IN].name |
10335 | || filter->dlist[FILTER_IN].name | |
10336 | || filter->aslist[FILTER_IN].name | |
10337 | || filter->map[RMAP_IN].name) | |
10338 | vty_out(vty, " Inbound path policy configured\n"); | |
10339 | if (filter->plist[FILTER_OUT].name | |
10340 | || filter->dlist[FILTER_OUT].name | |
10341 | || filter->aslist[FILTER_OUT].name | |
10342 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10343 | vty_out(vty, " Outbound path policy configured\n"); | |
10344 | ||
10345 | /* prefix-list */ | |
10346 | if (filter->plist[FILTER_IN].name) | |
10347 | vty_out(vty, | |
10348 | " Incoming update prefix filter list is %s%s\n", | |
10349 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10350 | filter->plist[FILTER_IN].name); | |
10351 | if (filter->plist[FILTER_OUT].name) | |
10352 | vty_out(vty, | |
10353 | " Outgoing update prefix filter list is %s%s\n", | |
10354 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10355 | filter->plist[FILTER_OUT].name); | |
10356 | ||
10357 | /* distribute-list */ | |
10358 | if (filter->dlist[FILTER_IN].name) | |
10359 | vty_out(vty, | |
10360 | " Incoming update network filter list is %s%s\n", | |
10361 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10362 | filter->dlist[FILTER_IN].name); | |
10363 | if (filter->dlist[FILTER_OUT].name) | |
10364 | vty_out(vty, | |
10365 | " Outgoing update network filter list is %s%s\n", | |
10366 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10367 | filter->dlist[FILTER_OUT].name); | |
10368 | ||
10369 | /* filter-list. */ | |
10370 | if (filter->aslist[FILTER_IN].name) | |
10371 | vty_out(vty, | |
10372 | " Incoming update AS path filter list is %s%s\n", | |
10373 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10374 | filter->aslist[FILTER_IN].name); | |
10375 | if (filter->aslist[FILTER_OUT].name) | |
10376 | vty_out(vty, | |
10377 | " Outgoing update AS path filter list is %s%s\n", | |
10378 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10379 | filter->aslist[FILTER_OUT].name); | |
10380 | ||
10381 | /* route-map. */ | |
10382 | if (filter->map[RMAP_IN].name) | |
10383 | vty_out(vty, | |
10384 | " Route map for incoming advertisements is %s%s\n", | |
10385 | filter->map[RMAP_IN].map ? "*" : "", | |
10386 | filter->map[RMAP_IN].name); | |
10387 | if (filter->map[RMAP_OUT].name) | |
10388 | vty_out(vty, | |
10389 | " Route map for outgoing advertisements is %s%s\n", | |
10390 | filter->map[RMAP_OUT].map ? "*" : "", | |
10391 | filter->map[RMAP_OUT].name); | |
10392 | ||
9dac9fc8 DA |
10393 | /* ebgp-requires-policy (inbound) */ |
10394 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10395 | && !bgp_inbound_policy_exists(p, filter)) | |
10396 | vty_out(vty, | |
10397 | " Inbound updates discarded due to missing policy\n"); | |
10398 | ||
10399 | /* ebgp-requires-policy (outbound) */ | |
10400 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
10401 | && !bgp_outbound_policy_exists(p, filter)) | |
10402 | vty_out(vty, | |
10403 | " Outbound updates discarded due to missing policy\n"); | |
10404 | ||
d62a17ae | 10405 | /* unsuppress-map */ |
10406 | if (filter->usmap.name) | |
10407 | vty_out(vty, | |
10408 | " Route map for selective unsuppress is %s%s\n", | |
10409 | filter->usmap.map ? "*" : "", | |
10410 | filter->usmap.name); | |
10411 | ||
10412 | /* Receive prefix count */ | |
a0a87037 DA |
10413 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10414 | p->pcount[afi][safi]); | |
d62a17ae | 10415 | |
fde246e8 DA |
10416 | /* maximum-prefix-out */ |
10417 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10418 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10419 | vty_out(vty, | |
10420 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10421 | p->pmax_out[afi][safi]); | |
10422 | ||
d62a17ae | 10423 | /* Maximum prefix */ |
10424 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10425 | vty_out(vty, |
10426 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10427 | p->pmax[afi][safi], |
10428 | CHECK_FLAG(p->af_flags[afi][safi], | |
10429 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10430 | ? " (warning-only)" | |
10431 | : ""); | |
10432 | vty_out(vty, " Threshold for warning message %d%%", | |
10433 | p->pmax_threshold[afi][safi]); | |
10434 | if (p->pmax_restart[afi][safi]) | |
10435 | vty_out(vty, ", restart interval %d min", | |
10436 | p->pmax_restart[afi][safi]); | |
10437 | vty_out(vty, "\n"); | |
10438 | } | |
10439 | ||
10440 | vty_out(vty, "\n"); | |
10441 | } | |
10442 | } | |
10443 | ||
9f049418 | 10444 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10445 | json_object *json) |
718e3744 | 10446 | { |
d62a17ae | 10447 | struct bgp *bgp; |
10448 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10449 | char timebuf[BGP_UPTIME_LEN]; | |
10450 | char dn_flag[2]; | |
d62a17ae | 10451 | afi_t afi; |
10452 | safi_t safi; | |
d7c0a89a QY |
10453 | uint16_t i; |
10454 | uint8_t *msg; | |
d62a17ae | 10455 | json_object *json_neigh = NULL; |
10456 | time_t epoch_tbuf; | |
718e3744 | 10457 | |
d62a17ae | 10458 | bgp = p->bgp; |
10459 | ||
10460 | if (use_json) | |
10461 | json_neigh = json_object_new_object(); | |
10462 | ||
10463 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10464 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10465 | dn_flag[0] = '*'; | |
10466 | ||
10467 | if (!use_json) { | |
10468 | if (p->conf_if) /* Configured interface name. */ | |
10469 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10470 | BGP_PEER_SU_UNSPEC(p) | |
10471 | ? "None" | |
10472 | : sockunion2str(&p->su, buf, | |
10473 | SU_ADDRSTRLEN)); | |
10474 | else /* Configured IP address. */ | |
10475 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10476 | p->host); | |
10477 | } | |
10478 | ||
10479 | if (use_json) { | |
10480 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10481 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10482 | "none"); | |
10483 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10484 | json_object_string_add( | |
10485 | json_neigh, "bgpNeighborAddr", | |
10486 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10487 | ||
10488 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10489 | ||
10490 | if (p->change_local_as) | |
10491 | json_object_int_add(json_neigh, "localAs", | |
10492 | p->change_local_as); | |
10493 | else | |
10494 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10495 | ||
10496 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10497 | json_object_boolean_true_add(json_neigh, | |
10498 | "localAsNoPrepend"); | |
10499 | ||
10500 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10501 | json_object_boolean_true_add(json_neigh, | |
10502 | "localAsReplaceAs"); | |
10503 | } else { | |
10504 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10505 | || (p->as_type == AS_INTERNAL)) | |
10506 | vty_out(vty, "remote AS %u, ", p->as); | |
10507 | else | |
10508 | vty_out(vty, "remote AS Unspecified, "); | |
10509 | vty_out(vty, "local AS %u%s%s, ", | |
10510 | p->change_local_as ? p->change_local_as : p->local_as, | |
10511 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10512 | ? " no-prepend" | |
10513 | : "", | |
10514 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10515 | ? " replace-as" | |
10516 | : ""); | |
10517 | } | |
faa16034 DS |
10518 | /* peer type internal or confed-internal */ |
10519 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10520 | if (use_json) { |
10521 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10522 | json_object_boolean_true_add( | |
10523 | json_neigh, "nbrConfedInternalLink"); | |
10524 | else | |
10525 | json_object_boolean_true_add(json_neigh, | |
10526 | "nbrInternalLink"); | |
10527 | } else { | |
10528 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10529 | vty_out(vty, "confed-internal link\n"); | |
10530 | else | |
10531 | vty_out(vty, "internal link\n"); | |
10532 | } | |
faa16034 DS |
10533 | /* peer type external or confed-external */ |
10534 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10535 | if (use_json) { |
10536 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10537 | json_object_boolean_true_add( | |
10538 | json_neigh, "nbrConfedExternalLink"); | |
10539 | else | |
10540 | json_object_boolean_true_add(json_neigh, | |
10541 | "nbrExternalLink"); | |
10542 | } else { | |
10543 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10544 | vty_out(vty, "confed-external link\n"); | |
10545 | else | |
10546 | vty_out(vty, "external link\n"); | |
10547 | } | |
faa16034 DS |
10548 | } else { |
10549 | if (use_json) | |
10550 | json_object_boolean_true_add(json_neigh, | |
10551 | "nbrUnspecifiedLink"); | |
10552 | else | |
10553 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10554 | } |
10555 | ||
10556 | /* Description. */ | |
10557 | if (p->desc) { | |
10558 | if (use_json) | |
10559 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10560 | else | |
10561 | vty_out(vty, " Description: %s\n", p->desc); | |
10562 | } | |
10563 | ||
10564 | if (p->hostname) { | |
10565 | if (use_json) { | |
10566 | if (p->hostname) | |
10567 | json_object_string_add(json_neigh, "hostname", | |
10568 | p->hostname); | |
10569 | ||
10570 | if (p->domainname) | |
10571 | json_object_string_add(json_neigh, "domainname", | |
10572 | p->domainname); | |
10573 | } else { | |
10574 | if (p->domainname && (p->domainname[0] != '\0')) | |
10575 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10576 | p->domainname); | |
10577 | else | |
10578 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10579 | } | |
10580 | } | |
10581 | ||
10582 | /* Peer-group */ | |
10583 | if (p->group) { | |
10584 | if (use_json) { | |
10585 | json_object_string_add(json_neigh, "peerGroup", | |
10586 | p->group->name); | |
10587 | ||
10588 | if (dn_flag[0]) { | |
10589 | struct prefix prefix, *range = NULL; | |
10590 | ||
10591 | sockunion2hostprefix(&(p->su), &prefix); | |
10592 | range = peer_group_lookup_dynamic_neighbor_range( | |
10593 | p->group, &prefix); | |
10594 | ||
10595 | if (range) { | |
10596 | prefix2str(range, buf1, sizeof(buf1)); | |
10597 | json_object_string_add( | |
10598 | json_neigh, | |
10599 | "peerSubnetRangeGroup", buf1); | |
10600 | } | |
10601 | } | |
10602 | } else { | |
10603 | vty_out(vty, | |
10604 | " Member of peer-group %s for session parameters\n", | |
10605 | p->group->name); | |
10606 | ||
10607 | if (dn_flag[0]) { | |
10608 | struct prefix prefix, *range = NULL; | |
10609 | ||
10610 | sockunion2hostprefix(&(p->su), &prefix); | |
10611 | range = peer_group_lookup_dynamic_neighbor_range( | |
10612 | p->group, &prefix); | |
10613 | ||
10614 | if (range) { | |
10615 | prefix2str(range, buf1, sizeof(buf1)); | |
10616 | vty_out(vty, | |
10617 | " Belongs to the subnet range group: %s\n", | |
10618 | buf1); | |
10619 | } | |
10620 | } | |
10621 | } | |
10622 | } | |
10623 | ||
10624 | if (use_json) { | |
10625 | /* Administrative shutdown. */ | |
10626 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10627 | json_object_boolean_true_add(json_neigh, | |
10628 | "adminShutDown"); | |
10629 | ||
10630 | /* BGP Version. */ | |
10631 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10632 | json_object_string_add( | |
10633 | json_neigh, "remoteRouterId", | |
10634 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10635 | json_object_string_add( |
10636 | json_neigh, "localRouterId", | |
10637 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10638 | sizeof(buf1))); | |
d62a17ae | 10639 | |
10640 | /* Confederation */ | |
10641 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10642 | && bgp_confederation_peers_check(bgp, p->as)) | |
10643 | json_object_boolean_true_add(json_neigh, | |
10644 | "nbrCommonAdmin"); | |
10645 | ||
10646 | /* Status. */ | |
10647 | json_object_string_add( | |
10648 | json_neigh, "bgpState", | |
10649 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10650 | ||
10651 | if (p->status == Established) { | |
10652 | time_t uptime; | |
d62a17ae | 10653 | |
10654 | uptime = bgp_clock(); | |
10655 | uptime -= p->uptime; | |
d62a17ae | 10656 | epoch_tbuf = time(NULL) - uptime; |
10657 | ||
d3c7efed DS |
10658 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10659 | uptime * 1000); | |
d62a17ae | 10660 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10661 | peer_uptime(p->uptime, timebuf, | |
10662 | BGP_UPTIME_LEN, 0, | |
10663 | NULL)); | |
10664 | json_object_int_add(json_neigh, | |
10665 | "bgpTimerUpEstablishedEpoch", | |
10666 | epoch_tbuf); | |
10667 | } | |
10668 | ||
10669 | else if (p->status == Active) { | |
10670 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10671 | json_object_string_add(json_neigh, "bgpStateIs", | |
10672 | "passive"); | |
10673 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10674 | json_object_string_add(json_neigh, "bgpStateIs", | |
10675 | "passiveNSF"); | |
10676 | } | |
10677 | ||
10678 | /* read timer */ | |
10679 | time_t uptime; | |
a2700b50 | 10680 | struct tm tm; |
d62a17ae | 10681 | |
10682 | uptime = bgp_clock(); | |
10683 | uptime -= p->readtime; | |
a2700b50 MS |
10684 | gmtime_r(&uptime, &tm); |
10685 | ||
d62a17ae | 10686 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
10687 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10688 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10689 | |
10690 | uptime = bgp_clock(); | |
10691 | uptime -= p->last_write; | |
a2700b50 MS |
10692 | gmtime_r(&uptime, &tm); |
10693 | ||
d62a17ae | 10694 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
10695 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10696 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10697 | |
10698 | uptime = bgp_clock(); | |
10699 | uptime -= p->update_time; | |
a2700b50 MS |
10700 | gmtime_r(&uptime, &tm); |
10701 | ||
d62a17ae | 10702 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
10703 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10704 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10705 | |
10706 | /* Configured timer values. */ | |
10707 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10708 | p->v_holdtime * 1000); | |
10709 | json_object_int_add(json_neigh, | |
10710 | "bgpTimerKeepAliveIntervalMsecs", | |
10711 | p->v_keepalive * 1000); | |
b90a8e13 | 10712 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10713 | json_object_int_add(json_neigh, |
10714 | "bgpTimerConfiguredHoldTimeMsecs", | |
10715 | p->holdtime * 1000); | |
10716 | json_object_int_add( | |
10717 | json_neigh, | |
10718 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10719 | p->keepalive * 1000); | |
5d5393b9 DL |
10720 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10721 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10722 | json_object_int_add(json_neigh, |
10723 | "bgpTimerConfiguredHoldTimeMsecs", | |
10724 | bgp->default_holdtime); | |
10725 | json_object_int_add( | |
10726 | json_neigh, | |
10727 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10728 | bgp->default_keepalive); | |
d62a17ae | 10729 | } |
10730 | } else { | |
10731 | /* Administrative shutdown. */ | |
10732 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10733 | vty_out(vty, " Administratively shut down\n"); | |
10734 | ||
10735 | /* BGP Version. */ | |
10736 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10737 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10738 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10739 | vty_out(vty, ", local router ID %s\n", |
10740 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10741 | sizeof(buf1))); | |
d62a17ae | 10742 | |
10743 | /* Confederation */ | |
10744 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10745 | && bgp_confederation_peers_check(bgp, p->as)) | |
10746 | vty_out(vty, | |
10747 | " Neighbor under common administration\n"); | |
10748 | ||
10749 | /* Status. */ | |
10750 | vty_out(vty, " BGP state = %s", | |
10751 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10752 | ||
10753 | if (p->status == Established) | |
10754 | vty_out(vty, ", up for %8s", | |
10755 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10756 | 0, NULL)); | |
10757 | ||
10758 | else if (p->status == Active) { | |
10759 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10760 | vty_out(vty, " (passive)"); | |
10761 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10762 | vty_out(vty, " (NSF passive)"); | |
10763 | } | |
10764 | vty_out(vty, "\n"); | |
10765 | ||
10766 | /* read timer */ | |
10767 | vty_out(vty, " Last read %s", | |
10768 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10769 | NULL)); | |
10770 | vty_out(vty, ", Last write %s\n", | |
10771 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10772 | NULL)); | |
10773 | ||
10774 | /* Configured timer values. */ | |
10775 | vty_out(vty, | |
10776 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10777 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10778 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10779 | vty_out(vty, " Configured hold time is %d", |
10780 | p->holdtime); | |
10781 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10782 | p->keepalive); | |
5d5393b9 DL |
10783 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10784 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10785 | vty_out(vty, " Configured hold time is %d", |
10786 | bgp->default_holdtime); | |
10787 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10788 | bgp->default_keepalive); | |
d62a17ae | 10789 | } |
10790 | } | |
10791 | /* Capability. */ | |
10792 | if (p->status == Established) { | |
10793 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10794 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10795 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10796 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10797 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10798 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10799 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10800 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10801 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10802 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10803 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10804 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10805 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10806 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10807 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10808 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10809 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10810 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10811 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10812 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10813 | if (use_json) { | |
10814 | json_object *json_cap = NULL; | |
10815 | ||
10816 | json_cap = json_object_new_object(); | |
10817 | ||
10818 | /* AS4 */ | |
10819 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10820 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10821 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10822 | && CHECK_FLAG(p->cap, | |
10823 | PEER_CAP_AS4_RCV)) | |
10824 | json_object_string_add( | |
10825 | json_cap, "4byteAs", | |
10826 | "advertisedAndReceived"); | |
10827 | else if (CHECK_FLAG(p->cap, | |
10828 | PEER_CAP_AS4_ADV)) | |
10829 | json_object_string_add( | |
10830 | json_cap, "4byteAs", | |
10831 | "advertised"); | |
10832 | else if (CHECK_FLAG(p->cap, | |
10833 | PEER_CAP_AS4_RCV)) | |
10834 | json_object_string_add( | |
10835 | json_cap, "4byteAs", | |
10836 | "received"); | |
10837 | } | |
10838 | ||
10839 | /* AddPath */ | |
10840 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10841 | || CHECK_FLAG(p->cap, | |
10842 | PEER_CAP_ADDPATH_ADV)) { | |
10843 | json_object *json_add = NULL; | |
10844 | const char *print_store; | |
10845 | ||
10846 | json_add = json_object_new_object(); | |
10847 | ||
05c7a1cc QY |
10848 | FOREACH_AFI_SAFI (afi, safi) { |
10849 | json_object *json_sub = NULL; | |
10850 | json_sub = | |
10851 | json_object_new_object(); | |
5cb5f4d0 DD |
10852 | print_store = get_afi_safi_str( |
10853 | afi, safi, true); | |
d62a17ae | 10854 | |
05c7a1cc QY |
10855 | if (CHECK_FLAG( |
10856 | p->af_cap[afi] | |
10857 | [safi], | |
10858 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10859 | || CHECK_FLAG( | |
10860 | p->af_cap[afi] | |
10861 | [safi], | |
10862 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10863 | if (CHECK_FLAG( |
10864 | p->af_cap | |
10865 | [afi] | |
10866 | [safi], | |
10867 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10868 | && CHECK_FLAG( |
d62a17ae | 10869 | p->af_cap |
10870 | [afi] | |
10871 | [safi], | |
05c7a1cc QY |
10872 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
10873 | json_object_boolean_true_add( | |
10874 | json_sub, | |
10875 | "txAdvertisedAndReceived"); | |
10876 | else if ( | |
10877 | CHECK_FLAG( | |
10878 | p->af_cap | |
10879 | [afi] | |
10880 | [safi], | |
10881 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
10882 | json_object_boolean_true_add( | |
10883 | json_sub, | |
10884 | "txAdvertised"); | |
10885 | else if ( | |
10886 | CHECK_FLAG( | |
10887 | p->af_cap | |
10888 | [afi] | |
10889 | [safi], | |
10890 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10891 | json_object_boolean_true_add( | |
10892 | json_sub, | |
10893 | "txReceived"); | |
10894 | } | |
d62a17ae | 10895 | |
05c7a1cc QY |
10896 | if (CHECK_FLAG( |
10897 | p->af_cap[afi] | |
10898 | [safi], | |
10899 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10900 | || CHECK_FLAG( | |
10901 | p->af_cap[afi] | |
10902 | [safi], | |
10903 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10904 | if (CHECK_FLAG( |
10905 | p->af_cap | |
10906 | [afi] | |
10907 | [safi], | |
10908 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10909 | && CHECK_FLAG( |
d62a17ae | 10910 | p->af_cap |
10911 | [afi] | |
10912 | [safi], | |
10913 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10914 | json_object_boolean_true_add( |
10915 | json_sub, | |
10916 | "rxAdvertisedAndReceived"); | |
10917 | else if ( | |
10918 | CHECK_FLAG( | |
10919 | p->af_cap | |
10920 | [afi] | |
10921 | [safi], | |
10922 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10923 | json_object_boolean_true_add( | |
10924 | json_sub, | |
10925 | "rxAdvertised"); | |
10926 | else if ( | |
10927 | CHECK_FLAG( | |
10928 | p->af_cap | |
10929 | [afi] | |
10930 | [safi], | |
10931 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10932 | json_object_boolean_true_add( | |
10933 | json_sub, | |
10934 | "rxReceived"); | |
d62a17ae | 10935 | } |
10936 | ||
05c7a1cc QY |
10937 | if (CHECK_FLAG( |
10938 | p->af_cap[afi] | |
10939 | [safi], | |
10940 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10941 | || CHECK_FLAG( | |
10942 | p->af_cap[afi] | |
10943 | [safi], | |
10944 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
10945 | || CHECK_FLAG( | |
10946 | p->af_cap[afi] | |
10947 | [safi], | |
10948 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10949 | || CHECK_FLAG( | |
10950 | p->af_cap[afi] | |
10951 | [safi], | |
10952 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
10953 | json_object_object_add( | |
10954 | json_add, | |
10955 | print_store, | |
10956 | json_sub); | |
10957 | else | |
10958 | json_object_free( | |
10959 | json_sub); | |
10960 | } | |
10961 | ||
d62a17ae | 10962 | json_object_object_add( |
10963 | json_cap, "addPath", json_add); | |
10964 | } | |
10965 | ||
10966 | /* Dynamic */ | |
10967 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10968 | || CHECK_FLAG(p->cap, | |
10969 | PEER_CAP_DYNAMIC_ADV)) { | |
10970 | if (CHECK_FLAG(p->cap, | |
10971 | PEER_CAP_DYNAMIC_ADV) | |
10972 | && CHECK_FLAG(p->cap, | |
10973 | PEER_CAP_DYNAMIC_RCV)) | |
10974 | json_object_string_add( | |
10975 | json_cap, "dynamic", | |
10976 | "advertisedAndReceived"); | |
10977 | else if (CHECK_FLAG( | |
10978 | p->cap, | |
10979 | PEER_CAP_DYNAMIC_ADV)) | |
10980 | json_object_string_add( | |
10981 | json_cap, "dynamic", | |
10982 | "advertised"); | |
10983 | else if (CHECK_FLAG( | |
10984 | p->cap, | |
10985 | PEER_CAP_DYNAMIC_RCV)) | |
10986 | json_object_string_add( | |
10987 | json_cap, "dynamic", | |
10988 | "received"); | |
10989 | } | |
10990 | ||
10991 | /* Extended nexthop */ | |
10992 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10993 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10994 | json_object *json_nxt = NULL; | |
10995 | const char *print_store; | |
10996 | ||
10997 | ||
10998 | if (CHECK_FLAG(p->cap, | |
10999 | PEER_CAP_ENHE_ADV) | |
11000 | && CHECK_FLAG(p->cap, | |
11001 | PEER_CAP_ENHE_RCV)) | |
11002 | json_object_string_add( | |
11003 | json_cap, | |
11004 | "extendedNexthop", | |
11005 | "advertisedAndReceived"); | |
11006 | else if (CHECK_FLAG(p->cap, | |
11007 | PEER_CAP_ENHE_ADV)) | |
11008 | json_object_string_add( | |
11009 | json_cap, | |
11010 | "extendedNexthop", | |
11011 | "advertised"); | |
11012 | else if (CHECK_FLAG(p->cap, | |
11013 | PEER_CAP_ENHE_RCV)) | |
11014 | json_object_string_add( | |
11015 | json_cap, | |
11016 | "extendedNexthop", | |
11017 | "received"); | |
11018 | ||
11019 | if (CHECK_FLAG(p->cap, | |
11020 | PEER_CAP_ENHE_RCV)) { | |
11021 | json_nxt = | |
11022 | json_object_new_object(); | |
11023 | ||
11024 | for (safi = SAFI_UNICAST; | |
11025 | safi < SAFI_MAX; safi++) { | |
11026 | if (CHECK_FLAG( | |
11027 | p->af_cap | |
11028 | [AFI_IP] | |
11029 | [safi], | |
11030 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11031 | print_store = get_afi_safi_str( |
d62a17ae | 11032 | AFI_IP, |
5cb5f4d0 | 11033 | safi, true); |
d62a17ae | 11034 | json_object_string_add( |
11035 | json_nxt, | |
11036 | print_store, | |
54f29523 | 11037 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11038 | } |
11039 | } | |
11040 | json_object_object_add( | |
11041 | json_cap, | |
11042 | "extendedNexthopFamililesByPeer", | |
11043 | json_nxt); | |
11044 | } | |
11045 | } | |
11046 | ||
11047 | /* Route Refresh */ | |
11048 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11049 | || CHECK_FLAG(p->cap, | |
11050 | PEER_CAP_REFRESH_NEW_RCV) | |
11051 | || CHECK_FLAG(p->cap, | |
11052 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11053 | if (CHECK_FLAG(p->cap, | |
11054 | PEER_CAP_REFRESH_ADV) | |
11055 | && (CHECK_FLAG( | |
11056 | p->cap, | |
11057 | PEER_CAP_REFRESH_NEW_RCV) | |
11058 | || CHECK_FLAG( | |
11059 | p->cap, | |
11060 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11061 | if (CHECK_FLAG( | |
11062 | p->cap, | |
11063 | PEER_CAP_REFRESH_OLD_RCV) | |
11064 | && CHECK_FLAG( | |
11065 | p->cap, | |
11066 | PEER_CAP_REFRESH_NEW_RCV)) | |
11067 | json_object_string_add( | |
11068 | json_cap, | |
11069 | "routeRefresh", | |
11070 | "advertisedAndReceivedOldNew"); | |
11071 | else { | |
11072 | if (CHECK_FLAG( | |
11073 | p->cap, | |
11074 | PEER_CAP_REFRESH_OLD_RCV)) | |
11075 | json_object_string_add( | |
11076 | json_cap, | |
11077 | "routeRefresh", | |
11078 | "advertisedAndReceivedOld"); | |
11079 | else | |
11080 | json_object_string_add( | |
11081 | json_cap, | |
11082 | "routeRefresh", | |
11083 | "advertisedAndReceivedNew"); | |
11084 | } | |
11085 | } else if ( | |
11086 | CHECK_FLAG( | |
11087 | p->cap, | |
11088 | PEER_CAP_REFRESH_ADV)) | |
11089 | json_object_string_add( | |
11090 | json_cap, | |
11091 | "routeRefresh", | |
11092 | "advertised"); | |
11093 | else if ( | |
11094 | CHECK_FLAG( | |
11095 | p->cap, | |
11096 | PEER_CAP_REFRESH_NEW_RCV) | |
11097 | || CHECK_FLAG( | |
11098 | p->cap, | |
11099 | PEER_CAP_REFRESH_OLD_RCV)) | |
11100 | json_object_string_add( | |
11101 | json_cap, | |
11102 | "routeRefresh", | |
11103 | "received"); | |
11104 | } | |
11105 | ||
11106 | /* Multiprotocol Extensions */ | |
11107 | json_object *json_multi = NULL; | |
11108 | json_multi = json_object_new_object(); | |
11109 | ||
05c7a1cc QY |
11110 | FOREACH_AFI_SAFI (afi, safi) { |
11111 | if (p->afc_adv[afi][safi] | |
11112 | || p->afc_recv[afi][safi]) { | |
11113 | json_object *json_exten = NULL; | |
11114 | json_exten = | |
11115 | json_object_new_object(); | |
11116 | ||
d62a17ae | 11117 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11118 | && p->afc_recv[afi][safi]) |
11119 | json_object_boolean_true_add( | |
11120 | json_exten, | |
11121 | "advertisedAndReceived"); | |
11122 | else if (p->afc_adv[afi][safi]) | |
11123 | json_object_boolean_true_add( | |
11124 | json_exten, | |
11125 | "advertised"); | |
11126 | else if (p->afc_recv[afi][safi]) | |
11127 | json_object_boolean_true_add( | |
11128 | json_exten, | |
11129 | "received"); | |
d62a17ae | 11130 | |
05c7a1cc QY |
11131 | json_object_object_add( |
11132 | json_multi, | |
5cb5f4d0 DD |
11133 | get_afi_safi_str(afi, |
11134 | safi, | |
11135 | true), | |
05c7a1cc | 11136 | json_exten); |
d62a17ae | 11137 | } |
11138 | } | |
11139 | json_object_object_add( | |
11140 | json_cap, "multiprotocolExtensions", | |
11141 | json_multi); | |
11142 | ||
d77114b7 | 11143 | /* Hostname capabilities */ |
60466a63 | 11144 | json_object *json_hname = NULL; |
d77114b7 MK |
11145 | |
11146 | json_hname = json_object_new_object(); | |
11147 | ||
11148 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11149 | json_object_string_add( | |
60466a63 QY |
11150 | json_hname, "advHostName", |
11151 | bgp->peer_self->hostname | |
11152 | ? bgp->peer_self | |
11153 | ->hostname | |
d77114b7 MK |
11154 | : "n/a"); |
11155 | json_object_string_add( | |
60466a63 QY |
11156 | json_hname, "advDomainName", |
11157 | bgp->peer_self->domainname | |
11158 | ? bgp->peer_self | |
11159 | ->domainname | |
d77114b7 MK |
11160 | : "n/a"); |
11161 | } | |
11162 | ||
11163 | ||
11164 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11165 | json_object_string_add( | |
60466a63 QY |
11166 | json_hname, "rcvHostName", |
11167 | p->hostname ? p->hostname | |
11168 | : "n/a"); | |
d77114b7 | 11169 | json_object_string_add( |
60466a63 QY |
11170 | json_hname, "rcvDomainName", |
11171 | p->domainname ? p->domainname | |
11172 | : "n/a"); | |
d77114b7 MK |
11173 | } |
11174 | ||
60466a63 | 11175 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11176 | json_hname); |
11177 | ||
d62a17ae | 11178 | /* Gracefull Restart */ |
11179 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11180 | || CHECK_FLAG(p->cap, | |
11181 | PEER_CAP_RESTART_ADV)) { | |
11182 | if (CHECK_FLAG(p->cap, | |
11183 | PEER_CAP_RESTART_ADV) | |
11184 | && CHECK_FLAG(p->cap, | |
11185 | PEER_CAP_RESTART_RCV)) | |
11186 | json_object_string_add( | |
11187 | json_cap, | |
11188 | "gracefulRestart", | |
11189 | "advertisedAndReceived"); | |
11190 | else if (CHECK_FLAG( | |
11191 | p->cap, | |
11192 | PEER_CAP_RESTART_ADV)) | |
11193 | json_object_string_add( | |
11194 | json_cap, | |
11195 | "gracefulRestartCapability", | |
11196 | "advertised"); | |
11197 | else if (CHECK_FLAG( | |
11198 | p->cap, | |
11199 | PEER_CAP_RESTART_RCV)) | |
11200 | json_object_string_add( | |
11201 | json_cap, | |
11202 | "gracefulRestartCapability", | |
11203 | "received"); | |
11204 | ||
11205 | if (CHECK_FLAG(p->cap, | |
11206 | PEER_CAP_RESTART_RCV)) { | |
11207 | int restart_af_count = 0; | |
11208 | json_object *json_restart = | |
11209 | NULL; | |
11210 | json_restart = | |
11211 | json_object_new_object(); | |
11212 | ||
11213 | json_object_int_add( | |
11214 | json_cap, | |
11215 | "gracefulRestartRemoteTimerMsecs", | |
11216 | p->v_gr_restart * 1000); | |
11217 | ||
05c7a1cc QY |
11218 | FOREACH_AFI_SAFI (afi, safi) { |
11219 | if (CHECK_FLAG( | |
11220 | p->af_cap | |
11221 | [afi] | |
11222 | [safi], | |
11223 | PEER_CAP_RESTART_AF_RCV)) { | |
11224 | json_object * | |
11225 | json_sub = | |
11226 | NULL; | |
11227 | json_sub = | |
11228 | json_object_new_object(); | |
11229 | ||
d62a17ae | 11230 | if (CHECK_FLAG( |
11231 | p->af_cap | |
11232 | [afi] | |
11233 | [safi], | |
05c7a1cc QY |
11234 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11235 | json_object_boolean_true_add( | |
11236 | json_sub, | |
11237 | "preserved"); | |
11238 | restart_af_count++; | |
11239 | json_object_object_add( | |
11240 | json_restart, | |
5cb5f4d0 | 11241 | get_afi_safi_str( |
05c7a1cc | 11242 | afi, |
5cb5f4d0 DD |
11243 | safi, |
11244 | true), | |
05c7a1cc | 11245 | json_sub); |
d62a17ae | 11246 | } |
11247 | } | |
11248 | if (!restart_af_count) { | |
11249 | json_object_string_add( | |
11250 | json_cap, | |
11251 | "addressFamiliesByPeer", | |
11252 | "none"); | |
11253 | json_object_free( | |
11254 | json_restart); | |
11255 | } else | |
11256 | json_object_object_add( | |
11257 | json_cap, | |
11258 | "addressFamiliesByPeer", | |
11259 | json_restart); | |
11260 | } | |
11261 | } | |
11262 | json_object_object_add(json_neigh, | |
11263 | "neighborCapabilities", | |
11264 | json_cap); | |
11265 | } else { | |
11266 | vty_out(vty, " Neighbor capabilities:\n"); | |
11267 | ||
11268 | /* AS4 */ | |
11269 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11270 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11271 | vty_out(vty, " 4 Byte AS:"); | |
11272 | if (CHECK_FLAG(p->cap, | |
11273 | PEER_CAP_AS4_ADV)) | |
11274 | vty_out(vty, " advertised"); | |
11275 | if (CHECK_FLAG(p->cap, | |
11276 | PEER_CAP_AS4_RCV)) | |
11277 | vty_out(vty, " %sreceived", | |
11278 | CHECK_FLAG( | |
11279 | p->cap, | |
11280 | PEER_CAP_AS4_ADV) | |
11281 | ? "and " | |
11282 | : ""); | |
11283 | vty_out(vty, "\n"); | |
11284 | } | |
11285 | ||
11286 | /* AddPath */ | |
11287 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11288 | || CHECK_FLAG(p->cap, | |
11289 | PEER_CAP_ADDPATH_ADV)) { | |
11290 | vty_out(vty, " AddPath:\n"); | |
11291 | ||
05c7a1cc QY |
11292 | FOREACH_AFI_SAFI (afi, safi) { |
11293 | if (CHECK_FLAG( | |
11294 | p->af_cap[afi] | |
11295 | [safi], | |
11296 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11297 | || CHECK_FLAG( | |
11298 | p->af_cap[afi] | |
11299 | [safi], | |
11300 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11301 | vty_out(vty, | |
11302 | " %s: TX ", | |
5cb5f4d0 | 11303 | get_afi_safi_str( |
05c7a1cc | 11304 | afi, |
5cb5f4d0 DD |
11305 | safi, |
11306 | false)); | |
05c7a1cc | 11307 | |
d62a17ae | 11308 | if (CHECK_FLAG( |
11309 | p->af_cap | |
11310 | [afi] | |
11311 | [safi], | |
05c7a1cc | 11312 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11313 | vty_out(vty, |
05c7a1cc | 11314 | "advertised %s", |
5cb5f4d0 | 11315 | get_afi_safi_str( |
d62a17ae | 11316 | afi, |
5cb5f4d0 DD |
11317 | safi, |
11318 | false)); | |
d62a17ae | 11319 | |
05c7a1cc QY |
11320 | if (CHECK_FLAG( |
11321 | p->af_cap | |
11322 | [afi] | |
11323 | [safi], | |
11324 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11325 | vty_out(vty, | |
11326 | "%sreceived", | |
11327 | CHECK_FLAG( | |
11328 | p->af_cap | |
11329 | [afi] | |
11330 | [safi], | |
11331 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11332 | ? " and " | |
11333 | : ""); | |
d62a17ae | 11334 | |
05c7a1cc QY |
11335 | vty_out(vty, "\n"); |
11336 | } | |
d62a17ae | 11337 | |
05c7a1cc QY |
11338 | if (CHECK_FLAG( |
11339 | p->af_cap[afi] | |
11340 | [safi], | |
11341 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11342 | || CHECK_FLAG( | |
11343 | p->af_cap[afi] | |
11344 | [safi], | |
11345 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11346 | vty_out(vty, | |
11347 | " %s: RX ", | |
5cb5f4d0 | 11348 | get_afi_safi_str( |
05c7a1cc | 11349 | afi, |
5cb5f4d0 DD |
11350 | safi, |
11351 | false)); | |
d62a17ae | 11352 | |
11353 | if (CHECK_FLAG( | |
11354 | p->af_cap | |
11355 | [afi] | |
11356 | [safi], | |
05c7a1cc | 11357 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11358 | vty_out(vty, |
05c7a1cc | 11359 | "advertised %s", |
5cb5f4d0 | 11360 | get_afi_safi_str( |
d62a17ae | 11361 | afi, |
5cb5f4d0 DD |
11362 | safi, |
11363 | false)); | |
d62a17ae | 11364 | |
05c7a1cc QY |
11365 | if (CHECK_FLAG( |
11366 | p->af_cap | |
11367 | [afi] | |
11368 | [safi], | |
11369 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11370 | vty_out(vty, |
05c7a1cc QY |
11371 | "%sreceived", |
11372 | CHECK_FLAG( | |
11373 | p->af_cap | |
11374 | [afi] | |
11375 | [safi], | |
11376 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11377 | ? " and " | |
11378 | : ""); | |
11379 | ||
11380 | vty_out(vty, "\n"); | |
d62a17ae | 11381 | } |
05c7a1cc | 11382 | } |
d62a17ae | 11383 | } |
11384 | ||
11385 | /* Dynamic */ | |
11386 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11387 | || CHECK_FLAG(p->cap, | |
11388 | PEER_CAP_DYNAMIC_ADV)) { | |
11389 | vty_out(vty, " Dynamic:"); | |
11390 | if (CHECK_FLAG(p->cap, | |
11391 | PEER_CAP_DYNAMIC_ADV)) | |
11392 | vty_out(vty, " advertised"); | |
11393 | if (CHECK_FLAG(p->cap, | |
11394 | PEER_CAP_DYNAMIC_RCV)) | |
11395 | vty_out(vty, " %sreceived", | |
11396 | CHECK_FLAG( | |
11397 | p->cap, | |
11398 | PEER_CAP_DYNAMIC_ADV) | |
11399 | ? "and " | |
11400 | : ""); | |
11401 | vty_out(vty, "\n"); | |
11402 | } | |
11403 | ||
11404 | /* Extended nexthop */ | |
11405 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11406 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11407 | vty_out(vty, " Extended nexthop:"); | |
11408 | if (CHECK_FLAG(p->cap, | |
11409 | PEER_CAP_ENHE_ADV)) | |
11410 | vty_out(vty, " advertised"); | |
11411 | if (CHECK_FLAG(p->cap, | |
11412 | PEER_CAP_ENHE_RCV)) | |
11413 | vty_out(vty, " %sreceived", | |
11414 | CHECK_FLAG( | |
11415 | p->cap, | |
11416 | PEER_CAP_ENHE_ADV) | |
11417 | ? "and " | |
11418 | : ""); | |
11419 | vty_out(vty, "\n"); | |
11420 | ||
11421 | if (CHECK_FLAG(p->cap, | |
11422 | PEER_CAP_ENHE_RCV)) { | |
11423 | vty_out(vty, | |
11424 | " Address families by peer:\n "); | |
11425 | for (safi = SAFI_UNICAST; | |
11426 | safi < SAFI_MAX; safi++) | |
11427 | if (CHECK_FLAG( | |
11428 | p->af_cap | |
11429 | [AFI_IP] | |
11430 | [safi], | |
11431 | PEER_CAP_ENHE_AF_RCV)) | |
11432 | vty_out(vty, | |
11433 | " %s\n", | |
5cb5f4d0 | 11434 | get_afi_safi_str( |
d62a17ae | 11435 | AFI_IP, |
5cb5f4d0 DD |
11436 | safi, |
11437 | false)); | |
d62a17ae | 11438 | } |
11439 | } | |
11440 | ||
11441 | /* Route Refresh */ | |
11442 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11443 | || CHECK_FLAG(p->cap, | |
11444 | PEER_CAP_REFRESH_NEW_RCV) | |
11445 | || CHECK_FLAG(p->cap, | |
11446 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11447 | vty_out(vty, " Route refresh:"); | |
11448 | if (CHECK_FLAG(p->cap, | |
11449 | PEER_CAP_REFRESH_ADV)) | |
11450 | vty_out(vty, " advertised"); | |
11451 | if (CHECK_FLAG(p->cap, | |
11452 | PEER_CAP_REFRESH_NEW_RCV) | |
11453 | || CHECK_FLAG( | |
11454 | p->cap, | |
11455 | PEER_CAP_REFRESH_OLD_RCV)) | |
11456 | vty_out(vty, " %sreceived(%s)", | |
11457 | CHECK_FLAG( | |
11458 | p->cap, | |
11459 | PEER_CAP_REFRESH_ADV) | |
11460 | ? "and " | |
11461 | : "", | |
11462 | (CHECK_FLAG( | |
11463 | p->cap, | |
11464 | PEER_CAP_REFRESH_OLD_RCV) | |
11465 | && CHECK_FLAG( | |
11466 | p->cap, | |
11467 | PEER_CAP_REFRESH_NEW_RCV)) | |
11468 | ? "old & new" | |
11469 | : CHECK_FLAG( | |
11470 | p->cap, | |
11471 | PEER_CAP_REFRESH_OLD_RCV) | |
11472 | ? "old" | |
11473 | : "new"); | |
11474 | ||
11475 | vty_out(vty, "\n"); | |
11476 | } | |
11477 | ||
11478 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11479 | FOREACH_AFI_SAFI (afi, safi) |
11480 | if (p->afc_adv[afi][safi] | |
11481 | || p->afc_recv[afi][safi]) { | |
11482 | vty_out(vty, | |
11483 | " Address Family %s:", | |
5cb5f4d0 DD |
11484 | get_afi_safi_str( |
11485 | afi, | |
11486 | safi, | |
11487 | false)); | |
05c7a1cc | 11488 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11489 | vty_out(vty, |
05c7a1cc QY |
11490 | " advertised"); |
11491 | if (p->afc_recv[afi][safi]) | |
11492 | vty_out(vty, | |
11493 | " %sreceived", | |
11494 | p->afc_adv[afi] | |
11495 | [safi] | |
11496 | ? "and " | |
11497 | : ""); | |
11498 | vty_out(vty, "\n"); | |
11499 | } | |
d62a17ae | 11500 | |
11501 | /* Hostname capability */ | |
60466a63 | 11502 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11503 | |
11504 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11505 | vty_out(vty, |
11506 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11507 | bgp->peer_self->hostname |
11508 | ? bgp->peer_self | |
11509 | ->hostname | |
d77114b7 | 11510 | : "n/a", |
60466a63 QY |
11511 | bgp->peer_self->domainname |
11512 | ? bgp->peer_self | |
11513 | ->domainname | |
d77114b7 MK |
11514 | : "n/a"); |
11515 | } else { | |
11516 | vty_out(vty, " not advertised"); | |
d62a17ae | 11517 | } |
11518 | ||
d77114b7 | 11519 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11520 | vty_out(vty, |
11521 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11522 | p->hostname ? p->hostname |
11523 | : "n/a", | |
11524 | p->domainname ? p->domainname | |
11525 | : "n/a"); | |
d77114b7 MK |
11526 | } else { |
11527 | vty_out(vty, " not received"); | |
11528 | } | |
11529 | ||
11530 | vty_out(vty, "\n"); | |
11531 | ||
61bfbd51 | 11532 | /* Graceful Restart */ |
d62a17ae | 11533 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11534 | || CHECK_FLAG(p->cap, | |
11535 | PEER_CAP_RESTART_ADV)) { | |
11536 | vty_out(vty, | |
61bfbd51 | 11537 | " Graceful Restart Capability:"); |
d62a17ae | 11538 | if (CHECK_FLAG(p->cap, |
11539 | PEER_CAP_RESTART_ADV)) | |
11540 | vty_out(vty, " advertised"); | |
11541 | if (CHECK_FLAG(p->cap, | |
11542 | PEER_CAP_RESTART_RCV)) | |
11543 | vty_out(vty, " %sreceived", | |
11544 | CHECK_FLAG( | |
11545 | p->cap, | |
11546 | PEER_CAP_RESTART_ADV) | |
11547 | ? "and " | |
11548 | : ""); | |
11549 | vty_out(vty, "\n"); | |
11550 | ||
11551 | if (CHECK_FLAG(p->cap, | |
11552 | PEER_CAP_RESTART_RCV)) { | |
11553 | int restart_af_count = 0; | |
11554 | ||
11555 | vty_out(vty, | |
11556 | " Remote Restart timer is %d seconds\n", | |
11557 | p->v_gr_restart); | |
11558 | vty_out(vty, | |
11559 | " Address families by peer:\n "); | |
11560 | ||
05c7a1cc QY |
11561 | FOREACH_AFI_SAFI (afi, safi) |
11562 | if (CHECK_FLAG( | |
11563 | p->af_cap | |
11564 | [afi] | |
11565 | [safi], | |
11566 | PEER_CAP_RESTART_AF_RCV)) { | |
11567 | vty_out(vty, | |
11568 | "%s%s(%s)", | |
11569 | restart_af_count | |
11570 | ? ", " | |
11571 | : "", | |
5cb5f4d0 | 11572 | get_afi_safi_str( |
05c7a1cc | 11573 | afi, |
5cb5f4d0 DD |
11574 | safi, |
11575 | false), | |
05c7a1cc QY |
11576 | CHECK_FLAG( |
11577 | p->af_cap | |
11578 | [afi] | |
11579 | [safi], | |
11580 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11581 | ? "preserved" | |
11582 | : "not preserved"); | |
11583 | restart_af_count++; | |
11584 | } | |
d62a17ae | 11585 | if (!restart_af_count) |
11586 | vty_out(vty, "none"); | |
11587 | vty_out(vty, "\n"); | |
11588 | } | |
2986cac2 | 11589 | } /* Gracefull Restart */ |
d62a17ae | 11590 | } |
11591 | } | |
11592 | } | |
11593 | ||
11594 | /* graceful restart information */ | |
d62a17ae | 11595 | json_object *json_grace = NULL; |
11596 | json_object *json_grace_send = NULL; | |
11597 | json_object *json_grace_recv = NULL; | |
11598 | int eor_send_af_count = 0; | |
11599 | int eor_receive_af_count = 0; | |
11600 | ||
11601 | if (use_json) { | |
11602 | json_grace = json_object_new_object(); | |
11603 | json_grace_send = json_object_new_object(); | |
11604 | json_grace_recv = json_object_new_object(); | |
11605 | ||
36235319 QY |
11606 | if ((p->status == Established) |
11607 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11608 | FOREACH_AFI_SAFI (afi, safi) { |
11609 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11610 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11611 | json_object_boolean_true_add( |
11612 | json_grace_send, | |
5cb5f4d0 DD |
11613 | get_afi_safi_str(afi, |
11614 | safi, | |
11615 | true)); | |
05c7a1cc | 11616 | eor_send_af_count++; |
d62a17ae | 11617 | } |
11618 | } | |
05c7a1cc QY |
11619 | FOREACH_AFI_SAFI (afi, safi) { |
11620 | if (CHECK_FLAG( | |
36235319 QY |
11621 | p->af_sflags[afi][safi], |
11622 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11623 | json_object_boolean_true_add( |
11624 | json_grace_recv, | |
5cb5f4d0 DD |
11625 | get_afi_safi_str(afi, |
11626 | safi, | |
11627 | true)); | |
05c7a1cc | 11628 | eor_receive_af_count++; |
d62a17ae | 11629 | } |
11630 | } | |
11631 | } | |
36235319 QY |
11632 | json_object_object_add(json_grace, "endOfRibSend", |
11633 | json_grace_send); | |
11634 | json_object_object_add(json_grace, "endOfRibRecv", | |
11635 | json_grace_recv); | |
d62a17ae | 11636 | |
d62a17ae | 11637 | |
11638 | if (p->t_gr_restart) | |
11639 | json_object_int_add(json_grace, | |
11640 | "gracefulRestartTimerMsecs", | |
11641 | thread_timer_remain_second( | |
11642 | p->t_gr_restart) | |
11643 | * 1000); | |
11644 | ||
11645 | if (p->t_gr_stale) | |
11646 | json_object_int_add( | |
11647 | json_grace, | |
11648 | "gracefulStalepathTimerMsecs", | |
11649 | thread_timer_remain_second( | |
11650 | p->t_gr_stale) | |
11651 | * 1000); | |
2986cac2 | 11652 | /* more gr info in new format */ |
11653 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11654 | json_grace); |
d62a17ae | 11655 | json_object_object_add( |
11656 | json_neigh, "gracefulRestartInfo", json_grace); | |
11657 | } else { | |
2089dd80 | 11658 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
11659 | if ((p->status == Established) |
11660 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11661 | |
d62a17ae | 11662 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11663 | FOREACH_AFI_SAFI (afi, safi) { |
11664 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11665 | PEER_STATUS_EOR_SEND)) { | |
11666 | vty_out(vty, "%s%s", | |
11667 | eor_send_af_count ? ", " | |
11668 | : "", | |
36235319 QY |
11669 | get_afi_safi_str( |
11670 | afi, safi, | |
11671 | false)); | |
05c7a1cc | 11672 | eor_send_af_count++; |
d62a17ae | 11673 | } |
11674 | } | |
11675 | vty_out(vty, "\n"); | |
11676 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11677 | FOREACH_AFI_SAFI (afi, safi) { |
11678 | if (CHECK_FLAG( | |
11679 | p->af_sflags[afi][safi], | |
11680 | PEER_STATUS_EOR_RECEIVED)) { | |
11681 | vty_out(vty, "%s%s", | |
11682 | eor_receive_af_count | |
11683 | ? ", " | |
11684 | : "", | |
5cb5f4d0 DD |
11685 | get_afi_safi_str(afi, |
11686 | safi, | |
11687 | false)); | |
05c7a1cc | 11688 | eor_receive_af_count++; |
d62a17ae | 11689 | } |
11690 | } | |
11691 | vty_out(vty, "\n"); | |
11692 | } | |
11693 | ||
11694 | if (p->t_gr_restart) | |
11695 | vty_out(vty, | |
11696 | " The remaining time of restart timer is %ld\n", | |
11697 | thread_timer_remain_second( | |
11698 | p->t_gr_restart)); | |
11699 | ||
11700 | if (p->t_gr_stale) | |
11701 | vty_out(vty, | |
11702 | " The remaining time of stalepath timer is %ld\n", | |
11703 | thread_timer_remain_second( | |
11704 | p->t_gr_stale)); | |
2986cac2 | 11705 | |
11706 | /* more gr info in new format */ | |
11707 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11708 | } |
2986cac2 | 11709 | |
d62a17ae | 11710 | if (use_json) { |
11711 | json_object *json_stat = NULL; | |
11712 | json_stat = json_object_new_object(); | |
11713 | /* Packet counts. */ | |
11714 | json_object_int_add(json_stat, "depthInq", 0); | |
11715 | json_object_int_add(json_stat, "depthOutq", | |
11716 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
11717 | json_object_int_add(json_stat, "opensSent", |
11718 | atomic_load_explicit(&p->open_out, | |
11719 | memory_order_relaxed)); | |
11720 | json_object_int_add(json_stat, "opensRecv", | |
11721 | atomic_load_explicit(&p->open_in, | |
11722 | memory_order_relaxed)); | |
d62a17ae | 11723 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11724 | atomic_load_explicit(&p->notify_out, |
11725 | memory_order_relaxed)); | |
d62a17ae | 11726 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11727 | atomic_load_explicit(&p->notify_in, |
11728 | memory_order_relaxed)); | |
11729 | json_object_int_add(json_stat, "updatesSent", | |
11730 | atomic_load_explicit(&p->update_out, | |
11731 | memory_order_relaxed)); | |
11732 | json_object_int_add(json_stat, "updatesRecv", | |
11733 | atomic_load_explicit(&p->update_in, | |
11734 | memory_order_relaxed)); | |
d62a17ae | 11735 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11736 | atomic_load_explicit(&p->keepalive_out, |
11737 | memory_order_relaxed)); | |
d62a17ae | 11738 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11739 | atomic_load_explicit(&p->keepalive_in, |
11740 | memory_order_relaxed)); | |
d62a17ae | 11741 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11742 | atomic_load_explicit(&p->refresh_out, |
11743 | memory_order_relaxed)); | |
d62a17ae | 11744 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11745 | atomic_load_explicit(&p->refresh_in, |
11746 | memory_order_relaxed)); | |
d62a17ae | 11747 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11748 | atomic_load_explicit(&p->dynamic_cap_out, |
11749 | memory_order_relaxed)); | |
d62a17ae | 11750 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11751 | atomic_load_explicit(&p->dynamic_cap_in, |
11752 | memory_order_relaxed)); | |
11753 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11754 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11755 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11756 | } else { | |
11757 | /* Packet counts. */ | |
11758 | vty_out(vty, " Message statistics:\n"); | |
11759 | vty_out(vty, " Inq depth is 0\n"); | |
11760 | vty_out(vty, " Outq depth is %lu\n", | |
11761 | (unsigned long)p->obuf->count); | |
11762 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
11763 | vty_out(vty, " Opens: %10d %10d\n", |
11764 | atomic_load_explicit(&p->open_out, | |
11765 | memory_order_relaxed), | |
11766 | atomic_load_explicit(&p->open_in, | |
11767 | memory_order_relaxed)); | |
11768 | vty_out(vty, " Notifications: %10d %10d\n", | |
11769 | atomic_load_explicit(&p->notify_out, | |
11770 | memory_order_relaxed), | |
11771 | atomic_load_explicit(&p->notify_in, | |
11772 | memory_order_relaxed)); | |
11773 | vty_out(vty, " Updates: %10d %10d\n", | |
11774 | atomic_load_explicit(&p->update_out, | |
11775 | memory_order_relaxed), | |
11776 | atomic_load_explicit(&p->update_in, | |
11777 | memory_order_relaxed)); | |
11778 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11779 | atomic_load_explicit(&p->keepalive_out, | |
11780 | memory_order_relaxed), | |
11781 | atomic_load_explicit(&p->keepalive_in, | |
11782 | memory_order_relaxed)); | |
11783 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11784 | atomic_load_explicit(&p->refresh_out, | |
11785 | memory_order_relaxed), | |
11786 | atomic_load_explicit(&p->refresh_in, | |
11787 | memory_order_relaxed)); | |
d62a17ae | 11788 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11789 | atomic_load_explicit(&p->dynamic_cap_out, |
11790 | memory_order_relaxed), | |
11791 | atomic_load_explicit(&p->dynamic_cap_in, | |
11792 | memory_order_relaxed)); | |
11793 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11794 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11795 | } |
11796 | ||
11797 | if (use_json) { | |
11798 | /* advertisement-interval */ | |
11799 | json_object_int_add(json_neigh, | |
11800 | "minBtwnAdvertisementRunsTimerMsecs", | |
11801 | p->v_routeadv * 1000); | |
11802 | ||
11803 | /* Update-source. */ | |
11804 | if (p->update_if || p->update_source) { | |
11805 | if (p->update_if) | |
11806 | json_object_string_add(json_neigh, | |
11807 | "updateSource", | |
11808 | p->update_if); | |
11809 | else if (p->update_source) | |
11810 | json_object_string_add( | |
11811 | json_neigh, "updateSource", | |
11812 | sockunion2str(p->update_source, buf1, | |
11813 | SU_ADDRSTRLEN)); | |
11814 | } | |
11815 | } else { | |
11816 | /* advertisement-interval */ | |
11817 | vty_out(vty, | |
11818 | " Minimum time between advertisement runs is %d seconds\n", | |
11819 | p->v_routeadv); | |
11820 | ||
11821 | /* Update-source. */ | |
11822 | if (p->update_if || p->update_source) { | |
11823 | vty_out(vty, " Update source is "); | |
11824 | if (p->update_if) | |
11825 | vty_out(vty, "%s", p->update_if); | |
11826 | else if (p->update_source) | |
11827 | vty_out(vty, "%s", | |
11828 | sockunion2str(p->update_source, buf1, | |
11829 | SU_ADDRSTRLEN)); | |
11830 | vty_out(vty, "\n"); | |
11831 | } | |
11832 | ||
11833 | vty_out(vty, "\n"); | |
11834 | } | |
11835 | ||
11836 | /* Address Family Information */ | |
11837 | json_object *json_hold = NULL; | |
11838 | ||
11839 | if (use_json) | |
11840 | json_hold = json_object_new_object(); | |
11841 | ||
05c7a1cc QY |
11842 | FOREACH_AFI_SAFI (afi, safi) |
11843 | if (p->afc[afi][safi]) | |
11844 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11845 | json_hold); | |
d62a17ae | 11846 | |
11847 | if (use_json) { | |
11848 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11849 | json_hold); | |
11850 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11851 | p->established); | |
11852 | json_object_int_add(json_neigh, "connectionsDropped", | |
11853 | p->dropped); | |
11854 | } else | |
11855 | vty_out(vty, " Connections established %d; dropped %d\n", | |
11856 | p->established, p->dropped); | |
11857 | ||
11858 | if (!p->last_reset) { | |
11859 | if (use_json) | |
11860 | json_object_string_add(json_neigh, "lastReset", | |
11861 | "never"); | |
11862 | else | |
11863 | vty_out(vty, " Last reset never\n"); | |
11864 | } else { | |
11865 | if (use_json) { | |
11866 | time_t uptime; | |
a2700b50 | 11867 | struct tm tm; |
d62a17ae | 11868 | |
11869 | uptime = bgp_clock(); | |
11870 | uptime -= p->resettime; | |
a2700b50 MS |
11871 | gmtime_r(&uptime, &tm); |
11872 | ||
d62a17ae | 11873 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
11874 | (tm.tm_sec * 1000) |
11875 | + (tm.tm_min * 60000) | |
11876 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 11877 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 11878 | } else { |
11879 | vty_out(vty, " Last reset %s, ", | |
11880 | peer_uptime(p->resettime, timebuf, | |
11881 | BGP_UPTIME_LEN, 0, NULL)); | |
11882 | ||
3577f1c5 | 11883 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 11884 | if (p->last_reset_cause_size) { |
11885 | msg = p->last_reset_cause; | |
11886 | vty_out(vty, | |
11887 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
11888 | for (i = 1; i <= p->last_reset_cause_size; | |
11889 | i++) { | |
11890 | vty_out(vty, "%02X", *msg++); | |
11891 | ||
11892 | if (i != p->last_reset_cause_size) { | |
11893 | if (i % 16 == 0) { | |
11894 | vty_out(vty, "\n "); | |
11895 | } else if (i % 4 == 0) { | |
11896 | vty_out(vty, " "); | |
11897 | } | |
11898 | } | |
11899 | } | |
11900 | vty_out(vty, "\n"); | |
11901 | } | |
11902 | } | |
11903 | } | |
11904 | ||
11905 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11906 | if (use_json) | |
11907 | json_object_boolean_true_add(json_neigh, | |
11908 | "prefixesConfigExceedMax"); | |
11909 | else | |
11910 | vty_out(vty, | |
11911 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11912 | ||
11913 | if (p->t_pmax_restart) { | |
11914 | if (use_json) { | |
11915 | json_object_boolean_true_add( | |
11916 | json_neigh, "reducePrefixNumFrom"); | |
11917 | json_object_int_add(json_neigh, | |
11918 | "restartInTimerMsec", | |
11919 | thread_timer_remain_second( | |
11920 | p->t_pmax_restart) | |
11921 | * 1000); | |
11922 | } else | |
11923 | vty_out(vty, | |
11924 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
11925 | p->host, thread_timer_remain_second( |
11926 | p->t_pmax_restart)); | |
d62a17ae | 11927 | } else { |
11928 | if (use_json) | |
11929 | json_object_boolean_true_add( | |
11930 | json_neigh, | |
11931 | "reducePrefixNumAndClearIpBgp"); | |
11932 | else | |
11933 | vty_out(vty, | |
11934 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
11935 | p->host); | |
11936 | } | |
11937 | } | |
11938 | ||
11939 | /* EBGP Multihop and GTSM */ | |
11940 | if (p->sort != BGP_PEER_IBGP) { | |
11941 | if (use_json) { | |
e2521429 | 11942 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 11943 | json_object_int_add(json_neigh, |
11944 | "externalBgpNbrMaxHopsAway", | |
11945 | p->gtsm_hops); | |
c8d6f0d6 | 11946 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11947 | json_object_int_add(json_neigh, |
11948 | "externalBgpNbrMaxHopsAway", | |
11949 | p->ttl); | |
11950 | } else { | |
e2521429 | 11951 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 11952 | vty_out(vty, |
11953 | " External BGP neighbor may be up to %d hops away.\n", | |
11954 | p->gtsm_hops); | |
c8d6f0d6 | 11955 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 11956 | vty_out(vty, |
11957 | " External BGP neighbor may be up to %d hops away.\n", | |
11958 | p->ttl); | |
11959 | } | |
11960 | } else { | |
e2521429 | 11961 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 11962 | if (use_json) |
11963 | json_object_int_add(json_neigh, | |
11964 | "internalBgpNbrMaxHopsAway", | |
11965 | p->gtsm_hops); | |
11966 | else | |
11967 | vty_out(vty, | |
11968 | " Internal BGP neighbor may be up to %d hops away.\n", | |
11969 | p->gtsm_hops); | |
11970 | } | |
11971 | } | |
11972 | ||
11973 | /* Local address. */ | |
11974 | if (p->su_local) { | |
11975 | if (use_json) { | |
11976 | json_object_string_add(json_neigh, "hostLocal", | |
11977 | sockunion2str(p->su_local, buf1, | |
11978 | SU_ADDRSTRLEN)); | |
11979 | json_object_int_add(json_neigh, "portLocal", | |
11980 | ntohs(p->su_local->sin.sin_port)); | |
11981 | } else | |
11982 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
11983 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
11984 | ntohs(p->su_local->sin.sin_port)); | |
11985 | } | |
11986 | ||
11987 | /* Remote address. */ | |
11988 | if (p->su_remote) { | |
11989 | if (use_json) { | |
11990 | json_object_string_add(json_neigh, "hostForeign", | |
11991 | sockunion2str(p->su_remote, buf1, | |
11992 | SU_ADDRSTRLEN)); | |
11993 | json_object_int_add(json_neigh, "portForeign", | |
11994 | ntohs(p->su_remote->sin.sin_port)); | |
11995 | } else | |
11996 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
11997 | sockunion2str(p->su_remote, buf1, | |
11998 | SU_ADDRSTRLEN), | |
11999 | ntohs(p->su_remote->sin.sin_port)); | |
12000 | } | |
12001 | ||
12002 | /* Nexthop display. */ | |
12003 | if (p->su_local) { | |
12004 | if (use_json) { | |
12005 | json_object_string_add(json_neigh, "nexthop", | |
12006 | inet_ntop(AF_INET, | |
12007 | &p->nexthop.v4, buf1, | |
12008 | sizeof(buf1))); | |
12009 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12010 | inet_ntop(AF_INET6, | |
12011 | &p->nexthop.v6_global, | |
12012 | buf1, sizeof(buf1))); | |
12013 | json_object_string_add(json_neigh, "nexthopLocal", | |
12014 | inet_ntop(AF_INET6, | |
12015 | &p->nexthop.v6_local, | |
12016 | buf1, sizeof(buf1))); | |
12017 | if (p->shared_network) | |
12018 | json_object_string_add(json_neigh, | |
12019 | "bgpConnection", | |
12020 | "sharedNetwork"); | |
12021 | else | |
12022 | json_object_string_add(json_neigh, | |
12023 | "bgpConnection", | |
12024 | "nonSharedNetwork"); | |
12025 | } else { | |
12026 | vty_out(vty, "Nexthop: %s\n", | |
12027 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12028 | sizeof(buf1))); | |
12029 | vty_out(vty, "Nexthop global: %s\n", | |
12030 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12031 | sizeof(buf1))); | |
12032 | vty_out(vty, "Nexthop local: %s\n", | |
12033 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12034 | sizeof(buf1))); | |
12035 | vty_out(vty, "BGP connection: %s\n", | |
12036 | p->shared_network ? "shared network" | |
12037 | : "non shared network"); | |
12038 | } | |
12039 | } | |
12040 | ||
12041 | /* Timer information. */ | |
12042 | if (use_json) { | |
12043 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12044 | p->v_connect); | |
12045 | if (p->status == Established && p->rtt) | |
12046 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12047 | p->rtt); | |
12048 | if (p->t_start) | |
12049 | json_object_int_add( | |
12050 | json_neigh, "nextStartTimerDueInMsecs", | |
12051 | thread_timer_remain_second(p->t_start) * 1000); | |
12052 | if (p->t_connect) | |
12053 | json_object_int_add( | |
12054 | json_neigh, "nextConnectTimerDueInMsecs", | |
12055 | thread_timer_remain_second(p->t_connect) | |
12056 | * 1000); | |
12057 | if (p->t_routeadv) { | |
12058 | json_object_int_add(json_neigh, "mraiInterval", | |
12059 | p->v_routeadv); | |
12060 | json_object_int_add( | |
12061 | json_neigh, "mraiTimerExpireInMsecs", | |
12062 | thread_timer_remain_second(p->t_routeadv) | |
12063 | * 1000); | |
12064 | } | |
12065 | if (p->password) | |
12066 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12067 | 1); | |
12068 | ||
12069 | if (p->t_read) | |
12070 | json_object_string_add(json_neigh, "readThread", "on"); | |
12071 | else | |
12072 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12073 | |
12074 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12075 | json_object_string_add(json_neigh, "writeThread", "on"); |
12076 | else | |
12077 | json_object_string_add(json_neigh, "writeThread", | |
12078 | "off"); | |
12079 | } else { | |
12080 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12081 | p->v_connect); | |
12082 | if (p->status == Established && p->rtt) | |
12083 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12084 | p->rtt); | |
12085 | if (p->t_start) | |
12086 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12087 | thread_timer_remain_second(p->t_start)); | |
12088 | if (p->t_connect) | |
12089 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12090 | thread_timer_remain_second(p->t_connect)); | |
12091 | if (p->t_routeadv) | |
12092 | vty_out(vty, | |
12093 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12094 | p->v_routeadv, | |
12095 | thread_timer_remain_second(p->t_routeadv)); | |
12096 | if (p->password) | |
12097 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12098 | ||
cac9e917 | 12099 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12100 | p->t_read ? "on" : "off", |
12101 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12102 | ? "on" | |
cac9e917 | 12103 | : "off", p->fd); |
d62a17ae | 12104 | } |
12105 | ||
12106 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12107 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12108 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12109 | ||
12110 | if (!use_json) | |
12111 | vty_out(vty, "\n"); | |
12112 | ||
12113 | /* BFD information. */ | |
12114 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12115 | ||
12116 | if (use_json) { | |
12117 | if (p->conf_if) /* Configured interface name. */ | |
12118 | json_object_object_add(json, p->conf_if, json_neigh); | |
12119 | else /* Configured IP address. */ | |
12120 | json_object_object_add(json, p->host, json_neigh); | |
12121 | } | |
12122 | } | |
12123 | ||
36235319 QY |
12124 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12125 | enum show_type type, | |
12126 | union sockunion *su, | |
12127 | const char *conf_if, afi_t afi, | |
12128 | bool use_json, json_object *json) | |
2986cac2 | 12129 | { |
12130 | struct listnode *node, *nnode; | |
12131 | struct peer *peer; | |
12132 | int find = 0; | |
12133 | safi_t safi = SAFI_UNICAST; | |
12134 | json_object *json_neighbor = NULL; | |
12135 | ||
12136 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12137 | ||
12138 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12139 | continue; | |
12140 | ||
12141 | if ((peer->afc[afi][safi]) == 0) | |
12142 | continue; | |
12143 | ||
12144 | if (use_json) | |
12145 | json_neighbor = json_object_new_object(); | |
12146 | ||
2ba1fe69 | 12147 | if (type == show_all) { |
2986cac2 | 12148 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12149 | json_neighbor); |
2986cac2 | 12150 | |
12151 | if (use_json) | |
13909c4f DS |
12152 | json_object_object_add(json, peer->host, |
12153 | json_neighbor); | |
2986cac2 | 12154 | |
2ba1fe69 | 12155 | } else if (type == show_peer) { |
2986cac2 | 12156 | if (conf_if) { |
12157 | if ((peer->conf_if | |
13909c4f DS |
12158 | && !strcmp(peer->conf_if, conf_if)) |
12159 | || (peer->hostname | |
2986cac2 | 12160 | && !strcmp(peer->hostname, conf_if))) { |
12161 | find = 1; | |
13909c4f DS |
12162 | bgp_show_peer_gr_status(vty, peer, |
12163 | use_json, | |
12164 | json_neighbor); | |
2986cac2 | 12165 | } |
12166 | } else { | |
12167 | if (sockunion_same(&peer->su, su)) { | |
12168 | find = 1; | |
13909c4f DS |
12169 | bgp_show_peer_gr_status(vty, peer, |
12170 | use_json, | |
12171 | json_neighbor); | |
2986cac2 | 12172 | } |
12173 | } | |
13909c4f DS |
12174 | if (use_json && find) |
12175 | json_object_object_add(json, peer->host, | |
12176 | json_neighbor); | |
2986cac2 | 12177 | } |
12178 | ||
12179 | if (find) | |
12180 | break; | |
12181 | } | |
12182 | ||
12183 | if (type == show_peer && !find) { | |
12184 | if (use_json) | |
13909c4f | 12185 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12186 | else |
12187 | vty_out(vty, "%% No such neighbor\n"); | |
12188 | } | |
12189 | if (use_json) { | |
13909c4f DS |
12190 | vty_out(vty, "%s\n", |
12191 | json_object_to_json_string_ext( | |
12192 | json, JSON_C_TO_STRING_PRETTY)); | |
2986cac2 | 12193 | } else { |
12194 | vty_out(vty, "\n"); | |
12195 | } | |
12196 | ||
12197 | return CMD_SUCCESS; | |
12198 | } | |
12199 | ||
d62a17ae | 12200 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12201 | enum show_type type, union sockunion *su, | |
9f049418 | 12202 | const char *conf_if, bool use_json, |
d62a17ae | 12203 | json_object *json) |
12204 | { | |
12205 | struct listnode *node, *nnode; | |
12206 | struct peer *peer; | |
12207 | int find = 0; | |
9f049418 | 12208 | bool nbr_output = false; |
d1927ebe AS |
12209 | afi_t afi = AFI_MAX; |
12210 | safi_t safi = SAFI_MAX; | |
12211 | ||
12212 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12213 | afi = AFI_IP; | |
12214 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12215 | afi = AFI_IP6; | |
12216 | } | |
d62a17ae | 12217 | |
12218 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12219 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12220 | continue; | |
12221 | ||
12222 | switch (type) { | |
12223 | case show_all: | |
12224 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12225 | nbr_output = true; |
d62a17ae | 12226 | break; |
12227 | case show_peer: | |
12228 | if (conf_if) { | |
12229 | if ((peer->conf_if | |
12230 | && !strcmp(peer->conf_if, conf_if)) | |
12231 | || (peer->hostname | |
12232 | && !strcmp(peer->hostname, conf_if))) { | |
12233 | find = 1; | |
12234 | bgp_show_peer(vty, peer, use_json, | |
12235 | json); | |
12236 | } | |
12237 | } else { | |
12238 | if (sockunion_same(&peer->su, su)) { | |
12239 | find = 1; | |
12240 | bgp_show_peer(vty, peer, use_json, | |
12241 | json); | |
12242 | } | |
12243 | } | |
12244 | break; | |
d1927ebe AS |
12245 | case show_ipv4_peer: |
12246 | case show_ipv6_peer: | |
12247 | FOREACH_SAFI (safi) { | |
12248 | if (peer->afc[afi][safi]) { | |
12249 | if (conf_if) { | |
12250 | if ((peer->conf_if | |
12251 | && !strcmp(peer->conf_if, conf_if)) | |
12252 | || (peer->hostname | |
12253 | && !strcmp(peer->hostname, conf_if))) { | |
12254 | find = 1; | |
12255 | bgp_show_peer(vty, peer, use_json, | |
12256 | json); | |
12257 | break; | |
12258 | } | |
12259 | } else { | |
12260 | if (sockunion_same(&peer->su, su)) { | |
12261 | find = 1; | |
12262 | bgp_show_peer(vty, peer, use_json, | |
12263 | json); | |
12264 | break; | |
12265 | } | |
12266 | } | |
12267 | } | |
12268 | } | |
12269 | break; | |
12270 | case show_ipv4_all: | |
12271 | case show_ipv6_all: | |
12272 | FOREACH_SAFI (safi) { | |
12273 | if (peer->afc[afi][safi]) { | |
12274 | bgp_show_peer(vty, peer, use_json, json); | |
12275 | nbr_output = true; | |
12276 | break; | |
12277 | } | |
12278 | } | |
12279 | break; | |
d62a17ae | 12280 | } |
12281 | } | |
12282 | ||
d1927ebe AS |
12283 | if ((type == show_peer || type == show_ipv4_peer || |
12284 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12285 | if (use_json) |
12286 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12287 | else | |
88b7d255 | 12288 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12289 | } |
12290 | ||
d1927ebe AS |
12291 | if (type != show_peer && type != show_ipv4_peer && |
12292 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12293 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12294 | |
d62a17ae | 12295 | if (use_json) { |
996c9314 LB |
12296 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12297 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12298 | } else { |
12299 | vty_out(vty, "\n"); | |
12300 | } | |
12301 | ||
12302 | return CMD_SUCCESS; | |
12303 | } | |
12304 | ||
36235319 QY |
12305 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12306 | enum show_type type, | |
12307 | const char *ip_str, | |
12308 | afi_t afi, bool use_json) | |
2986cac2 | 12309 | { |
12310 | ||
12311 | int ret; | |
12312 | struct bgp *bgp; | |
12313 | union sockunion su; | |
12314 | json_object *json = NULL; | |
12315 | ||
12316 | bgp = bgp_get_default(); | |
12317 | ||
13909c4f DS |
12318 | if (!bgp) |
12319 | return; | |
2986cac2 | 12320 | |
13909c4f DS |
12321 | if (!use_json) |
12322 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12323 | NULL); | |
2986cac2 | 12324 | |
13909c4f DS |
12325 | json = json_object_new_object(); |
12326 | if (ip_str) { | |
12327 | ret = str2sockunion(ip_str, &su); | |
12328 | if (ret < 0) | |
12329 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, | |
12330 | ip_str, afi, | |
12331 | use_json, json); | |
12332 | else | |
12333 | bgp_show_neighbor_graceful_restart( | |
12334 | vty, bgp, type, &su, NULL, afi, use_json, json); | |
12335 | } else | |
12336 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
12337 | afi, use_json, json); | |
12338 | json_object_free(json); | |
2986cac2 | 12339 | } |
12340 | ||
d62a17ae | 12341 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12342 | enum show_type type, |
12343 | const char *ip_str, | |
9f049418 | 12344 | bool use_json) |
d62a17ae | 12345 | { |
0291c246 MK |
12346 | struct listnode *node, *nnode; |
12347 | struct bgp *bgp; | |
71aedaa3 | 12348 | union sockunion su; |
0291c246 | 12349 | json_object *json = NULL; |
71aedaa3 | 12350 | int ret, is_first = 1; |
9f049418 | 12351 | bool nbr_output = false; |
d62a17ae | 12352 | |
12353 | if (use_json) | |
12354 | vty_out(vty, "{\n"); | |
12355 | ||
12356 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12357 | nbr_output = true; |
d62a17ae | 12358 | if (use_json) { |
12359 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12360 | flog_err( |
e50f7cfd | 12361 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12362 | "Unable to allocate memory for JSON object"); |
12363 | vty_out(vty, | |
12364 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12365 | return; | |
12366 | } | |
12367 | ||
12368 | json_object_int_add(json, "vrfId", | |
12369 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12370 | ? -1 |
12371 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12372 | json_object_string_add( |
12373 | json, "vrfName", | |
12374 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12375 | ? VRF_DEFAULT_NAME |
d62a17ae | 12376 | : bgp->name); |
12377 | ||
12378 | if (!is_first) | |
12379 | vty_out(vty, ",\n"); | |
12380 | else | |
12381 | is_first = 0; | |
12382 | ||
12383 | vty_out(vty, "\"%s\":", | |
12384 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12385 | ? VRF_DEFAULT_NAME |
d62a17ae | 12386 | : bgp->name); |
12387 | } else { | |
12388 | vty_out(vty, "\nInstance %s:\n", | |
12389 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12390 | ? VRF_DEFAULT_NAME |
d62a17ae | 12391 | : bgp->name); |
12392 | } | |
71aedaa3 | 12393 | |
d1927ebe AS |
12394 | if (type == show_peer || type == show_ipv4_peer || |
12395 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12396 | ret = str2sockunion(ip_str, &su); |
12397 | if (ret < 0) | |
12398 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12399 | use_json, json); | |
12400 | else | |
12401 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12402 | use_json, json); | |
12403 | } else { | |
d1927ebe | 12404 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12405 | use_json, json); |
12406 | } | |
b77004d6 | 12407 | json_object_free(json); |
d62a17ae | 12408 | } |
12409 | ||
01cbfd04 | 12410 | if (use_json) { |
d62a17ae | 12411 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12412 | json_object_free(json); |
12413 | } | |
9f049418 DS |
12414 | else if (!nbr_output) |
12415 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12416 | } |
12417 | ||
12418 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12419 | enum show_type type, const char *ip_str, | |
9f049418 | 12420 | bool use_json) |
d62a17ae | 12421 | { |
12422 | int ret; | |
12423 | struct bgp *bgp; | |
12424 | union sockunion su; | |
12425 | json_object *json = NULL; | |
12426 | ||
12427 | if (name) { | |
12428 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12429 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12430 | use_json); | |
d62a17ae | 12431 | return CMD_SUCCESS; |
12432 | } else { | |
12433 | bgp = bgp_lookup_by_name(name); | |
12434 | if (!bgp) { | |
12435 | if (use_json) { | |
12436 | json = json_object_new_object(); | |
d62a17ae | 12437 | vty_out(vty, "%s\n", |
12438 | json_object_to_json_string_ext( | |
12439 | json, | |
12440 | JSON_C_TO_STRING_PRETTY)); | |
12441 | json_object_free(json); | |
12442 | } else | |
12443 | vty_out(vty, | |
9f049418 | 12444 | "%% BGP instance not found\n"); |
d62a17ae | 12445 | |
12446 | return CMD_WARNING; | |
12447 | } | |
12448 | } | |
12449 | } else { | |
12450 | bgp = bgp_get_default(); | |
12451 | } | |
12452 | ||
12453 | if (bgp) { | |
12454 | json = json_object_new_object(); | |
12455 | if (ip_str) { | |
12456 | ret = str2sockunion(ip_str, &su); | |
12457 | if (ret < 0) | |
12458 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12459 | use_json, json); | |
12460 | else | |
12461 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12462 | use_json, json); | |
12463 | } else { | |
12464 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12465 | json); | |
12466 | } | |
12467 | json_object_free(json); | |
ca61fd25 DS |
12468 | } else { |
12469 | if (use_json) | |
12470 | vty_out(vty, "{}\n"); | |
12471 | else | |
12472 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12473 | } |
12474 | ||
12475 | return CMD_SUCCESS; | |
4fb25c53 DW |
12476 | } |
12477 | ||
2986cac2 | 12478 | |
12479 | ||
12480 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12481 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12482 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12483 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12484 | SHOW_STR | |
12485 | BGP_STR | |
12486 | IP_STR | |
12487 | IPV6_STR | |
12488 | NEIGHBOR_STR | |
12489 | "Neighbor to display information about\n" | |
12490 | "Neighbor to display information about\n" | |
12491 | "Neighbor on BGP configured interface\n" | |
12492 | GR_SHOW | |
12493 | JSON_STR) | |
12494 | { | |
12495 | char *sh_arg = NULL; | |
12496 | enum show_type sh_type; | |
12497 | int idx = 0; | |
12498 | afi_t afi = AFI_MAX; | |
2986cac2 | 12499 | bool uj = use_json(argc, argv); |
12500 | ||
36235319 | 12501 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12502 | afi = AFI_MAX; |
12503 | ||
12504 | idx++; | |
12505 | ||
12506 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12507 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12508 | || argv_find(argv, argc, "WORD", &idx)) { | |
12509 | sh_type = show_peer; | |
12510 | sh_arg = argv[idx]->arg; | |
12511 | } else | |
12512 | sh_type = show_all; | |
12513 | ||
12514 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12515 | return CMD_SUCCESS; | |
12516 | ||
12517 | ||
36235319 QY |
12518 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12519 | afi, uj); | |
2986cac2 | 12520 | } |
12521 | ||
716b2d8a | 12522 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12523 | DEFUN (show_ip_bgp_neighbors, |
12524 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12525 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12526 | SHOW_STR |
12527 | IP_STR | |
12528 | BGP_STR | |
f2a8972b | 12529 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12530 | "Address Family\n" |
12531 | "Address Family\n" | |
718e3744 | 12532 | "Detailed information on TCP and BGP neighbor connections\n" |
12533 | "Neighbor to display information about\n" | |
a80beece | 12534 | "Neighbor to display information about\n" |
91d37724 | 12535 | "Neighbor on BGP configured interface\n" |
9973d184 | 12536 | JSON_STR) |
718e3744 | 12537 | { |
d62a17ae | 12538 | char *vrf = NULL; |
12539 | char *sh_arg = NULL; | |
12540 | enum show_type sh_type; | |
d1927ebe | 12541 | afi_t afi = AFI_MAX; |
718e3744 | 12542 | |
9f049418 | 12543 | bool uj = use_json(argc, argv); |
718e3744 | 12544 | |
d62a17ae | 12545 | int idx = 0; |
718e3744 | 12546 | |
9a8bdf1c PG |
12547 | /* [<vrf> VIEWVRFNAME] */ |
12548 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12549 | vrf = argv[idx + 1]->arg; | |
12550 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12551 | vrf = NULL; | |
12552 | } else if (argv_find(argv, argc, "view", &idx)) | |
12553 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12554 | vrf = argv[idx + 1]->arg; |
718e3744 | 12555 | |
d62a17ae | 12556 | idx++; |
d1927ebe AS |
12557 | |
12558 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12559 | sh_type = show_ipv4_all; | |
12560 | afi = AFI_IP; | |
12561 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12562 | sh_type = show_ipv6_all; | |
12563 | afi = AFI_IP6; | |
12564 | } else { | |
12565 | sh_type = show_all; | |
12566 | } | |
12567 | ||
d62a17ae | 12568 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12569 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12570 | || argv_find(argv, argc, "WORD", &idx)) { | |
12571 | sh_type = show_peer; | |
12572 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12573 | } |
12574 | ||
12575 | if (sh_type == show_peer && afi == AFI_IP) { | |
12576 | sh_type = show_ipv4_peer; | |
12577 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12578 | sh_type = show_ipv6_peer; | |
12579 | } | |
856ca177 | 12580 | |
d62a17ae | 12581 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12582 | } |
12583 | ||
716b2d8a | 12584 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12585 | paths' and `show ip mbgp paths'. Those functions results are the |
12586 | same.*/ | |
f412b39a | 12587 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12588 | show_ip_bgp_paths_cmd, |
46f296b4 | 12589 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12590 | SHOW_STR |
12591 | IP_STR | |
12592 | BGP_STR | |
46f296b4 | 12593 | BGP_SAFI_HELP_STR |
718e3744 | 12594 | "Path information\n") |
12595 | { | |
d62a17ae | 12596 | vty_out(vty, "Address Refcnt Path\n"); |
12597 | aspath_print_all_vty(vty); | |
12598 | return CMD_SUCCESS; | |
718e3744 | 12599 | } |
12600 | ||
718e3744 | 12601 | #include "hash.h" |
12602 | ||
e3b78da8 | 12603 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12604 | struct vty *vty) |
718e3744 | 12605 | { |
d62a17ae | 12606 | struct community *com; |
718e3744 | 12607 | |
e3b78da8 | 12608 | com = (struct community *)bucket->data; |
3f65c5b1 | 12609 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12610 | community_str(com, false)); |
718e3744 | 12611 | } |
12612 | ||
12613 | /* Show BGP's community internal data. */ | |
f412b39a | 12614 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12615 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12616 | "show [ip] bgp community-info", |
718e3744 | 12617 | SHOW_STR |
12618 | IP_STR | |
12619 | BGP_STR | |
12620 | "List all bgp community information\n") | |
12621 | { | |
d62a17ae | 12622 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12623 | |
d62a17ae | 12624 | hash_iterate(community_hash(), |
e3b78da8 | 12625 | (void (*)(struct hash_bucket *, |
d62a17ae | 12626 | void *))community_show_all_iterator, |
12627 | vty); | |
718e3744 | 12628 | |
d62a17ae | 12629 | return CMD_SUCCESS; |
718e3744 | 12630 | } |
12631 | ||
e3b78da8 | 12632 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12633 | struct vty *vty) |
57d187bc | 12634 | { |
d62a17ae | 12635 | struct lcommunity *lcom; |
57d187bc | 12636 | |
e3b78da8 | 12637 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12638 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12639 | lcommunity_str(lcom, false)); |
57d187bc JS |
12640 | } |
12641 | ||
12642 | /* Show BGP's community internal data. */ | |
12643 | DEFUN (show_ip_bgp_lcommunity_info, | |
12644 | show_ip_bgp_lcommunity_info_cmd, | |
12645 | "show ip bgp large-community-info", | |
12646 | SHOW_STR | |
12647 | IP_STR | |
12648 | BGP_STR | |
12649 | "List all bgp large-community information\n") | |
12650 | { | |
d62a17ae | 12651 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12652 | |
d62a17ae | 12653 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12654 | (void (*)(struct hash_bucket *, |
d62a17ae | 12655 | void *))lcommunity_show_all_iterator, |
12656 | vty); | |
57d187bc | 12657 | |
d62a17ae | 12658 | return CMD_SUCCESS; |
57d187bc | 12659 | } |
2986cac2 | 12660 | /* Graceful Restart */ |
12661 | ||
12662 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
12663 | struct bgp *bgp, |
12664 | bool use_json, | |
12665 | json_object *json) | |
2986cac2 | 12666 | { |
57d187bc JS |
12667 | |
12668 | ||
2986cac2 | 12669 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12670 | ||
7318ae88 | 12671 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 12672 | |
12673 | switch (bgp_global_gr_mode) { | |
12674 | ||
12675 | case GLOBAL_HELPER: | |
13909c4f | 12676 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12677 | break; |
12678 | ||
12679 | case GLOBAL_GR: | |
13909c4f | 12680 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12681 | break; |
12682 | ||
12683 | case GLOBAL_DISABLE: | |
13909c4f | 12684 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12685 | break; |
12686 | ||
12687 | case GLOBAL_INVALID: | |
2986cac2 | 12688 | vty_out(vty, |
2ba1fe69 | 12689 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12690 | break; |
12691 | } | |
12692 | vty_out(vty, "\n"); | |
12693 | } | |
12694 | ||
36235319 QY |
12695 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
12696 | enum show_type type, | |
12697 | const char *ip_str, | |
12698 | afi_t afi, bool use_json) | |
2986cac2 | 12699 | { |
12700 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12701 | afi = AFI_IP; | |
12702 | ||
12703 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12704 | ||
36235319 QY |
12705 | bgp_show_neighbor_graceful_restart_vty( |
12706 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 12707 | afi++; |
12708 | } | |
12709 | } else if (afi != AFI_MAX) { | |
36235319 QY |
12710 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
12711 | use_json); | |
2986cac2 | 12712 | } else { |
12713 | return CMD_ERR_INCOMPLETE; | |
12714 | } | |
12715 | ||
12716 | return CMD_SUCCESS; | |
12717 | } | |
12718 | /* Graceful Restart */ | |
12719 | ||
f412b39a | 12720 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12721 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12722 | "show [ip] bgp attribute-info", |
718e3744 | 12723 | SHOW_STR |
12724 | IP_STR | |
12725 | BGP_STR | |
12726 | "List all bgp attribute information\n") | |
12727 | { | |
d62a17ae | 12728 | attr_show_all(vty); |
12729 | return CMD_SUCCESS; | |
718e3744 | 12730 | } |
6b0655a2 | 12731 | |
03915806 CS |
12732 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12733 | afi_t afi, safi_t safi, | |
12734 | bool use_json, json_object *json) | |
53089bec | 12735 | { |
12736 | struct bgp *bgp; | |
12737 | struct listnode *node; | |
12738 | char *vname; | |
12739 | char buf1[INET6_ADDRSTRLEN]; | |
12740 | char *ecom_str; | |
12741 | vpn_policy_direction_t dir; | |
12742 | ||
03915806 | 12743 | if (json) { |
b46dfd20 DS |
12744 | json_object *json_import_vrfs = NULL; |
12745 | json_object *json_export_vrfs = NULL; | |
12746 | ||
b46dfd20 DS |
12747 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12748 | ||
53089bec | 12749 | if (!bgp) { |
b46dfd20 DS |
12750 | vty_out(vty, "%s\n", |
12751 | json_object_to_json_string_ext( | |
12752 | json, | |
12753 | JSON_C_TO_STRING_PRETTY)); | |
12754 | json_object_free(json); | |
12755 | ||
53089bec | 12756 | return CMD_WARNING; |
12757 | } | |
b46dfd20 | 12758 | |
94d4c685 DS |
12759 | /* Provide context for the block */ |
12760 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12761 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12762 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12763 | |
b46dfd20 DS |
12764 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12765 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12766 | json_object_string_add(json, "importFromVrfs", "none"); | |
12767 | json_object_string_add(json, "importRts", "none"); | |
12768 | } else { | |
6ce24e52 DS |
12769 | json_import_vrfs = json_object_new_array(); |
12770 | ||
b46dfd20 DS |
12771 | for (ALL_LIST_ELEMENTS_RO( |
12772 | bgp->vpn_policy[afi].import_vrf, | |
12773 | node, vname)) | |
12774 | json_object_array_add(json_import_vrfs, | |
12775 | json_object_new_string(vname)); | |
12776 | ||
b20875ea CS |
12777 | json_object_object_add(json, "importFromVrfs", |
12778 | json_import_vrfs); | |
b46dfd20 | 12779 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12780 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12781 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12782 | bgp->vpn_policy[afi].rtlist[dir], |
12783 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12784 | json_object_string_add(json, "importRts", |
12785 | ecom_str); | |
12786 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12787 | } else | |
12788 | json_object_string_add(json, "importRts", | |
12789 | "none"); | |
b46dfd20 DS |
12790 | } |
12791 | ||
12792 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12793 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12794 | json_object_string_add(json, "exportToVrfs", "none"); | |
12795 | json_object_string_add(json, "routeDistinguisher", | |
12796 | "none"); | |
12797 | json_object_string_add(json, "exportRts", "none"); | |
12798 | } else { | |
6ce24e52 DS |
12799 | json_export_vrfs = json_object_new_array(); |
12800 | ||
b46dfd20 DS |
12801 | for (ALL_LIST_ELEMENTS_RO( |
12802 | bgp->vpn_policy[afi].export_vrf, | |
12803 | node, vname)) | |
12804 | json_object_array_add(json_export_vrfs, | |
12805 | json_object_new_string(vname)); | |
12806 | json_object_object_add(json, "exportToVrfs", | |
12807 | json_export_vrfs); | |
12808 | json_object_string_add(json, "routeDistinguisher", | |
12809 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12810 | buf1, RD_ADDRSTRLEN)); | |
12811 | ||
12812 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12813 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12814 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12815 | bgp->vpn_policy[afi].rtlist[dir], |
12816 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12817 | json_object_string_add(json, "exportRts", |
12818 | ecom_str); | |
12819 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12820 | } else | |
12821 | json_object_string_add(json, "exportRts", | |
12822 | "none"); | |
b46dfd20 DS |
12823 | } |
12824 | ||
03915806 CS |
12825 | if (use_json) { |
12826 | vty_out(vty, "%s\n", | |
12827 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12828 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12829 | json_object_free(json); |
12830 | } | |
53089bec | 12831 | } else { |
b46dfd20 DS |
12832 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12833 | ||
53089bec | 12834 | if (!bgp) { |
b46dfd20 | 12835 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12836 | return CMD_WARNING; |
12837 | } | |
53089bec | 12838 | |
b46dfd20 DS |
12839 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12840 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12841 | vty_out(vty, | |
12842 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12843 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12844 | else { |
12845 | vty_out(vty, | |
12846 | "This VRF is importing %s routes from 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].import_vrf, | |
12851 | node, vname)) | |
12852 | vty_out(vty, " %s\n", vname); | |
12853 | ||
12854 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
12855 | ecom_str = NULL; |
12856 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
12857 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12858 | bgp->vpn_policy[afi].rtlist[dir], |
12859 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 12860 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 12861 | |
b20875ea CS |
12862 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
12863 | } else | |
12864 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12865 | } |
53089bec | 12866 | |
b46dfd20 DS |
12867 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12868 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12869 | vty_out(vty, | |
12870 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 12871 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12872 | else { |
12873 | vty_out(vty, | |
04c9077f | 12874 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 12875 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12876 | |
12877 | for (ALL_LIST_ELEMENTS_RO( | |
12878 | bgp->vpn_policy[afi].export_vrf, | |
12879 | node, vname)) | |
12880 | vty_out(vty, " %s\n", vname); | |
12881 | ||
12882 | vty_out(vty, "RD: %s\n", | |
12883 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12884 | buf1, RD_ADDRSTRLEN)); | |
12885 | ||
12886 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12887 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12888 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12889 | bgp->vpn_policy[afi].rtlist[dir], |
12890 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12891 | vty_out(vty, "Export RT: %s\n", ecom_str); |
12892 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12893 | } else | |
12894 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12895 | } |
53089bec | 12896 | } |
12897 | ||
12898 | return CMD_SUCCESS; | |
12899 | } | |
12900 | ||
03915806 CS |
12901 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
12902 | safi_t safi, bool use_json) | |
12903 | { | |
12904 | struct listnode *node, *nnode; | |
12905 | struct bgp *bgp; | |
12906 | char *vrf_name = NULL; | |
12907 | json_object *json = NULL; | |
12908 | json_object *json_vrf = NULL; | |
12909 | json_object *json_vrfs = NULL; | |
12910 | ||
12911 | if (use_json) { | |
12912 | json = json_object_new_object(); | |
12913 | json_vrfs = json_object_new_object(); | |
12914 | } | |
12915 | ||
12916 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
12917 | ||
12918 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
12919 | vrf_name = bgp->name; | |
12920 | ||
12921 | if (use_json) { | |
12922 | json_vrf = json_object_new_object(); | |
12923 | } else { | |
12924 | vty_out(vty, "\nInstance %s:\n", | |
12925 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12926 | ? VRF_DEFAULT_NAME : bgp->name); | |
12927 | } | |
12928 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
12929 | if (use_json) { | |
12930 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
12931 | json_object_object_add(json_vrfs, | |
12932 | VRF_DEFAULT_NAME, json_vrf); | |
12933 | else | |
12934 | json_object_object_add(json_vrfs, vrf_name, | |
12935 | json_vrf); | |
12936 | } | |
12937 | } | |
12938 | ||
12939 | if (use_json) { | |
12940 | json_object_object_add(json, "vrfs", json_vrfs); | |
12941 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
12942 | JSON_C_TO_STRING_PRETTY)); | |
12943 | json_object_free(json); | |
12944 | } | |
12945 | ||
12946 | return CMD_SUCCESS; | |
12947 | } | |
12948 | ||
53089bec | 12949 | /* "show [ip] bgp route-leak" command. */ |
12950 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
12951 | show_ip_bgp_route_leak_cmd, |
12952 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
12953 | SHOW_STR |
12954 | IP_STR | |
12955 | BGP_STR | |
12956 | BGP_INSTANCE_HELP_STR | |
12957 | BGP_AFI_HELP_STR | |
12958 | BGP_SAFI_HELP_STR | |
12959 | "Route leaking information\n" | |
12960 | JSON_STR) | |
53089bec | 12961 | { |
12962 | char *vrf = NULL; | |
12963 | afi_t afi = AFI_MAX; | |
12964 | safi_t safi = SAFI_MAX; | |
12965 | ||
9f049418 | 12966 | bool uj = use_json(argc, argv); |
53089bec | 12967 | int idx = 0; |
03915806 | 12968 | json_object *json = NULL; |
53089bec | 12969 | |
12970 | /* show [ip] bgp */ | |
12971 | if (argv_find(argv, argc, "ip", &idx)) { | |
12972 | afi = AFI_IP; | |
12973 | safi = SAFI_UNICAST; | |
12974 | } | |
12975 | /* [vrf VIEWVRFNAME] */ | |
12976 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
12977 | vty_out(vty, |
12978 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 12979 | return CMD_WARNING; |
12980 | } | |
12981 | ||
9a8bdf1c PG |
12982 | if (argv_find(argv, argc, "vrf", &idx)) { |
12983 | vrf = argv[idx + 1]->arg; | |
12984 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12985 | vrf = NULL; | |
12986 | } | |
53089bec | 12987 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
12988 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
12989 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
12990 | } | |
12991 | ||
12992 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
12993 | vty_out(vty, |
12994 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 12995 | return CMD_WARNING; |
12996 | } | |
12997 | ||
03915806 CS |
12998 | if (vrf && strmatch(vrf, "all")) |
12999 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13000 | ||
13001 | if (uj) | |
13002 | json = json_object_new_object(); | |
13003 | ||
13004 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13005 | } |
13006 | ||
d62a17ae | 13007 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13008 | safi_t safi) | |
f186de26 | 13009 | { |
d62a17ae | 13010 | struct listnode *node, *nnode; |
13011 | struct bgp *bgp; | |
f186de26 | 13012 | |
d62a17ae | 13013 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13014 | vty_out(vty, "\nInstance %s:\n", | |
13015 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13016 | ? VRF_DEFAULT_NAME |
d62a17ae | 13017 | : bgp->name); |
13018 | update_group_show(bgp, afi, safi, vty, 0); | |
13019 | } | |
f186de26 | 13020 | } |
13021 | ||
d62a17ae | 13022 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13023 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13024 | { |
d62a17ae | 13025 | struct bgp *bgp; |
4fb25c53 | 13026 | |
d62a17ae | 13027 | if (name) { |
13028 | if (strmatch(name, "all")) { | |
13029 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13030 | return CMD_SUCCESS; | |
13031 | } else { | |
13032 | bgp = bgp_lookup_by_name(name); | |
13033 | } | |
13034 | } else { | |
13035 | bgp = bgp_get_default(); | |
13036 | } | |
4fb25c53 | 13037 | |
d62a17ae | 13038 | if (bgp) |
13039 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13040 | return CMD_SUCCESS; | |
4fb25c53 DW |
13041 | } |
13042 | ||
8fe8a7f6 DS |
13043 | DEFUN (show_ip_bgp_updgrps, |
13044 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13045 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13046 | SHOW_STR |
13047 | IP_STR | |
13048 | BGP_STR | |
13049 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13050 | BGP_AFI_HELP_STR |
9bedbb1e | 13051 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13052 | "Detailed info about dynamic update groups\n" |
13053 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13054 | { |
d62a17ae | 13055 | char *vrf = NULL; |
13056 | afi_t afi = AFI_IP6; | |
13057 | safi_t safi = SAFI_UNICAST; | |
13058 | uint64_t subgrp_id = 0; | |
13059 | ||
13060 | int idx = 0; | |
13061 | ||
13062 | /* show [ip] bgp */ | |
13063 | if (argv_find(argv, argc, "ip", &idx)) | |
13064 | afi = AFI_IP; | |
9a8bdf1c PG |
13065 | /* [<vrf> VIEWVRFNAME] */ |
13066 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13067 | vrf = argv[idx + 1]->arg; | |
13068 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13069 | vrf = NULL; | |
13070 | } else if (argv_find(argv, argc, "view", &idx)) | |
13071 | /* [<view> VIEWVRFNAME] */ | |
13072 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13073 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13074 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13075 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13076 | } | |
5bf15956 | 13077 | |
d62a17ae | 13078 | /* get subgroup id, if provided */ |
13079 | idx = argc - 1; | |
13080 | if (argv[idx]->type == VARIABLE_TKN) | |
13081 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13082 | |
d62a17ae | 13083 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13084 | } |
13085 | ||
f186de26 | 13086 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13087 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13088 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13089 | SHOW_STR |
716b2d8a | 13090 | IP_STR |
f186de26 | 13091 | BGP_STR |
13092 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13093 | "Detailed info about dynamic update groups\n") |
f186de26 | 13094 | { |
d62a17ae | 13095 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13096 | return CMD_SUCCESS; | |
f186de26 | 13097 | } |
13098 | ||
43d3f4fc DS |
13099 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13100 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13101 | "show [ip] bgp l2vpn evpn update-groups", | |
13102 | SHOW_STR | |
13103 | IP_STR | |
13104 | BGP_STR | |
13105 | "l2vpn address family\n" | |
13106 | "evpn sub-address family\n" | |
13107 | "Detailed info about dynamic update groups\n") | |
13108 | { | |
13109 | char *vrf = NULL; | |
13110 | uint64_t subgrp_id = 0; | |
13111 | ||
13112 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13113 | return CMD_SUCCESS; | |
13114 | } | |
13115 | ||
5bf15956 DW |
13116 | DEFUN (show_bgp_updgrps_stats, |
13117 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13118 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13119 | SHOW_STR |
716b2d8a | 13120 | IP_STR |
3f9c7369 | 13121 | BGP_STR |
0c7b1b01 | 13122 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13123 | "Statistics\n") |
13124 | { | |
d62a17ae | 13125 | struct bgp *bgp; |
3f9c7369 | 13126 | |
d62a17ae | 13127 | bgp = bgp_get_default(); |
13128 | if (bgp) | |
13129 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13130 | |
d62a17ae | 13131 | return CMD_SUCCESS; |
3f9c7369 DS |
13132 | } |
13133 | ||
8386ac43 | 13134 | DEFUN (show_bgp_instance_updgrps_stats, |
13135 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13136 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13137 | SHOW_STR |
716b2d8a | 13138 | IP_STR |
8386ac43 | 13139 | BGP_STR |
13140 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13141 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13142 | "Statistics\n") |
13143 | { | |
d62a17ae | 13144 | int idx_word = 3; |
13145 | struct bgp *bgp; | |
8386ac43 | 13146 | |
d62a17ae | 13147 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13148 | if (bgp) | |
13149 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13150 | |
d62a17ae | 13151 | return CMD_SUCCESS; |
8386ac43 | 13152 | } |
13153 | ||
d62a17ae | 13154 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13155 | afi_t afi, safi_t safi, | |
13156 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13157 | { |
d62a17ae | 13158 | struct bgp *bgp; |
8386ac43 | 13159 | |
d62a17ae | 13160 | if (name) |
13161 | bgp = bgp_lookup_by_name(name); | |
13162 | else | |
13163 | bgp = bgp_get_default(); | |
8386ac43 | 13164 | |
d62a17ae | 13165 | if (bgp) { |
13166 | if (!strcmp(what, "advertise-queue")) | |
13167 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13168 | subgrp_id); | |
13169 | else if (!strcmp(what, "advertised-routes")) | |
13170 | update_group_show_advertised(bgp, afi, safi, vty, | |
13171 | subgrp_id); | |
13172 | else if (!strcmp(what, "packet-queue")) | |
13173 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13174 | subgrp_id); | |
13175 | } | |
3f9c7369 DS |
13176 | } |
13177 | ||
dc64bdec QY |
13178 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13179 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13180 | "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", | |
13181 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13182 | BGP_SAFI_HELP_STR | |
13183 | "Detailed info about dynamic update groups\n" | |
13184 | "Specific subgroup to display info for\n" | |
13185 | "Advertisement queue\n" | |
13186 | "Announced routes\n" | |
13187 | "Packet queue\n") | |
3f9c7369 | 13188 | { |
dc64bdec QY |
13189 | uint64_t subgrp_id = 0; |
13190 | afi_t afiz; | |
13191 | safi_t safiz; | |
13192 | if (sgid) | |
13193 | subgrp_id = strtoull(sgid, NULL, 10); | |
13194 | ||
13195 | if (!ip && !afi) | |
13196 | afiz = AFI_IP6; | |
13197 | if (!ip && afi) | |
13198 | afiz = bgp_vty_afi_from_str(afi); | |
13199 | if (ip && !afi) | |
13200 | afiz = AFI_IP; | |
13201 | if (ip && afi) { | |
13202 | afiz = bgp_vty_afi_from_str(afi); | |
13203 | if (afiz != AFI_IP) | |
13204 | vty_out(vty, | |
13205 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13206 | return CMD_WARNING; | |
13207 | } | |
d62a17ae | 13208 | |
dc64bdec | 13209 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13210 | |
dc64bdec | 13211 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13212 | return CMD_SUCCESS; |
13213 | } | |
13214 | ||
d62a17ae | 13215 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13216 | { | |
13217 | struct listnode *node, *nnode; | |
13218 | struct prefix *range; | |
13219 | struct peer *conf; | |
13220 | struct peer *peer; | |
13221 | char buf[PREFIX2STR_BUFFER]; | |
13222 | afi_t afi; | |
13223 | safi_t safi; | |
13224 | const char *peer_status; | |
13225 | const char *af_str; | |
13226 | int lr_count; | |
13227 | int dynamic; | |
13228 | int af_cfgd; | |
13229 | ||
13230 | conf = group->conf; | |
13231 | ||
13232 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13233 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13234 | group->name, conf->as); | |
d62a17ae | 13235 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13236 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13237 | group->name, group->bgp->as); | |
d62a17ae | 13238 | } else { |
13239 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13240 | } | |
f14e6fdb | 13241 | |
d62a17ae | 13242 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13243 | vty_out(vty, " Peer-group type is internal\n"); | |
13244 | else | |
13245 | vty_out(vty, " Peer-group type is external\n"); | |
13246 | ||
13247 | /* Display AFs configured. */ | |
13248 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13249 | FOREACH_AFI_SAFI (afi, safi) { |
13250 | if (conf->afc[afi][safi]) { | |
13251 | af_cfgd = 1; | |
5cb5f4d0 | 13252 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13253 | } |
05c7a1cc | 13254 | } |
d62a17ae | 13255 | if (!af_cfgd) |
13256 | vty_out(vty, " none\n"); | |
13257 | else | |
13258 | vty_out(vty, "\n"); | |
13259 | ||
13260 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13261 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13262 | if (afi == AFI_IP) | |
13263 | af_str = "IPv4"; | |
13264 | else if (afi == AFI_IP6) | |
13265 | af_str = "IPv6"; | |
13266 | else | |
13267 | af_str = "???"; | |
13268 | lr_count = listcount(group->listen_range[afi]); | |
13269 | if (lr_count) { | |
13270 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13271 | af_str); | |
13272 | ||
13273 | ||
13274 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13275 | nnode, range)) { | |
13276 | prefix2str(range, buf, sizeof(buf)); | |
13277 | vty_out(vty, " %s\n", buf); | |
13278 | } | |
13279 | } | |
13280 | } | |
f14e6fdb | 13281 | |
d62a17ae | 13282 | /* Display group members and their status */ |
13283 | if (listcount(group->peer)) { | |
13284 | vty_out(vty, " Peer-group members:\n"); | |
13285 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13286 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13287 | peer_status = "Idle (Admin)"; | |
13288 | else if (CHECK_FLAG(peer->sflags, | |
13289 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13290 | peer_status = "Idle (PfxCt)"; | |
13291 | else | |
13292 | peer_status = lookup_msg(bgp_status_msg, | |
13293 | peer->status, NULL); | |
13294 | ||
13295 | dynamic = peer_dynamic_neighbor(peer); | |
13296 | vty_out(vty, " %s %s %s \n", peer->host, | |
13297 | dynamic ? "(dynamic)" : "", peer_status); | |
13298 | } | |
13299 | } | |
f14e6fdb | 13300 | |
d62a17ae | 13301 | return CMD_SUCCESS; |
13302 | } | |
13303 | ||
ff9959b0 QY |
13304 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13305 | const char *group_name) | |
d62a17ae | 13306 | { |
ff9959b0 | 13307 | struct bgp *bgp; |
d62a17ae | 13308 | struct listnode *node, *nnode; |
13309 | struct peer_group *group; | |
ff9959b0 QY |
13310 | bool found = false; |
13311 | ||
13312 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13313 | ||
13314 | if (!bgp) { | |
9f049418 | 13315 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13316 | return CMD_WARNING; |
13317 | } | |
d62a17ae | 13318 | |
13319 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13320 | if (group_name) { |
13321 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13322 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13323 | found = true; |
13324 | break; | |
d62a17ae | 13325 | } |
ff9959b0 QY |
13326 | } else { |
13327 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13328 | } |
f14e6fdb | 13329 | } |
f14e6fdb | 13330 | |
ff9959b0 | 13331 | if (group_name && !found) |
d62a17ae | 13332 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13333 | |
d62a17ae | 13334 | return CMD_SUCCESS; |
f14e6fdb DS |
13335 | } |
13336 | ||
f14e6fdb DS |
13337 | DEFUN (show_ip_bgp_peer_groups, |
13338 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13339 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13340 | SHOW_STR |
13341 | IP_STR | |
13342 | BGP_STR | |
8386ac43 | 13343 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13344 | "Detailed information on BGP peer groups\n" |
13345 | "Peer group name\n") | |
f14e6fdb | 13346 | { |
d62a17ae | 13347 | char *vrf, *pg; |
d62a17ae | 13348 | int idx = 0; |
f14e6fdb | 13349 | |
a4d82a8a PZ |
13350 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13351 | : NULL; | |
d62a17ae | 13352 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13353 | |
ff9959b0 | 13354 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13355 | } |
3f9c7369 | 13356 | |
d6e3c605 | 13357 | |
718e3744 | 13358 | /* Redistribute VTY commands. */ |
13359 | ||
718e3744 | 13360 | DEFUN (bgp_redistribute_ipv4, |
13361 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13362 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13363 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13364 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13365 | { |
d62a17ae | 13366 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13367 | int idx_protocol = 1; | |
13368 | int type; | |
718e3744 | 13369 | |
d62a17ae | 13370 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13371 | if (type < 0) { | |
13372 | vty_out(vty, "%% Invalid route type\n"); | |
13373 | return CMD_WARNING_CONFIG_FAILED; | |
13374 | } | |
7f323236 | 13375 | |
d62a17ae | 13376 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13377 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13378 | } |
13379 | ||
d62a17ae | 13380 | ALIAS_HIDDEN( |
13381 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13382 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13383 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13384 | |
718e3744 | 13385 | DEFUN (bgp_redistribute_ipv4_rmap, |
13386 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13387 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13388 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13389 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13390 | "Route map reference\n" |
13391 | "Pointer to route-map entries\n") | |
13392 | { | |
d62a17ae | 13393 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13394 | int idx_protocol = 1; | |
13395 | int idx_word = 3; | |
13396 | int type; | |
13397 | struct bgp_redist *red; | |
e923dd62 | 13398 | bool changed; |
1de27621 DA |
13399 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13400 | vty, argv[idx_word]->arg); | |
718e3744 | 13401 | |
d62a17ae | 13402 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13403 | if (type < 0) { | |
13404 | vty_out(vty, "%% Invalid route type\n"); | |
13405 | return CMD_WARNING_CONFIG_FAILED; | |
13406 | } | |
718e3744 | 13407 | |
d62a17ae | 13408 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13409 | changed = |
13410 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13411 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13412 | } |
13413 | ||
d62a17ae | 13414 | ALIAS_HIDDEN( |
13415 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13416 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13417 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13418 | "Route map reference\n" | |
13419 | "Pointer to route-map entries\n") | |
596c17ba | 13420 | |
718e3744 | 13421 | DEFUN (bgp_redistribute_ipv4_metric, |
13422 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13423 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13424 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13425 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13426 | "Metric for redistributed routes\n" |
13427 | "Default metric\n") | |
13428 | { | |
d62a17ae | 13429 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13430 | int idx_protocol = 1; | |
13431 | int idx_number = 3; | |
13432 | int type; | |
d7c0a89a | 13433 | uint32_t metric; |
d62a17ae | 13434 | struct bgp_redist *red; |
e923dd62 | 13435 | bool changed; |
d62a17ae | 13436 | |
13437 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13438 | if (type < 0) { | |
13439 | vty_out(vty, "%% Invalid route type\n"); | |
13440 | return CMD_WARNING_CONFIG_FAILED; | |
13441 | } | |
13442 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13443 | ||
13444 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13445 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13446 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13447 | } |
13448 | ||
13449 | ALIAS_HIDDEN( | |
13450 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13451 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13452 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13453 | "Metric for redistributed routes\n" | |
13454 | "Default metric\n") | |
596c17ba | 13455 | |
718e3744 | 13456 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13457 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13458 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13459 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13460 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13461 | "Route map reference\n" |
13462 | "Pointer to route-map entries\n" | |
13463 | "Metric for redistributed routes\n" | |
13464 | "Default metric\n") | |
13465 | { | |
d62a17ae | 13466 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13467 | int idx_protocol = 1; | |
13468 | int idx_word = 3; | |
13469 | int idx_number = 5; | |
13470 | int type; | |
d7c0a89a | 13471 | uint32_t metric; |
d62a17ae | 13472 | struct bgp_redist *red; |
e923dd62 | 13473 | bool changed; |
1de27621 DA |
13474 | struct route_map *route_map = |
13475 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13476 | |
13477 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13478 | if (type < 0) { | |
13479 | vty_out(vty, "%% Invalid route type\n"); | |
13480 | return CMD_WARNING_CONFIG_FAILED; | |
13481 | } | |
13482 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13483 | ||
13484 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13485 | changed = |
13486 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13487 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13488 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13489 | } |
13490 | ||
13491 | ALIAS_HIDDEN( | |
13492 | bgp_redistribute_ipv4_rmap_metric, | |
13493 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13494 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13495 | " route-map WORD metric (0-4294967295)", | |
13496 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13497 | "Route map reference\n" | |
13498 | "Pointer to route-map entries\n" | |
13499 | "Metric for redistributed routes\n" | |
13500 | "Default metric\n") | |
596c17ba | 13501 | |
718e3744 | 13502 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13503 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13504 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13505 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13506 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13507 | "Metric for redistributed routes\n" |
13508 | "Default metric\n" | |
13509 | "Route map reference\n" | |
13510 | "Pointer to route-map entries\n") | |
13511 | { | |
d62a17ae | 13512 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13513 | int idx_protocol = 1; | |
13514 | int idx_number = 3; | |
13515 | int idx_word = 5; | |
13516 | int type; | |
d7c0a89a | 13517 | uint32_t metric; |
d62a17ae | 13518 | struct bgp_redist *red; |
e923dd62 | 13519 | bool changed; |
1de27621 DA |
13520 | struct route_map *route_map = |
13521 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13522 | |
13523 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13524 | if (type < 0) { | |
13525 | vty_out(vty, "%% Invalid route type\n"); | |
13526 | return CMD_WARNING_CONFIG_FAILED; | |
13527 | } | |
13528 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13529 | ||
13530 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13531 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13532 | changed |= |
13533 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13534 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13535 | } |
13536 | ||
13537 | ALIAS_HIDDEN( | |
13538 | bgp_redistribute_ipv4_metric_rmap, | |
13539 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13540 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13541 | " metric (0-4294967295) route-map WORD", | |
13542 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13543 | "Metric for redistributed routes\n" | |
13544 | "Default metric\n" | |
13545 | "Route map reference\n" | |
13546 | "Pointer to route-map entries\n") | |
596c17ba | 13547 | |
7c8ff89e DS |
13548 | DEFUN (bgp_redistribute_ipv4_ospf, |
13549 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13550 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13551 | "Redistribute information from another routing protocol\n" |
13552 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13553 | "Non-main Kernel Routing Table\n" |
13554 | "Instance ID/Table ID\n") | |
7c8ff89e | 13555 | { |
d62a17ae | 13556 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13557 | int idx_ospf_table = 1; | |
13558 | int idx_number = 2; | |
d7c0a89a QY |
13559 | unsigned short instance; |
13560 | unsigned short protocol; | |
7c8ff89e | 13561 | |
d62a17ae | 13562 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13563 | |
d62a17ae | 13564 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13565 | protocol = ZEBRA_ROUTE_OSPF; | |
13566 | else | |
13567 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13568 | |
d62a17ae | 13569 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13570 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13571 | } |
13572 | ||
d62a17ae | 13573 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13574 | "redistribute <ospf|table> (1-65535)", | |
13575 | "Redistribute information from another routing protocol\n" | |
13576 | "Open Shortest Path First (OSPFv2)\n" | |
13577 | "Non-main Kernel Routing Table\n" | |
13578 | "Instance ID/Table ID\n") | |
596c17ba | 13579 | |
7c8ff89e DS |
13580 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13581 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13582 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13583 | "Redistribute information from another routing protocol\n" |
13584 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13585 | "Non-main Kernel Routing Table\n" |
13586 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13587 | "Route map reference\n" |
13588 | "Pointer to route-map entries\n") | |
13589 | { | |
d62a17ae | 13590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13591 | int idx_ospf_table = 1; | |
13592 | int idx_number = 2; | |
13593 | int idx_word = 4; | |
13594 | struct bgp_redist *red; | |
d7c0a89a | 13595 | unsigned short instance; |
d62a17ae | 13596 | int protocol; |
e923dd62 | 13597 | bool changed; |
1de27621 DA |
13598 | struct route_map *route_map = |
13599 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13600 | |
13601 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13602 | protocol = ZEBRA_ROUTE_OSPF; | |
13603 | else | |
13604 | protocol = ZEBRA_ROUTE_TABLE; | |
13605 | ||
13606 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13607 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13608 | changed = |
13609 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13610 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13611 | } |
13612 | ||
13613 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13614 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13615 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13616 | "Redistribute information from another routing protocol\n" | |
13617 | "Open Shortest Path First (OSPFv2)\n" | |
13618 | "Non-main Kernel Routing Table\n" | |
13619 | "Instance ID/Table ID\n" | |
13620 | "Route map reference\n" | |
13621 | "Pointer to route-map entries\n") | |
596c17ba | 13622 | |
7c8ff89e DS |
13623 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13624 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13625 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13626 | "Redistribute information from another routing protocol\n" |
13627 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13628 | "Non-main Kernel Routing Table\n" |
13629 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13630 | "Metric for redistributed routes\n" |
13631 | "Default metric\n") | |
13632 | { | |
d62a17ae | 13633 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13634 | int idx_ospf_table = 1; | |
13635 | int idx_number = 2; | |
13636 | int idx_number_2 = 4; | |
d7c0a89a | 13637 | uint32_t metric; |
d62a17ae | 13638 | struct bgp_redist *red; |
d7c0a89a | 13639 | unsigned short instance; |
d62a17ae | 13640 | int protocol; |
e923dd62 | 13641 | bool changed; |
d62a17ae | 13642 | |
13643 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13644 | protocol = ZEBRA_ROUTE_OSPF; | |
13645 | else | |
13646 | protocol = ZEBRA_ROUTE_TABLE; | |
13647 | ||
13648 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13649 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13650 | ||
13651 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13652 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13653 | metric); | |
13654 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13655 | } |
13656 | ||
13657 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13658 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13659 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13660 | "Redistribute information from another routing protocol\n" | |
13661 | "Open Shortest Path First (OSPFv2)\n" | |
13662 | "Non-main Kernel Routing Table\n" | |
13663 | "Instance ID/Table ID\n" | |
13664 | "Metric for redistributed routes\n" | |
13665 | "Default metric\n") | |
596c17ba | 13666 | |
7c8ff89e DS |
13667 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13668 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13669 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13670 | "Redistribute information from another routing protocol\n" |
13671 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13672 | "Non-main Kernel Routing Table\n" |
13673 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13674 | "Route map reference\n" |
13675 | "Pointer to route-map entries\n" | |
13676 | "Metric for redistributed routes\n" | |
13677 | "Default metric\n") | |
13678 | { | |
d62a17ae | 13679 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13680 | int idx_ospf_table = 1; | |
13681 | int idx_number = 2; | |
13682 | int idx_word = 4; | |
13683 | int idx_number_2 = 6; | |
d7c0a89a | 13684 | uint32_t metric; |
d62a17ae | 13685 | struct bgp_redist *red; |
d7c0a89a | 13686 | unsigned short instance; |
d62a17ae | 13687 | int protocol; |
e923dd62 | 13688 | bool changed; |
1de27621 DA |
13689 | struct route_map *route_map = |
13690 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13691 | |
13692 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13693 | protocol = ZEBRA_ROUTE_OSPF; | |
13694 | else | |
13695 | protocol = ZEBRA_ROUTE_TABLE; | |
13696 | ||
13697 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13698 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13699 | ||
13700 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13701 | changed = |
13702 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13703 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13704 | metric); | |
13705 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13706 | } |
13707 | ||
13708 | ALIAS_HIDDEN( | |
13709 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13710 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13711 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13712 | "Redistribute information from another routing protocol\n" | |
13713 | "Open Shortest Path First (OSPFv2)\n" | |
13714 | "Non-main Kernel Routing Table\n" | |
13715 | "Instance ID/Table ID\n" | |
13716 | "Route map reference\n" | |
13717 | "Pointer to route-map entries\n" | |
13718 | "Metric for redistributed routes\n" | |
13719 | "Default metric\n") | |
596c17ba | 13720 | |
7c8ff89e DS |
13721 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13722 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13723 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13724 | "Redistribute information from another routing protocol\n" |
13725 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13726 | "Non-main Kernel Routing Table\n" |
13727 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13728 | "Metric for redistributed routes\n" |
13729 | "Default metric\n" | |
13730 | "Route map reference\n" | |
13731 | "Pointer to route-map entries\n") | |
13732 | { | |
d62a17ae | 13733 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13734 | int idx_ospf_table = 1; | |
13735 | int idx_number = 2; | |
13736 | int idx_number_2 = 4; | |
13737 | int idx_word = 6; | |
d7c0a89a | 13738 | uint32_t metric; |
d62a17ae | 13739 | struct bgp_redist *red; |
d7c0a89a | 13740 | unsigned short instance; |
d62a17ae | 13741 | int protocol; |
e923dd62 | 13742 | bool changed; |
1de27621 DA |
13743 | struct route_map *route_map = |
13744 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13745 | |
13746 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13747 | protocol = ZEBRA_ROUTE_OSPF; | |
13748 | else | |
13749 | protocol = ZEBRA_ROUTE_TABLE; | |
13750 | ||
13751 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13752 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13753 | ||
13754 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13755 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13756 | metric); | |
1de27621 DA |
13757 | changed |= |
13758 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13759 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13760 | } |
13761 | ||
13762 | ALIAS_HIDDEN( | |
13763 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13764 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13765 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13766 | "Redistribute information from another routing protocol\n" | |
13767 | "Open Shortest Path First (OSPFv2)\n" | |
13768 | "Non-main Kernel Routing Table\n" | |
13769 | "Instance ID/Table ID\n" | |
13770 | "Metric for redistributed routes\n" | |
13771 | "Default metric\n" | |
13772 | "Route map reference\n" | |
13773 | "Pointer to route-map entries\n") | |
596c17ba | 13774 | |
7c8ff89e DS |
13775 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13776 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13777 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13778 | NO_STR |
13779 | "Redistribute information from another routing protocol\n" | |
13780 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13781 | "Non-main Kernel Routing Table\n" |
31500417 DW |
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") | |
7c8ff89e | 13787 | { |
d62a17ae | 13788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13789 | int idx_ospf_table = 2; | |
13790 | int idx_number = 3; | |
d7c0a89a | 13791 | unsigned short instance; |
d62a17ae | 13792 | int protocol; |
13793 | ||
13794 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13795 | protocol = ZEBRA_ROUTE_OSPF; | |
13796 | else | |
13797 | protocol = ZEBRA_ROUTE_TABLE; | |
13798 | ||
13799 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13800 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13801 | } | |
13802 | ||
13803 | ALIAS_HIDDEN( | |
13804 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13805 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13806 | NO_STR |
13807 | "Redistribute information from another routing protocol\n" | |
13808 | "Open Shortest Path First (OSPFv2)\n" | |
13809 | "Non-main Kernel Routing Table\n" | |
13810 | "Instance ID/Table ID\n" | |
13811 | "Metric for redistributed routes\n" | |
13812 | "Default metric\n" | |
13813 | "Route map reference\n" | |
13814 | "Pointer to route-map entries\n") | |
596c17ba | 13815 | |
718e3744 | 13816 | DEFUN (no_bgp_redistribute_ipv4, |
13817 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13818 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13819 | NO_STR |
13820 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13821 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13822 | "Metric for redistributed routes\n" |
13823 | "Default metric\n" | |
13824 | "Route map reference\n" | |
13825 | "Pointer to route-map entries\n") | |
718e3744 | 13826 | { |
d62a17ae | 13827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13828 | int idx_protocol = 2; | |
13829 | int type; | |
13830 | ||
13831 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13832 | if (type < 0) { | |
13833 | vty_out(vty, "%% Invalid route type\n"); | |
13834 | return CMD_WARNING_CONFIG_FAILED; | |
13835 | } | |
13836 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13837 | } | |
13838 | ||
13839 | ALIAS_HIDDEN( | |
13840 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13841 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13842 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13843 | NO_STR |
13844 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13845 | "Metric for redistributed routes\n" | |
13846 | "Default metric\n" | |
13847 | "Route map reference\n" | |
13848 | "Pointer to route-map entries\n") | |
596c17ba | 13849 | |
718e3744 | 13850 | DEFUN (bgp_redistribute_ipv6, |
13851 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 13852 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 13853 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13854 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 13855 | { |
d62a17ae | 13856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13857 | int idx_protocol = 1; | |
13858 | int type; | |
718e3744 | 13859 | |
d62a17ae | 13860 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13861 | if (type < 0) { | |
13862 | vty_out(vty, "%% Invalid route type\n"); | |
13863 | return CMD_WARNING_CONFIG_FAILED; | |
13864 | } | |
718e3744 | 13865 | |
d62a17ae | 13866 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13867 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 13868 | } |
13869 | ||
13870 | DEFUN (bgp_redistribute_ipv6_rmap, | |
13871 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 13872 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13873 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13874 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13875 | "Route map reference\n" |
13876 | "Pointer to route-map entries\n") | |
13877 | { | |
d62a17ae | 13878 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13879 | int idx_protocol = 1; | |
13880 | int idx_word = 3; | |
13881 | int type; | |
13882 | struct bgp_redist *red; | |
e923dd62 | 13883 | bool changed; |
1de27621 DA |
13884 | struct route_map *route_map = |
13885 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 13886 | |
d62a17ae | 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 | } | |
718e3744 | 13892 | |
d62a17ae | 13893 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13894 | changed = |
13895 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13896 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13897 | } |
13898 | ||
13899 | DEFUN (bgp_redistribute_ipv6_metric, | |
13900 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 13901 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13902 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13903 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13904 | "Metric for redistributed routes\n" |
13905 | "Default metric\n") | |
13906 | { | |
d62a17ae | 13907 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13908 | int idx_protocol = 1; | |
13909 | int idx_number = 3; | |
13910 | int type; | |
d7c0a89a | 13911 | uint32_t metric; |
d62a17ae | 13912 | struct bgp_redist *red; |
e923dd62 | 13913 | bool changed; |
d62a17ae | 13914 | |
13915 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13916 | if (type < 0) { | |
13917 | vty_out(vty, "%% Invalid route type\n"); | |
13918 | return CMD_WARNING_CONFIG_FAILED; | |
13919 | } | |
13920 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13921 | |
d62a17ae | 13922 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13923 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
13924 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13925 | } |
13926 | ||
13927 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
13928 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 13929 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13930 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13931 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13932 | "Route map reference\n" |
13933 | "Pointer to route-map entries\n" | |
13934 | "Metric for redistributed routes\n" | |
13935 | "Default metric\n") | |
13936 | { | |
d62a17ae | 13937 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13938 | int idx_protocol = 1; | |
13939 | int idx_word = 3; | |
13940 | int idx_number = 5; | |
13941 | int type; | |
d7c0a89a | 13942 | uint32_t metric; |
d62a17ae | 13943 | struct bgp_redist *red; |
e923dd62 | 13944 | bool changed; |
1de27621 DA |
13945 | struct route_map *route_map = |
13946 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13947 | |
13948 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13949 | if (type < 0) { | |
13950 | vty_out(vty, "%% Invalid route type\n"); | |
13951 | return CMD_WARNING_CONFIG_FAILED; | |
13952 | } | |
13953 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13954 | |
d62a17ae | 13955 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13956 | changed = |
13957 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13958 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
13959 | metric); | |
13960 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 13961 | } |
13962 | ||
13963 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
13964 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 13965 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13966 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13967 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13968 | "Metric for redistributed routes\n" |
13969 | "Default metric\n" | |
13970 | "Route map reference\n" | |
13971 | "Pointer to route-map entries\n") | |
13972 | { | |
d62a17ae | 13973 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13974 | int idx_protocol = 1; | |
13975 | int idx_number = 3; | |
13976 | int idx_word = 5; | |
13977 | int type; | |
d7c0a89a | 13978 | uint32_t metric; |
d62a17ae | 13979 | struct bgp_redist *red; |
e923dd62 | 13980 | bool changed; |
1de27621 DA |
13981 | struct route_map *route_map = |
13982 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13983 | |
13984 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
13985 | if (type < 0) { | |
13986 | vty_out(vty, "%% Invalid route type\n"); | |
13987 | return CMD_WARNING_CONFIG_FAILED; | |
13988 | } | |
13989 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 13990 | |
d62a17ae | 13991 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13992 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
13993 | metric); | |
1de27621 DA |
13994 | changed |= |
13995 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13996 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13997 | } |
13998 | ||
13999 | DEFUN (no_bgp_redistribute_ipv6, | |
14000 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14001 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14002 | NO_STR |
14003 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14004 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14005 | "Metric for redistributed routes\n" |
14006 | "Default metric\n" | |
14007 | "Route map reference\n" | |
14008 | "Pointer to route-map entries\n") | |
718e3744 | 14009 | { |
d62a17ae | 14010 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14011 | int idx_protocol = 2; | |
14012 | int type; | |
718e3744 | 14013 | |
d62a17ae | 14014 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14015 | if (type < 0) { | |
14016 | vty_out(vty, "%% Invalid route type\n"); | |
14017 | return CMD_WARNING_CONFIG_FAILED; | |
14018 | } | |
718e3744 | 14019 | |
d62a17ae | 14020 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14021 | } | |
14022 | ||
dd65f45e DL |
14023 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14024 | afi_t afi, safi_t safi) | |
d62a17ae | 14025 | { |
14026 | int i; | |
14027 | ||
14028 | /* Unicast redistribution only. */ | |
14029 | if (safi != SAFI_UNICAST) | |
2b791107 | 14030 | return; |
d62a17ae | 14031 | |
14032 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14033 | /* Redistribute BGP does not make sense. */ | |
14034 | if (i != ZEBRA_ROUTE_BGP) { | |
14035 | struct list *red_list; | |
14036 | struct listnode *node; | |
14037 | struct bgp_redist *red; | |
14038 | ||
14039 | red_list = bgp->redist[afi][i]; | |
14040 | if (!red_list) | |
14041 | continue; | |
14042 | ||
14043 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14044 | /* "redistribute" configuration. */ |
14045 | vty_out(vty, " redistribute %s", | |
14046 | zebra_route_string(i)); | |
14047 | if (red->instance) | |
14048 | vty_out(vty, " %d", red->instance); | |
14049 | if (red->redist_metric_flag) | |
14050 | vty_out(vty, " metric %u", | |
14051 | red->redist_metric); | |
14052 | if (red->rmap.name) | |
14053 | vty_out(vty, " route-map %s", | |
14054 | red->rmap.name); | |
14055 | vty_out(vty, "\n"); | |
14056 | } | |
14057 | } | |
14058 | } | |
718e3744 | 14059 | } |
6b0655a2 | 14060 | |
dd65f45e DL |
14061 | /* peer-group helpers for config-write */ |
14062 | ||
14063 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14064 | { | |
14065 | if (!peer_group_active(peer)) { | |
14066 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14067 | return !CHECK_FLAG(peer->flags, flag); | |
14068 | else | |
14069 | return !!CHECK_FLAG(peer->flags, flag); | |
14070 | } | |
14071 | ||
14072 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14073 | } | |
14074 | ||
14075 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14076 | uint32_t flag) | |
14077 | { | |
14078 | if (!peer_group_active(peer)) { | |
14079 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14080 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14081 | else | |
14082 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14083 | } | |
14084 | ||
14085 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14086 | } | |
14087 | ||
14088 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14089 | uint8_t type, int direct) | |
14090 | { | |
14091 | struct bgp_filter *filter; | |
14092 | ||
14093 | if (peer_group_active(peer)) | |
14094 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14095 | type); | |
14096 | ||
14097 | filter = &peer->filter[afi][safi]; | |
14098 | switch (type) { | |
14099 | case PEER_FT_DISTRIBUTE_LIST: | |
14100 | return !!(filter->dlist[direct].name); | |
14101 | case PEER_FT_FILTER_LIST: | |
14102 | return !!(filter->aslist[direct].name); | |
14103 | case PEER_FT_PREFIX_LIST: | |
14104 | return !!(filter->plist[direct].name); | |
14105 | case PEER_FT_ROUTE_MAP: | |
14106 | return !!(filter->map[direct].name); | |
14107 | case PEER_FT_UNSUPPRESS_MAP: | |
14108 | return !!(filter->usmap.name); | |
14109 | default: | |
14110 | return false; | |
14111 | } | |
14112 | } | |
14113 | ||
14114 | /* Return true if the addpath type is set for peer and different from | |
14115 | * peer-group. | |
14116 | */ | |
3dc339cd DA |
14117 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
14118 | safi_t safi) | |
dd65f45e DL |
14119 | { |
14120 | enum bgp_addpath_strat type, g_type; | |
14121 | ||
14122 | type = peer->addpath_type[afi][safi]; | |
14123 | ||
14124 | if (type != BGP_ADDPATH_NONE) { | |
14125 | if (peer_group_active(peer)) { | |
14126 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14127 | ||
14128 | if (type != g_type) | |
3dc339cd | 14129 | return true; |
dd65f45e | 14130 | else |
3dc339cd | 14131 | return false; |
dd65f45e DL |
14132 | } |
14133 | ||
3dc339cd | 14134 | return true; |
dd65f45e DL |
14135 | } |
14136 | ||
3dc339cd | 14137 | return false; |
dd65f45e DL |
14138 | } |
14139 | ||
b9c7bc5a | 14140 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14141 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14142 | afi_t afi) |
14143 | { | |
b9c7bc5a | 14144 | int indent = 2; |
ddb5b488 | 14145 | |
8a066a70 | 14146 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
14147 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14148 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
14149 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
14150 | bgp->vpn_policy[afi] | |
bb4f6190 | 14151 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14152 | else |
14153 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14154 | bgp->vpn_policy[afi] | |
14155 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14156 | } | |
12a844a5 DS |
14157 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14158 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14159 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14160 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14161 | return; | |
14162 | ||
e70e9f8e PZ |
14163 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14164 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14165 | ||
14166 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14167 | ||
14168 | } else { | |
14169 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14170 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14171 | bgp->vpn_policy[afi].tovpn_label); | |
14172 | } | |
ddb5b488 PZ |
14173 | } |
14174 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14175 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14176 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14177 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14178 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14179 | sizeof(buf))); | |
14180 | } | |
14181 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14182 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14183 | ||
14184 | char buf[PREFIX_STRLEN]; | |
14185 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14186 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14187 | sizeof(buf))) { | |
14188 | ||
b9c7bc5a PZ |
14189 | vty_out(vty, "%*snexthop vpn export %s\n", |
14190 | indent, "", buf); | |
ddb5b488 PZ |
14191 | } |
14192 | } | |
14193 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14194 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14195 | && ecommunity_cmp( | |
14196 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14197 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14198 | ||
14199 | char *b = ecommunity_ecom2str( | |
14200 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14201 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14202 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14203 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14204 | } else { | |
14205 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14206 | char *b = ecommunity_ecom2str( | |
14207 | bgp->vpn_policy[afi] | |
14208 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14209 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14210 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14211 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14212 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14213 | } | |
14214 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14215 | char *b = ecommunity_ecom2str( | |
14216 | bgp->vpn_policy[afi] | |
14217 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14218 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14219 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14220 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14221 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14222 | } | |
14223 | } | |
bb4f6190 DS |
14224 | |
14225 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14226 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14227 | bgp->vpn_policy[afi] |
14228 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14229 | |
301ad80a PG |
14230 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14231 | char *b = ecommunity_ecom2str( | |
14232 | bgp->vpn_policy[afi] | |
14233 | .import_redirect_rtlist, | |
14234 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14235 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14236 | |
301ad80a PG |
14237 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14238 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14239 | } | |
ddb5b488 PZ |
14240 | } |
14241 | ||
dd65f45e DL |
14242 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14243 | afi_t afi, safi_t safi) | |
14244 | { | |
14245 | struct bgp_filter *filter; | |
14246 | char *addr; | |
14247 | ||
14248 | addr = peer->host; | |
14249 | filter = &peer->filter[afi][safi]; | |
14250 | ||
14251 | /* distribute-list. */ | |
14252 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14253 | FILTER_IN)) | |
14254 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14255 | filter->dlist[FILTER_IN].name); | |
14256 | ||
14257 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14258 | FILTER_OUT)) | |
14259 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14260 | filter->dlist[FILTER_OUT].name); | |
14261 | ||
14262 | /* prefix-list. */ | |
14263 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14264 | FILTER_IN)) | |
14265 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14266 | filter->plist[FILTER_IN].name); | |
14267 | ||
14268 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14269 | FILTER_OUT)) | |
14270 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14271 | filter->plist[FILTER_OUT].name); | |
14272 | ||
14273 | /* route-map. */ | |
14274 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14275 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14276 | filter->map[RMAP_IN].name); | |
14277 | ||
14278 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14279 | RMAP_OUT)) | |
14280 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14281 | filter->map[RMAP_OUT].name); | |
14282 | ||
14283 | /* unsuppress-map */ | |
14284 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14285 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14286 | filter->usmap.name); | |
14287 | ||
14288 | /* filter-list. */ | |
14289 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14290 | FILTER_IN)) | |
14291 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14292 | filter->aslist[FILTER_IN].name); | |
14293 | ||
14294 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14295 | FILTER_OUT)) | |
14296 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14297 | filter->aslist[FILTER_OUT].name); | |
14298 | } | |
14299 | ||
14300 | /* BGP peer configuration display function. */ | |
14301 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14302 | struct peer *peer) | |
14303 | { | |
14304 | struct peer *g_peer = NULL; | |
14305 | char buf[SU_ADDRSTRLEN]; | |
14306 | char *addr; | |
14307 | int if_pg_printed = false; | |
14308 | int if_ras_printed = false; | |
14309 | ||
14310 | /* Skip dynamic neighbors. */ | |
14311 | if (peer_dynamic_neighbor(peer)) | |
14312 | return; | |
14313 | ||
14314 | if (peer->conf_if) | |
14315 | addr = peer->conf_if; | |
14316 | else | |
14317 | addr = peer->host; | |
14318 | ||
14319 | /************************************ | |
14320 | ****** Global to the neighbor ****** | |
14321 | ************************************/ | |
14322 | if (peer->conf_if) { | |
14323 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14324 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14325 | else | |
14326 | vty_out(vty, " neighbor %s interface", addr); | |
14327 | ||
14328 | if (peer_group_active(peer)) { | |
14329 | vty_out(vty, " peer-group %s", peer->group->name); | |
14330 | if_pg_printed = true; | |
14331 | } else if (peer->as_type == AS_SPECIFIED) { | |
14332 | vty_out(vty, " remote-as %u", peer->as); | |
14333 | if_ras_printed = true; | |
14334 | } else if (peer->as_type == AS_INTERNAL) { | |
14335 | vty_out(vty, " remote-as internal"); | |
14336 | if_ras_printed = true; | |
14337 | } else if (peer->as_type == AS_EXTERNAL) { | |
14338 | vty_out(vty, " remote-as external"); | |
14339 | if_ras_printed = true; | |
14340 | } | |
14341 | ||
14342 | vty_out(vty, "\n"); | |
14343 | } | |
14344 | ||
14345 | /* remote-as and peer-group */ | |
14346 | /* peer is a member of a peer-group */ | |
14347 | if (peer_group_active(peer)) { | |
14348 | g_peer = peer->group->conf; | |
14349 | ||
14350 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14351 | if (peer->as_type == AS_SPECIFIED) { | |
14352 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14353 | addr, peer->as); | |
14354 | } else if (peer->as_type == AS_INTERNAL) { | |
14355 | vty_out(vty, | |
14356 | " neighbor %s remote-as internal\n", | |
14357 | addr); | |
14358 | } else if (peer->as_type == AS_EXTERNAL) { | |
14359 | vty_out(vty, | |
14360 | " neighbor %s remote-as external\n", | |
14361 | addr); | |
14362 | } | |
14363 | } | |
14364 | ||
14365 | /* For swpX peers we displayed the peer-group | |
14366 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14367 | if (!if_pg_printed) | |
14368 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14369 | peer->group->name); | |
14370 | } | |
14371 | ||
14372 | /* peer is NOT a member of a peer-group */ | |
14373 | else { | |
14374 | /* peer is a peer-group, declare the peer-group */ | |
14375 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14376 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14377 | } | |
14378 | ||
14379 | if (!if_ras_printed) { | |
14380 | if (peer->as_type == AS_SPECIFIED) { | |
14381 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14382 | addr, peer->as); | |
14383 | } else if (peer->as_type == AS_INTERNAL) { | |
14384 | vty_out(vty, | |
14385 | " neighbor %s remote-as internal\n", | |
14386 | addr); | |
14387 | } else if (peer->as_type == AS_EXTERNAL) { | |
14388 | vty_out(vty, | |
14389 | " neighbor %s remote-as external\n", | |
14390 | addr); | |
14391 | } | |
14392 | } | |
14393 | } | |
14394 | ||
14395 | /* local-as */ | |
14396 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14397 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14398 | peer->change_local_as); | |
14399 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14400 | vty_out(vty, " no-prepend"); | |
14401 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14402 | vty_out(vty, " replace-as"); | |
14403 | vty_out(vty, "\n"); | |
14404 | } | |
14405 | ||
14406 | /* description */ | |
14407 | if (peer->desc) { | |
14408 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14409 | } | |
14410 | ||
14411 | /* shutdown */ | |
14412 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14413 | if (peer->tx_shutdown_message) | |
14414 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14415 | peer->tx_shutdown_message); | |
14416 | else | |
14417 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14418 | } | |
14419 | ||
14420 | /* bfd */ | |
14421 | if (peer->bfd_info) { | |
14422 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14423 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14424 | } | |
14425 | } | |
14426 | ||
14427 | /* password */ | |
14428 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14429 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14430 | peer->password); | |
14431 | ||
14432 | /* neighbor solo */ | |
14433 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14434 | if (!peer_group_active(peer)) { | |
14435 | vty_out(vty, " neighbor %s solo\n", addr); | |
14436 | } | |
14437 | } | |
14438 | ||
14439 | /* BGP port */ | |
14440 | if (peer->port != BGP_PORT_DEFAULT) { | |
14441 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14442 | } | |
14443 | ||
14444 | /* Local interface name */ | |
14445 | if (peer->ifname) { | |
14446 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14447 | } | |
14448 | ||
14449 | /* passive */ | |
14450 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14451 | vty_out(vty, " neighbor %s passive\n", addr); | |
14452 | ||
14453 | /* ebgp-multihop */ | |
14454 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14455 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14456 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14457 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14458 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14459 | peer->ttl); | |
14460 | } | |
14461 | } | |
14462 | ||
14463 | /* ttl-security hops */ | |
e2521429 | 14464 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14465 | if (!peer_group_active(peer) |
14466 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14467 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14468 | addr, peer->gtsm_hops); | |
14469 | } | |
14470 | } | |
14471 | ||
14472 | /* disable-connected-check */ | |
14473 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14474 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14475 | ||
14476 | /* enforce-first-as */ | |
14477 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14478 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14479 | ||
14480 | /* update-source */ | |
14481 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14482 | if (peer->update_source) | |
14483 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14484 | sockunion2str(peer->update_source, buf, | |
14485 | SU_ADDRSTRLEN)); | |
14486 | else if (peer->update_if) | |
14487 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14488 | peer->update_if); | |
14489 | } | |
14490 | ||
14491 | /* advertisement-interval */ | |
14492 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14493 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14494 | peer->routeadv); | |
14495 | ||
14496 | /* timers */ | |
14497 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14498 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14499 | peer->keepalive, peer->holdtime); | |
14500 | ||
14501 | /* timers connect */ | |
14502 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14503 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14504 | peer->connect); | |
5d5393b9 DL |
14505 | /* need special-case handling for changed default values due to |
14506 | * config profile / version (because there is no "timers bgp connect" | |
14507 | * command, we need to save this per-peer :/) | |
14508 | */ | |
14509 | else if (!peer_group_active(peer) && !peer->connect && | |
14510 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14511 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14512 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14513 | |
14514 | /* capability dynamic */ | |
14515 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14516 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14517 | ||
14518 | /* capability extended-nexthop */ | |
14519 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14520 | if (!peer->conf_if) { | |
14521 | if (CHECK_FLAG(peer->flags_invert, | |
14522 | PEER_FLAG_CAPABILITY_ENHE)) | |
14523 | vty_out(vty, | |
14524 | " no neighbor %s capability extended-nexthop\n", | |
14525 | addr); | |
14526 | else | |
14527 | vty_out(vty, | |
14528 | " neighbor %s capability extended-nexthop\n", | |
14529 | addr); | |
14530 | } | |
14531 | } | |
14532 | ||
14533 | /* dont-capability-negotiation */ | |
14534 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14535 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14536 | ||
14537 | /* override-capability */ | |
14538 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14539 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14540 | ||
14541 | /* strict-capability-match */ | |
14542 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14543 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14544 | ||
14545 | /* Sender side AS path loop detection. */ | |
14546 | if (peer->as_path_loop_detection) | |
14547 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14548 | addr); | |
cfd47646 | 14549 | |
14550 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14551 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14552 | |
14553 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14554 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14555 | vty_out(vty, |
14556 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14557 | } else if (CHECK_FLAG( |
14558 | peer->peer_gr_new_status_flag, | |
14559 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14560 | vty_out(vty, |
14561 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14562 | } else if ( |
14563 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14564 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14565 | && !(CHECK_FLAG( | |
14566 | peer->peer_gr_new_status_flag, | |
14567 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14568 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14569 | addr); | |
cfd47646 | 14570 | } |
14571 | } | |
dd65f45e DL |
14572 | } |
14573 | ||
14574 | /* BGP peer configuration display function. */ | |
14575 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14576 | struct peer *peer, afi_t afi, safi_t safi) | |
14577 | { | |
14578 | struct peer *g_peer = NULL; | |
14579 | char *addr; | |
14580 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14581 | ||
14582 | /* Skip dynamic neighbors. */ | |
14583 | if (peer_dynamic_neighbor(peer)) | |
14584 | return; | |
14585 | ||
14586 | if (peer->conf_if) | |
14587 | addr = peer->conf_if; | |
14588 | else | |
14589 | addr = peer->host; | |
14590 | ||
14591 | /************************************ | |
14592 | ****** Per AF to the neighbor ****** | |
14593 | ************************************/ | |
14594 | if (peer_group_active(peer)) { | |
14595 | g_peer = peer->group->conf; | |
14596 | ||
14597 | /* If the peer-group is active but peer is not, print a 'no | |
14598 | * activate' */ | |
14599 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14600 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14601 | } | |
14602 | ||
14603 | /* If the peer-group is not active but peer is, print an | |
14604 | 'activate' */ | |
14605 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14606 | vty_out(vty, " neighbor %s activate\n", addr); | |
14607 | } | |
14608 | } else { | |
14609 | if (peer->afc[afi][safi]) { | |
14610 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14611 | if (CHECK_FLAG(bgp->flags, |
14612 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14613 | vty_out(vty, " neighbor %s activate\n", |
14614 | addr); | |
14615 | } | |
14616 | } else | |
14617 | vty_out(vty, " neighbor %s activate\n", addr); | |
14618 | } else { | |
14619 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14620 | if (!CHECK_FLAG(bgp->flags, |
14621 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14622 | vty_out(vty, |
14623 | " no neighbor %s activate\n", | |
14624 | addr); | |
14625 | } | |
14626 | } | |
14627 | } | |
14628 | } | |
14629 | ||
14630 | /* addpath TX knobs */ | |
14631 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14632 | switch (peer->addpath_type[afi][safi]) { | |
14633 | case BGP_ADDPATH_ALL: | |
14634 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14635 | addr); | |
14636 | break; | |
14637 | case BGP_ADDPATH_BEST_PER_AS: | |
14638 | vty_out(vty, | |
14639 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14640 | addr); | |
14641 | break; | |
14642 | case BGP_ADDPATH_MAX: | |
14643 | case BGP_ADDPATH_NONE: | |
14644 | break; | |
14645 | } | |
14646 | } | |
14647 | ||
14648 | /* ORF capability. */ | |
14649 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14650 | || peergroup_af_flag_check(peer, afi, safi, | |
14651 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14652 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14653 | ||
14654 | if (peergroup_af_flag_check(peer, afi, safi, | |
14655 | PEER_FLAG_ORF_PREFIX_SM) | |
14656 | && peergroup_af_flag_check(peer, afi, safi, | |
14657 | PEER_FLAG_ORF_PREFIX_RM)) | |
14658 | vty_out(vty, " both"); | |
14659 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14660 | PEER_FLAG_ORF_PREFIX_SM)) | |
14661 | vty_out(vty, " send"); | |
14662 | else | |
14663 | vty_out(vty, " receive"); | |
14664 | vty_out(vty, "\n"); | |
14665 | } | |
14666 | ||
14667 | /* BGP flag dampening. */ | |
14668 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14669 | BGP_CONFIG_DAMPENING)) | |
14670 | bgp_config_write_damp(vty, afi, safi); | |
14671 | ||
14672 | /* Route reflector client. */ | |
14673 | if (peergroup_af_flag_check(peer, afi, safi, | |
14674 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14675 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14676 | } | |
14677 | ||
14678 | /* next-hop-self force */ | |
14679 | if (peergroup_af_flag_check(peer, afi, safi, | |
14680 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14681 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14682 | } | |
14683 | ||
14684 | /* next-hop-self */ | |
14685 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14686 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14687 | } | |
14688 | ||
14689 | /* remove-private-AS */ | |
14690 | if (peergroup_af_flag_check(peer, afi, safi, | |
14691 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14692 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14693 | addr); | |
14694 | } | |
14695 | ||
14696 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14697 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14698 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14699 | addr); | |
14700 | } | |
14701 | ||
14702 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14703 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14704 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14705 | } | |
14706 | ||
14707 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14708 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14709 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14710 | } | |
14711 | ||
14712 | /* as-override */ | |
14713 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14714 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14715 | } | |
14716 | ||
14717 | /* send-community print. */ | |
14718 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14719 | PEER_FLAG_SEND_COMMUNITY); | |
14720 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14721 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14722 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14723 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14724 | ||
14725 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14726 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14727 | } else { | |
14728 | if (flag_scomm) | |
14729 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14730 | if (flag_secomm) | |
14731 | vty_out(vty, | |
14732 | " no neighbor %s send-community extended\n", | |
14733 | addr); | |
14734 | ||
14735 | if (flag_slcomm) | |
14736 | vty_out(vty, " no neighbor %s send-community large\n", | |
14737 | addr); | |
14738 | } | |
14739 | ||
14740 | /* Default information */ | |
14741 | if (peergroup_af_flag_check(peer, afi, safi, | |
14742 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14743 | vty_out(vty, " neighbor %s default-originate", addr); | |
14744 | ||
14745 | if (peer->default_rmap[afi][safi].name) | |
14746 | vty_out(vty, " route-map %s", | |
14747 | peer->default_rmap[afi][safi].name); | |
14748 | ||
14749 | vty_out(vty, "\n"); | |
14750 | } | |
14751 | ||
14752 | /* Soft reconfiguration inbound. */ | |
14753 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14754 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14755 | addr); | |
14756 | } | |
14757 | ||
14758 | /* maximum-prefix. */ | |
14759 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14760 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14761 | peer->pmax[afi][safi]); | |
14762 | ||
14763 | if (peer->pmax_threshold[afi][safi] | |
14764 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14765 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14766 | if (peer_af_flag_check(peer, afi, safi, | |
14767 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14768 | vty_out(vty, " warning-only"); | |
14769 | if (peer->pmax_restart[afi][safi]) | |
14770 | vty_out(vty, " restart %u", | |
14771 | peer->pmax_restart[afi][safi]); | |
14772 | ||
14773 | vty_out(vty, "\n"); | |
14774 | } | |
14775 | ||
fde246e8 DA |
14776 | /* maximum-prefix-out */ |
14777 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14778 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14779 | addr, peer->pmax_out[afi][safi]); | |
14780 | ||
dd65f45e DL |
14781 | /* Route server client. */ |
14782 | if (peergroup_af_flag_check(peer, afi, safi, | |
14783 | PEER_FLAG_RSERVER_CLIENT)) { | |
14784 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14785 | } | |
14786 | ||
14787 | /* Nexthop-local unchanged. */ | |
14788 | if (peergroup_af_flag_check(peer, afi, safi, | |
14789 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14790 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14791 | } | |
14792 | ||
14793 | /* allowas-in <1-10> */ | |
14794 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14795 | if (peer_af_flag_check(peer, afi, safi, | |
14796 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14797 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14798 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14799 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14800 | } else { | |
14801 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14802 | peer->allowas_in[afi][safi]); | |
14803 | } | |
14804 | } | |
14805 | ||
14806 | /* weight */ | |
14807 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14808 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14809 | peer->weight[afi][safi]); | |
14810 | ||
14811 | /* Filter. */ | |
14812 | bgp_config_write_filter(vty, peer, afi, safi); | |
14813 | ||
14814 | /* atribute-unchanged. */ | |
14815 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14816 | || (safi != SAFI_EVPN | |
14817 | && peer_af_flag_check(peer, afi, safi, | |
14818 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14819 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14820 | ||
14821 | if (!peer_group_active(peer) | |
14822 | || peergroup_af_flag_check(peer, afi, safi, | |
14823 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14824 | || peergroup_af_flag_check(peer, afi, safi, | |
14825 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14826 | || peergroup_af_flag_check(peer, afi, safi, | |
14827 | PEER_FLAG_MED_UNCHANGED)) { | |
14828 | ||
14829 | vty_out(vty, | |
14830 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14831 | addr, | |
14832 | peer_af_flag_check(peer, afi, safi, | |
14833 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14834 | ? " as-path" | |
14835 | : "", | |
14836 | peer_af_flag_check(peer, afi, safi, | |
14837 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14838 | ? " next-hop" | |
14839 | : "", | |
14840 | peer_af_flag_check(peer, afi, safi, | |
14841 | PEER_FLAG_MED_UNCHANGED) | |
14842 | ? " med" | |
14843 | : ""); | |
14844 | } | |
14845 | } | |
14846 | } | |
14847 | ||
14848 | /* Address family based peer configuration display. */ | |
14849 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14850 | safi_t safi) | |
14851 | { | |
14852 | struct peer *peer; | |
14853 | struct peer_group *group; | |
14854 | struct listnode *node, *nnode; | |
14855 | ||
14856 | ||
14857 | vty_frame(vty, " !\n address-family "); | |
14858 | if (afi == AFI_IP) { | |
14859 | if (safi == SAFI_UNICAST) | |
14860 | vty_frame(vty, "ipv4 unicast"); | |
14861 | else if (safi == SAFI_LABELED_UNICAST) | |
14862 | vty_frame(vty, "ipv4 labeled-unicast"); | |
14863 | else if (safi == SAFI_MULTICAST) | |
14864 | vty_frame(vty, "ipv4 multicast"); | |
14865 | else if (safi == SAFI_MPLS_VPN) | |
14866 | vty_frame(vty, "ipv4 vpn"); | |
14867 | else if (safi == SAFI_ENCAP) | |
14868 | vty_frame(vty, "ipv4 encap"); | |
14869 | else if (safi == SAFI_FLOWSPEC) | |
14870 | vty_frame(vty, "ipv4 flowspec"); | |
14871 | } else if (afi == AFI_IP6) { | |
14872 | if (safi == SAFI_UNICAST) | |
14873 | vty_frame(vty, "ipv6 unicast"); | |
14874 | else if (safi == SAFI_LABELED_UNICAST) | |
14875 | vty_frame(vty, "ipv6 labeled-unicast"); | |
14876 | else if (safi == SAFI_MULTICAST) | |
14877 | vty_frame(vty, "ipv6 multicast"); | |
14878 | else if (safi == SAFI_MPLS_VPN) | |
14879 | vty_frame(vty, "ipv6 vpn"); | |
14880 | else if (safi == SAFI_ENCAP) | |
14881 | vty_frame(vty, "ipv6 encap"); | |
14882 | else if (safi == SAFI_FLOWSPEC) | |
14883 | vty_frame(vty, "ipv6 flowspec"); | |
14884 | } else if (afi == AFI_L2VPN) { | |
14885 | if (safi == SAFI_EVPN) | |
14886 | vty_frame(vty, "l2vpn evpn"); | |
14887 | } | |
14888 | vty_frame(vty, "\n"); | |
14889 | ||
14890 | bgp_config_write_distance(vty, bgp, afi, safi); | |
14891 | ||
14892 | bgp_config_write_network(vty, bgp, afi, safi); | |
14893 | ||
14894 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
14895 | ||
14896 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
14897 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
14898 | ||
14899 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14900 | /* Skip dynamic neighbors. */ | |
14901 | if (peer_dynamic_neighbor(peer)) | |
14902 | continue; | |
14903 | ||
14904 | /* Do not display doppelganger peers */ | |
14905 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14906 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
14907 | } | |
14908 | ||
14909 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
14910 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
14911 | ||
14912 | if (safi == SAFI_EVPN) | |
14913 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
14914 | ||
14915 | if (safi == SAFI_FLOWSPEC) | |
14916 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
14917 | ||
14918 | if (safi == SAFI_UNICAST) { | |
14919 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
14920 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14921 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
14922 | ||
14923 | vty_out(vty, " export vpn\n"); | |
14924 | } | |
14925 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14926 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
14927 | ||
14928 | vty_out(vty, " import vpn\n"); | |
14929 | } | |
14930 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14931 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14932 | char *name; | |
14933 | ||
14934 | for (ALL_LIST_ELEMENTS_RO( | |
14935 | bgp->vpn_policy[afi].import_vrf, node, | |
14936 | name)) | |
14937 | vty_out(vty, " import vrf %s\n", name); | |
14938 | } | |
14939 | } | |
14940 | ||
14941 | vty_endframe(vty, " exit-address-family\n"); | |
14942 | } | |
14943 | ||
14944 | int bgp_config_write(struct vty *vty) | |
14945 | { | |
14946 | struct bgp *bgp; | |
14947 | struct peer_group *group; | |
14948 | struct peer *peer; | |
14949 | struct listnode *node, *nnode; | |
14950 | struct listnode *mnode, *mnnode; | |
14951 | ||
14952 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
14953 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
14954 | bm->rmap_update_timer); | |
14955 | ||
14956 | /* BGP configuration. */ | |
14957 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
14958 | ||
14959 | /* skip all auto created vrf as they dont have user config */ | |
14960 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
14961 | continue; | |
14962 | ||
14963 | /* Router bgp ASN */ | |
14964 | vty_out(vty, "router bgp %u", bgp->as); | |
14965 | ||
14966 | if (bgp->name) | |
14967 | vty_out(vty, " %s %s", | |
14968 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
14969 | ? "view" : "vrf", bgp->name); | |
14970 | vty_out(vty, "\n"); | |
14971 | ||
14972 | /* BGP fast-external-failover. */ | |
14973 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
14974 | vty_out(vty, " no bgp fast-external-failover\n"); | |
14975 | ||
14976 | /* BGP router ID. */ | |
14977 | if (bgp->router_id_static.s_addr != 0) | |
14978 | vty_out(vty, " bgp router-id %s\n", | |
14979 | inet_ntoa(bgp->router_id_static)); | |
14980 | ||
14981 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 14982 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 14983 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 14984 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
14985 | CHECK_FLAG(bgp->flags, |
14986 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
14987 | ? "" |
14988 | : "no "); | |
14989 | ||
14990 | /* BGP configuration. */ | |
892fedb6 | 14991 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
14992 | vty_out(vty, " bgp always-compare-med\n"); |
14993 | ||
14994 | /* RFC8212 default eBGP policy. */ | |
14995 | if (bgp->ebgp_requires_policy | |
14996 | == DEFAULT_EBGP_POLICY_ENABLED) | |
14997 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
14998 | ||
14999 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
15000 | if (bgp->reject_as_sets == BGP_REJECT_AS_SETS_ENABLED) | |
15001 | vty_out(vty, " bgp reject-as-sets\n"); | |
15002 | ||
15003 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 15004 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
15005 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
15006 | ||
15007 | /* BGP default local-preference. */ | |
15008 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15009 | vty_out(vty, " bgp default local-preference %u\n", | |
15010 | bgp->default_local_pref); | |
15011 | ||
15012 | /* BGP default show-hostname */ | |
892fedb6 | 15013 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 15014 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 15015 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 15016 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
15017 | ? "" |
15018 | : "no "); | |
15019 | ||
15020 | /* BGP default subgroup-pkt-queue-max. */ | |
15021 | if (bgp->default_subgroup_pkt_queue_max | |
15022 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15023 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15024 | bgp->default_subgroup_pkt_queue_max); | |
15025 | ||
15026 | /* BGP client-to-client reflection. */ | |
892fedb6 | 15027 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
15028 | vty_out(vty, " no bgp client-to-client reflection\n"); |
15029 | ||
15030 | /* BGP cluster ID. */ | |
15031 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15032 | vty_out(vty, " bgp cluster-id %s\n", | |
15033 | inet_ntoa(bgp->cluster_id)); | |
15034 | ||
15035 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15036 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15037 | vty_out(vty, |
15038 | " bgp disable-ebgp-connected-route-check\n"); | |
15039 | ||
15040 | /* Confederation identifier*/ | |
15041 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15042 | vty_out(vty, " bgp confederation identifier %u\n", | |
15043 | bgp->confed_id); | |
15044 | ||
15045 | /* Confederation peer */ | |
15046 | if (bgp->confed_peers_cnt > 0) { | |
15047 | int i; | |
15048 | ||
15049 | vty_out(vty, " bgp confederation peers"); | |
15050 | ||
15051 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15052 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15053 | ||
15054 | vty_out(vty, "\n"); | |
15055 | } | |
15056 | ||
15057 | /* BGP deterministic-med. */ | |
892fedb6 | 15058 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15059 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15060 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15061 | CHECK_FLAG(bgp->flags, |
15062 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15063 | ? "" |
15064 | : "no "); | |
15065 | ||
15066 | /* BGP update-delay. */ | |
15067 | bgp_config_write_update_delay(vty, bgp); | |
15068 | ||
15069 | if (bgp->v_maxmed_onstartup | |
15070 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15071 | vty_out(vty, " bgp max-med on-startup %u", | |
15072 | bgp->v_maxmed_onstartup); | |
15073 | if (bgp->maxmed_onstartup_value | |
15074 | != BGP_MAXMED_VALUE_DEFAULT) | |
15075 | vty_out(vty, " %u", | |
15076 | bgp->maxmed_onstartup_value); | |
15077 | vty_out(vty, "\n"); | |
15078 | } | |
15079 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15080 | vty_out(vty, " bgp max-med administrative"); | |
15081 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15082 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15083 | vty_out(vty, "\n"); | |
15084 | } | |
15085 | ||
15086 | /* write quanta */ | |
15087 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15088 | /* read quanta */ | |
15089 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15090 | ||
15091 | /* coalesce time */ | |
15092 | bgp_config_write_coalesce_time(vty, bgp); | |
15093 | ||
15094 | /* BGP graceful-restart. */ | |
15095 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15096 | vty_out(vty, | |
15097 | " bgp graceful-restart stalepath-time %u\n", | |
15098 | bgp->stalepath_time); | |
cfd47646 | 15099 | |
dd65f45e DL |
15100 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15101 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15102 | bgp->restart_time); | |
cfd47646 | 15103 | |
15104 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15105 | vty_out(vty, | |
15106 | " bgp graceful-restart select-defer-time %u\n", | |
15107 | bgp->select_defer_time); | |
15108 | ||
15109 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15110 | vty_out(vty, " bgp graceful-restart\n"); |
15111 | ||
cfd47646 | 15112 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15113 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15114 | ||
dd65f45e | 15115 | /* BGP graceful-shutdown */ |
892fedb6 | 15116 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15117 | vty_out(vty, " bgp graceful-shutdown\n"); |
15118 | ||
15119 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15120 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15121 | vty_out(vty, |
15122 | " bgp graceful-restart preserve-fw-state\n"); | |
15123 | ||
dc95985f | 15124 | /* Stale timer for RIB */ |
15125 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15126 | vty_out(vty, | |
15127 | " bgp graceful-restart rib-stale-time %u\n", | |
15128 | bgp->rib_stale_time); | |
15129 | ||
dd65f45e | 15130 | /* BGP bestpath method. */ |
892fedb6 | 15131 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15132 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15133 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15134 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15135 | ||
892fedb6 DA |
15136 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15137 | if (CHECK_FLAG(bgp->flags, | |
15138 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15139 | vty_out(vty, |
15140 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15141 | } else { | |
15142 | vty_out(vty, | |
15143 | " bgp bestpath as-path multipath-relax\n"); | |
15144 | } | |
15145 | } | |
15146 | ||
892fedb6 | 15147 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15148 | vty_out(vty, |
15149 | " bgp route-reflector allow-outbound-policy\n"); | |
15150 | } | |
892fedb6 | 15151 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15152 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15153 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15154 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15155 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15156 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15157 | vty_out(vty, " confed"); |
892fedb6 DA |
15158 | if (CHECK_FLAG(bgp->flags, |
15159 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15160 | vty_out(vty, " missing-as-worst"); |
15161 | vty_out(vty, "\n"); | |
15162 | } | |
15163 | ||
15164 | /* BGP network import check. */ | |
892fedb6 | 15165 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15166 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15167 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15168 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15169 | ? "" |
15170 | : "no "); | |
15171 | ||
15172 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15173 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15174 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15175 | vty_out(vty, " timers bgp %u %u\n", |
15176 | bgp->default_keepalive, bgp->default_holdtime); | |
15177 | ||
15178 | /* peer-group */ | |
15179 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15180 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15181 | } | |
15182 | ||
15183 | /* Normal neighbor configuration. */ | |
15184 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15185 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15186 | bgp_config_write_peer_global(vty, bgp, peer); | |
15187 | } | |
15188 | ||
15189 | /* listen range and limit for dynamic BGP neighbors */ | |
15190 | bgp_config_write_listen(vty, bgp); | |
15191 | ||
15192 | /* | |
15193 | * BGP default autoshutdown neighbors | |
15194 | * | |
15195 | * This must be placed after any peer and peer-group | |
15196 | * configuration, to avoid setting all peers to shutdown after | |
15197 | * a daemon restart, which is undesired behavior. (see #2286) | |
15198 | */ | |
15199 | if (bgp->autoshutdown) | |
15200 | vty_out(vty, " bgp default shutdown\n"); | |
15201 | ||
15202 | /* IPv4 unicast configuration. */ | |
15203 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15204 | ||
15205 | /* IPv4 multicast configuration. */ | |
15206 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15207 | ||
15208 | /* IPv4 labeled-unicast configuration. */ | |
15209 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15210 | ||
15211 | /* IPv4 VPN configuration. */ | |
15212 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15213 | ||
15214 | /* ENCAPv4 configuration. */ | |
15215 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15216 | ||
15217 | /* FLOWSPEC v4 configuration. */ | |
15218 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15219 | ||
15220 | /* IPv6 unicast configuration. */ | |
15221 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15222 | ||
15223 | /* IPv6 multicast configuration. */ | |
15224 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15225 | ||
15226 | /* IPv6 labeled-unicast configuration. */ | |
15227 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15228 | SAFI_LABELED_UNICAST); | |
15229 | ||
15230 | /* IPv6 VPN configuration. */ | |
15231 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15232 | ||
15233 | /* ENCAPv6 configuration. */ | |
15234 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15235 | ||
15236 | /* FLOWSPEC v6 configuration. */ | |
15237 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15238 | ||
15239 | /* EVPN configuration. */ | |
15240 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15241 | ||
15242 | hook_call(bgp_inst_config_write, bgp, vty); | |
15243 | ||
15244 | #if ENABLE_BGP_VNC | |
15245 | bgp_rfapi_cfg_write(vty, bgp); | |
15246 | #endif | |
15247 | ||
15248 | vty_out(vty, "!\n"); | |
15249 | } | |
15250 | return 0; | |
15251 | } | |
15252 | ||
ddb5b488 | 15253 | |
718e3744 | 15254 | /* BGP node structure. */ |
d62a17ae | 15255 | static struct cmd_node bgp_node = { |
9d303b37 | 15256 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 15257 | }; |
15258 | ||
d62a17ae | 15259 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 15260 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15261 | }; |
15262 | ||
d62a17ae | 15263 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 15264 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15265 | }; |
15266 | ||
d62a17ae | 15267 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 15268 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15269 | }; |
15270 | ||
d62a17ae | 15271 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 15272 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 15273 | }; |
15274 | ||
d62a17ae | 15275 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 15276 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 15277 | }; |
15278 | ||
d62a17ae | 15279 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 15280 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
15281 | }; |
15282 | ||
d62a17ae | 15283 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
15284 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 15285 | |
d62a17ae | 15286 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
15287 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 15288 | |
d62a17ae | 15289 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
15290 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 15291 | |
d62a17ae | 15292 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
15293 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 15294 | |
7c40bf39 | 15295 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
15296 | "%s(config-router-af)# ", 1}; | |
15297 | ||
15298 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
15299 | "%s(config-router-af-vpnv6)# ", 1}; | |
15300 | ||
d62a17ae | 15301 | static void community_list_vty(void); |
1f8ae70b | 15302 | |
d62a17ae | 15303 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15304 | { |
d62a17ae | 15305 | struct bgp *bgp; |
15306 | struct peer *peer; | |
d62a17ae | 15307 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15308 | |
d62a17ae | 15309 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15310 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15311 | /* only provide suggestions on the appropriate input | |
15312 | * token type, | |
15313 | * they'll otherwise show up multiple times */ | |
15314 | enum cmd_token_type match_type; | |
15315 | char *name = peer->host; | |
d48ed3e0 | 15316 | |
d62a17ae | 15317 | if (peer->conf_if) { |
15318 | match_type = VARIABLE_TKN; | |
15319 | name = peer->conf_if; | |
15320 | } else if (strchr(peer->host, ':')) | |
15321 | match_type = IPV6_TKN; | |
15322 | else | |
15323 | match_type = IPV4_TKN; | |
d48ed3e0 | 15324 | |
d62a17ae | 15325 | if (token->type != match_type) |
15326 | continue; | |
d48ed3e0 | 15327 | |
d62a17ae | 15328 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15329 | } | |
d62a17ae | 15330 | } |
b8a815e5 DL |
15331 | } |
15332 | ||
15333 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15334 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15335 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15336 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15337 | {.completions = NULL}}; |
15338 | ||
47a306a0 DS |
15339 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15340 | { | |
15341 | struct bgp *bgp; | |
15342 | struct peer_group *group; | |
15343 | struct listnode *lnbgp, *lnpeer; | |
15344 | ||
15345 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15346 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15347 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15348 | group->name)); | |
15349 | } | |
15350 | } | |
15351 | ||
15352 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15353 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15354 | {.completions = NULL} }; | |
15355 | ||
d62a17ae | 15356 | void bgp_vty_init(void) |
15357 | { | |
15358 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15359 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15360 | |
15361 | /* Install bgp top node. */ | |
15362 | install_node(&bgp_node, bgp_config_write); | |
15363 | install_node(&bgp_ipv4_unicast_node, NULL); | |
15364 | install_node(&bgp_ipv4_multicast_node, NULL); | |
15365 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
15366 | install_node(&bgp_ipv6_unicast_node, NULL); | |
15367 | install_node(&bgp_ipv6_multicast_node, NULL); | |
15368 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
15369 | install_node(&bgp_vpnv4_node, NULL); | |
15370 | install_node(&bgp_vpnv6_node, NULL); | |
15371 | install_node(&bgp_evpn_node, NULL); | |
15372 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 15373 | install_node(&bgp_flowspecv4_node, NULL); |
15374 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 15375 | |
15376 | /* Install default VTY commands to new nodes. */ | |
15377 | install_default(BGP_NODE); | |
15378 | install_default(BGP_IPV4_NODE); | |
15379 | install_default(BGP_IPV4M_NODE); | |
15380 | install_default(BGP_IPV4L_NODE); | |
15381 | install_default(BGP_IPV6_NODE); | |
15382 | install_default(BGP_IPV6M_NODE); | |
15383 | install_default(BGP_IPV6L_NODE); | |
15384 | install_default(BGP_VPNV4_NODE); | |
15385 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15386 | install_default(BGP_FLOWSPECV4_NODE); |
15387 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15388 | install_default(BGP_EVPN_NODE); |
15389 | install_default(BGP_EVPN_VNI_NODE); | |
15390 | ||
8029b216 AK |
15391 | /* "bgp local-mac" hidden commands. */ |
15392 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15393 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15394 | ||
d62a17ae | 15395 | /* bgp route-map delay-timer commands. */ |
15396 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15397 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15398 | ||
15399 | /* Dummy commands (Currently not supported) */ | |
15400 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15401 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15402 | ||
15403 | /* "router bgp" commands. */ | |
15404 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15405 | ||
15406 | /* "no router bgp" commands. */ | |
15407 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15408 | ||
15409 | /* "bgp router-id" commands. */ | |
15410 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15411 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15412 | ||
15413 | /* "bgp cluster-id" commands. */ | |
15414 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15415 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15416 | ||
15417 | /* "bgp confederation" commands. */ | |
15418 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15419 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15420 | ||
15421 | /* "bgp confederation peers" commands. */ | |
15422 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15423 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15424 | ||
15425 | /* bgp max-med command */ | |
15426 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15427 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15428 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15429 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15430 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15431 | ||
15432 | /* bgp disable-ebgp-connected-nh-check */ | |
15433 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15434 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15435 | ||
15436 | /* bgp update-delay command */ | |
15437 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15438 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15439 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15440 | ||
15441 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15442 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15443 | |
15444 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15445 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15446 | ||
15447 | /* "maximum-paths" commands. */ | |
15448 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15449 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15450 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15451 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15452 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15453 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15454 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15455 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15456 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15457 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15458 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15459 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15460 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15461 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15462 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15463 | ||
15464 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15465 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15466 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15467 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15468 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15469 | ||
15470 | /* "timers bgp" commands. */ | |
15471 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15472 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15473 | ||
15474 | /* route-map delay-timer commands - per instance for backwards compat. | |
15475 | */ | |
15476 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15477 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15478 | ||
15479 | /* "bgp client-to-client reflection" commands */ | |
15480 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15481 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15482 | ||
15483 | /* "bgp always-compare-med" commands */ | |
15484 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15485 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15486 | ||
9dac9fc8 DA |
15487 | /* bgp ebgp-requires-policy */ |
15488 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15489 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15490 | ||
fb29348a DA |
15491 | /* bgp reject-as-sets */ |
15492 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15493 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15494 | ||
d62a17ae | 15495 | /* "bgp deterministic-med" commands */ |
15496 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15497 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15498 | ||
055679e9 | 15499 | /* "bgp graceful-restart" command */ |
36235319 QY |
15500 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15501 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15502 | |
15503 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15504 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15505 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15506 | |
15507 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15508 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15509 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15510 | |
15511 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15512 | install_element(BGP_NODE, | |
15513 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15514 | install_element(BGP_NODE, | |
15515 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15516 | ||
15517 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15518 | install_element(BGP_NODE, | |
15519 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15520 | install_element(BGP_NODE, | |
15521 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15522 | ||
d62a17ae | 15523 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15524 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15525 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15526 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15527 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15528 | install_element(BGP_NODE, |
15529 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15530 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15531 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15532 | ||
d6e3c15b | 15533 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15534 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15535 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15536 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15537 | |
7f323236 DW |
15538 | /* "bgp graceful-shutdown" commands */ |
15539 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15540 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15541 | ||
d62a17ae | 15542 | /* "bgp fast-external-failover" commands */ |
15543 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15544 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15545 | ||
d62a17ae | 15546 | /* "bgp bestpath compare-routerid" commands */ |
15547 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15548 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15549 | ||
15550 | /* "bgp bestpath as-path ignore" commands */ | |
15551 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15552 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15553 | ||
15554 | /* "bgp bestpath as-path confed" commands */ | |
15555 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15556 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15557 | ||
15558 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15559 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15560 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15561 | ||
15562 | /* "bgp log-neighbor-changes" commands */ | |
15563 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15564 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15565 | ||
15566 | /* "bgp bestpath med" commands */ | |
15567 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15568 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15569 | ||
15570 | /* "no bgp default ipv4-unicast" commands. */ | |
15571 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15572 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15573 | ||
15574 | /* "bgp network import-check" commands. */ | |
15575 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15576 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15577 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15578 | ||
15579 | /* "bgp default local-preference" commands. */ | |
15580 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15581 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15582 | ||
15583 | /* bgp default show-hostname */ | |
15584 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15585 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15586 | ||
15587 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15588 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15589 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15590 | ||
15591 | /* bgp ibgp-allow-policy-mods command */ | |
15592 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15593 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15594 | ||
15595 | /* "bgp listen limit" commands. */ | |
15596 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15597 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15598 | ||
15599 | /* "bgp listen range" commands. */ | |
15600 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15601 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15602 | ||
8175f54a | 15603 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15604 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15605 | ||
d62a17ae | 15606 | /* "neighbor remote-as" commands. */ |
15607 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15608 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15609 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15610 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15611 | install_element(BGP_NODE, | |
15612 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15613 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15614 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15615 | ||
15616 | /* "neighbor peer-group" commands. */ | |
15617 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15618 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15619 | install_element(BGP_NODE, | |
15620 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15621 | ||
15622 | /* "neighbor local-as" commands. */ | |
15623 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15624 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15625 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15626 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15627 | ||
15628 | /* "neighbor solo" commands. */ | |
15629 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15630 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15631 | ||
15632 | /* "neighbor password" commands. */ | |
15633 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15634 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15635 | ||
15636 | /* "neighbor activate" commands. */ | |
15637 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15638 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15639 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15640 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15641 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15642 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15643 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15644 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15645 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15646 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15647 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15648 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15649 | ||
15650 | /* "no neighbor activate" commands. */ | |
15651 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15652 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15653 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15654 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15655 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15656 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15657 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15658 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15659 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15660 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15661 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15662 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15663 | ||
15664 | /* "neighbor peer-group" set commands. */ | |
15665 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15666 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15667 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15668 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15669 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15670 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15671 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15672 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15673 | install_element(BGP_FLOWSPECV4_NODE, |
15674 | &neighbor_set_peer_group_hidden_cmd); | |
15675 | install_element(BGP_FLOWSPECV6_NODE, | |
15676 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15677 | |
15678 | /* "no neighbor peer-group unset" commands. */ | |
15679 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15680 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15681 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15682 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15683 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15684 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15685 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15686 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15687 | install_element(BGP_FLOWSPECV4_NODE, |
15688 | &no_neighbor_set_peer_group_hidden_cmd); | |
15689 | install_element(BGP_FLOWSPECV6_NODE, | |
15690 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15691 | |
15692 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15693 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15694 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15695 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15696 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15697 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15698 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15699 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15700 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15701 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15702 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15703 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15704 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15705 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15706 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15707 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15708 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15709 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15710 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15711 | install_element(BGP_FLOWSPECV4_NODE, |
15712 | &neighbor_soft_reconfiguration_cmd); | |
15713 | install_element(BGP_FLOWSPECV4_NODE, | |
15714 | &no_neighbor_soft_reconfiguration_cmd); | |
15715 | install_element(BGP_FLOWSPECV6_NODE, | |
15716 | &neighbor_soft_reconfiguration_cmd); | |
15717 | install_element(BGP_FLOWSPECV6_NODE, | |
15718 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15719 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15720 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15721 | |
15722 | /* "neighbor attribute-unchanged" commands. */ | |
15723 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15724 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15725 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15726 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15727 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15728 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15729 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15730 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15731 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15732 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15733 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15734 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15735 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15736 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15737 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15738 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15739 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15740 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15741 | ||
15742 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15743 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15744 | ||
15745 | /* "nexthop-local unchanged" commands */ | |
15746 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15747 | install_element(BGP_IPV6_NODE, | |
15748 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15749 | ||
15750 | /* "neighbor next-hop-self" commands. */ | |
15751 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15752 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15753 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15754 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15755 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15756 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15757 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15758 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15759 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15760 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15761 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15762 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15763 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15764 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15765 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15766 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15767 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15768 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15769 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15770 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15771 | |
15772 | /* "neighbor next-hop-self force" commands. */ | |
15773 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15774 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15775 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15776 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15777 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15778 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15779 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15780 | install_element(BGP_IPV4_NODE, | |
15781 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15782 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15783 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15784 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15785 | install_element(BGP_IPV4M_NODE, | |
15786 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15787 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
15788 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15789 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15790 | install_element(BGP_IPV4L_NODE, | |
15791 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15792 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
15793 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15794 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15795 | install_element(BGP_IPV6_NODE, | |
15796 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15797 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
15798 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15799 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15800 | install_element(BGP_IPV6M_NODE, | |
15801 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15802 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
15803 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15804 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15805 | install_element(BGP_IPV6L_NODE, | |
15806 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15807 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
15808 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15809 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15810 | install_element(BGP_VPNV4_NODE, | |
15811 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15812 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
15813 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15814 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15815 | install_element(BGP_VPNV6_NODE, | |
15816 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15817 | |
15818 | /* "neighbor as-override" commands. */ | |
15819 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
15820 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
15821 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
15822 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
15823 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
15824 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
15825 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
15826 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
15827 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
15828 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
15829 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
15830 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
15831 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
15832 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
15833 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
15834 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
15835 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
15836 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
15837 | ||
15838 | /* "neighbor remove-private-AS" commands. */ | |
15839 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
15840 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
15841 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
15842 | install_element(BGP_NODE, | |
15843 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
15844 | install_element(BGP_NODE, | |
15845 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
15846 | install_element(BGP_NODE, | |
15847 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
15848 | install_element(BGP_NODE, | |
15849 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15850 | install_element( | |
15851 | BGP_NODE, | |
15852 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15853 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
15854 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15855 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15856 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15857 | install_element(BGP_IPV4_NODE, | |
15858 | &neighbor_remove_private_as_replace_as_cmd); | |
15859 | install_element(BGP_IPV4_NODE, | |
15860 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15861 | install_element(BGP_IPV4_NODE, | |
15862 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15863 | install_element(BGP_IPV4_NODE, | |
15864 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15865 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
15866 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
15867 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
15868 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15869 | install_element(BGP_IPV4M_NODE, | |
15870 | &neighbor_remove_private_as_replace_as_cmd); | |
15871 | install_element(BGP_IPV4M_NODE, | |
15872 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15873 | install_element(BGP_IPV4M_NODE, | |
15874 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15875 | install_element(BGP_IPV4M_NODE, | |
15876 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15877 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
15878 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
15879 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
15880 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15881 | install_element(BGP_IPV4L_NODE, | |
15882 | &neighbor_remove_private_as_replace_as_cmd); | |
15883 | install_element(BGP_IPV4L_NODE, | |
15884 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15885 | install_element(BGP_IPV4L_NODE, | |
15886 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15887 | install_element(BGP_IPV4L_NODE, | |
15888 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15889 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
15890 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15891 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15892 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15893 | install_element(BGP_IPV6_NODE, | |
15894 | &neighbor_remove_private_as_replace_as_cmd); | |
15895 | install_element(BGP_IPV6_NODE, | |
15896 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15897 | install_element(BGP_IPV6_NODE, | |
15898 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15899 | install_element(BGP_IPV6_NODE, | |
15900 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15901 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
15902 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
15903 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
15904 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15905 | install_element(BGP_IPV6M_NODE, | |
15906 | &neighbor_remove_private_as_replace_as_cmd); | |
15907 | install_element(BGP_IPV6M_NODE, | |
15908 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15909 | install_element(BGP_IPV6M_NODE, | |
15910 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15911 | install_element(BGP_IPV6M_NODE, | |
15912 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15913 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
15914 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
15915 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
15916 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15917 | install_element(BGP_IPV6L_NODE, | |
15918 | &neighbor_remove_private_as_replace_as_cmd); | |
15919 | install_element(BGP_IPV6L_NODE, | |
15920 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15921 | install_element(BGP_IPV6L_NODE, | |
15922 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15923 | install_element(BGP_IPV6L_NODE, | |
15924 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15925 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
15926 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
15927 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
15928 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15929 | install_element(BGP_VPNV4_NODE, | |
15930 | &neighbor_remove_private_as_replace_as_cmd); | |
15931 | install_element(BGP_VPNV4_NODE, | |
15932 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15933 | install_element(BGP_VPNV4_NODE, | |
15934 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15935 | install_element(BGP_VPNV4_NODE, | |
15936 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15937 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
15938 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
15939 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
15940 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
15941 | install_element(BGP_VPNV6_NODE, | |
15942 | &neighbor_remove_private_as_replace_as_cmd); | |
15943 | install_element(BGP_VPNV6_NODE, | |
15944 | &no_neighbor_remove_private_as_replace_as_cmd); | |
15945 | install_element(BGP_VPNV6_NODE, | |
15946 | &neighbor_remove_private_as_all_replace_as_cmd); | |
15947 | install_element(BGP_VPNV6_NODE, | |
15948 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
15949 | ||
15950 | /* "neighbor send-community" commands.*/ | |
15951 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
15952 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
15953 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
15954 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
15955 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
15956 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
15957 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
15958 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
15959 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
15960 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
15961 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
15962 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
15963 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
15964 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
15965 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
15966 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
15967 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
15968 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
15969 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
15970 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
15971 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
15972 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
15973 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
15974 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
15975 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
15976 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
15977 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
15978 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
15979 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
15980 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
15981 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
15982 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
15983 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
15984 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
15985 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
15986 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
15987 | ||
15988 | /* "neighbor route-reflector" commands.*/ | |
15989 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
15990 | install_element(BGP_NODE, | |
15991 | &no_neighbor_route_reflector_client_hidden_cmd); | |
15992 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
15993 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
15994 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
15995 | install_element(BGP_IPV4M_NODE, | |
15996 | &no_neighbor_route_reflector_client_cmd); | |
15997 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
15998 | install_element(BGP_IPV4L_NODE, | |
15999 | &no_neighbor_route_reflector_client_cmd); | |
16000 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16001 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16002 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16003 | install_element(BGP_IPV6M_NODE, | |
16004 | &no_neighbor_route_reflector_client_cmd); | |
16005 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16006 | install_element(BGP_IPV6L_NODE, | |
16007 | &no_neighbor_route_reflector_client_cmd); | |
16008 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16009 | install_element(BGP_VPNV4_NODE, | |
16010 | &no_neighbor_route_reflector_client_cmd); | |
16011 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16012 | install_element(BGP_VPNV6_NODE, | |
16013 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16014 | install_element(BGP_FLOWSPECV4_NODE, |
16015 | &neighbor_route_reflector_client_cmd); | |
16016 | install_element(BGP_FLOWSPECV4_NODE, | |
16017 | &no_neighbor_route_reflector_client_cmd); | |
16018 | install_element(BGP_FLOWSPECV6_NODE, | |
16019 | &neighbor_route_reflector_client_cmd); | |
16020 | install_element(BGP_FLOWSPECV6_NODE, | |
16021 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16022 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16023 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16024 | ||
16025 | /* "neighbor route-server" commands.*/ | |
16026 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16027 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16028 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16029 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16030 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16031 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16032 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16033 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16034 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16035 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16036 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16037 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16038 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16039 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16040 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16041 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16042 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16043 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16044 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16045 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16046 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16047 | install_element(BGP_FLOWSPECV4_NODE, | |
16048 | &no_neighbor_route_server_client_cmd); | |
16049 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16050 | install_element(BGP_FLOWSPECV6_NODE, | |
16051 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16052 | |
16053 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16054 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16055 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16056 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16057 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16058 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16059 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16060 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16061 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16062 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16063 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16064 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16065 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16066 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16067 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16068 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16069 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16070 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16071 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16072 | ||
16073 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16074 | install_element(BGP_NODE, | |
16075 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16076 | install_element(BGP_NODE, | |
16077 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16078 | install_element(BGP_IPV4_NODE, | |
16079 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16080 | install_element(BGP_IPV4_NODE, | |
16081 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16082 | install_element(BGP_IPV4M_NODE, | |
16083 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16084 | install_element(BGP_IPV4M_NODE, | |
16085 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16086 | install_element(BGP_IPV4L_NODE, | |
16087 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16088 | install_element(BGP_IPV4L_NODE, | |
16089 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16090 | install_element(BGP_IPV6_NODE, | |
16091 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16092 | install_element(BGP_IPV6_NODE, | |
16093 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16094 | install_element(BGP_IPV6M_NODE, | |
16095 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16096 | install_element(BGP_IPV6M_NODE, | |
16097 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16098 | install_element(BGP_IPV6L_NODE, | |
16099 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16100 | install_element(BGP_IPV6L_NODE, | |
16101 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16102 | install_element(BGP_VPNV4_NODE, | |
16103 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16104 | install_element(BGP_VPNV4_NODE, | |
16105 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16106 | install_element(BGP_VPNV6_NODE, | |
16107 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16108 | install_element(BGP_VPNV6_NODE, | |
16109 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16110 | ||
2b31007c RZ |
16111 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16112 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16113 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16114 | ||
d62a17ae | 16115 | /* "neighbor passive" commands. */ |
16116 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16117 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16118 | ||
16119 | ||
16120 | /* "neighbor shutdown" commands. */ | |
16121 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16122 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16123 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16124 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16125 | ||
16126 | /* "neighbor capability extended-nexthop" commands.*/ | |
16127 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16128 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16129 | ||
16130 | /* "neighbor capability orf prefix-list" commands.*/ | |
16131 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16132 | install_element(BGP_NODE, | |
16133 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16134 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16135 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16136 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16137 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16138 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16139 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16140 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16141 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16142 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16143 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16144 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16145 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16146 | ||
16147 | /* "neighbor capability dynamic" commands.*/ | |
16148 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16149 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16150 | ||
16151 | /* "neighbor dont-capability-negotiate" commands. */ | |
16152 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16153 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16154 | ||
16155 | /* "neighbor ebgp-multihop" commands. */ | |
16156 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16157 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16158 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16159 | ||
16160 | /* "neighbor disable-connected-check" commands. */ | |
16161 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16162 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16163 | ||
47cbc09b PM |
16164 | /* "neighbor enforce-first-as" commands. */ |
16165 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16166 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16167 | ||
d62a17ae | 16168 | /* "neighbor description" commands. */ |
16169 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16170 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16171 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16172 | |
16173 | /* "neighbor update-source" commands. "*/ | |
16174 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16175 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16176 | ||
16177 | /* "neighbor default-originate" commands. */ | |
16178 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16179 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16180 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16181 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16182 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16183 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16184 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16185 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16186 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16187 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16188 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16189 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16190 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16191 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16192 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16193 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16194 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16195 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16196 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16197 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16198 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16199 | ||
16200 | /* "neighbor port" commands. */ | |
16201 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16202 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16203 | ||
16204 | /* "neighbor weight" commands. */ | |
16205 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16206 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16207 | ||
16208 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16209 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16210 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16211 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16212 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16213 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16214 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16215 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16216 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16217 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16218 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16219 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16220 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16221 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16222 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16223 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16224 | ||
16225 | /* "neighbor override-capability" commands. */ | |
16226 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16227 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16228 | ||
16229 | /* "neighbor strict-capability-match" commands. */ | |
16230 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16231 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16232 | ||
16233 | /* "neighbor timers" commands. */ | |
16234 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16235 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16236 | ||
16237 | /* "neighbor timers connect" commands. */ | |
16238 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16239 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16240 | ||
16241 | /* "neighbor advertisement-interval" commands. */ | |
16242 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16243 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16244 | ||
16245 | /* "neighbor interface" commands. */ | |
16246 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16247 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16248 | ||
16249 | /* "neighbor distribute" commands. */ | |
16250 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16251 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16252 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16253 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16254 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16255 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16256 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16257 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16258 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16259 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16260 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16261 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16262 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16263 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16264 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16265 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16266 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16267 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16268 | ||
16269 | /* "neighbor prefix-list" commands. */ | |
16270 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16271 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16272 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16273 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16274 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16275 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16276 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16277 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16278 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16279 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16280 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16281 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16282 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16283 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16284 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16285 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16286 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16287 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16288 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16289 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16290 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16291 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16292 | |
16293 | /* "neighbor filter-list" commands. */ | |
16294 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16295 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16296 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16297 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16298 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16299 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16300 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16301 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16302 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16303 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16304 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16305 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16306 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16307 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16308 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16309 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16310 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16311 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16312 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16313 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16314 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16315 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16316 | |
16317 | /* "neighbor route-map" commands. */ | |
16318 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16319 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16320 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16321 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16322 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16323 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16324 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16325 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16326 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16327 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16328 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16329 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16330 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16331 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16332 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16333 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16334 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16335 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16336 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16337 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16338 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16339 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16340 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16341 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16342 | |
16343 | /* "neighbor unsuppress-map" commands. */ | |
16344 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16345 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16346 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16347 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16348 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16349 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16350 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16351 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16352 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16353 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16354 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16355 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16356 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16357 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16358 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16359 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16360 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16361 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16362 | ||
fde246e8 DA |
16363 | /* neighbor maximum-prefix-out commands. */ |
16364 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16365 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16366 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16367 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16368 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16369 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16370 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16371 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16372 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16373 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16374 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16375 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16376 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16377 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16378 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16379 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16380 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16381 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16382 | ||
d62a17ae | 16383 | /* "neighbor maximum-prefix" commands. */ |
16384 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16385 | install_element(BGP_NODE, | |
16386 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16387 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16388 | install_element(BGP_NODE, | |
16389 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16390 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16391 | install_element(BGP_NODE, | |
16392 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16393 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16394 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16395 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16396 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16397 | install_element(BGP_IPV4_NODE, | |
16398 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16399 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16400 | install_element(BGP_IPV4_NODE, | |
16401 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16402 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16403 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16404 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16405 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16406 | install_element(BGP_IPV4M_NODE, | |
16407 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16408 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16409 | install_element(BGP_IPV4M_NODE, | |
16410 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16411 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16412 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16413 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16414 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16415 | install_element(BGP_IPV4L_NODE, | |
16416 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16417 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16418 | install_element(BGP_IPV4L_NODE, | |
16419 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16420 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16421 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16422 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16423 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16424 | install_element(BGP_IPV6_NODE, | |
16425 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16426 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16427 | install_element(BGP_IPV6_NODE, | |
16428 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16429 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16430 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16431 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16432 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16433 | install_element(BGP_IPV6M_NODE, | |
16434 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16435 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16436 | install_element(BGP_IPV6M_NODE, | |
16437 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16438 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16439 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16440 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16441 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16442 | install_element(BGP_IPV6L_NODE, | |
16443 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16444 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16445 | install_element(BGP_IPV6L_NODE, | |
16446 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16447 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16448 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16449 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16450 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16451 | install_element(BGP_VPNV4_NODE, | |
16452 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16453 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16454 | install_element(BGP_VPNV4_NODE, | |
16455 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16456 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16457 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16458 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16459 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16460 | install_element(BGP_VPNV6_NODE, | |
16461 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16462 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16463 | install_element(BGP_VPNV6_NODE, | |
16464 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16465 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16466 | ||
16467 | /* "neighbor allowas-in" */ | |
16468 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16469 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16470 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16471 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16472 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16473 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16474 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16475 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16476 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16477 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16478 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16479 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16480 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16481 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16482 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16483 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16484 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16485 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16486 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16487 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16488 | ||
16489 | /* address-family commands. */ | |
16490 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16491 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16492 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16493 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16494 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16495 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16496 | |
d62a17ae | 16497 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16498 | ||
16499 | /* "exit-address-family" command. */ | |
16500 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16501 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16502 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16503 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16504 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16505 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16506 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16507 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16508 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16509 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16510 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16511 | ||
16512 | /* "clear ip bgp commands" */ | |
16513 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16514 | ||
16515 | /* clear ip bgp prefix */ | |
16516 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16517 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16518 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16519 | ||
16520 | /* "show [ip] bgp summary" commands. */ | |
16521 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16522 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16523 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16524 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16525 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16526 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16527 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16528 | ||
16529 | /* "show [ip] bgp neighbors" commands. */ | |
16530 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16531 | ||
36235319 | 16532 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16533 | |
d62a17ae | 16534 | /* "show [ip] bgp peer-group" commands. */ |
16535 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16536 | ||
16537 | /* "show [ip] bgp paths" commands. */ | |
16538 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16539 | ||
16540 | /* "show [ip] bgp community" commands. */ | |
16541 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16542 | ||
16543 | /* "show ip bgp large-community" commands. */ | |
16544 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16545 | /* "show [ip] bgp attribute-info" commands. */ | |
16546 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16547 | /* "show [ip] bgp route-leak" command */ |
16548 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16549 | |
16550 | /* "redistribute" commands. */ | |
16551 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16552 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16553 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16554 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16555 | install_element(BGP_NODE, | |
16556 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16557 | install_element(BGP_NODE, | |
16558 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16559 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16560 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16561 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16562 | install_element(BGP_NODE, | |
16563 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16564 | install_element(BGP_NODE, | |
16565 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16566 | install_element(BGP_NODE, | |
16567 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16568 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16569 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16570 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16571 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16572 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16573 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16574 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16575 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16576 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16577 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16578 | install_element(BGP_IPV4_NODE, | |
16579 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16580 | install_element(BGP_IPV4_NODE, | |
16581 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16582 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16583 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16584 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16585 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16586 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16587 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16588 | ||
b9c7bc5a PZ |
16589 | /* import|export vpn [route-map WORD] */ |
16590 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16591 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16592 | |
12a844a5 DS |
16593 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16594 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16595 | ||
d62a17ae | 16596 | /* ttl_security commands */ |
16597 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16598 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16599 | ||
16600 | /* "show [ip] bgp memory" commands. */ | |
16601 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16602 | ||
acf71666 MK |
16603 | /* "show bgp martian next-hop" */ |
16604 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16605 | ||
48ecf8f5 DS |
16606 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16607 | ||
d62a17ae | 16608 | /* "show [ip] bgp views" commands. */ |
16609 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16610 | ||
16611 | /* "show [ip] bgp vrfs" commands. */ | |
16612 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16613 | ||
16614 | /* Community-list. */ | |
16615 | community_list_vty(); | |
ddb5b488 PZ |
16616 | |
16617 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16618 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16619 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16620 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16621 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16622 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16623 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16624 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16625 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16626 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16627 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16628 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16629 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16630 | |
301ad80a PG |
16631 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16632 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16633 | ||
b9c7bc5a PZ |
16634 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16635 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16636 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16637 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
16638 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
16639 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16640 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16641 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16642 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16643 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16644 | } |
6b0655a2 | 16645 | |
718e3744 | 16646 | #include "memory.h" |
16647 | #include "bgp_regex.h" | |
16648 | #include "bgp_clist.h" | |
16649 | #include "bgp_ecommunity.h" | |
16650 | ||
16651 | /* VTY functions. */ | |
16652 | ||
16653 | /* Direction value to string conversion. */ | |
d62a17ae | 16654 | static const char *community_direct_str(int direct) |
16655 | { | |
16656 | switch (direct) { | |
16657 | case COMMUNITY_DENY: | |
16658 | return "deny"; | |
16659 | case COMMUNITY_PERMIT: | |
16660 | return "permit"; | |
16661 | default: | |
16662 | return "unknown"; | |
16663 | } | |
718e3744 | 16664 | } |
16665 | ||
16666 | /* Display error string. */ | |
d62a17ae | 16667 | static void community_list_perror(struct vty *vty, int ret) |
16668 | { | |
16669 | switch (ret) { | |
16670 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16671 | vty_out(vty, "%% Can't find community-list\n"); | |
16672 | break; | |
16673 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16674 | vty_out(vty, "%% Malformed community-list value\n"); | |
16675 | break; | |
16676 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16677 | vty_out(vty, | |
16678 | "%% Community name conflict, previously defined as standard community\n"); | |
16679 | break; | |
16680 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16681 | vty_out(vty, | |
16682 | "%% Community name conflict, previously defined as expanded community\n"); | |
16683 | break; | |
16684 | } | |
718e3744 | 16685 | } |
16686 | ||
5bf15956 DW |
16687 | /* "community-list" keyword help string. */ |
16688 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16689 | ||
7336e101 SP |
16690 | /*community-list standard */ |
16691 | DEFUN (community_list_standard, | |
16692 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 16693 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 16694 | BGP_STR |
718e3744 | 16695 | COMMUNITY_LIST_STR |
16696 | "Community list number (standard)\n" | |
5bf15956 | 16697 | "Add an standard community-list entry\n" |
718e3744 | 16698 | "Community list name\n" |
2f8cc0e5 DA |
16699 | "Sequence number of an entry\n" |
16700 | "Sequence number\n" | |
718e3744 | 16701 | "Specify community to reject\n" |
16702 | "Specify community to accept\n" | |
16703 | COMMUNITY_VAL_STR) | |
16704 | { | |
d62a17ae | 16705 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16706 | char *seq = NULL; |
d62a17ae | 16707 | int direct = 0; |
16708 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16709 | int idx = 0; |
7336e101 | 16710 | |
2f8cc0e5 DA |
16711 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16712 | if (idx) | |
16713 | seq = argv[idx]->arg; | |
16714 | ||
16715 | idx = 0; | |
d62a17ae | 16716 | argv_find(argv, argc, "(1-99)", &idx); |
16717 | argv_find(argv, argc, "WORD", &idx); | |
16718 | cl_name_or_number = argv[idx]->arg; | |
16719 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16720 | : COMMUNITY_DENY; | |
16721 | argv_find(argv, argc, "AA:NN", &idx); | |
16722 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16723 | |
2f8cc0e5 DA |
16724 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16725 | direct, style); | |
42f914d4 | 16726 | |
d62a17ae | 16727 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16728 | |
d62a17ae | 16729 | if (ret < 0) { |
16730 | /* Display error string. */ | |
16731 | community_list_perror(vty, ret); | |
16732 | return CMD_WARNING_CONFIG_FAILED; | |
16733 | } | |
42f914d4 | 16734 | |
d62a17ae | 16735 | return CMD_SUCCESS; |
718e3744 | 16736 | } |
16737 | ||
7336e101 SP |
16738 | DEFUN (no_community_list_standard_all, |
16739 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 16740 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16741 | NO_STR |
16742 | BGP_STR | |
16743 | COMMUNITY_LIST_STR | |
16744 | "Community list number (standard)\n" | |
16745 | "Add an standard community-list entry\n" | |
16746 | "Community list name\n" | |
2f8cc0e5 DA |
16747 | "Sequence number of an entry\n" |
16748 | "Sequence number\n" | |
7336e101 SP |
16749 | "Specify community to reject\n" |
16750 | "Specify community to accept\n" | |
16751 | COMMUNITY_VAL_STR) | |
718e3744 | 16752 | { |
d62a17ae | 16753 | char *cl_name_or_number = NULL; |
174b5cb9 | 16754 | char *str = NULL; |
d62a17ae | 16755 | int direct = 0; |
16756 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 16757 | char *seq = NULL; |
d62a17ae | 16758 | int idx = 0; |
7336e101 | 16759 | |
2f8cc0e5 DA |
16760 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16761 | if (idx) | |
16762 | seq = argv[idx]->arg; | |
16763 | ||
16764 | idx = 0; | |
174b5cb9 DA |
16765 | argv_find(argv, argc, "permit", &idx); |
16766 | argv_find(argv, argc, "deny", &idx); | |
16767 | ||
16768 | if (idx) { | |
16769 | direct = argv_find(argv, argc, "permit", &idx) | |
16770 | ? COMMUNITY_PERMIT | |
16771 | : COMMUNITY_DENY; | |
16772 | ||
16773 | idx = 0; | |
16774 | argv_find(argv, argc, "AA:NN", &idx); | |
16775 | str = argv_concat(argv, argc, idx); | |
16776 | } | |
16777 | ||
16778 | idx = 0; | |
d62a17ae | 16779 | argv_find(argv, argc, "(1-99)", &idx); |
16780 | argv_find(argv, argc, "WORD", &idx); | |
16781 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16782 | |
2f8cc0e5 | 16783 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16784 | direct, style); |
42f914d4 | 16785 | |
d62a17ae | 16786 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16787 | |
d62a17ae | 16788 | if (ret < 0) { |
16789 | community_list_perror(vty, ret); | |
16790 | return CMD_WARNING_CONFIG_FAILED; | |
16791 | } | |
42f914d4 | 16792 | |
d62a17ae | 16793 | return CMD_SUCCESS; |
718e3744 | 16794 | } |
7336e101 | 16795 | |
174b5cb9 DA |
16796 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
16797 | "no bgp community-list <(1-99)|standard WORD>", | |
16798 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
16799 | "Community list number (standard)\n" | |
16800 | "Add an standard community-list entry\n" | |
16801 | "Community list name\n") | |
16802 | ||
7336e101 SP |
16803 | /*community-list expanded */ |
16804 | DEFUN (community_list_expanded_all, | |
16805 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16806 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16807 | BGP_STR |
16808 | COMMUNITY_LIST_STR | |
718e3744 | 16809 | "Community list number (expanded)\n" |
5bf15956 | 16810 | "Add an expanded community-list entry\n" |
718e3744 | 16811 | "Community list name\n" |
2f8cc0e5 DA |
16812 | "Sequence number of an entry\n" |
16813 | "Sequence number\n" | |
718e3744 | 16814 | "Specify community to reject\n" |
16815 | "Specify community to accept\n" | |
16816 | COMMUNITY_VAL_STR) | |
16817 | { | |
d62a17ae | 16818 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16819 | char *seq = NULL; |
d62a17ae | 16820 | int direct = 0; |
16821 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16822 | int idx = 0; |
7b9a4750 | 16823 | |
2f8cc0e5 DA |
16824 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16825 | if (idx) | |
16826 | seq = argv[idx]->arg; | |
16827 | ||
16828 | idx = 0; | |
16829 | ||
d62a17ae | 16830 | argv_find(argv, argc, "(100-500)", &idx); |
16831 | argv_find(argv, argc, "WORD", &idx); | |
16832 | cl_name_or_number = argv[idx]->arg; | |
16833 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16834 | : COMMUNITY_DENY; | |
16835 | argv_find(argv, argc, "AA:NN", &idx); | |
16836 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16837 | |
2f8cc0e5 DA |
16838 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16839 | direct, style); | |
42f914d4 | 16840 | |
d62a17ae | 16841 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16842 | |
d62a17ae | 16843 | if (ret < 0) { |
16844 | /* Display error string. */ | |
16845 | community_list_perror(vty, ret); | |
16846 | return CMD_WARNING_CONFIG_FAILED; | |
16847 | } | |
42f914d4 | 16848 | |
d62a17ae | 16849 | return CMD_SUCCESS; |
718e3744 | 16850 | } |
16851 | ||
7336e101 SP |
16852 | DEFUN (no_community_list_expanded_all, |
16853 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16854 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16855 | NO_STR |
16856 | BGP_STR | |
16857 | COMMUNITY_LIST_STR | |
16858 | "Community list number (expanded)\n" | |
16859 | "Add an expanded community-list entry\n" | |
16860 | "Community list name\n" | |
2f8cc0e5 DA |
16861 | "Sequence number of an entry\n" |
16862 | "Sequence number\n" | |
7336e101 SP |
16863 | "Specify community to reject\n" |
16864 | "Specify community to accept\n" | |
16865 | COMMUNITY_VAL_STR) | |
718e3744 | 16866 | { |
d62a17ae | 16867 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16868 | char *seq = NULL; |
174b5cb9 | 16869 | char *str = NULL; |
d62a17ae | 16870 | int direct = 0; |
16871 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16872 | int idx = 0; |
174b5cb9 | 16873 | |
2f8cc0e5 DA |
16874 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16875 | if (idx) | |
16876 | seq = argv[idx]->arg; | |
16877 | ||
16878 | idx = 0; | |
174b5cb9 DA |
16879 | argv_find(argv, argc, "permit", &idx); |
16880 | argv_find(argv, argc, "deny", &idx); | |
16881 | ||
16882 | if (idx) { | |
16883 | direct = argv_find(argv, argc, "permit", &idx) | |
16884 | ? COMMUNITY_PERMIT | |
16885 | : COMMUNITY_DENY; | |
16886 | ||
16887 | idx = 0; | |
16888 | argv_find(argv, argc, "AA:NN", &idx); | |
16889 | str = argv_concat(argv, argc, idx); | |
7336e101 | 16890 | } |
174b5cb9 DA |
16891 | |
16892 | idx = 0; | |
d62a17ae | 16893 | argv_find(argv, argc, "(100-500)", &idx); |
16894 | argv_find(argv, argc, "WORD", &idx); | |
16895 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16896 | |
2f8cc0e5 | 16897 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16898 | direct, style); |
42f914d4 | 16899 | |
d62a17ae | 16900 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16901 | |
d62a17ae | 16902 | if (ret < 0) { |
16903 | community_list_perror(vty, ret); | |
16904 | return CMD_WARNING_CONFIG_FAILED; | |
16905 | } | |
42f914d4 | 16906 | |
d62a17ae | 16907 | return CMD_SUCCESS; |
718e3744 | 16908 | } |
16909 | ||
174b5cb9 DA |
16910 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
16911 | "no bgp community-list <(100-500)|expanded WORD>", | |
16912 | NO_STR IP_STR COMMUNITY_LIST_STR | |
16913 | "Community list number (expanded)\n" | |
16914 | "Add an expanded community-list entry\n" | |
16915 | "Community list name\n") | |
16916 | ||
8d9b8ed9 PM |
16917 | /* Return configuration string of community-list entry. */ |
16918 | static const char *community_list_config_str(struct community_entry *entry) | |
16919 | { | |
16920 | const char *str; | |
16921 | ||
16922 | if (entry->any) | |
16923 | str = ""; | |
16924 | else { | |
16925 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
16926 | str = community_str(entry->u.com, false); | |
16927 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
16928 | str = lcommunity_str(entry->u.lcom, false); | |
16929 | else | |
16930 | str = entry->config; | |
16931 | } | |
16932 | return str; | |
16933 | } | |
16934 | ||
d62a17ae | 16935 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 16936 | { |
d62a17ae | 16937 | struct community_entry *entry; |
718e3744 | 16938 | |
d62a17ae | 16939 | for (entry = list->head; entry; entry = entry->next) { |
16940 | if (entry == list->head) { | |
16941 | if (all_digit(list->name)) | |
16942 | vty_out(vty, "Community %s list %s\n", | |
16943 | entry->style == COMMUNITY_LIST_STANDARD | |
16944 | ? "standard" | |
16945 | : "(expanded) access", | |
16946 | list->name); | |
16947 | else | |
16948 | vty_out(vty, "Named Community %s list %s\n", | |
16949 | entry->style == COMMUNITY_LIST_STANDARD | |
16950 | ? "standard" | |
16951 | : "expanded", | |
16952 | list->name); | |
16953 | } | |
16954 | if (entry->any) | |
16955 | vty_out(vty, " %s\n", | |
16956 | community_direct_str(entry->direct)); | |
16957 | else | |
16958 | vty_out(vty, " %s %s\n", | |
16959 | community_direct_str(entry->direct), | |
8d9b8ed9 | 16960 | community_list_config_str(entry)); |
d62a17ae | 16961 | } |
718e3744 | 16962 | } |
16963 | ||
7336e101 SP |
16964 | DEFUN (show_community_list, |
16965 | show_bgp_community_list_cmd, | |
16966 | "show bgp community-list", | |
718e3744 | 16967 | SHOW_STR |
7336e101 | 16968 | BGP_STR |
718e3744 | 16969 | "List community-list\n") |
16970 | { | |
d62a17ae | 16971 | struct community_list *list; |
16972 | struct community_list_master *cm; | |
718e3744 | 16973 | |
d62a17ae | 16974 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
16975 | if (!cm) | |
16976 | return CMD_SUCCESS; | |
718e3744 | 16977 | |
d62a17ae | 16978 | for (list = cm->num.head; list; list = list->next) |
16979 | community_list_show(vty, list); | |
718e3744 | 16980 | |
d62a17ae | 16981 | for (list = cm->str.head; list; list = list->next) |
16982 | community_list_show(vty, list); | |
718e3744 | 16983 | |
d62a17ae | 16984 | return CMD_SUCCESS; |
718e3744 | 16985 | } |
16986 | ||
7336e101 SP |
16987 | DEFUN (show_community_list_arg, |
16988 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 16989 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
16990 | SHOW_STR |
16991 | BGP_STR | |
718e3744 | 16992 | "List community-list\n" |
16993 | "Community-list number\n" | |
960b69b9 | 16994 | "Community-list name\n" |
16995 | "Detailed information on community-list\n") | |
718e3744 | 16996 | { |
d62a17ae | 16997 | int idx_comm_list = 3; |
16998 | struct community_list *list; | |
718e3744 | 16999 | |
e237b0d2 | 17000 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17001 | COMMUNITY_LIST_MASTER); |
17002 | if (!list) { | |
17003 | vty_out(vty, "%% Can't find community-list\n"); | |
17004 | return CMD_WARNING; | |
17005 | } | |
718e3744 | 17006 | |
d62a17ae | 17007 | community_list_show(vty, list); |
718e3744 | 17008 | |
d62a17ae | 17009 | return CMD_SUCCESS; |
718e3744 | 17010 | } |
6b0655a2 | 17011 | |
57d187bc JS |
17012 | /* |
17013 | * Large Community code. | |
17014 | */ | |
d62a17ae | 17015 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17016 | struct cmd_token **argv, int style, | |
17017 | int reject_all_digit_name) | |
17018 | { | |
17019 | int ret; | |
17020 | int direct; | |
17021 | char *str; | |
17022 | int idx = 0; | |
17023 | char *cl_name; | |
2f8cc0e5 DA |
17024 | char *seq = NULL; |
17025 | ||
17026 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17027 | if (idx) | |
17028 | seq = argv[idx]->arg; | |
d62a17ae | 17029 | |
2f8cc0e5 | 17030 | idx = 0; |
d62a17ae | 17031 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17032 | : COMMUNITY_DENY; | |
17033 | ||
17034 | /* All digit name check. */ | |
17035 | idx = 0; | |
17036 | argv_find(argv, argc, "WORD", &idx); | |
17037 | argv_find(argv, argc, "(1-99)", &idx); | |
17038 | argv_find(argv, argc, "(100-500)", &idx); | |
17039 | cl_name = argv[idx]->arg; | |
17040 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17041 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17042 | return CMD_WARNING_CONFIG_FAILED; | |
17043 | } | |
17044 | ||
17045 | idx = 0; | |
17046 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17047 | argv_find(argv, argc, "LINE", &idx); | |
17048 | /* Concat community string argument. */ | |
17049 | if (idx) | |
17050 | str = argv_concat(argv, argc, idx); | |
17051 | else | |
17052 | str = NULL; | |
17053 | ||
2f8cc0e5 | 17054 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17055 | |
17056 | /* Free temporary community list string allocated by | |
17057 | argv_concat(). */ | |
0a22ddfb | 17058 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17059 | |
17060 | if (ret < 0) { | |
17061 | community_list_perror(vty, ret); | |
17062 | return CMD_WARNING_CONFIG_FAILED; | |
17063 | } | |
17064 | return CMD_SUCCESS; | |
17065 | } | |
17066 | ||
17067 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17068 | struct cmd_token **argv, int style) | |
17069 | { | |
17070 | int ret; | |
17071 | int direct = 0; | |
17072 | char *str = NULL; | |
17073 | int idx = 0; | |
2f8cc0e5 | 17074 | char *seq = NULL; |
d62a17ae | 17075 | |
2f8cc0e5 DA |
17076 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17077 | if (idx) | |
17078 | seq = argv[idx]->arg; | |
d62a17ae | 17079 | |
2f8cc0e5 | 17080 | idx = 0; |
d62a17ae | 17081 | argv_find(argv, argc, "permit", &idx); |
17082 | argv_find(argv, argc, "deny", &idx); | |
17083 | ||
17084 | if (idx) { | |
17085 | /* Check the list direct. */ | |
17086 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17087 | direct = COMMUNITY_PERMIT; | |
17088 | else | |
17089 | direct = COMMUNITY_DENY; | |
17090 | ||
17091 | idx = 0; | |
17092 | argv_find(argv, argc, "LINE", &idx); | |
17093 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17094 | /* Concat community string argument. */ | |
17095 | str = argv_concat(argv, argc, idx); | |
17096 | } | |
17097 | ||
17098 | idx = 0; | |
17099 | argv_find(argv, argc, "(1-99)", &idx); | |
17100 | argv_find(argv, argc, "(100-500)", &idx); | |
17101 | argv_find(argv, argc, "WORD", &idx); | |
17102 | ||
17103 | /* Unset community list. */ | |
2f8cc0e5 | 17104 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17105 | style); |
17106 | ||
17107 | /* Free temporary community list string allocated by | |
17108 | argv_concat(). */ | |
0a22ddfb | 17109 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17110 | |
17111 | if (ret < 0) { | |
17112 | community_list_perror(vty, ret); | |
17113 | return CMD_WARNING_CONFIG_FAILED; | |
17114 | } | |
17115 | ||
17116 | return CMD_SUCCESS; | |
57d187bc JS |
17117 | } |
17118 | ||
17119 | /* "large-community-list" keyword help string. */ | |
17120 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17121 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17122 | ||
7336e101 SP |
17123 | DEFUN (lcommunity_list_standard, |
17124 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17125 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17126 | BGP_STR |
17127 | LCOMMUNITY_LIST_STR | |
17128 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17129 | "Sequence number of an entry\n" |
17130 | "Sequence number\n" | |
7336e101 SP |
17131 | "Specify large community to reject\n" |
17132 | "Specify large community to accept\n" | |
17133 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17134 | { |
d62a17ae | 17135 | return lcommunity_list_set_vty(vty, argc, argv, |
17136 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17137 | } |
17138 | ||
7336e101 SP |
17139 | DEFUN (lcommunity_list_expanded, |
17140 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17141 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17142 | BGP_STR |
17143 | LCOMMUNITY_LIST_STR | |
17144 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17145 | "Sequence number of an entry\n" |
17146 | "Sequence number\n" | |
7336e101 SP |
17147 | "Specify large community to reject\n" |
17148 | "Specify large community to accept\n" | |
17149 | "An ordered list as a regular-expression\n") | |
57d187bc | 17150 | { |
d62a17ae | 17151 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17152 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17153 | } |
17154 | ||
7336e101 SP |
17155 | DEFUN (lcommunity_list_name_standard, |
17156 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17157 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17158 | BGP_STR |
17159 | LCOMMUNITY_LIST_STR | |
17160 | "Specify standard large-community-list\n" | |
17161 | "Large Community list name\n" | |
2f8cc0e5 DA |
17162 | "Sequence number of an entry\n" |
17163 | "Sequence number\n" | |
7336e101 SP |
17164 | "Specify large community to reject\n" |
17165 | "Specify large community to accept\n" | |
17166 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17167 | { |
d62a17ae | 17168 | return lcommunity_list_set_vty(vty, argc, argv, |
17169 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17170 | } |
17171 | ||
7336e101 SP |
17172 | DEFUN (lcommunity_list_name_expanded, |
17173 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17174 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17175 | BGP_STR |
17176 | LCOMMUNITY_LIST_STR | |
17177 | "Specify expanded large-community-list\n" | |
17178 | "Large Community list name\n" | |
2f8cc0e5 DA |
17179 | "Sequence number of an entry\n" |
17180 | "Sequence number\n" | |
7336e101 SP |
17181 | "Specify large community to reject\n" |
17182 | "Specify large community to accept\n" | |
17183 | "An ordered list as a regular-expression\n") | |
57d187bc | 17184 | { |
d62a17ae | 17185 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17186 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17187 | } |
17188 | ||
4378f57c DA |
17189 | DEFUN (no_lcommunity_list_all, |
17190 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17191 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17192 | NO_STR | |
17193 | BGP_STR | |
17194 | LCOMMUNITY_LIST_STR | |
17195 | "Large Community list number (standard)\n" | |
17196 | "Large Community list number (expanded)\n" | |
17197 | "Large Community list name\n") | |
57d187bc | 17198 | { |
7336e101 SP |
17199 | return lcommunity_list_unset_vty(vty, argc, argv, |
17200 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17201 | } |
17202 | ||
4378f57c DA |
17203 | DEFUN (no_lcommunity_list_name_standard_all, |
17204 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17205 | "no bgp large-community-list standard WORD", | |
17206 | NO_STR | |
17207 | BGP_STR | |
17208 | LCOMMUNITY_LIST_STR | |
17209 | "Specify standard large-community-list\n" | |
17210 | "Large Community list name\n") | |
17211 | { | |
17212 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17213 | LARGE_COMMUNITY_LIST_STANDARD); | |
17214 | } | |
17215 | ||
7336e101 SP |
17216 | DEFUN (no_lcommunity_list_name_expanded_all, |
17217 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17218 | "no bgp large-community-list expanded WORD", | |
17219 | NO_STR | |
17220 | BGP_STR | |
17221 | LCOMMUNITY_LIST_STR | |
17222 | "Specify expanded large-community-list\n" | |
17223 | "Large Community list name\n") | |
57d187bc | 17224 | { |
d62a17ae | 17225 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17226 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17227 | } |
17228 | ||
7336e101 SP |
17229 | DEFUN (no_lcommunity_list_standard, |
17230 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17231 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17232 | NO_STR |
17233 | BGP_STR | |
17234 | LCOMMUNITY_LIST_STR | |
17235 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17236 | "Sequence number of an entry\n" |
17237 | "Sequence number\n" | |
7336e101 SP |
17238 | "Specify large community to reject\n" |
17239 | "Specify large community to accept\n" | |
17240 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17241 | { |
d62a17ae | 17242 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17243 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17244 | } |
17245 | ||
7336e101 SP |
17246 | DEFUN (no_lcommunity_list_expanded, |
17247 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17248 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17249 | NO_STR |
17250 | BGP_STR | |
17251 | LCOMMUNITY_LIST_STR | |
17252 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17253 | "Sequence number of an entry\n" |
17254 | "Sequence number\n" | |
7336e101 SP |
17255 | "Specify large community to reject\n" |
17256 | "Specify large community to accept\n" | |
17257 | "An ordered list as a regular-expression\n") | |
57d187bc | 17258 | { |
d62a17ae | 17259 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17260 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17261 | } |
17262 | ||
7336e101 SP |
17263 | DEFUN (no_lcommunity_list_name_standard, |
17264 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17265 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17266 | NO_STR |
17267 | BGP_STR | |
17268 | LCOMMUNITY_LIST_STR | |
17269 | "Specify standard large-community-list\n" | |
17270 | "Large Community list name\n" | |
2f8cc0e5 DA |
17271 | "Sequence number of an entry\n" |
17272 | "Sequence number\n" | |
7336e101 SP |
17273 | "Specify large community to reject\n" |
17274 | "Specify large community to accept\n" | |
17275 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17276 | { |
d62a17ae | 17277 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17278 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17279 | } |
17280 | ||
7336e101 SP |
17281 | DEFUN (no_lcommunity_list_name_expanded, |
17282 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17283 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17284 | NO_STR |
17285 | BGP_STR | |
17286 | LCOMMUNITY_LIST_STR | |
17287 | "Specify expanded large-community-list\n" | |
17288 | "Large community list name\n" | |
2f8cc0e5 DA |
17289 | "Sequence number of an entry\n" |
17290 | "Sequence number\n" | |
7336e101 SP |
17291 | "Specify large community to reject\n" |
17292 | "Specify large community to accept\n" | |
17293 | "An ordered list as a regular-expression\n") | |
57d187bc | 17294 | { |
d62a17ae | 17295 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17296 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17297 | } |
17298 | ||
d62a17ae | 17299 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17300 | { | |
17301 | struct community_entry *entry; | |
17302 | ||
17303 | for (entry = list->head; entry; entry = entry->next) { | |
17304 | if (entry == list->head) { | |
17305 | if (all_digit(list->name)) | |
17306 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17307 | entry->style == |
17308 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17309 | ? "standard" |
17310 | : "(expanded) access", | |
17311 | list->name); | |
17312 | else | |
17313 | vty_out(vty, | |
17314 | "Named large community %s list %s\n", | |
169b72c8 | 17315 | entry->style == |
17316 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17317 | ? "standard" |
17318 | : "expanded", | |
17319 | list->name); | |
17320 | } | |
17321 | if (entry->any) | |
17322 | vty_out(vty, " %s\n", | |
17323 | community_direct_str(entry->direct)); | |
17324 | else | |
17325 | vty_out(vty, " %s %s\n", | |
17326 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17327 | community_list_config_str(entry)); |
d62a17ae | 17328 | } |
57d187bc JS |
17329 | } |
17330 | ||
7336e101 SP |
17331 | DEFUN (show_lcommunity_list, |
17332 | show_bgp_lcommunity_list_cmd, | |
17333 | "show bgp large-community-list", | |
57d187bc | 17334 | SHOW_STR |
7336e101 | 17335 | BGP_STR |
57d187bc JS |
17336 | "List large-community list\n") |
17337 | { | |
d62a17ae | 17338 | struct community_list *list; |
17339 | struct community_list_master *cm; | |
57d187bc | 17340 | |
d62a17ae | 17341 | cm = community_list_master_lookup(bgp_clist, |
17342 | LARGE_COMMUNITY_LIST_MASTER); | |
17343 | if (!cm) | |
17344 | return CMD_SUCCESS; | |
57d187bc | 17345 | |
d62a17ae | 17346 | for (list = cm->num.head; list; list = list->next) |
17347 | lcommunity_list_show(vty, list); | |
57d187bc | 17348 | |
d62a17ae | 17349 | for (list = cm->str.head; list; list = list->next) |
17350 | lcommunity_list_show(vty, list); | |
57d187bc | 17351 | |
d62a17ae | 17352 | return CMD_SUCCESS; |
57d187bc JS |
17353 | } |
17354 | ||
7336e101 SP |
17355 | DEFUN (show_lcommunity_list_arg, |
17356 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17357 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17358 | SHOW_STR |
17359 | BGP_STR | |
57d187bc | 17360 | "List large-community list\n" |
960b69b9 | 17361 | "Large-community-list number\n" |
17362 | "Large-community-list name\n" | |
17363 | "Detailed information on large-community-list\n") | |
57d187bc | 17364 | { |
d62a17ae | 17365 | struct community_list *list; |
57d187bc | 17366 | |
e237b0d2 | 17367 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17368 | LARGE_COMMUNITY_LIST_MASTER); |
17369 | if (!list) { | |
960b69b9 | 17370 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17371 | return CMD_WARNING; |
17372 | } | |
57d187bc | 17373 | |
d62a17ae | 17374 | lcommunity_list_show(vty, list); |
57d187bc | 17375 | |
d62a17ae | 17376 | return CMD_SUCCESS; |
57d187bc JS |
17377 | } |
17378 | ||
718e3744 | 17379 | /* "extcommunity-list" keyword help string. */ |
17380 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17381 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17382 | ||
7336e101 SP |
17383 | DEFUN (extcommunity_list_standard, |
17384 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17385 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17386 | BGP_STR |
718e3744 | 17387 | EXTCOMMUNITY_LIST_STR |
17388 | "Extended Community list number (standard)\n" | |
718e3744 | 17389 | "Specify standard extcommunity-list\n" |
5bf15956 | 17390 | "Community list name\n" |
2f8cc0e5 DA |
17391 | "Sequence number of an entry\n" |
17392 | "Sequence number\n" | |
718e3744 | 17393 | "Specify community to reject\n" |
17394 | "Specify community to accept\n" | |
17395 | EXTCOMMUNITY_VAL_STR) | |
17396 | { | |
d62a17ae | 17397 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17398 | int direct = 0; | |
17399 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17400 | char *seq = NULL; |
42f914d4 | 17401 | |
d62a17ae | 17402 | int idx = 0; |
7b9a4750 | 17403 | |
d62a17ae | 17404 | argv_find(argv, argc, "(1-99)", &idx); |
17405 | argv_find(argv, argc, "WORD", &idx); | |
17406 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17407 | |
17408 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17409 | if (idx) | |
17410 | seq = argv[idx]->arg; | |
17411 | ||
d62a17ae | 17412 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17413 | : COMMUNITY_DENY; | |
17414 | argv_find(argv, argc, "AA:NN", &idx); | |
17415 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17416 | |
2f8cc0e5 | 17417 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17418 | direct, style); |
42f914d4 | 17419 | |
d62a17ae | 17420 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17421 | |
d62a17ae | 17422 | if (ret < 0) { |
17423 | community_list_perror(vty, ret); | |
17424 | return CMD_WARNING_CONFIG_FAILED; | |
17425 | } | |
42f914d4 | 17426 | |
d62a17ae | 17427 | return CMD_SUCCESS; |
718e3744 | 17428 | } |
17429 | ||
7336e101 SP |
17430 | DEFUN (extcommunity_list_name_expanded, |
17431 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17432 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17433 | BGP_STR |
17434 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17435 | "Extended Community list number (expanded)\n" |
718e3744 | 17436 | "Specify expanded extcommunity-list\n" |
17437 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17438 | "Sequence number of an entry\n" |
17439 | "Sequence number\n" | |
718e3744 | 17440 | "Specify community to reject\n" |
17441 | "Specify community to accept\n" | |
17442 | "An ordered list as a regular-expression\n") | |
17443 | { | |
d62a17ae | 17444 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17445 | int direct = 0; | |
17446 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17447 | char *seq = NULL; |
d62a17ae | 17448 | int idx = 0; |
7336e101 | 17449 | |
d62a17ae | 17450 | argv_find(argv, argc, "(100-500)", &idx); |
17451 | argv_find(argv, argc, "WORD", &idx); | |
17452 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17453 | |
17454 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17455 | if (idx) | |
17456 | seq = argv[idx]->arg; | |
17457 | ||
d62a17ae | 17458 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17459 | : COMMUNITY_DENY; | |
17460 | argv_find(argv, argc, "LINE", &idx); | |
17461 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17462 | |
2f8cc0e5 | 17463 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17464 | direct, style); |
42f914d4 | 17465 | |
d62a17ae | 17466 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17467 | |
d62a17ae | 17468 | if (ret < 0) { |
17469 | community_list_perror(vty, ret); | |
17470 | return CMD_WARNING_CONFIG_FAILED; | |
17471 | } | |
42f914d4 | 17472 | |
d62a17ae | 17473 | return CMD_SUCCESS; |
718e3744 | 17474 | } |
17475 | ||
7336e101 SP |
17476 | DEFUN (no_extcommunity_list_standard_all, |
17477 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17478 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17479 | NO_STR |
17480 | BGP_STR | |
17481 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17482 | "Extended Community list number (standard)\n" |
718e3744 | 17483 | "Specify standard extcommunity-list\n" |
5bf15956 | 17484 | "Community list name\n" |
2f8cc0e5 DA |
17485 | "Sequence number of an entry\n" |
17486 | "Sequence number\n" | |
718e3744 | 17487 | "Specify community to reject\n" |
17488 | "Specify community to accept\n" | |
17489 | EXTCOMMUNITY_VAL_STR) | |
17490 | { | |
d62a17ae | 17491 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17492 | int direct = 0; | |
17493 | char *cl_number_or_name = NULL; | |
d4455c89 | 17494 | char *str = NULL; |
2f8cc0e5 | 17495 | char *seq = NULL; |
d62a17ae | 17496 | int idx = 0; |
d4455c89 | 17497 | |
2f8cc0e5 DA |
17498 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17499 | if (idx) | |
17500 | seq = argv[idx]->arg; | |
17501 | ||
17502 | idx = 0; | |
d4455c89 DA |
17503 | argv_find(argv, argc, "permit", &idx); |
17504 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17505 | if (idx) { |
17506 | direct = argv_find(argv, argc, "permit", &idx) | |
17507 | ? COMMUNITY_PERMIT | |
17508 | : COMMUNITY_DENY; | |
17509 | ||
17510 | idx = 0; | |
17511 | argv_find(argv, argc, "AA:NN", &idx); | |
17512 | str = argv_concat(argv, argc, idx); | |
17513 | } | |
17514 | ||
17515 | idx = 0; | |
d62a17ae | 17516 | argv_find(argv, argc, "(1-99)", &idx); |
17517 | argv_find(argv, argc, "WORD", &idx); | |
17518 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17519 | |
d62a17ae | 17520 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17521 | seq, direct, style); |
42f914d4 | 17522 | |
d62a17ae | 17523 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17524 | |
d62a17ae | 17525 | if (ret < 0) { |
17526 | community_list_perror(vty, ret); | |
17527 | return CMD_WARNING_CONFIG_FAILED; | |
17528 | } | |
42f914d4 | 17529 | |
d62a17ae | 17530 | return CMD_SUCCESS; |
718e3744 | 17531 | } |
17532 | ||
d4455c89 DA |
17533 | ALIAS(no_extcommunity_list_standard_all, |
17534 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17535 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17536 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17537 | "Extended Community list number (standard)\n" | |
17538 | "Specify standard extcommunity-list\n" | |
17539 | "Community list name\n") | |
17540 | ||
7336e101 SP |
17541 | DEFUN (no_extcommunity_list_expanded_all, |
17542 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17543 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17544 | NO_STR |
17545 | BGP_STR | |
17546 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17547 | "Extended Community list number (expanded)\n" |
718e3744 | 17548 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17549 | "Extended Community list name\n" |
2f8cc0e5 DA |
17550 | "Sequence number of an entry\n" |
17551 | "Sequence number\n" | |
718e3744 | 17552 | "Specify community to reject\n" |
17553 | "Specify community to accept\n" | |
17554 | "An ordered list as a regular-expression\n") | |
17555 | { | |
d62a17ae | 17556 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17557 | int direct = 0; | |
17558 | char *cl_number_or_name = NULL; | |
d4455c89 | 17559 | char *str = NULL; |
2f8cc0e5 | 17560 | char *seq = NULL; |
d62a17ae | 17561 | int idx = 0; |
d4455c89 | 17562 | |
2f8cc0e5 DA |
17563 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17564 | if (idx) | |
17565 | seq = argv[idx]->arg; | |
17566 | ||
17567 | idx = 0; | |
d4455c89 DA |
17568 | argv_find(argv, argc, "permit", &idx); |
17569 | argv_find(argv, argc, "deny", &idx); | |
17570 | ||
17571 | if (idx) { | |
17572 | direct = argv_find(argv, argc, "permit", &idx) | |
17573 | ? COMMUNITY_PERMIT | |
17574 | : COMMUNITY_DENY; | |
17575 | ||
17576 | idx = 0; | |
17577 | argv_find(argv, argc, "LINE", &idx); | |
17578 | str = argv_concat(argv, argc, idx); | |
17579 | } | |
17580 | ||
17581 | idx = 0; | |
d62a17ae | 17582 | argv_find(argv, argc, "(100-500)", &idx); |
17583 | argv_find(argv, argc, "WORD", &idx); | |
17584 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17585 | |
d62a17ae | 17586 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17587 | seq, direct, style); |
42f914d4 | 17588 | |
d62a17ae | 17589 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17590 | |
d62a17ae | 17591 | if (ret < 0) { |
17592 | community_list_perror(vty, ret); | |
17593 | return CMD_WARNING_CONFIG_FAILED; | |
17594 | } | |
42f914d4 | 17595 | |
d62a17ae | 17596 | return CMD_SUCCESS; |
718e3744 | 17597 | } |
17598 | ||
d4455c89 DA |
17599 | ALIAS(no_extcommunity_list_expanded_all, |
17600 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17601 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17602 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17603 | "Extended Community list number (expanded)\n" | |
17604 | "Specify expanded extcommunity-list\n" | |
17605 | "Extended Community list name\n") | |
17606 | ||
d62a17ae | 17607 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17608 | { |
d62a17ae | 17609 | struct community_entry *entry; |
718e3744 | 17610 | |
d62a17ae | 17611 | for (entry = list->head; entry; entry = entry->next) { |
17612 | if (entry == list->head) { | |
17613 | if (all_digit(list->name)) | |
17614 | vty_out(vty, "Extended community %s list %s\n", | |
17615 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17616 | ? "standard" | |
17617 | : "(expanded) access", | |
17618 | list->name); | |
17619 | else | |
17620 | vty_out(vty, | |
17621 | "Named extended community %s list %s\n", | |
17622 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17623 | ? "standard" | |
17624 | : "expanded", | |
17625 | list->name); | |
17626 | } | |
17627 | if (entry->any) | |
17628 | vty_out(vty, " %s\n", | |
17629 | community_direct_str(entry->direct)); | |
17630 | else | |
17631 | vty_out(vty, " %s %s\n", | |
17632 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17633 | community_list_config_str(entry)); |
d62a17ae | 17634 | } |
718e3744 | 17635 | } |
17636 | ||
7336e101 SP |
17637 | DEFUN (show_extcommunity_list, |
17638 | show_bgp_extcommunity_list_cmd, | |
17639 | "show bgp extcommunity-list", | |
718e3744 | 17640 | SHOW_STR |
7336e101 | 17641 | BGP_STR |
718e3744 | 17642 | "List extended-community list\n") |
17643 | { | |
d62a17ae | 17644 | struct community_list *list; |
17645 | struct community_list_master *cm; | |
718e3744 | 17646 | |
d62a17ae | 17647 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17648 | if (!cm) | |
17649 | return CMD_SUCCESS; | |
718e3744 | 17650 | |
d62a17ae | 17651 | for (list = cm->num.head; list; list = list->next) |
17652 | extcommunity_list_show(vty, list); | |
718e3744 | 17653 | |
d62a17ae | 17654 | for (list = cm->str.head; list; list = list->next) |
17655 | extcommunity_list_show(vty, list); | |
718e3744 | 17656 | |
d62a17ae | 17657 | return CMD_SUCCESS; |
718e3744 | 17658 | } |
17659 | ||
7336e101 SP |
17660 | DEFUN (show_extcommunity_list_arg, |
17661 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17662 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17663 | SHOW_STR |
17664 | BGP_STR | |
718e3744 | 17665 | "List extended-community list\n" |
17666 | "Extcommunity-list number\n" | |
960b69b9 | 17667 | "Extcommunity-list name\n" |
17668 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17669 | { |
d62a17ae | 17670 | int idx_comm_list = 3; |
17671 | struct community_list *list; | |
718e3744 | 17672 | |
e237b0d2 | 17673 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17674 | EXTCOMMUNITY_LIST_MASTER); |
17675 | if (!list) { | |
17676 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17677 | return CMD_WARNING; | |
17678 | } | |
718e3744 | 17679 | |
d62a17ae | 17680 | extcommunity_list_show(vty, list); |
718e3744 | 17681 | |
d62a17ae | 17682 | return CMD_SUCCESS; |
718e3744 | 17683 | } |
6b0655a2 | 17684 | |
718e3744 | 17685 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17686 | static int community_list_config_write(struct vty *vty) |
17687 | { | |
17688 | struct community_list *list; | |
17689 | struct community_entry *entry; | |
17690 | struct community_list_master *cm; | |
17691 | int write = 0; | |
17692 | ||
17693 | /* Community-list. */ | |
17694 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17695 | ||
17696 | for (list = cm->num.head; list; list = list->next) | |
17697 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17698 | vty_out(vty, |
17699 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
17700 | list->name, entry->seq, | |
d62a17ae | 17701 | community_direct_str(entry->direct), |
17702 | community_list_config_str(entry)); | |
17703 | write++; | |
17704 | } | |
17705 | for (list = cm->str.head; list; list = list->next) | |
17706 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17707 | vty_out(vty, |
17708 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 17709 | entry->style == COMMUNITY_LIST_STANDARD |
17710 | ? "standard" | |
17711 | : "expanded", | |
2f8cc0e5 DA |
17712 | list->name, entry->seq, |
17713 | community_direct_str(entry->direct), | |
d62a17ae | 17714 | community_list_config_str(entry)); |
17715 | write++; | |
17716 | } | |
17717 | ||
17718 | /* Extcommunity-list. */ | |
17719 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17720 | ||
17721 | for (list = cm->num.head; list; list = list->next) | |
17722 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17723 | vty_out(vty, |
17724 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
17725 | list->name, entry->seq, | |
17726 | community_direct_str(entry->direct), | |
d62a17ae | 17727 | community_list_config_str(entry)); |
17728 | write++; | |
17729 | } | |
17730 | for (list = cm->str.head; list; list = list->next) | |
17731 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17732 | vty_out(vty, |
17733 | "bgp extcommunity-list %s %s seq %" PRId64 | |
17734 | " %s %s\n", | |
d62a17ae | 17735 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17736 | ? "standard" | |
17737 | : "expanded", | |
2f8cc0e5 DA |
17738 | list->name, entry->seq, |
17739 | community_direct_str(entry->direct), | |
d62a17ae | 17740 | community_list_config_str(entry)); |
17741 | write++; | |
17742 | } | |
17743 | ||
17744 | ||
17745 | /* lcommunity-list. */ | |
17746 | cm = community_list_master_lookup(bgp_clist, | |
17747 | LARGE_COMMUNITY_LIST_MASTER); | |
17748 | ||
17749 | for (list = cm->num.head; list; list = list->next) | |
17750 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17751 | vty_out(vty, |
17752 | "bgp large-community-list %s seq %" PRId64 | |
17753 | " %s %s\n", | |
17754 | list->name, entry->seq, | |
17755 | community_direct_str(entry->direct), | |
d62a17ae | 17756 | community_list_config_str(entry)); |
17757 | write++; | |
17758 | } | |
17759 | for (list = cm->str.head; list; list = list->next) | |
17760 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17761 | vty_out(vty, |
17762 | "bgp large-community-list %s %s seq %" PRId64 | |
17763 | " %s %s\n", | |
17764 | ||
d62a17ae | 17765 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17766 | ? "standard" | |
17767 | : "expanded", | |
2f8cc0e5 | 17768 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 17769 | community_list_config_str(entry)); |
17770 | write++; | |
17771 | } | |
17772 | ||
17773 | return write; | |
17774 | } | |
17775 | ||
17776 | static struct cmd_node community_list_node = { | |
17777 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 17778 | }; |
17779 | ||
d62a17ae | 17780 | static void community_list_vty(void) |
17781 | { | |
17782 | install_node(&community_list_node, community_list_config_write); | |
17783 | ||
17784 | /* Community-list. */ | |
7336e101 SP |
17785 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
17786 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
17787 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 17788 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 17789 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 17790 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
17791 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
17792 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 17793 | |
17794 | /* Extcommunity-list. */ | |
7336e101 SP |
17795 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
17796 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
17797 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
17798 | install_element(CONFIG_NODE, |
17799 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 17800 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
17801 | install_element(CONFIG_NODE, |
17802 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
17803 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
17804 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 17805 | |
17806 | /* Large Community List */ | |
7336e101 | 17807 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
17808 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
17809 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 17810 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
17811 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
17812 | install_element(CONFIG_NODE, | |
17813 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
17814 | install_element(CONFIG_NODE, |
17815 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
17816 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
17817 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
17818 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
17819 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
17820 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
17821 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 17822 | } |