]>
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" |
b5e140c8 | 68 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 69 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 70 | #include "bgpd/bgp_mac.h" |
dd65f45e | 71 | #include "bgpd/bgp_flowspec.h" |
49e5a4a0 | 72 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
73 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
74 | #endif | |
75 | ||
ff8a8a7a CS |
76 | #include "northbound.h" |
77 | #include "northbound_cli.h" | |
78 | #include "bgpd/bgp_nb.h" | |
79 | ||
80 | ||
5d5393b9 | 81 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
82 | { |
83 | .val_bool = false, | |
84 | .match_profile = "traditional", | |
85 | .match_version = "< 7.4", | |
86 | }, | |
87 | { .val_bool = true }, | |
5d5393b9 DL |
88 | ) |
89 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
90 | { .val_bool = true, .match_profile = "datacenter", }, |
91 | { .val_bool = false }, | |
5d5393b9 | 92 | ) |
aef999a2 DA |
93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
94 | { .val_bool = true, .match_profile = "datacenter", }, | |
95 | { .val_bool = false }, | |
96 | ) | |
5d5393b9 | 97 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
98 | { .val_bool = true, .match_profile = "datacenter", }, |
99 | { .val_bool = false }, | |
5d5393b9 DL |
100 | ) |
101 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
102 | { .val_bool = true, .match_profile = "datacenter", }, |
103 | { .val_bool = false }, | |
5d5393b9 DL |
104 | ) |
105 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
106 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
107 | { .val_ulong = 120 }, | |
108 | ) | |
109 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
110 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 180 }, | |
112 | ) | |
113 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
114 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 60 }, | |
116 | ) | |
1d3fdccf DA |
117 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
118 | { .val_bool = false, .match_profile = "datacenter", }, | |
119 | { .val_bool = false, .match_version = "< 7.4", }, | |
120 | { .val_bool = true }, | |
121 | ) | |
2adac256 DA |
122 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
123 | { .val_bool = false, .match_version = "< 7.6", }, | |
124 | { .val_bool = true }, | |
125 | ) | |
5d5393b9 | 126 | |
dd65f45e DL |
127 | DEFINE_HOOK(bgp_inst_config_write, |
128 | (struct bgp *bgp, struct vty *vty), | |
129 | (bgp, vty)) | |
0d020cd6 | 130 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)) |
718e3744 | 131 | |
36235319 QY |
132 | #define GR_NO_OPER \ |
133 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
134 | #define GR_INVALID \ | |
135 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 136 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
137 | struct prefix *range, int exact); | |
138 | ||
055679e9 | 139 | /* Show BGP peer's information. */ |
140 | enum show_type { | |
141 | show_all, | |
142 | show_peer, | |
143 | show_ipv4_all, | |
144 | show_ipv6_all, | |
145 | show_ipv4_peer, | |
146 | show_ipv6_peer | |
147 | }; | |
148 | ||
36235319 QY |
149 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
150 | struct prefix *range, int exact); | |
2986cac2 | 151 | |
36235319 QY |
152 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
153 | struct bgp *bgp, | |
154 | bool use_json, | |
155 | json_object *json); | |
2986cac2 | 156 | |
36235319 QY |
157 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
158 | enum show_type type, | |
159 | const char *ip_str, | |
160 | afi_t afi, bool use_json); | |
2986cac2 | 161 | |
f4b8ec07 CS |
162 | static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str, |
163 | char *base_xpath, int xpath_len, | |
164 | char *abs_xpath); | |
165 | ||
d62a17ae | 166 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
167 | { | |
168 | switch (afi) { | |
169 | case AFI_IP: | |
170 | switch (safi) { | |
171 | case SAFI_UNICAST: | |
172 | return BGP_IPV4_NODE; | |
d62a17ae | 173 | case SAFI_MULTICAST: |
174 | return BGP_IPV4M_NODE; | |
d62a17ae | 175 | case SAFI_LABELED_UNICAST: |
176 | return BGP_IPV4L_NODE; | |
d62a17ae | 177 | case SAFI_MPLS_VPN: |
178 | return BGP_VPNV4_NODE; | |
7c40bf39 | 179 | case SAFI_FLOWSPEC: |
180 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
181 | default: |
182 | /* not expected */ | |
183 | return BGP_IPV4_NODE; | |
d62a17ae | 184 | } |
185 | break; | |
186 | case AFI_IP6: | |
187 | switch (safi) { | |
188 | case SAFI_UNICAST: | |
189 | return BGP_IPV6_NODE; | |
d62a17ae | 190 | case SAFI_MULTICAST: |
191 | return BGP_IPV6M_NODE; | |
d62a17ae | 192 | case SAFI_LABELED_UNICAST: |
193 | return BGP_IPV6L_NODE; | |
d62a17ae | 194 | case SAFI_MPLS_VPN: |
195 | return BGP_VPNV6_NODE; | |
7c40bf39 | 196 | case SAFI_FLOWSPEC: |
197 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
198 | default: |
199 | /* not expected */ | |
200 | return BGP_IPV4_NODE; | |
d62a17ae | 201 | } |
202 | break; | |
203 | case AFI_L2VPN: | |
204 | return BGP_EVPN_NODE; | |
b26f891d | 205 | case AFI_UNSPEC: |
d62a17ae | 206 | case AFI_MAX: |
207 | // We should never be here but to clarify the switch statement.. | |
208 | return BGP_IPV4_NODE; | |
d62a17ae | 209 | } |
210 | ||
211 | // Impossible to happen | |
212 | return BGP_IPV4_NODE; | |
f51bae9c | 213 | } |
20eb8864 | 214 | |
5cb5f4d0 DD |
215 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
216 | { | |
7d0d37de DS |
217 | if (afi == AFI_IP) { |
218 | if (safi == SAFI_UNICAST) | |
219 | return "IPv4 Unicast"; | |
220 | if (safi == SAFI_MULTICAST) | |
221 | return "IPv4 Multicast"; | |
222 | if (safi == SAFI_LABELED_UNICAST) | |
223 | return "IPv4 Labeled Unicast"; | |
224 | if (safi == SAFI_MPLS_VPN) | |
225 | return "IPv4 VPN"; | |
226 | if (safi == SAFI_ENCAP) | |
227 | return "IPv4 Encap"; | |
228 | if (safi == SAFI_FLOWSPEC) | |
229 | return "IPv4 Flowspec"; | |
230 | } else if (afi == AFI_IP6) { | |
231 | if (safi == SAFI_UNICAST) | |
232 | return "IPv6 Unicast"; | |
233 | if (safi == SAFI_MULTICAST) | |
234 | return "IPv6 Multicast"; | |
235 | if (safi == SAFI_LABELED_UNICAST) | |
236 | return "IPv6 Labeled Unicast"; | |
237 | if (safi == SAFI_MPLS_VPN) | |
238 | return "IPv6 VPN"; | |
239 | if (safi == SAFI_ENCAP) | |
240 | return "IPv6 Encap"; | |
241 | if (safi == SAFI_FLOWSPEC) | |
242 | return "IPv6 Flowspec"; | |
243 | } else if (afi == AFI_L2VPN) { | |
244 | if (safi == SAFI_EVPN) | |
245 | return "L2VPN EVPN"; | |
246 | } | |
247 | ||
248 | return "Unknown"; | |
5cb5f4d0 DD |
249 | } |
250 | ||
251 | /* | |
252 | * Please note that we have intentionally camelCased | |
253 | * the return strings here. So if you want | |
254 | * to use this function, please ensure you | |
255 | * are doing this within json output | |
256 | */ | |
257 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
258 | { | |
7d0d37de DS |
259 | if (afi == AFI_IP) { |
260 | if (safi == SAFI_UNICAST) | |
261 | return "ipv4Unicast"; | |
262 | if (safi == SAFI_MULTICAST) | |
263 | return "ipv4Multicast"; | |
264 | if (safi == SAFI_LABELED_UNICAST) | |
265 | return "ipv4LabeledUnicast"; | |
266 | if (safi == SAFI_MPLS_VPN) | |
267 | return "ipv4Vpn"; | |
268 | if (safi == SAFI_ENCAP) | |
269 | return "ipv4Encap"; | |
270 | if (safi == SAFI_FLOWSPEC) | |
271 | return "ipv4Flowspec"; | |
272 | } else if (afi == AFI_IP6) { | |
273 | if (safi == SAFI_UNICAST) | |
274 | return "ipv6Unicast"; | |
275 | if (safi == SAFI_MULTICAST) | |
276 | return "ipv6Multicast"; | |
277 | if (safi == SAFI_LABELED_UNICAST) | |
278 | return "ipv6LabeledUnicast"; | |
279 | if (safi == SAFI_MPLS_VPN) | |
280 | return "ipv6Vpn"; | |
281 | if (safi == SAFI_ENCAP) | |
282 | return "ipv6Encap"; | |
283 | if (safi == SAFI_FLOWSPEC) | |
284 | return "ipv6Flowspec"; | |
285 | } else if (afi == AFI_L2VPN) { | |
286 | if (safi == SAFI_EVPN) | |
287 | return "l2VpnEvpn"; | |
288 | } | |
289 | ||
290 | return "Unknown"; | |
5cb5f4d0 DD |
291 | } |
292 | ||
37a87b8f CS |
293 | /* return string maps to afi-safi specific container names |
294 | * defined in bgp yang file. | |
295 | */ | |
296 | const char *bgp_afi_safi_get_container_str(afi_t afi, safi_t safi) | |
297 | { | |
7d0d37de DS |
298 | if (afi == AFI_IP) { |
299 | if (safi == SAFI_UNICAST) | |
300 | return "ipv4-unicast"; | |
301 | if (safi == SAFI_MULTICAST) | |
302 | return "ipv4-multicast"; | |
303 | if (safi == SAFI_LABELED_UNICAST) | |
304 | return "ipv4-labeled-unicast"; | |
305 | if (safi == SAFI_MPLS_VPN) | |
306 | return "l3vpn-ipv4-unicast"; | |
307 | if (safi == SAFI_FLOWSPEC) | |
308 | return "ipv4-flowspec"; | |
309 | } else if (afi == AFI_IP6) { | |
310 | if (safi == SAFI_UNICAST) | |
311 | return "ipv6-unicast"; | |
312 | if (safi == SAFI_MULTICAST) | |
313 | return "ipv6-multicast"; | |
314 | if (safi == SAFI_LABELED_UNICAST) | |
315 | return "ipv6-labeled-unicast"; | |
316 | if (safi == SAFI_MPLS_VPN) | |
317 | return "l3vpn-ipv6-unicast"; | |
318 | if (safi == SAFI_FLOWSPEC) | |
319 | return "ipv6-flowspec"; | |
320 | } else if (afi == AFI_L2VPN) { | |
321 | if (safi == SAFI_EVPN) | |
322 | return "l2vpn-evpn"; | |
323 | } | |
324 | ||
325 | return "Unknown"; | |
37a87b8f CS |
326 | } |
327 | ||
718e3744 | 328 | /* Utility function to get address family from current node. */ |
d62a17ae | 329 | afi_t bgp_node_afi(struct vty *vty) |
330 | { | |
331 | afi_t afi; | |
332 | switch (vty->node) { | |
333 | case BGP_IPV6_NODE: | |
334 | case BGP_IPV6M_NODE: | |
335 | case BGP_IPV6L_NODE: | |
336 | case BGP_VPNV6_NODE: | |
7c40bf39 | 337 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 338 | afi = AFI_IP6; |
339 | break; | |
340 | case BGP_EVPN_NODE: | |
341 | afi = AFI_L2VPN; | |
342 | break; | |
343 | default: | |
344 | afi = AFI_IP; | |
345 | break; | |
346 | } | |
347 | return afi; | |
718e3744 | 348 | } |
349 | ||
350 | /* Utility function to get subsequent address family from current | |
351 | node. */ | |
d62a17ae | 352 | safi_t bgp_node_safi(struct vty *vty) |
353 | { | |
354 | safi_t safi; | |
355 | switch (vty->node) { | |
356 | case BGP_VPNV4_NODE: | |
357 | case BGP_VPNV6_NODE: | |
358 | safi = SAFI_MPLS_VPN; | |
359 | break; | |
360 | case BGP_IPV4M_NODE: | |
361 | case BGP_IPV6M_NODE: | |
362 | safi = SAFI_MULTICAST; | |
363 | break; | |
364 | case BGP_EVPN_NODE: | |
365 | safi = SAFI_EVPN; | |
366 | break; | |
367 | case BGP_IPV4L_NODE: | |
368 | case BGP_IPV6L_NODE: | |
369 | safi = SAFI_LABELED_UNICAST; | |
370 | break; | |
7c40bf39 | 371 | case BGP_FLOWSPECV4_NODE: |
372 | case BGP_FLOWSPECV6_NODE: | |
373 | safi = SAFI_FLOWSPEC; | |
374 | break; | |
d62a17ae | 375 | default: |
376 | safi = SAFI_UNICAST; | |
377 | break; | |
378 | } | |
379 | return safi; | |
718e3744 | 380 | } |
381 | ||
55f91488 QY |
382 | /** |
383 | * Converts an AFI in string form to afi_t | |
384 | * | |
385 | * @param afi string, one of | |
386 | * - "ipv4" | |
387 | * - "ipv6" | |
81cf0de5 | 388 | * - "l2vpn" |
55f91488 QY |
389 | * @return the corresponding afi_t |
390 | */ | |
d62a17ae | 391 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
392 | { | |
393 | afi_t afi = AFI_MAX; /* unknown */ | |
394 | if (strmatch(afi_str, "ipv4")) | |
395 | afi = AFI_IP; | |
396 | else if (strmatch(afi_str, "ipv6")) | |
397 | afi = AFI_IP6; | |
81cf0de5 CS |
398 | else if (strmatch(afi_str, "l2vpn")) |
399 | afi = AFI_L2VPN; | |
d62a17ae | 400 | return afi; |
401 | } | |
402 | ||
403 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
404 | afi_t *afi) | |
405 | { | |
406 | int ret = 0; | |
407 | if (argv_find(argv, argc, "ipv4", index)) { | |
408 | ret = 1; | |
409 | if (afi) | |
410 | *afi = AFI_IP; | |
411 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
412 | ret = 1; | |
413 | if (afi) | |
414 | *afi = AFI_IP6; | |
8688b3e7 DS |
415 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
416 | ret = 1; | |
417 | if (afi) | |
418 | *afi = AFI_L2VPN; | |
d62a17ae | 419 | } |
420 | return ret; | |
46f296b4 LB |
421 | } |
422 | ||
375a2e67 | 423 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 424 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
425 | { | |
426 | safi_t safi = SAFI_MAX; /* unknown */ | |
427 | if (strmatch(safi_str, "multicast")) | |
428 | safi = SAFI_MULTICAST; | |
429 | else if (strmatch(safi_str, "unicast")) | |
430 | safi = SAFI_UNICAST; | |
431 | else if (strmatch(safi_str, "vpn")) | |
432 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
433 | else if (strmatch(safi_str, "evpn")) |
434 | safi = SAFI_EVPN; | |
d62a17ae | 435 | else if (strmatch(safi_str, "labeled-unicast")) |
436 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 437 | else if (strmatch(safi_str, "flowspec")) |
438 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 439 | return safi; |
440 | } | |
441 | ||
442 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
443 | safi_t *safi) | |
444 | { | |
445 | int ret = 0; | |
446 | if (argv_find(argv, argc, "unicast", index)) { | |
447 | ret = 1; | |
448 | if (safi) | |
449 | *safi = SAFI_UNICAST; | |
450 | } else if (argv_find(argv, argc, "multicast", index)) { | |
451 | ret = 1; | |
452 | if (safi) | |
453 | *safi = SAFI_MULTICAST; | |
454 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
455 | ret = 1; | |
456 | if (safi) | |
457 | *safi = SAFI_LABELED_UNICAST; | |
458 | } else if (argv_find(argv, argc, "vpn", index)) { | |
459 | ret = 1; | |
460 | if (safi) | |
461 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
462 | } else if (argv_find(argv, argc, "evpn", index)) { |
463 | ret = 1; | |
464 | if (safi) | |
465 | *safi = SAFI_EVPN; | |
7c40bf39 | 466 | } else if (argv_find(argv, argc, "flowspec", index)) { |
467 | ret = 1; | |
468 | if (safi) | |
469 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 470 | } |
471 | return ret; | |
46f296b4 LB |
472 | } |
473 | ||
5d5393b9 DL |
474 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
475 | enum bgp_instance_type inst_type) | |
476 | { | |
477 | int ret = bgp_get(bgp, as, name, inst_type); | |
478 | ||
479 | if (ret == BGP_CREATED) { | |
480 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 481 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
482 | |
483 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 484 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 485 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 486 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
487 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
488 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 489 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 490 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 491 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 492 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
493 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
494 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
495 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
496 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
5d5393b9 DL |
497 | |
498 | ret = BGP_SUCCESS; | |
499 | } | |
500 | return ret; | |
501 | } | |
502 | ||
7eeee51e | 503 | /* |
f212a857 | 504 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 505 | * |
f212a857 DS |
506 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
507 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
508 | * to appropriate values for the calling function. This is to allow the |
509 | * calling function to make decisions appropriate for the show command | |
510 | * that is being parsed. | |
511 | * | |
512 | * The show commands are generally of the form: | |
d62a17ae | 513 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
514 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
515 | * |
516 | * Since we use argv_find if the show command in particular doesn't have: | |
517 | * [ip] | |
18c57037 | 518 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 519 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
520 | * The command parsing should still be ok. |
521 | * | |
522 | * vty -> The vty for the command so we can output some useful data in | |
523 | * the event of a parse error in the vrf. | |
524 | * argv -> The command tokens | |
525 | * argc -> How many command tokens we have | |
d62a17ae | 526 | * idx -> The current place in the command, generally should be 0 for this |
527 | * function | |
7eeee51e DS |
528 | * afi -> The parsed afi if it was included in the show command, returned here |
529 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 530 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 531 | * use_json -> json is configured or not |
7eeee51e DS |
532 | * |
533 | * The function returns the correct location in the parse tree for the | |
534 | * last token found. | |
0e37c258 DS |
535 | * |
536 | * Returns 0 for failure to parse correctly, else the idx position of where | |
537 | * it found the last token. | |
7eeee51e | 538 | */ |
d62a17ae | 539 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
540 | struct cmd_token **argv, int argc, | |
541 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 542 | struct bgp **bgp, bool use_json) |
d62a17ae | 543 | { |
544 | char *vrf_name = NULL; | |
545 | ||
546 | assert(afi); | |
547 | assert(safi); | |
548 | assert(bgp); | |
549 | ||
550 | if (argv_find(argv, argc, "ip", idx)) | |
551 | *afi = AFI_IP; | |
552 | ||
9a8bdf1c | 553 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 554 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
555 | else if (argv_find(argv, argc, "vrf", idx)) { |
556 | vrf_name = argv[*idx + 1]->arg; | |
557 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
558 | vrf_name = NULL; | |
559 | } | |
560 | if (vrf_name) { | |
d62a17ae | 561 | if (strmatch(vrf_name, "all")) |
562 | *bgp = NULL; | |
563 | else { | |
564 | *bgp = bgp_lookup_by_name(vrf_name); | |
565 | if (!*bgp) { | |
52e5b8c4 SP |
566 | if (use_json) { |
567 | json_object *json = NULL; | |
568 | json = json_object_new_object(); | |
569 | json_object_string_add( | |
570 | json, "warning", | |
571 | "View/Vrf is unknown"); | |
572 | vty_out(vty, "%s\n", | |
573 | json_object_to_json_string_ext(json, | |
574 | JSON_C_TO_STRING_PRETTY)); | |
575 | json_object_free(json); | |
576 | } | |
ca61fd25 DS |
577 | else |
578 | vty_out(vty, "View/Vrf %s is unknown\n", | |
579 | vrf_name); | |
d62a17ae | 580 | *idx = 0; |
581 | return 0; | |
582 | } | |
583 | } | |
584 | } else { | |
585 | *bgp = bgp_get_default(); | |
586 | if (!*bgp) { | |
52e5b8c4 SP |
587 | if (use_json) { |
588 | json_object *json = NULL; | |
589 | json = json_object_new_object(); | |
590 | json_object_string_add( | |
591 | json, "warning", | |
592 | "Default BGP instance not found"); | |
593 | vty_out(vty, "%s\n", | |
594 | json_object_to_json_string_ext(json, | |
595 | JSON_C_TO_STRING_PRETTY)); | |
596 | json_object_free(json); | |
597 | } | |
ca61fd25 DS |
598 | else |
599 | vty_out(vty, | |
600 | "Default BGP instance not found\n"); | |
d62a17ae | 601 | *idx = 0; |
602 | return 0; | |
603 | } | |
604 | } | |
605 | ||
606 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
607 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
608 | ||
609 | *idx += 1; | |
610 | return *idx; | |
611 | } | |
612 | ||
f4b8ec07 | 613 | bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 614 | { |
615 | struct interface *ifp = NULL; | |
616 | ||
617 | if (su->sa.sa_family == AF_INET) | |
618 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
619 | else if (su->sa.sa_family == AF_INET6) | |
620 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
621 | su->sin6.sin6_scope_id, | |
622 | bgp->vrf_id); | |
623 | ||
624 | if (ifp) | |
3dc339cd | 625 | return true; |
d62a17ae | 626 | |
3dc339cd | 627 | return false; |
718e3744 | 628 | } |
629 | ||
718e3744 | 630 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
631 | /* This is used only for configuration, so disallow if attempted on |
632 | * a dynamic neighbor. | |
633 | */ | |
d62a17ae | 634 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
635 | { | |
636 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
637 | int ret; | |
638 | union sockunion su; | |
639 | struct peer *peer = NULL; | |
640 | struct peer_group *group = NULL; | |
641 | ||
642 | if (!bgp) { | |
643 | return NULL; | |
644 | } | |
645 | ||
646 | ret = str2sockunion(peer_str, &su); | |
647 | if (ret == 0) { | |
648 | /* IP address, locate peer. */ | |
649 | peer = peer_lookup(bgp, &su); | |
650 | } else { | |
651 | /* Not IP, could match either peer configured on interface or a | |
652 | * group. */ | |
653 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
654 | if (!peer) | |
655 | group = peer_group_lookup(bgp, peer_str); | |
656 | } | |
657 | ||
658 | if (peer) { | |
659 | if (peer_dynamic_neighbor(peer)) { | |
660 | vty_out(vty, | |
661 | "%% Operation not allowed on a dynamic neighbor\n"); | |
662 | return NULL; | |
663 | } | |
664 | ||
665 | return peer; | |
666 | } | |
667 | ||
668 | if (group) | |
669 | return group->conf; | |
670 | ||
671 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
672 | ||
673 | return NULL; | |
674 | } | |
675 | ||
f4b8ec07 CS |
676 | int bgp_nb_errmsg_return(char *errmsg, size_t errmsg_len, int ret) |
677 | { | |
678 | const char *str = NULL; | |
679 | ||
680 | switch (ret) { | |
681 | case BGP_ERR_INVALID_VALUE: | |
682 | str = "Invalid value"; | |
683 | break; | |
684 | case BGP_ERR_INVALID_FLAG: | |
685 | str = "Invalid flag"; | |
686 | break; | |
687 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
688 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
689 | break; | |
690 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
691 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
692 | break; | |
693 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
694 | str = "Specify remote-as or peer-group remote AS first"; | |
695 | break; | |
696 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
697 | str = "Cannot change the peer-group. Deconfigure first"; | |
698 | break; | |
699 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
700 | str = "Peer is not a member of this peer-group"; | |
701 | break; | |
702 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
703 | str = "Prefix/distribute list can not co-exist"; | |
704 | break; | |
705 | case BGP_ERR_NOT_INTERNAL_PEER: | |
706 | str = "Invalid command. Not an internal neighbor"; | |
707 | break; | |
708 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
709 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
710 | break; | |
711 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
712 | str = "Local-AS allowed only for EBGP peers"; | |
713 | break; | |
714 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
715 | str = "Cannot have local-as same as BGP AS number"; | |
716 | break; | |
717 | case BGP_ERR_TCPSIG_FAILED: | |
718 | str = "Error while applying TCP-Sig to session(s)"; | |
719 | break; | |
720 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
721 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
722 | break; | |
723 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
724 | str = "ttl-security only allowed for EBGP peers"; | |
725 | break; | |
726 | case BGP_ERR_AS_OVERRIDE: | |
727 | str = "as-override cannot be configured for IBGP peers"; | |
728 | break; | |
729 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
730 | str = "Invalid limit for number of dynamic neighbors"; | |
731 | break; | |
732 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
733 | str = "Dynamic neighbor listen range already exists"; | |
734 | break; | |
735 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
736 | str = "Operation not allowed on a dynamic neighbor"; | |
737 | break; | |
738 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
739 | str = "Operation not allowed on a directly connected neighbor"; | |
740 | break; | |
741 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
742 | str = GR_INVALID; | |
743 | break; | |
744 | case BGP_ERR_GR_INVALID_CMD: | |
745 | str = "The Graceful Restart command used is not valid at this moment."; | |
746 | break; | |
747 | case BGP_ERR_GR_OPERATION_FAILED: | |
748 | str = "The Graceful Restart Operation failed due to an err."; | |
749 | break; | |
750 | case BGP_GR_NO_OPERATION: | |
751 | str = GR_NO_OPER; | |
752 | break; | |
753 | case BGP_ERR_PEER_GROUP_MEMBER: | |
754 | str = "Peer-group member cannot override remote-as of peer-group"; | |
755 | break; | |
756 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
757 | str = "Peer-group members must be all internal or all external"; | |
758 | break; | |
759 | } | |
760 | if (str) { | |
761 | snprintf(errmsg, errmsg_len, "%s", str); | |
762 | return -1; | |
763 | } | |
764 | ||
765 | return 0; | |
766 | } | |
767 | ||
d62a17ae | 768 | int bgp_vty_return(struct vty *vty, int ret) |
769 | { | |
770 | const char *str = NULL; | |
771 | ||
772 | switch (ret) { | |
773 | case BGP_ERR_INVALID_VALUE: | |
774 | str = "Invalid value"; | |
775 | break; | |
776 | case BGP_ERR_INVALID_FLAG: | |
777 | str = "Invalid flag"; | |
778 | break; | |
779 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
780 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
781 | break; | |
782 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
783 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
784 | break; | |
785 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
786 | str = "Specify remote-as or peer-group remote AS first"; | |
787 | break; | |
788 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
789 | str = "Cannot change the peer-group. Deconfigure first"; | |
790 | break; | |
791 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
792 | str = "Peer is not a member of this peer-group"; | |
793 | break; | |
794 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
795 | str = "Prefix/distribute list can not co-exist"; | |
796 | break; | |
797 | case BGP_ERR_NOT_INTERNAL_PEER: | |
798 | str = "Invalid command. Not an internal neighbor"; | |
799 | break; | |
800 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
801 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
802 | break; | |
803 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
804 | str = "Local-AS allowed only for EBGP peers"; | |
805 | break; | |
806 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
807 | str = "Cannot have local-as same as BGP AS number"; | |
808 | break; | |
809 | case BGP_ERR_TCPSIG_FAILED: | |
810 | str = "Error while applying TCP-Sig to session(s)"; | |
811 | break; | |
812 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
813 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
814 | break; | |
815 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
816 | str = "ttl-security only allowed for EBGP peers"; | |
817 | break; | |
818 | case BGP_ERR_AS_OVERRIDE: | |
819 | str = "as-override cannot be configured for IBGP peers"; | |
820 | break; | |
821 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
822 | str = "Invalid limit for number of dynamic neighbors"; | |
823 | break; | |
824 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
825 | str = "Dynamic neighbor listen range already exists"; | |
826 | break; | |
827 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
828 | str = "Operation not allowed on a dynamic neighbor"; | |
829 | break; | |
830 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
831 | str = "Operation not allowed on a directly connected neighbor"; | |
832 | break; | |
833 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 834 | str = GR_INVALID; |
835 | break; | |
836 | case BGP_ERR_GR_INVALID_CMD: | |
837 | str = "The Graceful Restart command used is not valid at this moment."; | |
838 | break; | |
839 | case BGP_ERR_GR_OPERATION_FAILED: | |
840 | str = "The Graceful Restart Operation failed due to an err."; | |
841 | break; | |
842 | case BGP_GR_NO_OPERATION: | |
843 | str = GR_NO_OPER; | |
d62a17ae | 844 | break; |
845 | } | |
846 | if (str) { | |
847 | vty_out(vty, "%% %s\n", str); | |
848 | return CMD_WARNING_CONFIG_FAILED; | |
849 | } | |
850 | return CMD_SUCCESS; | |
718e3744 | 851 | } |
852 | ||
7aafcaca | 853 | /* BGP clear sort. */ |
d62a17ae | 854 | enum clear_sort { |
855 | clear_all, | |
856 | clear_peer, | |
857 | clear_group, | |
858 | clear_external, | |
859 | clear_as | |
7aafcaca DS |
860 | }; |
861 | ||
ff8a8a7a CS |
862 | static void bgp_clear_vty_error(struct peer *peer, afi_t afi, safi_t safi, |
863 | int error, char *errmsg, size_t errmsg_len) | |
d62a17ae | 864 | { |
865 | switch (error) { | |
866 | case BGP_ERR_AF_UNCONFIGURED: | |
ff8a8a7a CS |
867 | snprintf(errmsg, errmsg_len, |
868 | "%%BGP: Enable %s address family for the neighbor %s", | |
869 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 870 | break; |
871 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
ff8a8a7a CS |
872 | snprintf( |
873 | errmsg, errmsg_len, | |
874 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig", | |
d62a17ae | 875 | peer->host); |
876 | break; | |
877 | default: | |
878 | break; | |
879 | } | |
7aafcaca DS |
880 | } |
881 | ||
dc912615 | 882 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 883 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
884 | { |
885 | int ret = 0; | |
2adac256 | 886 | struct peer_af *paf; |
dc912615 DS |
887 | |
888 | /* if afi/.safi not specified, spin thru all of them */ | |
889 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
890 | afi_t tmp_afi; | |
891 | safi_t tmp_safi; | |
892 | ||
893 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
2adac256 DA |
894 | paf = peer_af_find(peer, tmp_afi, tmp_safi); |
895 | if (paf && paf->subgroup) | |
896 | SET_FLAG(paf->subgroup->sflags, | |
897 | SUBGRP_STATUS_FORCE_UPDATES); | |
898 | ||
dc912615 DS |
899 | if (!peer->afc[tmp_afi][tmp_safi]) |
900 | continue; | |
901 | ||
902 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 903 | ret = peer_clear(peer, nnode); |
dc912615 DS |
904 | else |
905 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
906 | stype); | |
907 | } | |
908 | /* if afi specified and safi not, spin thru safis on this afi */ | |
909 | } else if (safi == SAFI_UNSPEC) { | |
910 | safi_t tmp_safi; | |
911 | ||
912 | for (tmp_safi = SAFI_UNICAST; | |
913 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
914 | if (!peer->afc[afi][tmp_safi]) | |
915 | continue; | |
916 | ||
2adac256 DA |
917 | paf = peer_af_find(peer, afi, tmp_safi); |
918 | if (paf && paf->subgroup) | |
919 | SET_FLAG(paf->subgroup->sflags, | |
920 | SUBGRP_STATUS_FORCE_UPDATES); | |
921 | ||
dc912615 | 922 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 923 | ret = peer_clear(peer, nnode); |
dc912615 DS |
924 | else |
925 | ret = peer_clear_soft(peer, afi, | |
926 | tmp_safi, stype); | |
927 | } | |
928 | /* both afi/safi specified, let the caller know if not defined */ | |
929 | } else { | |
930 | if (!peer->afc[afi][safi]) | |
931 | return 1; | |
932 | ||
2adac256 DA |
933 | paf = peer_af_find(peer, afi, safi); |
934 | if (paf && paf->subgroup) | |
935 | SET_FLAG(paf->subgroup->sflags, | |
936 | SUBGRP_STATUS_FORCE_UPDATES); | |
937 | ||
dc912615 | 938 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 939 | ret = peer_clear(peer, nnode); |
dc912615 DS |
940 | else |
941 | ret = peer_clear_soft(peer, afi, safi, stype); | |
942 | } | |
943 | ||
944 | return ret; | |
945 | } | |
946 | ||
7aafcaca | 947 | /* `clear ip bgp' functions. */ |
ff8a8a7a | 948 | static int bgp_clear(struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 949 | enum clear_sort sort, enum bgp_clear_type stype, |
ff8a8a7a | 950 | const char *arg, char *errmsg, size_t errmsg_len) |
d62a17ae | 951 | { |
dc912615 | 952 | int ret = 0; |
3ae8bfa5 | 953 | bool found = false; |
d62a17ae | 954 | struct peer *peer; |
dc95985f | 955 | |
956 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 957 | |
958 | /* Clear all neighbors. */ | |
959 | /* | |
960 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
961 | * nodes on the BGP instance as that may get freed if it is a |
962 | * doppelganger | |
d62a17ae | 963 | */ |
964 | if (sort == clear_all) { | |
965 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 966 | |
967 | bgp_peer_gr_flags_update(peer); | |
968 | ||
36235319 | 969 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 970 | gr_router_detected = true; |
971 | ||
c368171c | 972 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 973 | stype); |
d62a17ae | 974 | |
975 | if (ret < 0) | |
ff8a8a7a CS |
976 | bgp_clear_vty_error(peer, afi, safi, ret, |
977 | errmsg, errmsg_len); | |
dc95985f | 978 | } |
979 | ||
36235319 QY |
980 | if (gr_router_detected |
981 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 982 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
983 | } else if (!gr_router_detected |
984 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 985 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 986 | } |
d62a17ae | 987 | |
988 | /* This is to apply read-only mode on this clear. */ | |
989 | if (stype == BGP_CLEAR_SOFT_NONE) | |
990 | bgp->update_delay_over = 0; | |
991 | ||
992 | return CMD_SUCCESS; | |
7aafcaca DS |
993 | } |
994 | ||
3ae8bfa5 | 995 | /* Clear specified neighbor. */ |
d62a17ae | 996 | if (sort == clear_peer) { |
997 | union sockunion su; | |
d62a17ae | 998 | |
999 | /* Make sockunion for lookup. */ | |
1000 | ret = str2sockunion(arg, &su); | |
1001 | if (ret < 0) { | |
1002 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1003 | if (!peer) { | |
1004 | peer = peer_lookup_by_hostname(bgp, arg); | |
1005 | if (!peer) { | |
ff8a8a7a CS |
1006 | snprintf( |
1007 | errmsg, errmsg_len, | |
1008 | "Malformed address or name: %s", | |
d62a17ae | 1009 | arg); |
1010 | return CMD_WARNING; | |
1011 | } | |
1012 | } | |
1013 | } else { | |
1014 | peer = peer_lookup(bgp, &su); | |
1015 | if (!peer) { | |
ff8a8a7a CS |
1016 | snprintf(errmsg, errmsg_len, |
1017 | "%%BGP: Unknown neighbor - \"%s\"", | |
1018 | arg); | |
d62a17ae | 1019 | return CMD_WARNING; |
1020 | } | |
1021 | } | |
7aafcaca | 1022 | |
dc95985f | 1023 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1024 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1025 | ||
dc912615 DS |
1026 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1027 | ||
1028 | /* if afi/safi not defined for this peer, let caller know */ | |
1029 | if (ret == 1) | |
3ae8bfa5 | 1030 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1031 | |
d62a17ae | 1032 | if (ret < 0) |
ff8a8a7a CS |
1033 | bgp_clear_vty_error(peer, afi, safi, ret, errmsg, |
1034 | errmsg_len); | |
7aafcaca | 1035 | |
d62a17ae | 1036 | return CMD_SUCCESS; |
7aafcaca | 1037 | } |
7aafcaca | 1038 | |
3ae8bfa5 | 1039 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1040 | if (sort == clear_group) { |
1041 | struct peer_group *group; | |
7aafcaca | 1042 | |
d62a17ae | 1043 | group = peer_group_lookup(bgp, arg); |
1044 | if (!group) { | |
ff8a8a7a CS |
1045 | snprintf(errmsg, errmsg_len, |
1046 | "%%BGP: No such peer-group %s", arg); | |
d62a17ae | 1047 | return CMD_WARNING; |
1048 | } | |
1049 | ||
1050 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1051 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1052 | |
d62a17ae | 1053 | if (ret < 0) |
ff8a8a7a CS |
1054 | bgp_clear_vty_error(peer, afi, safi, ret, |
1055 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1056 | else |
1057 | found = true; | |
d62a17ae | 1058 | } |
3ae8bfa5 PM |
1059 | |
1060 | if (!found) | |
ff8a8a7a CS |
1061 | snprintf( |
1062 | errmsg, errmsg_len, | |
1063 | "%%BGP: No %s peer belonging to peer-group %s is configured", | |
5cb5f4d0 | 1064 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1065 | |
d62a17ae | 1066 | return CMD_SUCCESS; |
7aafcaca | 1067 | } |
7aafcaca | 1068 | |
3ae8bfa5 | 1069 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1070 | if (sort == clear_external) { |
1071 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1072 | if (peer->sort == BGP_PEER_IBGP) | |
1073 | continue; | |
7aafcaca | 1074 | |
dc95985f | 1075 | bgp_peer_gr_flags_update(peer); |
1076 | ||
36235319 | 1077 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1078 | gr_router_detected = true; |
dc95985f | 1079 | |
c368171c | 1080 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1081 | |
d62a17ae | 1082 | if (ret < 0) |
ff8a8a7a CS |
1083 | bgp_clear_vty_error(peer, afi, safi, ret, |
1084 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1085 | else |
1086 | found = true; | |
d62a17ae | 1087 | } |
3ae8bfa5 | 1088 | |
36235319 QY |
1089 | if (gr_router_detected |
1090 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1091 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1092 | } else if (!gr_router_detected |
1093 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1094 | bgp_zebra_send_capabilities(bgp, true); |
1095 | } | |
1096 | ||
3ae8bfa5 | 1097 | if (!found) |
ff8a8a7a CS |
1098 | snprintf(errmsg, errmsg_len, |
1099 | "%%BGP: No external %s peer is configured", | |
1100 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 1101 | |
d62a17ae | 1102 | return CMD_SUCCESS; |
1103 | } | |
1104 | ||
3ae8bfa5 | 1105 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1106 | if (sort == clear_as) { |
3ae8bfa5 | 1107 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1108 | |
1109 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1110 | if (peer->as != as) | |
1111 | continue; | |
1112 | ||
dc95985f | 1113 | bgp_peer_gr_flags_update(peer); |
1114 | ||
36235319 | 1115 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1116 | gr_router_detected = true; |
dc95985f | 1117 | |
c368171c | 1118 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1119 | |
1120 | if (ret < 0) | |
ff8a8a7a CS |
1121 | bgp_clear_vty_error(peer, afi, safi, ret, |
1122 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1123 | else |
1124 | found = true; | |
d62a17ae | 1125 | } |
3ae8bfa5 | 1126 | |
36235319 QY |
1127 | if (gr_router_detected |
1128 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1129 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1130 | } else if (!gr_router_detected |
1131 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1132 | bgp_zebra_send_capabilities(bgp, true); |
1133 | } | |
1134 | ||
3ae8bfa5 | 1135 | if (!found) |
ff8a8a7a CS |
1136 | snprintf(errmsg, errmsg_len, |
1137 | "%%BGP: No %s peer is configured with AS %s", | |
1138 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1139 | |
d62a17ae | 1140 | return CMD_SUCCESS; |
1141 | } | |
1142 | ||
1143 | return CMD_SUCCESS; | |
1144 | } | |
1145 | ||
ff8a8a7a CS |
1146 | static int bgp_clear_vty(const char *name, afi_t afi, safi_t safi, |
1147 | enum clear_sort sort, enum bgp_clear_type stype, | |
1148 | const char *arg, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1149 | { |
1150 | struct bgp *bgp; | |
1151 | ||
1152 | /* BGP structure lookup. */ | |
1153 | if (name) { | |
1154 | bgp = bgp_lookup_by_name(name); | |
1155 | if (bgp == NULL) { | |
ff8a8a7a CS |
1156 | snprintf(errmsg, errmsg_len, |
1157 | "Can't find BGP instance %s", name); | |
d62a17ae | 1158 | return CMD_WARNING; |
1159 | } | |
1160 | } else { | |
1161 | bgp = bgp_get_default(); | |
1162 | if (bgp == NULL) { | |
ff8a8a7a CS |
1163 | snprintf(errmsg, errmsg_len, |
1164 | "No BGP process is configured"); | |
d62a17ae | 1165 | return CMD_WARNING; |
1166 | } | |
1167 | } | |
1168 | ||
ff8a8a7a | 1169 | return bgp_clear(bgp, afi, safi, sort, stype, arg, errmsg, errmsg_len); |
7aafcaca DS |
1170 | } |
1171 | ||
1172 | /* clear soft inbound */ | |
ff8a8a7a | 1173 | int bgp_clear_star_soft_in(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1174 | { |
99b3ebd3 NS |
1175 | afi_t afi; |
1176 | safi_t safi; | |
ff8a8a7a CS |
1177 | int ret; |
1178 | ||
1179 | FOREACH_AFI_SAFI (afi, safi) { | |
1180 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1181 | BGP_CLEAR_SOFT_IN, NULL, errmsg, | |
1182 | errmsg_len); | |
1183 | if (ret != CMD_SUCCESS) | |
1184 | return -1; | |
1185 | } | |
99b3ebd3 | 1186 | |
ff8a8a7a | 1187 | return 0; |
7aafcaca DS |
1188 | } |
1189 | ||
1190 | /* clear soft outbound */ | |
ff8a8a7a | 1191 | int bgp_clear_star_soft_out(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1192 | { |
99b3ebd3 NS |
1193 | afi_t afi; |
1194 | safi_t safi; | |
ff8a8a7a | 1195 | int ret; |
99b3ebd3 | 1196 | |
ff8a8a7a CS |
1197 | FOREACH_AFI_SAFI (afi, safi) { |
1198 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1199 | BGP_CLEAR_SOFT_OUT, NULL, errmsg, | |
1200 | errmsg_len); | |
1201 | if (ret != CMD_SUCCESS) | |
1202 | return -1; | |
1203 | } | |
1204 | ||
1205 | return 0; | |
7aafcaca DS |
1206 | } |
1207 | ||
1208 | ||
f787d7a0 | 1209 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1210 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1211 | #endif |
1212 | ||
8029b216 AK |
1213 | DEFUN_HIDDEN (bgp_local_mac, |
1214 | bgp_local_mac_cmd, | |
093e3f23 | 1215 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1216 | BGP_STR |
1217 | "Local MAC config\n" | |
1218 | "VxLAN Network Identifier\n" | |
1219 | "VNI number\n" | |
1220 | "local mac\n" | |
1221 | "mac address\n" | |
1222 | "mac-mobility sequence\n" | |
1223 | "seq number\n") | |
1224 | { | |
1225 | int rv; | |
1226 | vni_t vni; | |
1227 | struct ethaddr mac; | |
1228 | struct ipaddr ip; | |
1229 | uint32_t seq; | |
1230 | struct bgp *bgp; | |
1231 | ||
1232 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1233 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1234 | vty_out(vty, "%% Malformed MAC address\n"); | |
1235 | return CMD_WARNING; | |
1236 | } | |
1237 | memset(&ip, 0, sizeof(ip)); | |
1238 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1239 | ||
1240 | bgp = bgp_get_default(); | |
1241 | if (!bgp) { | |
1242 | vty_out(vty, "Default BGP instance is not there\n"); | |
1243 | return CMD_WARNING; | |
1244 | } | |
1245 | ||
b5e140c8 AK |
1246 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1247 | zero_esi); | |
8029b216 AK |
1248 | if (rv < 0) { |
1249 | vty_out(vty, "Internal error\n"); | |
1250 | return CMD_WARNING; | |
1251 | } | |
1252 | ||
1253 | return CMD_SUCCESS; | |
1254 | } | |
1255 | ||
1256 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1257 | no_bgp_local_mac_cmd, | |
093e3f23 | 1258 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1259 | NO_STR |
1260 | BGP_STR | |
1261 | "Local MAC config\n" | |
1262 | "VxLAN Network Identifier\n" | |
1263 | "VNI number\n" | |
1264 | "local mac\n" | |
1265 | "mac address\n") | |
1266 | { | |
1267 | int rv; | |
1268 | vni_t vni; | |
1269 | struct ethaddr mac; | |
1270 | struct ipaddr ip; | |
1271 | struct bgp *bgp; | |
1272 | ||
1273 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1274 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1275 | vty_out(vty, "%% Malformed MAC address\n"); | |
1276 | return CMD_WARNING; | |
1277 | } | |
1278 | memset(&ip, 0, sizeof(ip)); | |
1279 | ||
1280 | bgp = bgp_get_default(); | |
1281 | if (!bgp) { | |
1282 | vty_out(vty, "Default BGP instance is not there\n"); | |
1283 | return CMD_WARNING; | |
1284 | } | |
1285 | ||
ec0ab544 | 1286 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1287 | if (rv < 0) { |
1288 | vty_out(vty, "Internal error\n"); | |
1289 | return CMD_WARNING; | |
1290 | } | |
1291 | ||
1292 | return CMD_SUCCESS; | |
1293 | } | |
1294 | ||
718e3744 | 1295 | DEFUN (no_synchronization, |
1296 | no_synchronization_cmd, | |
1297 | "no synchronization", | |
1298 | NO_STR | |
1299 | "Perform IGP synchronization\n") | |
1300 | { | |
d62a17ae | 1301 | return CMD_SUCCESS; |
718e3744 | 1302 | } |
1303 | ||
1304 | DEFUN (no_auto_summary, | |
1305 | no_auto_summary_cmd, | |
1306 | "no auto-summary", | |
1307 | NO_STR | |
1308 | "Enable automatic network number summarization\n") | |
1309 | { | |
d62a17ae | 1310 | return CMD_SUCCESS; |
718e3744 | 1311 | } |
3d515fd9 | 1312 | |
718e3744 | 1313 | /* "router bgp" commands. */ |
ff8a8a7a CS |
1314 | DEFUN_YANG_NOSH(router_bgp, |
1315 | router_bgp_cmd, | |
1316 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1317 | ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1318 | { |
d62a17ae | 1319 | int idx_asn = 2; |
1320 | int idx_view_vrf = 3; | |
1321 | int idx_vrf = 4; | |
ff8a8a7a | 1322 | int ret = CMD_SUCCESS; |
d62a17ae | 1323 | as_t as; |
1324 | struct bgp *bgp; | |
1325 | const char *name = NULL; | |
ff8a8a7a | 1326 | char as_str[12] = {'\0'}; |
d62a17ae | 1327 | enum bgp_instance_type inst_type; |
ff8a8a7a | 1328 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 1329 | |
1330 | // "router bgp" without an ASN | |
1331 | if (argc == 2) { | |
1332 | // Pending: Make VRF option available for ASN less config | |
1333 | bgp = bgp_get_default(); | |
1334 | ||
1335 | if (bgp == NULL) { | |
1336 | vty_out(vty, "%% No BGP process is configured\n"); | |
1337 | return CMD_WARNING_CONFIG_FAILED; | |
1338 | } | |
1339 | ||
1340 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1341 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1342 | return CMD_WARNING_CONFIG_FAILED; |
1343 | } | |
ff8a8a7a CS |
1344 | |
1345 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, | |
5ce106b7 | 1346 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); |
ff8a8a7a CS |
1347 | |
1348 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
1349 | snprintf(as_str, 12, "%d", bgp->as); | |
87ce2564 CS |
1350 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
1351 | as_str); | |
ff8a8a7a | 1352 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) { |
87ce2564 CS |
1353 | nb_cli_enqueue_change(vty, |
1354 | "./global/instance-type-view", | |
ff8a8a7a CS |
1355 | NB_OP_MODIFY, "true"); |
1356 | } | |
1357 | ||
a5ab756f | 1358 | nb_cli_pending_commit_check(vty); |
ff8a8a7a CS |
1359 | ret = nb_cli_apply_changes(vty, base_xpath); |
1360 | if (ret == CMD_SUCCESS) { | |
1361 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
1362 | ||
1363 | /* | |
1364 | * For backward compatibility with old commands we still | |
1365 | * need to use the qobj infrastructure. | |
1366 | */ | |
1367 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1368 | } | |
1369 | return ret; | |
d62a17ae | 1370 | } |
1371 | ||
1372 | // "router bgp X" | |
1373 | else { | |
d62a17ae | 1374 | |
ff8a8a7a | 1375 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
d62a17ae | 1376 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1377 | if (argc > 3) { | |
1378 | name = argv[idx_vrf]->arg; | |
1379 | ||
9a8bdf1c PG |
1380 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1381 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1382 | name = NULL; | |
1383 | else | |
1384 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
ff8a8a7a | 1385 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) { |
d62a17ae | 1386 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
ff8a8a7a | 1387 | } |
d62a17ae | 1388 | } |
ff8a8a7a CS |
1389 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1390 | "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME); | |
1391 | ||
1392 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
87ce2564 | 1393 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
ff8a8a7a CS |
1394 | argv[idx_asn]->arg); |
1395 | if (inst_type == BGP_INSTANCE_TYPE_VIEW) { | |
87ce2564 CS |
1396 | nb_cli_enqueue_change(vty, |
1397 | "./global/instance-type-view", | |
ff8a8a7a | 1398 | NB_OP_MODIFY, "true"); |
d62a17ae | 1399 | } |
1400 | ||
ff8a8a7a CS |
1401 | nb_cli_pending_commit_check(vty); |
1402 | ret = nb_cli_apply_changes(vty, base_xpath); | |
1403 | if (ret == CMD_SUCCESS) { | |
1404 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
3bd70bf8 | 1405 | |
ff8a8a7a CS |
1406 | /* |
1407 | * For backward compatibility with old commands we still | |
1408 | * need to use the qobj infrastructure. | |
1409 | */ | |
1410 | bgp = bgp_lookup(as, name); | |
1411 | if (bgp) | |
1412 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1413 | } | |
d62a17ae | 1414 | } |
1415 | ||
ff8a8a7a | 1416 | return ret; |
718e3744 | 1417 | } |
1418 | ||
718e3744 | 1419 | /* "no router bgp" commands. */ |
ff8a8a7a CS |
1420 | DEFUN_YANG(no_router_bgp, |
1421 | no_router_bgp_cmd, | |
1422 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1423 | NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1424 | { |
d62a17ae | 1425 | int idx_asn = 3; |
1426 | int idx_vrf = 5; | |
ff8a8a7a | 1427 | as_t as = 0; |
d62a17ae | 1428 | struct bgp *bgp; |
1429 | const char *name = NULL; | |
ff8a8a7a | 1430 | char base_xpath[XPATH_MAXLEN]; |
4b63e358 | 1431 | const struct lyd_node *bgp_glb_dnode; |
718e3744 | 1432 | |
d62a17ae | 1433 | // "no router bgp" without an ASN |
1434 | if (argc == 3) { | |
1435 | // Pending: Make VRF option available for ASN less config | |
4b63e358 CS |
1436 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1437 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); | |
718e3744 | 1438 | |
4b63e358 CS |
1439 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, |
1440 | base_xpath); | |
1441 | if (!bgp_glb_dnode) { | |
d62a17ae | 1442 | vty_out(vty, "%% No BGP process is configured\n"); |
1443 | return CMD_WARNING_CONFIG_FAILED; | |
1444 | } | |
7fb21a9f | 1445 | |
d62a17ae | 1446 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1447 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1448 | return CMD_WARNING_CONFIG_FAILED; |
1449 | } | |
0b5131c9 | 1450 | |
4b63e358 CS |
1451 | /* tcli mode bgp would not be set until apply stage. */ |
1452 | bgp = nb_running_get_entry(bgp_glb_dnode, NULL, false); | |
1453 | if (!bgp) | |
1454 | return CMD_SUCCESS; | |
1455 | ||
0b5131c9 MK |
1456 | if (bgp->l3vni) { |
1457 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1458 | bgp->l3vni); | |
1459 | return CMD_WARNING_CONFIG_FAILED; | |
1460 | } | |
d62a17ae | 1461 | } else { |
1462 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1463 | |
d62a17ae | 1464 | if (argc > 4) |
1465 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1466 | |
d62a17ae | 1467 | /* Lookup bgp structure. */ |
1468 | bgp = bgp_lookup(as, name); | |
1469 | if (!bgp) { | |
1470 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1471 | return CMD_WARNING_CONFIG_FAILED; | |
1472 | } | |
0b5131c9 MK |
1473 | |
1474 | if (bgp->l3vni) { | |
dd5868c2 | 1475 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1476 | bgp->l3vni); |
1477 | return CMD_WARNING_CONFIG_FAILED; | |
1478 | } | |
dd5868c2 DS |
1479 | |
1480 | /* Cannot delete default instance if vrf instances exist */ | |
1481 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1482 | struct listnode *node; | |
1483 | struct bgp *tmp_bgp; | |
1484 | ||
1485 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
999e803f PG |
1486 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) |
1487 | continue; | |
1488 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1489 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1490 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1491 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1492 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1493 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1494 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1495 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1496 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1497 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1498 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1499 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1500 | (bgp == bgp_get_evpn() && | |
1501 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1502 | BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST) || | |
1503 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1504 | BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))) || | |
1505 | (tmp_bgp->vnihash && hashcount(tmp_bgp->vnihash))) { | |
dd5868c2 DS |
1506 | vty_out(vty, |
1507 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1508 | return CMD_WARNING_CONFIG_FAILED; | |
1509 | } | |
1510 | } | |
1511 | } | |
d62a17ae | 1512 | } |
ff8a8a7a CS |
1513 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1514 | "frr-bgp:bgp", "bgp", | |
1515 | bgp->name ? bgp->name : VRF_DEFAULT_NAME); | |
718e3744 | 1516 | |
ff8a8a7a | 1517 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); |
718e3744 | 1518 | |
ff8a8a7a | 1519 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 1520 | } |
1521 | ||
ff8a8a7a CS |
1522 | void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode, |
1523 | bool show_defaults) | |
1524 | { | |
1525 | const struct lyd_node *vrf_dnode; | |
1526 | const char *vrf_name; | |
1527 | as_t as; | |
6b0655a2 | 1528 | |
ff8a8a7a CS |
1529 | vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol"); |
1530 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
5e42cb2f | 1531 | as = yang_dnode_get_uint32(dnode, "./global/local-as"); |
718e3744 | 1532 | |
ff8a8a7a CS |
1533 | vty_out(vty, "!\n"); |
1534 | vty_out(vty, "router bgp %u", as); | |
1535 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
1536 | vty_out(vty, " vrf %s", vrf_name); | |
1537 | vty_out(vty, "\n"); | |
718e3744 | 1538 | } |
1539 | ||
ff8a8a7a CS |
1540 | /* BGP router-id. */ |
1541 | ||
1542 | DEFPY_YANG(bgp_router_id, bgp_router_id_cmd, "bgp router-id A.B.C.D", | |
1543 | BGP_STR | |
1544 | "Override configured router identifier\n" | |
1545 | "Manually configured router identifier\n") | |
718e3744 | 1546 | { |
87ce2564 CS |
1547 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_MODIFY, |
1548 | router_id_str); | |
718e3744 | 1549 | |
ff8a8a7a CS |
1550 | return nb_cli_apply_changes(vty, NULL); |
1551 | } | |
718e3744 | 1552 | |
ff8a8a7a CS |
1553 | DEFPY_YANG(no_bgp_router_id, no_bgp_router_id_cmd, "no bgp router-id [A.B.C.D]", |
1554 | NO_STR BGP_STR | |
1555 | "Override configured router identifier\n" | |
1556 | "Manually configured router identifier\n") | |
1557 | { | |
87ce2564 | 1558 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_DESTROY, |
ff8a8a7a | 1559 | router_id_str ? router_id_str : NULL); |
718e3744 | 1560 | |
ff8a8a7a | 1561 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1562 | } |
1563 | ||
ff8a8a7a CS |
1564 | void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode, |
1565 | bool show_defaults) | |
1566 | { | |
1567 | vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL)); | |
1568 | } | |
6b0655a2 | 1569 | |
9acb67cb DS |
1570 | DEFPY (bgp_global_suppress_fib_pending, |
1571 | bgp_global_suppress_fib_pending_cmd, | |
1572 | "[no] bgp suppress-fib-pending", | |
1573 | NO_STR | |
1574 | BGP_STR | |
1575 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1576 | { | |
1577 | bm_wait_for_fib_set(!no); | |
1578 | ||
1579 | return CMD_SUCCESS; | |
1580 | } | |
1581 | ||
c208c586 S |
1582 | DEFPY (bgp_suppress_fib_pending, |
1583 | bgp_suppress_fib_pending_cmd, | |
1584 | "[no] bgp suppress-fib-pending", | |
1585 | NO_STR | |
1586 | BGP_STR | |
1587 | "Advertise only routes that are programmed in kernel to peers\n") | |
1588 | { | |
1589 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1590 | ||
1591 | bgp_suppress_fib_pending_set(bgp, !no); | |
1592 | return CMD_SUCCESS; | |
1593 | } | |
1594 | ||
1595 | ||
718e3744 | 1596 | /* BGP Cluster ID. */ |
ff8a8a7a CS |
1597 | DEFUN_YANG(bgp_cluster_id, |
1598 | bgp_cluster_id_cmd, | |
1599 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1600 | BGP_STR | |
1601 | "Configure Route-Reflector Cluster-id\n" | |
1602 | "Route-Reflector Cluster-id in IP address format\n" | |
1603 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1604 | { |
d62a17ae | 1605 | int idx_ipv4 = 2; |
718e3744 | 1606 | |
87ce2564 CS |
1607 | nb_cli_enqueue_change( |
1608 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1609 | NB_OP_MODIFY, argv[idx_ipv4]->arg); | |
718e3744 | 1610 | |
ff8a8a7a | 1611 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1612 | } |
1613 | ||
ff8a8a7a CS |
1614 | DEFUN_YANG(no_bgp_cluster_id, |
1615 | no_bgp_cluster_id_cmd, | |
1616 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1617 | NO_STR BGP_STR | |
1618 | "Configure Route-Reflector Cluster-id\n" | |
1619 | "Route-Reflector Cluster-id in IP address format\n" | |
1620 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1621 | { |
87ce2564 CS |
1622 | nb_cli_enqueue_change( |
1623 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1624 | NB_OP_DESTROY, NULL); | |
718e3744 | 1625 | |
ff8a8a7a | 1626 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1627 | } |
1628 | ||
c163f297 DS |
1629 | DEFPY (bgp_norib, |
1630 | bgp_norib_cmd, | |
1631 | "bgp no-rib", | |
1632 | BGP_STR | |
1633 | "Disable BGP route installation to RIB (Zebra)\n") | |
1634 | { | |
1635 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1636 | vty_out(vty, | |
1637 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1638 | return CMD_SUCCESS; | |
1639 | } | |
1640 | ||
1641 | bgp_option_norib_set_runtime(); | |
1642 | ||
1643 | return CMD_SUCCESS; | |
1644 | } | |
1645 | ||
1646 | DEFPY (no_bgp_norib, | |
1647 | no_bgp_norib_cmd, | |
1648 | "no bgp no-rib", | |
1649 | NO_STR | |
1650 | BGP_STR | |
1651 | "Disable BGP route installation to RIB (Zebra)\n") | |
1652 | { | |
1653 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1654 | vty_out(vty, | |
1655 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1656 | return CMD_SUCCESS; | |
1657 | } | |
1658 | ||
1659 | bgp_option_norib_unset_runtime(); | |
1660 | ||
1661 | return CMD_SUCCESS; | |
1662 | } | |
1663 | ||
e46723a5 DS |
1664 | DEFPY (no_bgp_send_extra_data, |
1665 | no_bgp_send_extra_data_cmd, | |
1666 | "[no] bgp send-extra-data zebra", | |
1667 | NO_STR | |
1668 | BGP_STR | |
1669 | "Extra data to Zebra for display/use\n" | |
1670 | "To zebra\n") | |
1671 | { | |
ec0acb80 DA |
1672 | if (no) |
1673 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1674 | else | |
1675 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1676 | |
1677 | return CMD_SUCCESS; | |
1678 | } | |
1679 | ||
ff8a8a7a CS |
1680 | DEFUN_YANG(bgp_confederation_identifier, |
1681 | bgp_confederation_identifier_cmd, | |
1682 | "bgp confederation identifier (1-4294967295)", | |
1683 | "BGP specific commands\n" | |
1684 | "AS confederation parameters\n" | |
1685 | "AS number\n" | |
1686 | "Set routing domain confederation AS\n") | |
718e3744 | 1687 | { |
d62a17ae | 1688 | int idx_number = 3; |
718e3744 | 1689 | |
87ce2564 CS |
1690 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1691 | NB_OP_MODIFY, argv[idx_number]->arg); | |
718e3744 | 1692 | |
ff8a8a7a | 1693 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1694 | } |
1695 | ||
ff8a8a7a CS |
1696 | DEFUN_YANG(no_bgp_confederation_identifier, |
1697 | no_bgp_confederation_identifier_cmd, | |
1698 | "no bgp confederation identifier [(1-4294967295)]", | |
1699 | NO_STR | |
1700 | "BGP specific commands\n" | |
1701 | "AS confederation parameters\n" | |
1702 | "AS number\n" | |
1703 | "Set routing domain confederation AS\n") | |
718e3744 | 1704 | { |
87ce2564 CS |
1705 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1706 | NB_OP_DESTROY, NULL); | |
718e3744 | 1707 | |
ff8a8a7a | 1708 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1709 | } |
1710 | ||
ff8a8a7a CS |
1711 | void cli_show_router_bgp_confederation_identifier(struct vty *vty, |
1712 | struct lyd_node *dnode, | |
1713 | bool show_defaults) | |
1714 | { | |
1715 | vty_out(vty, " bgp confederation identifier %u\n", | |
1716 | yang_dnode_get_uint32(dnode, NULL)); | |
1717 | } | |
1718 | ||
1719 | DEFUN_YANG(bgp_confederation_peers, | |
1720 | bgp_confederation_peers_cmd, | |
1721 | "bgp confederation peers (1-4294967295)...", | |
1722 | "BGP specific commands\n" | |
1723 | "AS confederation parameters\n" | |
1724 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1725 | { |
d62a17ae | 1726 | int idx_asn = 3; |
d62a17ae | 1727 | int i; |
718e3744 | 1728 | |
ff8a8a7a | 1729 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1730 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1731 | NB_OP_CREATE, argv[i]->arg); |
718e3744 | 1732 | |
ff8a8a7a | 1733 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1734 | } |
1735 | ||
ff8a8a7a CS |
1736 | DEFUN_YANG(no_bgp_confederation_peers, |
1737 | no_bgp_confederation_peers_cmd, | |
1738 | "no bgp confederation peers (1-4294967295)...", | |
1739 | NO_STR | |
1740 | "BGP specific commands\n" | |
1741 | "AS confederation parameters\n" | |
1742 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1743 | { |
d62a17ae | 1744 | int idx_asn = 4; |
d62a17ae | 1745 | int i; |
718e3744 | 1746 | |
ff8a8a7a | 1747 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1748 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1749 | NB_OP_DESTROY, argv[i]->arg); |
0b2aa3a0 | 1750 | |
ff8a8a7a CS |
1751 | return nb_cli_apply_changes(vty, NULL); |
1752 | } | |
1753 | ||
1754 | void cli_show_router_bgp_confederation_member_as(struct vty *vty, | |
1755 | struct lyd_node *dnode, | |
1756 | bool show_defaults) | |
1757 | { | |
1758 | vty_out(vty, " bgp confederation peers %u \n", | |
1759 | yang_dnode_get_uint32(dnode, NULL)); | |
718e3744 | 1760 | } |
6b0655a2 | 1761 | |
5e242b0d DS |
1762 | /** |
1763 | * Central routine for maximum-paths configuration. | |
1764 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1765 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1766 | */ | |
37a87b8f CS |
1767 | int bgp_maxpaths_config_vty(struct bgp *bgp, afi_t afi, safi_t safi, |
1768 | int peer_type, uint16_t maxpaths, uint16_t options, | |
1769 | int set, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1770 | { |
d62a17ae | 1771 | int ret; |
d62a17ae | 1772 | |
1773 | if (set) { | |
d62a17ae | 1774 | if (maxpaths > multipath_num) { |
37a87b8f CS |
1775 | snprintf( |
1776 | errmsg, errmsg_len, | |
d62a17ae | 1777 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1778 | maxpaths, multipath_num); | |
1779 | return CMD_WARNING_CONFIG_FAILED; | |
1780 | } | |
1781 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1782 | options); | |
1783 | } else | |
1784 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1785 | ||
1786 | if (ret < 0) { | |
37a87b8f CS |
1787 | snprintf( |
1788 | errmsg, errmsg_len, | |
d62a17ae | 1789 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1790 | (set == 1) ? "" : "un", | |
1791 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1792 | maxpaths, afi, safi); | |
1793 | return CMD_WARNING_CONFIG_FAILED; | |
1794 | } | |
1795 | ||
1796 | bgp_recalculate_all_bestpaths(bgp); | |
1797 | ||
1798 | return CMD_SUCCESS; | |
165b5fff JB |
1799 | } |
1800 | ||
ff8a8a7a CS |
1801 | void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode, |
1802 | bool show_defaults) | |
abc920f8 | 1803 | { |
ff8a8a7a CS |
1804 | if (yang_dnode_get_bool(dnode, "./enable-med-admin")) { |
1805 | uint32_t med_admin_val; | |
abc920f8 | 1806 | |
ff8a8a7a CS |
1807 | vty_out(vty, " bgp max-med administrative"); |
1808 | if ((med_admin_val = | |
1809 | yang_dnode_get_uint32(dnode, "./max-med-admin")) | |
1810 | != BGP_MAXMED_VALUE_DEFAULT) | |
1811 | vty_out(vty, " %u", med_admin_val); | |
1812 | vty_out(vty, "\n"); | |
1813 | } | |
abc920f8 | 1814 | |
ff8a8a7a CS |
1815 | if (yang_dnode_exists(dnode, "./max-med-onstart-up-time")) { |
1816 | uint32_t onstartup_val; | |
abc920f8 | 1817 | |
ff8a8a7a CS |
1818 | vty_out(vty, " bgp max-med on-startup %u", |
1819 | yang_dnode_get_uint32(dnode, | |
1820 | "./max-med-onstart-up-time")); | |
1821 | onstartup_val = yang_dnode_get_uint32( | |
1822 | dnode, "./max-med-onstart-up-value"); | |
1823 | if (onstartup_val != BGP_MAXMED_VALUE_DEFAULT) | |
1824 | vty_out(vty, " %u", onstartup_val); | |
1825 | ||
1826 | vty_out(vty, "\n"); | |
1827 | } | |
abc920f8 DS |
1828 | } |
1829 | ||
ff8a8a7a CS |
1830 | DEFUN_YANG(bgp_maxmed_admin, |
1831 | bgp_maxmed_admin_cmd, | |
1832 | "bgp max-med administrative ", | |
1833 | BGP_STR | |
1834 | "Advertise routes with max-med\n" | |
1835 | "Administratively applied, for an indefinite period\n") | |
1836 | { | |
87ce2564 | 1837 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a CS |
1838 | NB_OP_MODIFY, "true"); |
1839 | ||
1840 | return nb_cli_apply_changes(vty, NULL); | |
1841 | } | |
1842 | ||
1843 | DEFUN_YANG(bgp_maxmed_admin_medv, | |
1844 | bgp_maxmed_admin_medv_cmd, | |
1845 | "bgp max-med administrative (0-4294967295)", | |
1846 | BGP_STR | |
1847 | "Advertise routes with max-med\n" | |
1848 | "Administratively applied, for an indefinite period\n" | |
1849 | "Max MED value to be used\n") | |
abc920f8 | 1850 | { |
d62a17ae | 1851 | int idx_number = 3; |
abc920f8 | 1852 | |
87ce2564 | 1853 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1854 | NB_OP_MODIFY, "true"); |
abc920f8 | 1855 | |
87ce2564 CS |
1856 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1857 | NB_OP_MODIFY, argv[idx_number]->arg); | |
abc920f8 | 1858 | |
ff8a8a7a | 1859 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1860 | } |
1861 | ||
ff8a8a7a CS |
1862 | DEFUN_YANG(no_bgp_maxmed_admin, |
1863 | no_bgp_maxmed_admin_cmd, | |
1864 | "no bgp max-med administrative [(0-4294967295)]", | |
1865 | NO_STR BGP_STR | |
1866 | "Advertise routes with max-med\n" | |
1867 | "Administratively applied, for an indefinite period\n" | |
1868 | "Max MED value to be used\n") | |
abc920f8 | 1869 | { |
87ce2564 | 1870 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1871 | NB_OP_MODIFY, "false"); |
abc920f8 | 1872 | |
87ce2564 CS |
1873 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1874 | NB_OP_MODIFY, NULL); | |
ff8a8a7a CS |
1875 | |
1876 | return nb_cli_apply_changes(vty, NULL); | |
abc920f8 DS |
1877 | } |
1878 | ||
37a87b8f CS |
1879 | DEFUN_YANG (bgp_maxmed_onstartup, |
1880 | bgp_maxmed_onstartup_cmd, | |
1881 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1882 | BGP_STR | |
1883 | "Advertise routes with max-med\n" | |
1884 | "Effective on a startup\n" | |
1885 | "Time (seconds) period for max-med\n" | |
1886 | "Max MED value to be used\n") | |
abc920f8 | 1887 | { |
d62a17ae | 1888 | int idx = 0; |
4668a151 | 1889 | |
d62a17ae | 1890 | argv_find(argv, argc, "(5-86400)", &idx); |
87ce2564 CS |
1891 | nb_cli_enqueue_change(vty, |
1892 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a CS |
1893 | NB_OP_MODIFY, argv[idx]->arg); |
1894 | ||
d62a17ae | 1895 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
87ce2564 CS |
1896 | nb_cli_enqueue_change( |
1897 | vty, "./global/med-config/max-med-onstart-up-value", | |
1898 | NB_OP_MODIFY, argv[idx]->arg); | |
d62a17ae | 1899 | else |
87ce2564 CS |
1900 | nb_cli_enqueue_change( |
1901 | vty, "./global/med-config/max-med-onstart-up-value", | |
1902 | NB_OP_MODIFY, NULL); | |
abc920f8 | 1903 | |
ff8a8a7a | 1904 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1905 | } |
1906 | ||
37a87b8f CS |
1907 | DEFUN_YANG (no_bgp_maxmed_onstartup, |
1908 | no_bgp_maxmed_onstartup_cmd, | |
1909 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1910 | NO_STR BGP_STR | |
1911 | "Advertise routes with max-med\n" | |
1912 | "Effective on a startup\n" | |
1913 | "Time (seconds) period for max-med\n" | |
1914 | "Max MED value to be used\n") | |
abc920f8 | 1915 | { |
87ce2564 CS |
1916 | nb_cli_enqueue_change(vty, |
1917 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a | 1918 | NB_OP_DESTROY, NULL); |
abc920f8 | 1919 | |
87ce2564 CS |
1920 | nb_cli_enqueue_change(vty, |
1921 | "./global/med-config/max-med-onstart-up-value", | |
ff8a8a7a | 1922 | NB_OP_MODIFY, NULL); |
abc920f8 | 1923 | |
ff8a8a7a | 1924 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1925 | } |
1926 | ||
d70583f7 D |
1927 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1928 | uint16_t update_delay, | |
1929 | uint16_t establish_wait) | |
1930 | { | |
1931 | struct listnode *node, *nnode; | |
1932 | struct bgp *bgp; | |
1933 | bool vrf_cfg = false; | |
1934 | ||
1935 | /* | |
1936 | * See if update-delay is set per-vrf and warn user to delete it | |
1937 | * Note that we only need to check this if this is the first time | |
1938 | * setting the global config. | |
1939 | */ | |
1940 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1941 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1942 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1943 | vty_out(vty, | |
1944 | "%% update-delay configuration found in vrf %s\n", | |
1945 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1946 | ? VRF_DEFAULT_NAME | |
1947 | : bgp->name); | |
1948 | vrf_cfg = true; | |
1949 | } | |
1950 | } | |
1951 | } | |
1952 | ||
1953 | if (vrf_cfg) { | |
1954 | vty_out(vty, | |
1955 | "%%Failed: global update-delay config not permitted\n"); | |
1956 | return CMD_WARNING; | |
1957 | } | |
1958 | ||
1959 | if (!establish_wait) { /* update-delay <delay> */ | |
1960 | bm->v_update_delay = update_delay; | |
1961 | bm->v_establish_wait = bm->v_update_delay; | |
1962 | } else { | |
1963 | /* update-delay <delay> <establish-wait> */ | |
1964 | if (update_delay < establish_wait) { | |
1965 | vty_out(vty, | |
1966 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1967 | return CMD_WARNING_CONFIG_FAILED; | |
1968 | } | |
1969 | ||
1970 | bm->v_update_delay = update_delay; | |
1971 | bm->v_establish_wait = establish_wait; | |
1972 | } | |
1973 | ||
1974 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1975 | bgp->v_update_delay = bm->v_update_delay; | |
1976 | bgp->v_establish_wait = bm->v_establish_wait; | |
1977 | } | |
1978 | ||
1979 | return CMD_SUCCESS; | |
1980 | } | |
1981 | ||
1982 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
1983 | { | |
1984 | struct listnode *node, *nnode; | |
1985 | struct bgp *bgp; | |
1986 | ||
1987 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1988 | bm->v_establish_wait = bm->v_update_delay; | |
1989 | ||
1990 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1991 | bgp->v_update_delay = bm->v_update_delay; | |
1992 | bgp->v_establish_wait = bm->v_establish_wait; | |
1993 | } | |
1994 | ||
1995 | return CMD_SUCCESS; | |
1996 | } | |
1997 | ||
1998 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
1999 | uint16_t establish_wait) | |
f188f2c4 | 2000 | { |
d62a17ae | 2001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2002 | |
d70583f7 D |
2003 | /* if configured globally, per-instance config is not allowed */ |
2004 | if (bm->v_update_delay) { | |
2005 | vty_out(vty, | |
2006 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2007 | return CMD_WARNING_CONFIG_FAILED; | |
2008 | } | |
2009 | ||
f188f2c4 | 2010 | |
d70583f7 | 2011 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2012 | { |
2013 | bgp->v_update_delay = update_delay; | |
2014 | bgp->v_establish_wait = bgp->v_update_delay; | |
2015 | return CMD_SUCCESS; | |
2016 | } | |
f188f2c4 | 2017 | |
d62a17ae | 2018 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2019 | if (update_delay < establish_wait) { |
2020 | vty_out(vty, | |
2021 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2022 | return CMD_WARNING_CONFIG_FAILED; | |
2023 | } | |
f188f2c4 | 2024 | |
d62a17ae | 2025 | bgp->v_update_delay = update_delay; |
2026 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2027 | |
d62a17ae | 2028 | return CMD_SUCCESS; |
f188f2c4 DS |
2029 | } |
2030 | ||
d62a17ae | 2031 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2032 | { |
d62a17ae | 2033 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2034 | |
d70583f7 D |
2035 | /* If configured globally, cannot remove from one bgp instance */ |
2036 | if (bm->v_update_delay) { | |
2037 | vty_out(vty, | |
2038 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2039 | return CMD_WARNING_CONFIG_FAILED; | |
2040 | } | |
d62a17ae | 2041 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2042 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2043 | |
d62a17ae | 2044 | return CMD_SUCCESS; |
f188f2c4 DS |
2045 | } |
2046 | ||
2b791107 | 2047 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2048 | { |
d70583f7 D |
2049 | /* If configured globally, no need to display per-instance value */ |
2050 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2051 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2052 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2053 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2054 | vty_out(vty, "\n"); | |
2055 | } | |
f188f2c4 DS |
2056 | } |
2057 | ||
d70583f7 D |
2058 | /* Global update-delay configuration */ |
2059 | DEFPY (bgp_global_update_delay, | |
2060 | bgp_global_update_delay_cmd, | |
2061 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2062 | BGP_STR | |
2063 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2064 | "Max delay in seconds\n" | |
2065 | "Establish wait in seconds\n") | |
2066 | { | |
2067 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2068 | } | |
f188f2c4 | 2069 | |
d70583f7 D |
2070 | /* Global update-delay deconfiguration */ |
2071 | DEFPY (no_bgp_global_update_delay, | |
2072 | no_bgp_global_update_delay_cmd, | |
2073 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2074 | NO_STR | |
2075 | BGP_STR | |
f188f2c4 | 2076 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2077 | "Max delay in seconds\n" |
2078 | "Establish wait in seconds\n") | |
f188f2c4 | 2079 | { |
d70583f7 | 2080 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2081 | } |
2082 | ||
d70583f7 D |
2083 | /* Update-delay configuration */ |
2084 | ||
2085 | DEFPY (bgp_update_delay, | |
2086 | bgp_update_delay_cmd, | |
2087 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2088 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2089 | "Max delay in seconds\n" |
2090 | "Establish wait in seconds\n") | |
f188f2c4 | 2091 | { |
d70583f7 | 2092 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2093 | } |
2094 | ||
2095 | /* Update-delay deconfiguration */ | |
d70583f7 | 2096 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2097 | no_bgp_update_delay_cmd, |
838758ac DW |
2098 | "no update-delay [(0-3600) [(1-3600)]]", |
2099 | NO_STR | |
f188f2c4 | 2100 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2101 | "Max delay in seconds\n" |
2102 | "Establish wait in seconds\n") | |
f188f2c4 | 2103 | { |
d62a17ae | 2104 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2105 | } |
2106 | ||
5e242b0d | 2107 | |
ff8a8a7a | 2108 | int bgp_wpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
cb1faec9 | 2109 | { |
8fa7732f QY |
2110 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2111 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2112 | |
2113 | return CMD_SUCCESS; | |
2114 | } | |
2115 | ||
ff8a8a7a | 2116 | int bgp_rpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
555e09d4 | 2117 | { |
8fa7732f QY |
2118 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2119 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2120 | |
d62a17ae | 2121 | return CMD_SUCCESS; |
cb1faec9 DS |
2122 | } |
2123 | ||
2b791107 | 2124 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2125 | { |
555e09d4 QY |
2126 | uint32_t quanta = |
2127 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2128 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2129 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2130 | } |
2131 | ||
555e09d4 QY |
2132 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2133 | { | |
2134 | uint32_t quanta = | |
2135 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2136 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2137 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2138 | } |
cb1faec9 | 2139 | |
8fa7732f QY |
2140 | /* Packet quanta configuration |
2141 | * | |
2142 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2143 | * thread. When changing these limits be careful to prevent stack overflow. | |
2144 | * | |
2145 | * Furthermore, the maximums used here should correspond to | |
2146 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2147 | */ | |
37a87b8f CS |
2148 | DEFPY_YANG (bgp_wpkt_quanta, |
2149 | bgp_wpkt_quanta_cmd, | |
2150 | "[no] write-quanta (1-64)$quanta", | |
2151 | NO_STR | |
2152 | "How many packets to write to peer socket per run\n" | |
2153 | "Number of packets\n") | |
ff8a8a7a CS |
2154 | { |
2155 | if (!no) | |
2156 | nb_cli_enqueue_change( | |
2157 | vty, | |
87ce2564 | 2158 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
2159 | NB_OP_MODIFY, quanta_str); |
2160 | else | |
2161 | nb_cli_enqueue_change( | |
2162 | vty, | |
87ce2564 | 2163 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
2164 | NB_OP_MODIFY, NULL); |
2165 | ||
2166 | return nb_cli_apply_changes(vty, NULL); | |
2167 | } | |
2168 | ||
37a87b8f CS |
2169 | DEFPY_YANG (bgp_rpkt_quanta, |
2170 | bgp_rpkt_quanta_cmd, | |
2171 | "[no] read-quanta (1-10)$quanta", | |
2172 | NO_STR | |
2173 | "How many packets to read from peer socket per I/O cycle\n" | |
2174 | "Number of packets\n") | |
ff8a8a7a CS |
2175 | { |
2176 | if (!no) | |
2177 | nb_cli_enqueue_change( | |
2178 | vty, | |
87ce2564 | 2179 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a CS |
2180 | NB_OP_MODIFY, quanta_str); |
2181 | else | |
2182 | nb_cli_enqueue_change( | |
2183 | vty, | |
87ce2564 | 2184 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a | 2185 | NB_OP_MODIFY, NULL); |
cb1faec9 | 2186 | |
ff8a8a7a | 2187 | return nb_cli_apply_changes(vty, NULL); |
555e09d4 QY |
2188 | } |
2189 | ||
2b791107 | 2190 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2191 | { |
37a333fe | 2192 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2193 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2194 | } |
2195 | ||
ff8a8a7a CS |
2196 | void cli_show_router_global_update_group_config_coalesce_time( |
2197 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3f9c7369 | 2198 | { |
ff8a8a7a CS |
2199 | vty_out(vty, " coalesce-time %u\n", yang_dnode_get_uint32(dnode, NULL)); |
2200 | } | |
2201 | ||
4668a151 | 2202 | |
37a87b8f CS |
2203 | DEFUN_YANG (bgp_coalesce_time, |
2204 | bgp_coalesce_time_cmd, | |
2205 | "coalesce-time (0-4294967295)", | |
2206 | "Subgroup coalesce timer\n" | |
2207 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2208 | { |
d62a17ae | 2209 | int idx = 0; |
ff8a8a7a | 2210 | |
d62a17ae | 2211 | argv_find(argv, argc, "(0-4294967295)", &idx); |
87ce2564 CS |
2212 | nb_cli_enqueue_change( |
2213 | vty, "./global/global-update-group-config/coalesce-time", | |
2214 | NB_OP_MODIFY, argv[idx]->arg); | |
ff8a8a7a CS |
2215 | |
2216 | return nb_cli_apply_changes(vty, NULL); | |
3f9c7369 DS |
2217 | } |
2218 | ||
ff8a8a7a CS |
2219 | DEFUN_YANG(no_bgp_coalesce_time, |
2220 | no_bgp_coalesce_time_cmd, | |
2221 | "no coalesce-time (0-4294967295)", | |
2222 | NO_STR | |
2223 | "Subgroup coalesce timer\n" | |
2224 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2225 | { |
87ce2564 CS |
2226 | nb_cli_enqueue_change( |
2227 | vty, "./global/global-update-group-config/coalesce-time", | |
2228 | NB_OP_MODIFY, NULL); | |
4668a151 | 2229 | |
ff8a8a7a | 2230 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
2231 | } |
2232 | ||
5e242b0d | 2233 | /* Maximum-paths configuration */ |
37a87b8f CS |
2234 | DEFUN_YANG (bgp_maxpaths, |
2235 | bgp_maxpaths_cmd, | |
2236 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2237 | "Forward packets over multiple paths\n" | |
2238 | "Number of paths\n") | |
5e242b0d | 2239 | { |
d62a17ae | 2240 | int idx_number = 1; |
37a87b8f CS |
2241 | char base_xpath[XPATH_MAXLEN]; |
2242 | afi_t afi; | |
2243 | safi_t safi; | |
2244 | ||
2245 | afi = bgp_node_afi(vty); | |
2246 | safi = bgp_node_safi(vty); | |
2247 | ||
2248 | snprintf( | |
2249 | base_xpath, sizeof(base_xpath), | |
2250 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths", | |
2251 | yang_afi_safi_value2identity(afi, safi), | |
2252 | bgp_afi_safi_get_container_str(afi, safi)); | |
2253 | ||
2254 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2255 | argv[idx_number]->arg); | |
2256 | ||
2257 | return nb_cli_apply_changes(vty, NULL); | |
2258 | } | |
2259 | ||
2260 | void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths( | |
2261 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
2262 | { | |
2263 | vty_out(vty, " maximum-paths %d\n", | |
2264 | yang_dnode_get_uint16(dnode, NULL)); | |
5e242b0d DS |
2265 | } |
2266 | ||
d62a17ae | 2267 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2268 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2269 | "Forward packets over multiple paths\n" | |
2270 | "Number of paths\n") | |
596c17ba | 2271 | |
37a87b8f CS |
2272 | DEFUN_YANG (bgp_maxpaths_ibgp, |
2273 | bgp_maxpaths_ibgp_cmd, | |
2274 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2275 | "Forward packets over multiple paths\n" | |
2276 | "iBGP-multipath\n" | |
2277 | "Number of paths\n") | |
165b5fff | 2278 | { |
d62a17ae | 2279 | int idx_number = 2; |
37a87b8f CS |
2280 | char base_xpath[XPATH_MAXLEN]; |
2281 | afi_t afi; | |
2282 | safi_t safi; | |
2283 | ||
2284 | afi = bgp_node_afi(vty); | |
2285 | safi = bgp_node_safi(vty); | |
2286 | ||
2287 | snprintf( | |
2288 | base_xpath, sizeof(base_xpath), | |
2289 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2290 | yang_afi_safi_value2identity(afi, safi), | |
2291 | bgp_afi_safi_get_container_str(afi, safi)); | |
2292 | ||
2293 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2294 | argv[idx_number]->arg); | |
2295 | ||
2296 | return nb_cli_apply_changes(vty, NULL); | |
5e242b0d | 2297 | } |
165b5fff | 2298 | |
d62a17ae | 2299 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2300 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2301 | "Forward packets over multiple paths\n" | |
2302 | "iBGP-multipath\n" | |
2303 | "Number of paths\n") | |
596c17ba | 2304 | |
37a87b8f CS |
2305 | DEFUN_YANG (bgp_maxpaths_ibgp_cluster, |
2306 | bgp_maxpaths_ibgp_cluster_cmd, | |
2307 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2308 | "Forward packets over multiple paths\n" | |
2309 | "iBGP-multipath\n" | |
2310 | "Number of paths\n" | |
2311 | "Match the cluster length\n") | |
5e242b0d | 2312 | { |
d62a17ae | 2313 | int idx_number = 2; |
37a87b8f CS |
2314 | char base_xpath[XPATH_MAXLEN]; |
2315 | afi_t afi; | |
2316 | safi_t safi; | |
2317 | ||
2318 | afi = bgp_node_afi(vty); | |
2319 | safi = bgp_node_safi(vty); | |
2320 | ||
2321 | snprintf( | |
2322 | base_xpath, sizeof(base_xpath), | |
2323 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2324 | yang_afi_safi_value2identity(afi, safi), | |
2325 | bgp_afi_safi_get_container_str(afi, safi)); | |
2326 | ||
2327 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2328 | argv[idx_number]->arg); | |
2329 | ||
2330 | snprintf( | |
2331 | base_xpath, sizeof(base_xpath), | |
2332 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list", | |
2333 | yang_afi_safi_value2identity(afi, safi), | |
2334 | bgp_afi_safi_get_container_str(afi, safi)); | |
2335 | ||
2336 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, "true"); | |
2337 | ||
2338 | return nb_cli_apply_changes(vty, NULL); | |
2339 | } | |
2340 | ||
2341 | void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths( | |
2342 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
2343 | { | |
2344 | vty_out(vty, " maximum-paths ibgp %d", | |
2345 | yang_dnode_get_uint16(dnode, "./maximum-paths")); | |
2346 | if (yang_dnode_get_bool(dnode, "./cluster-length-list")) | |
2347 | vty_out(vty, " equal-cluster-length"); | |
2348 | vty_out(vty, "\n"); | |
165b5fff JB |
2349 | } |
2350 | ||
d62a17ae | 2351 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2352 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2353 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2354 | "Forward packets over multiple paths\n" | |
2355 | "iBGP-multipath\n" | |
2356 | "Number of paths\n" | |
2357 | "Match the cluster length\n") | |
596c17ba | 2358 | |
37a87b8f CS |
2359 | DEFUN_YANG (no_bgp_maxpaths, |
2360 | no_bgp_maxpaths_cmd, | |
2361 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2362 | NO_STR | |
2363 | "Forward packets over multiple paths\n" | |
2364 | "Number of paths\n") | |
165b5fff | 2365 | { |
37a87b8f CS |
2366 | char base_xpath[XPATH_MAXLEN]; |
2367 | afi_t afi; | |
2368 | safi_t safi; | |
2369 | ||
2370 | afi = bgp_node_afi(vty); | |
2371 | safi = bgp_node_safi(vty); | |
2372 | ||
2373 | snprintf( | |
2374 | base_xpath, sizeof(base_xpath), | |
2375 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths", | |
2376 | yang_afi_safi_value2identity(afi, safi), | |
2377 | bgp_afi_safi_get_container_str(afi, safi)); | |
2378 | ||
2379 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, NULL); | |
2380 | ||
2381 | return nb_cli_apply_changes(vty, NULL); | |
165b5fff JB |
2382 | } |
2383 | ||
d62a17ae | 2384 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2385 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2386 | "Forward packets over multiple paths\n" |
2387 | "Number of paths\n") | |
596c17ba | 2388 | |
37a87b8f CS |
2389 | DEFUN_YANG (no_bgp_maxpaths_ibgp, |
2390 | no_bgp_maxpaths_ibgp_cmd, | |
2391 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2392 | NO_STR | |
2393 | "Forward packets over multiple paths\n" | |
2394 | "iBGP-multipath\n" | |
2395 | "Number of paths\n" | |
2396 | "Match the cluster length\n") | |
165b5fff | 2397 | { |
37a87b8f CS |
2398 | char base_xpath[XPATH_MAXLEN]; |
2399 | afi_t afi; | |
2400 | safi_t safi; | |
2401 | ||
2402 | afi = bgp_node_afi(vty); | |
2403 | safi = bgp_node_safi(vty); | |
2404 | ||
2405 | snprintf( | |
2406 | base_xpath, sizeof(base_xpath), | |
2407 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2408 | yang_afi_safi_value2identity(afi, safi), | |
2409 | bgp_afi_safi_get_container_str(afi, safi)); | |
2410 | ||
2411 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, NULL); | |
2412 | ||
2413 | snprintf( | |
2414 | base_xpath, sizeof(base_xpath), | |
2415 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list", | |
2416 | yang_afi_safi_value2identity(afi, safi), | |
2417 | bgp_afi_safi_get_container_str(afi, safi)); | |
2418 | ||
2419 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, "false"); | |
2420 | ||
2421 | return nb_cli_apply_changes(vty, NULL); | |
165b5fff JB |
2422 | } |
2423 | ||
d62a17ae | 2424 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2425 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2426 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2427 | NO_STR | |
2428 | "Forward packets over multiple paths\n" | |
2429 | "iBGP-multipath\n" | |
2430 | "Number of paths\n" | |
2431 | "Match the cluster length\n") | |
596c17ba | 2432 | |
dd65f45e DL |
2433 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2434 | afi_t afi, safi_t safi) | |
165b5fff | 2435 | { |
00908b7a | 2436 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2437 | vty_out(vty, " maximum-paths %d\n", |
2438 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2439 | } | |
165b5fff | 2440 | |
00908b7a | 2441 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2442 | vty_out(vty, " maximum-paths ibgp %d", |
2443 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2444 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2445 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2446 | vty_out(vty, " equal-cluster-length"); | |
2447 | vty_out(vty, "\n"); | |
2448 | } | |
165b5fff | 2449 | } |
6b0655a2 | 2450 | |
718e3744 | 2451 | /* BGP timers. */ |
2452 | ||
37a87b8f CS |
2453 | DEFUN_YANG (bgp_timers, |
2454 | bgp_timers_cmd, | |
2455 | "timers bgp (0-65535) (0-65535)", | |
2456 | "Adjust routing timers\n" | |
2457 | "BGP timers\n" | |
2458 | "Keepalive interval\n" | |
2459 | "Holdtime\n") | |
718e3744 | 2460 | { |
d62a17ae | 2461 | int idx_number = 2; |
2462 | int idx_number_2 = 3; | |
718e3744 | 2463 | |
87ce2564 | 2464 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2465 | NB_OP_MODIFY, argv[idx_number]->arg); |
87ce2564 | 2466 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2467 | NB_OP_MODIFY, argv[idx_number_2]->arg); |
718e3744 | 2468 | |
ff8a8a7a CS |
2469 | return nb_cli_apply_changes(vty, NULL); |
2470 | } | |
718e3744 | 2471 | |
37a87b8f CS |
2472 | DEFUN_YANG (no_bgp_timers, |
2473 | no_bgp_timers_cmd, | |
2474 | "no timers bgp [(0-65535) (0-65535)]", | |
2475 | NO_STR | |
2476 | "Adjust routing timers\n" | |
2477 | "BGP timers\n" | |
2478 | "Keepalive interval\n" | |
2479 | "Holdtime\n") | |
ff8a8a7a | 2480 | { |
87ce2564 | 2481 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2482 | NB_OP_DESTROY, NULL); |
87ce2564 | 2483 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2484 | NB_OP_DESTROY, NULL); |
718e3744 | 2485 | |
ff8a8a7a | 2486 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2487 | } |
2488 | ||
ff8a8a7a CS |
2489 | void cli_show_router_bgp_route_reflector(struct vty *vty, |
2490 | struct lyd_node *dnode, | |
2491 | bool show_defaults) | |
718e3744 | 2492 | { |
ff8a8a7a CS |
2493 | if (yang_dnode_get_bool(dnode, "./no-client-reflect")) |
2494 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
718e3744 | 2495 | |
ff8a8a7a CS |
2496 | if (yang_dnode_get_bool(dnode, "./allow-outbound-policy")) |
2497 | vty_out(vty, " bgp route-reflector allow-outbound-policy\n"); | |
2498 | ||
2499 | if (yang_dnode_exists(dnode, "./route-reflector-cluster-id")) | |
2500 | vty_out(vty, " bgp cluster-id %s\n", | |
2501 | yang_dnode_get_string(dnode, | |
2502 | "./route-reflector-cluster-id")); | |
718e3744 | 2503 | } |
2504 | ||
ff8a8a7a CS |
2505 | DEFUN_YANG(bgp_client_to_client_reflection, |
2506 | bgp_client_to_client_reflection_cmd, | |
2507 | "bgp client-to-client reflection", | |
2508 | "BGP specific commands\n" | |
2509 | "Configure client to client route reflection\n" | |
2510 | "reflection of routes allowed\n") | |
2511 | { | |
87ce2564 | 2512 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2513 | NB_OP_MODIFY, "false"); |
6b0655a2 | 2514 | |
ff8a8a7a CS |
2515 | return nb_cli_apply_changes(vty, NULL); |
2516 | } | |
2517 | ||
2518 | DEFUN_YANG(no_bgp_client_to_client_reflection, | |
2519 | no_bgp_client_to_client_reflection_cmd, | |
2520 | "no bgp client-to-client reflection", | |
2521 | NO_STR | |
2522 | "BGP specific commands\n" | |
2523 | "Configure client to client route reflection\n" | |
2524 | "reflection of routes allowed\n") | |
718e3744 | 2525 | { |
87ce2564 | 2526 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2527 | NB_OP_MODIFY, "true"); |
7aafcaca | 2528 | |
ff8a8a7a | 2529 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2530 | } |
2531 | ||
ff8a8a7a CS |
2532 | void cli_show_router_bgp_route_selection(struct vty *vty, |
2533 | struct lyd_node *dnode, | |
2534 | bool show_defaults) | |
718e3744 | 2535 | { |
7aafcaca | 2536 | |
ff8a8a7a CS |
2537 | if (yang_dnode_get_bool(dnode, "./always-compare-med")) |
2538 | vty_out(vty, " bgp always-compare-med\n"); | |
2539 | ||
2540 | if (yang_dnode_get_bool(dnode, "./ignore-as-path-length")) | |
2541 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
2542 | ||
2543 | if (yang_dnode_get_bool(dnode, "./aspath-confed")) | |
2544 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
2545 | ||
2546 | if (yang_dnode_get_bool(dnode, "./external-compare-router-id")) | |
2547 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
2548 | ||
2549 | if (yang_dnode_get_bool(dnode, "./allow-multiple-as")) { | |
2550 | if (yang_dnode_get_bool(dnode, "./multi-path-as-set")) | |
2551 | vty_out(vty, | |
2552 | " bgp bestpath as-path multipath-relax as-set\n"); | |
2553 | else | |
2554 | vty_out(vty, " bgp bestpath as-path multipath-relax\n"); | |
2555 | } | |
2556 | ||
2557 | if (yang_dnode_get_bool(dnode, "./deterministic-med")) | |
2558 | vty_out(vty, " bgp deterministic-med\n"); | |
2559 | ||
2560 | if (yang_dnode_get_bool(dnode, "./confed-med") | |
2561 | || yang_dnode_get_bool(dnode, "./missing-as-worst-med")) { | |
2562 | vty_out(vty, " bgp bestpath med"); | |
2563 | if (yang_dnode_get_bool(dnode, "./confed-med")) | |
2564 | vty_out(vty, " confed"); | |
2565 | if (yang_dnode_get_bool(dnode, "./missing-as-worst-med")) | |
2566 | vty_out(vty, " missing-as-worst"); | |
2567 | vty_out(vty, "\n"); | |
2568 | } | |
718e3744 | 2569 | } |
2570 | ||
2571 | /* "bgp always-compare-med" configuration. */ | |
ff8a8a7a CS |
2572 | DEFUN_YANG(bgp_always_compare_med, |
2573 | bgp_always_compare_med_cmd, | |
2574 | "bgp always-compare-med", | |
2575 | "BGP specific commands\n" | |
2576 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2577 | { |
87ce2564 CS |
2578 | nb_cli_enqueue_change( |
2579 | vty, "./global/route-selection-options/always-compare-med", | |
2580 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2581 | |
ff8a8a7a | 2582 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2583 | } |
2584 | ||
ff8a8a7a CS |
2585 | DEFUN_YANG(no_bgp_always_compare_med, |
2586 | no_bgp_always_compare_med_cmd, | |
2587 | "no bgp always-compare-med", | |
2588 | NO_STR | |
2589 | "BGP specific commands\n" | |
2590 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2591 | { |
87ce2564 CS |
2592 | nb_cli_enqueue_change( |
2593 | vty, "./global/route-selection-options/always-compare-med", | |
2594 | NB_OP_MODIFY, "false"); | |
7aafcaca | 2595 | |
ff8a8a7a | 2596 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2597 | } |
6b0655a2 | 2598 | |
2adac256 DA |
2599 | DEFUN_YANG(bgp_suppress_duplicates, |
2600 | bgp_suppress_duplicates_cmd, | |
2601 | "bgp suppress-duplicates", | |
2602 | "BGP specific commands\n" | |
2603 | "Suppress duplicate updates if the route actually not changed\n") | |
2604 | { | |
2605 | nb_cli_enqueue_change(vty, "./global/suppress-duplicates", | |
2606 | NB_OP_MODIFY, "true"); | |
2607 | return nb_cli_apply_changes(vty, NULL); | |
2608 | } | |
2609 | ||
2610 | DEFUN_YANG(no_bgp_suppress_duplicates, | |
2611 | no_bgp_suppress_duplicates_cmd, | |
2612 | "no bgp suppress-duplicates", | |
2613 | NO_STR | |
2614 | "BGP specific commands\n" | |
2615 | "Suppress duplicate updates if the route actually not changed\n") | |
2616 | { | |
2617 | nb_cli_enqueue_change(vty, "./global/suppress-duplicates", | |
2618 | NB_OP_MODIFY, "false"); | |
2619 | return nb_cli_apply_changes(vty, NULL); | |
2620 | } | |
2621 | ||
2622 | void cli_show_router_bgp_suppress_duplicates(struct vty *vty, | |
2623 | struct lyd_node *dnode, | |
2624 | bool show_defaults) | |
2625 | { | |
2626 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SUPPRESS_DUPLICATES) | |
2627 | vty_out(vty, " bgp suppress-duplicates\n"); | |
2628 | } | |
2629 | ||
ff8a8a7a CS |
2630 | DEFUN_YANG(bgp_ebgp_requires_policy, |
2631 | bgp_ebgp_requires_policy_cmd, | |
2632 | "bgp ebgp-requires-policy", | |
2633 | "BGP specific commands\n" | |
2634 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2635 | { | |
87ce2564 CS |
2636 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2637 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
2638 | return nb_cli_apply_changes(vty, NULL); |
2639 | } | |
9dac9fc8 | 2640 | |
ff8a8a7a CS |
2641 | DEFUN_YANG(no_bgp_ebgp_requires_policy, |
2642 | no_bgp_ebgp_requires_policy_cmd, | |
2643 | "no bgp ebgp-requires-policy", | |
2644 | NO_STR | |
2645 | "BGP specific commands\n" | |
2646 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
9dac9fc8 | 2647 | { |
87ce2564 CS |
2648 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2649 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 2650 | return nb_cli_apply_changes(vty, NULL); |
9dac9fc8 DA |
2651 | } |
2652 | ||
ff8a8a7a CS |
2653 | void cli_show_router_bgp_ebgp_requires_policy(struct vty *vty, |
2654 | struct lyd_node *dnode, | |
2655 | bool show_defaults) | |
9dac9fc8 | 2656 | { |
ff8a8a7a CS |
2657 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_EBGP_REQUIRES_POLICY) |
2658 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
9dac9fc8 DA |
2659 | } |
2660 | ||
fb29348a DA |
2661 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2662 | "bgp reject-as-sets", | |
2663 | "BGP specific commands\n" | |
2664 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2665 | { | |
2666 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2667 | struct listnode *node, *nnode; | |
2668 | struct peer *peer; | |
2669 | ||
7f972cd8 | 2670 | bgp->reject_as_sets = true; |
fb29348a DA |
2671 | |
2672 | /* Reset existing BGP sessions to reject routes | |
2673 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2674 | */ | |
2675 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2676 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2677 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2678 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2679 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2680 | } | |
2681 | } | |
2682 | ||
2683 | return CMD_SUCCESS; | |
2684 | } | |
2685 | ||
2686 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2687 | "no bgp reject-as-sets", | |
2688 | NO_STR | |
2689 | "BGP specific commands\n" | |
2690 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2691 | { | |
2692 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2693 | struct listnode *node, *nnode; | |
2694 | struct peer *peer; | |
2695 | ||
7f972cd8 | 2696 | bgp->reject_as_sets = false; |
fb29348a DA |
2697 | |
2698 | /* Reset existing BGP sessions to reject routes | |
2699 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2700 | */ | |
2701 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2702 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2703 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2704 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2705 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2706 | } | |
2707 | } | |
2708 | ||
2709 | return CMD_SUCCESS; | |
2710 | } | |
9dac9fc8 | 2711 | |
718e3744 | 2712 | /* "bgp deterministic-med" configuration. */ |
ff8a8a7a | 2713 | DEFUN_YANG (bgp_deterministic_med, |
718e3744 | 2714 | bgp_deterministic_med_cmd, |
2715 | "bgp deterministic-med", | |
2716 | "BGP specific commands\n" | |
2717 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2718 | { | |
87ce2564 CS |
2719 | nb_cli_enqueue_change( |
2720 | vty, "./global/route-selection-options/deterministic-med", | |
2721 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2722 | |
ff8a8a7a | 2723 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2724 | } |
2725 | ||
ff8a8a7a | 2726 | DEFUN_YANG (no_bgp_deterministic_med, |
718e3744 | 2727 | no_bgp_deterministic_med_cmd, |
2728 | "no bgp deterministic-med", | |
2729 | NO_STR | |
2730 | "BGP specific commands\n" | |
2731 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2732 | { | |
87ce2564 CS |
2733 | nb_cli_enqueue_change( |
2734 | vty, "./global/route-selection-options/deterministic-med", | |
2735 | NB_OP_MODIFY, "false"); | |
d62a17ae | 2736 | |
ff8a8a7a | 2737 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2738 | } |
538621f2 | 2739 | |
055679e9 | 2740 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2741 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2742 | bgp_graceful_restart_cmd, |
2743 | "bgp graceful-restart", | |
2744 | "BGP specific commands\n" | |
2745 | GR_CMD | |
055679e9 | 2746 | ) |
538621f2 | 2747 | { |
055679e9 | 2748 | int ret = BGP_GR_FAILURE; |
2749 | ||
2750 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2751 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2752 | |
d62a17ae | 2753 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2754 | |
2755 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2756 | ||
36235319 QY |
2757 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2758 | ret); | |
5cce3f05 | 2759 | |
055679e9 | 2760 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2761 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2762 | vty_out(vty, |
2763 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2764 | return bgp_vty_return(vty, ret); |
538621f2 | 2765 | } |
2766 | ||
2767 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2768 | no_bgp_graceful_restart_cmd, |
2769 | "no bgp graceful-restart", | |
2770 | NO_STR | |
2771 | "BGP specific commands\n" | |
2772 | NO_GR_CMD | |
055679e9 | 2773 | ) |
538621f2 | 2774 | { |
d62a17ae | 2775 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2776 | |
2777 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2778 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2779 | |
2780 | int ret = BGP_GR_FAILURE; | |
2781 | ||
2782 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2783 | ||
36235319 QY |
2784 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2785 | ret); | |
5cce3f05 | 2786 | |
055679e9 | 2787 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2788 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2789 | vty_out(vty, |
2790 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2791 | |
2792 | return bgp_vty_return(vty, ret); | |
538621f2 | 2793 | } |
2794 | ||
93406d87 | 2795 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2796 | bgp_graceful_restart_stalepath_time_cmd, |
2797 | "bgp graceful-restart stalepath-time (1-4095)", | |
2798 | "BGP specific commands\n" | |
2799 | "Graceful restart capability parameters\n" | |
2800 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2801 | "Delay value (seconds)\n") | |
93406d87 | 2802 | { |
d62a17ae | 2803 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2804 | int idx_number = 3; | |
d7c0a89a | 2805 | uint32_t stalepath; |
93406d87 | 2806 | |
d62a17ae | 2807 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2808 | bgp->stalepath_time = stalepath; | |
2809 | return CMD_SUCCESS; | |
93406d87 | 2810 | } |
2811 | ||
eb6f1b41 | 2812 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2813 | bgp_graceful_restart_restart_time_cmd, |
2814 | "bgp graceful-restart restart-time (1-4095)", | |
2815 | "BGP specific commands\n" | |
2816 | "Graceful restart capability parameters\n" | |
2817 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2818 | "Delay value (seconds)\n") | |
eb6f1b41 | 2819 | { |
d62a17ae | 2820 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2821 | int idx_number = 3; | |
d7c0a89a | 2822 | uint32_t restart; |
eb6f1b41 | 2823 | |
d62a17ae | 2824 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2825 | bgp->restart_time = restart; | |
2826 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2827 | } |
2828 | ||
cfd47646 | 2829 | DEFUN (bgp_graceful_restart_select_defer_time, |
2830 | bgp_graceful_restart_select_defer_time_cmd, | |
2831 | "bgp graceful-restart select-defer-time (0-3600)", | |
2832 | "BGP specific commands\n" | |
2833 | "Graceful restart capability parameters\n" | |
2834 | "Set the time to defer the BGP route selection after restart\n" | |
2835 | "Delay value (seconds, 0 - disable)\n") | |
2836 | { | |
2837 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2838 | int idx_number = 3; | |
2839 | uint32_t defer_time; | |
2840 | ||
2841 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2842 | bgp->select_defer_time = defer_time; | |
2843 | if (defer_time == 0) | |
892fedb6 | 2844 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2845 | else |
892fedb6 | 2846 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2847 | |
2848 | return CMD_SUCCESS; | |
2849 | } | |
2850 | ||
93406d87 | 2851 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2852 | no_bgp_graceful_restart_stalepath_time_cmd, |
2853 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2854 | NO_STR | |
2855 | "BGP specific commands\n" | |
2856 | "Graceful restart capability parameters\n" | |
2857 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2858 | "Delay value (seconds)\n") | |
93406d87 | 2859 | { |
d62a17ae | 2860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2861 | |
d62a17ae | 2862 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2863 | return CMD_SUCCESS; | |
93406d87 | 2864 | } |
2865 | ||
eb6f1b41 | 2866 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2867 | no_bgp_graceful_restart_restart_time_cmd, |
2868 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2869 | NO_STR | |
2870 | "BGP specific commands\n" | |
2871 | "Graceful restart capability parameters\n" | |
2872 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2873 | "Delay value (seconds)\n") | |
eb6f1b41 | 2874 | { |
d62a17ae | 2875 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2876 | |
d62a17ae | 2877 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2878 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2879 | } |
2880 | ||
cfd47646 | 2881 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2882 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2883 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2884 | NO_STR | |
2885 | "BGP specific commands\n" | |
2886 | "Graceful restart capability parameters\n" | |
2887 | "Set the time to defer the BGP route selection after restart\n" | |
2888 | "Delay value (seconds)\n") | |
2889 | { | |
2890 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2891 | ||
2892 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2893 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2894 | |
2895 | return CMD_SUCCESS; | |
2896 | } | |
2897 | ||
43fc21b3 | 2898 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2899 | bgp_graceful_restart_preserve_fw_cmd, |
2900 | "bgp graceful-restart preserve-fw-state", | |
2901 | "BGP specific commands\n" | |
2902 | "Graceful restart capability parameters\n" | |
2903 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2904 | { |
d62a17ae | 2905 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2906 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2907 | return CMD_SUCCESS; |
43fc21b3 JC |
2908 | } |
2909 | ||
2910 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2911 | no_bgp_graceful_restart_preserve_fw_cmd, |
2912 | "no bgp graceful-restart preserve-fw-state", | |
2913 | NO_STR | |
2914 | "BGP specific commands\n" | |
2915 | "Graceful restart capability parameters\n" | |
2916 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2917 | { |
d62a17ae | 2918 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2919 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2920 | return CMD_SUCCESS; |
43fc21b3 JC |
2921 | } |
2922 | ||
055679e9 | 2923 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2924 | bgp_graceful_restart_disable_cmd, |
2925 | "bgp graceful-restart-disable", | |
2926 | "BGP specific commands\n" | |
2927 | GR_DISABLE) | |
055679e9 | 2928 | { |
2929 | int ret = BGP_GR_FAILURE; | |
2930 | ||
2931 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2932 | zlog_debug( | |
2ba1fe69 | 2933 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2934 | |
055679e9 | 2935 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2936 | ||
2937 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2938 | ||
dc95985f | 2939 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2940 | bgp->peer, ret); | |
5cce3f05 | 2941 | |
055679e9 | 2942 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2943 | zlog_debug( | |
2ba1fe69 | 2944 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2945 | vty_out(vty, |
2946 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2947 | ||
055679e9 | 2948 | return bgp_vty_return(vty, ret); |
2949 | } | |
2950 | ||
2951 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2952 | no_bgp_graceful_restart_disable_cmd, |
2953 | "no bgp graceful-restart-disable", | |
2954 | NO_STR | |
2955 | "BGP specific commands\n" | |
2956 | NO_GR_DISABLE | |
055679e9 | 2957 | ) |
2958 | { | |
2959 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2960 | ||
2961 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2962 | zlog_debug( | |
2ba1fe69 | 2963 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2964 | |
2965 | int ret = BGP_GR_FAILURE; | |
2966 | ||
2967 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2968 | ||
36235319 QY |
2969 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2970 | ret); | |
5cce3f05 | 2971 | |
055679e9 | 2972 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2973 | zlog_debug( | |
2ba1fe69 | 2974 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2975 | vty_out(vty, |
2976 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2977 | |
2978 | return bgp_vty_return(vty, ret); | |
2979 | } | |
2980 | ||
2981 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2982 | bgp_neighbor_graceful_restart_set_cmd, |
2983 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2984 | NEIGHBOR_STR | |
2985 | NEIGHBOR_ADDR_STR2 | |
2986 | GR_NEIGHBOR_CMD | |
055679e9 | 2987 | ) |
2988 | { | |
2989 | int idx_peer = 1; | |
2990 | struct peer *peer; | |
2991 | int ret = BGP_GR_FAILURE; | |
2992 | ||
dc95985f | 2993 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2994 | ||
055679e9 | 2995 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2996 | zlog_debug( | |
2ba1fe69 | 2997 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2998 | |
055679e9 | 2999 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3000 | if (!peer) | |
3001 | return CMD_WARNING_CONFIG_FAILED; | |
3002 | ||
3003 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
3004 | ||
dc95985f | 3005 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3006 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3007 | |
3008 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3009 | zlog_debug( | |
2ba1fe69 | 3010 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3011 | vty_out(vty, |
3012 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3013 | |
3014 | return bgp_vty_return(vty, ret); | |
3015 | } | |
3016 | ||
3017 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 3018 | no_bgp_neighbor_graceful_restart_set_cmd, |
3019 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3020 | NO_STR | |
3021 | NEIGHBOR_STR | |
3022 | NEIGHBOR_ADDR_STR2 | |
3023 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 3024 | ) |
3025 | { | |
3026 | int idx_peer = 2; | |
3027 | int ret = BGP_GR_FAILURE; | |
3028 | struct peer *peer; | |
3029 | ||
dc95985f | 3030 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3031 | ||
055679e9 | 3032 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3033 | if (!peer) | |
3034 | return CMD_WARNING_CONFIG_FAILED; | |
3035 | ||
3036 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3037 | zlog_debug( | |
2ba1fe69 | 3038 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 3039 | |
3040 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
3041 | ||
dc95985f | 3042 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3043 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3044 | |
3045 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3046 | zlog_debug( | |
2ba1fe69 | 3047 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3048 | vty_out(vty, |
3049 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3050 | |
3051 | return bgp_vty_return(vty, ret); | |
3052 | } | |
3053 | ||
3054 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 3055 | bgp_neighbor_graceful_restart_helper_set_cmd, |
3056 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3057 | NEIGHBOR_STR | |
3058 | NEIGHBOR_ADDR_STR2 | |
3059 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3060 | ) |
3061 | { | |
3062 | int idx_peer = 1; | |
3063 | struct peer *peer; | |
3064 | int ret = BGP_GR_FAILURE; | |
3065 | ||
dc95985f | 3066 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3067 | ||
055679e9 | 3068 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3069 | zlog_debug( | |
2ba1fe69 | 3070 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 3071 | |
055679e9 | 3072 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3073 | ||
055679e9 | 3074 | if (!peer) |
3075 | return CMD_WARNING_CONFIG_FAILED; | |
3076 | ||
3077 | ||
3078 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 3079 | |
dc95985f | 3080 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3081 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 3082 | |
055679e9 | 3083 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3084 | zlog_debug( | |
2ba1fe69 | 3085 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3086 | vty_out(vty, |
3087 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3088 | |
3089 | return bgp_vty_return(vty, ret); | |
3090 | } | |
3091 | ||
3092 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 3093 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
3094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3095 | NO_STR | |
3096 | NEIGHBOR_STR | |
3097 | NEIGHBOR_ADDR_STR2 | |
3098 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3099 | ) |
3100 | { | |
3101 | int idx_peer = 2; | |
3102 | int ret = BGP_GR_FAILURE; | |
3103 | struct peer *peer; | |
3104 | ||
dc95985f | 3105 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3106 | ||
055679e9 | 3107 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3108 | if (!peer) | |
3109 | return CMD_WARNING_CONFIG_FAILED; | |
3110 | ||
3111 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3112 | zlog_debug( | |
2ba1fe69 | 3113 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3114 | |
36235319 | 3115 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3116 | |
dc95985f | 3117 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3118 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3119 | |
3120 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3121 | zlog_debug( | |
2ba1fe69 | 3122 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3123 | vty_out(vty, |
3124 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3125 | |
3126 | return bgp_vty_return(vty, ret); | |
3127 | } | |
3128 | ||
3129 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3130 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3131 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3132 | NEIGHBOR_STR | |
3133 | NEIGHBOR_ADDR_STR2 | |
3134 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3135 | ) |
3136 | { | |
3137 | int idx_peer = 1; | |
3138 | struct peer *peer; | |
3139 | int ret = BGP_GR_FAILURE; | |
3140 | ||
dc95985f | 3141 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3142 | ||
055679e9 | 3143 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3144 | zlog_debug( | |
2ba1fe69 | 3145 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3146 | |
3147 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3148 | if (!peer) | |
3149 | return CMD_WARNING_CONFIG_FAILED; | |
3150 | ||
36235319 | 3151 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3152 | |
3153 | if (peer->bgp->t_startup) | |
3154 | bgp_peer_gr_flags_update(peer); | |
3155 | ||
dc95985f | 3156 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3157 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3158 | ||
055679e9 | 3159 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3160 | zlog_debug( | |
2ba1fe69 | 3161 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3162 | vty_out(vty, |
3163 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3164 | |
3165 | return bgp_vty_return(vty, ret); | |
3166 | } | |
3167 | ||
3168 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3169 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3170 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3171 | NO_STR | |
3172 | NEIGHBOR_STR | |
3173 | NEIGHBOR_ADDR_STR2 | |
3174 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3175 | ) |
3176 | { | |
3177 | int idx_peer = 2; | |
3178 | int ret = BGP_GR_FAILURE; | |
3179 | struct peer *peer; | |
3180 | ||
dc95985f | 3181 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3182 | ||
055679e9 | 3183 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3184 | if (!peer) | |
3185 | return CMD_WARNING_CONFIG_FAILED; | |
3186 | ||
3187 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3188 | zlog_debug( | |
2ba1fe69 | 3189 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3190 | |
3191 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3192 | ||
dc95985f | 3193 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3194 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3195 | |
3196 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3197 | zlog_debug( | |
2ba1fe69 | 3198 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3199 | vty_out(vty, |
3200 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3201 | |
3202 | return bgp_vty_return(vty, ret); | |
3203 | } | |
3204 | ||
d6e3c15b | 3205 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3206 | bgp_graceful_restart_disable_eor_cmd, | |
3207 | "bgp graceful-restart disable-eor", | |
3208 | "BGP specific commands\n" | |
3209 | "Graceful restart configuration parameters\n" | |
3210 | "Disable EOR Check\n") | |
3211 | { | |
3212 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3213 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3214 | |
d6e3c15b | 3215 | return CMD_SUCCESS; |
3216 | } | |
3217 | ||
3218 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3219 | no_bgp_graceful_restart_disable_eor_cmd, | |
3220 | "no bgp graceful-restart disable-eor", | |
3221 | NO_STR | |
3222 | "BGP specific commands\n" | |
3223 | "Graceful restart configuration parameters\n" | |
3224 | "Disable EOR Check\n") | |
3225 | { | |
3226 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3227 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3228 | |
3229 | return CMD_SUCCESS; | |
3230 | } | |
3231 | ||
3232 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3233 | bgp_graceful_restart_rib_stale_time_cmd, | |
3234 | "bgp graceful-restart rib-stale-time (1-3600)", | |
3235 | "BGP specific commands\n" | |
3236 | "Graceful restart configuration parameters\n" | |
3237 | "Specify the stale route removal timer in rib\n" | |
3238 | "Delay value (seconds)\n") | |
3239 | { | |
3240 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3241 | int idx_number = 3; | |
3242 | uint32_t stale_time; | |
3243 | ||
3244 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3245 | bgp->rib_stale_time = stale_time; | |
3246 | /* Send the stale timer update message to RIB */ | |
3247 | if (bgp_zebra_stale_timer_update(bgp)) | |
3248 | return CMD_WARNING; | |
3249 | ||
3250 | return CMD_SUCCESS; | |
3251 | } | |
3252 | ||
3253 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3254 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3255 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3256 | NO_STR | |
3257 | "BGP specific commands\n" | |
3258 | "Graceful restart configuration parameters\n" | |
3259 | "Specify the stale route removal timer in rib\n" | |
3260 | "Delay value (seconds)\n") | |
3261 | { | |
3262 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3263 | ||
3264 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3265 | /* Send the stale timer update message to RIB */ | |
3266 | if (bgp_zebra_stale_timer_update(bgp)) | |
3267 | return CMD_WARNING; | |
3268 | ||
d6e3c15b | 3269 | return CMD_SUCCESS; |
3270 | } | |
3271 | ||
ff8a8a7a CS |
3272 | static inline int bgp_initiate_graceful_shut_unshut(struct bgp *bgp, |
3273 | char *errmsg, | |
3274 | size_t errmsg_len) | |
05bd726c | 3275 | { |
3276 | bgp_static_redo_import_check(bgp); | |
3277 | bgp_redistribute_redo(bgp); | |
ff8a8a7a CS |
3278 | if (bgp_clear_star_soft_out(bgp->name, errmsg, errmsg_len) < 0) |
3279 | return -1; | |
3280 | if (bgp_clear_star_soft_in(bgp->name, errmsg, errmsg_len) < 0) | |
3281 | return -1; | |
3282 | ||
3283 | return 0; | |
05bd726c | 3284 | } |
3285 | ||
3286 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3287 | { | |
3288 | struct listnode *node, *nnode; | |
3289 | struct bgp *bgp; | |
3290 | bool vrf_cfg = false; | |
ff8a8a7a | 3291 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3292 | |
3293 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3294 | return CMD_SUCCESS; | |
3295 | ||
3296 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3297 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3298 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3299 | vty_out(vty, | |
3300 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3301 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3302 | VRF_DEFAULT_NAME : bgp->name); | |
3303 | vrf_cfg = true; | |
3304 | } | |
3305 | } | |
3306 | ||
3307 | if (vrf_cfg) { | |
3308 | vty_out(vty, | |
3309 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3310 | return CMD_WARNING; | |
3311 | } | |
3312 | ||
3313 | /* Set flag globally */ | |
3314 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3315 | ||
3316 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3317 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3318 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3319 | sizeof(errmsg)) | |
3320 | < 0) | |
3321 | if (strlen(errmsg)) | |
3322 | vty_out(vty, "%s\n", errmsg); | |
3323 | } | |
05bd726c | 3324 | |
3325 | return CMD_SUCCESS; | |
3326 | } | |
3327 | ||
3328 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3329 | { | |
3330 | struct listnode *node, *nnode; | |
3331 | struct bgp *bgp; | |
ff8a8a7a | 3332 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3333 | |
3334 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3335 | return CMD_SUCCESS; | |
3336 | ||
3337 | /* Unset flag globally */ | |
3338 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3339 | ||
3340 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3341 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3342 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3343 | sizeof(errmsg)) | |
3344 | < 0) | |
3345 | if (strlen(errmsg)) | |
3346 | vty_out(vty, "%s\n", errmsg); | |
3347 | } | |
05bd726c | 3348 | |
3349 | return CMD_SUCCESS; | |
3350 | } | |
3351 | ||
7f323236 DW |
3352 | /* "bgp graceful-shutdown" configuration */ |
3353 | DEFUN (bgp_graceful_shutdown, | |
3354 | bgp_graceful_shutdown_cmd, | |
3355 | "bgp graceful-shutdown", | |
3356 | BGP_STR | |
3357 | "Graceful shutdown parameters\n") | |
3358 | { | |
05bd726c | 3359 | if (vty->node == CONFIG_NODE) |
3360 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3361 | ||
87ce2564 CS |
3362 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3363 | NB_OP_MODIFY, "true"); | |
7f323236 | 3364 | |
ff8a8a7a | 3365 | return nb_cli_apply_changes(vty, NULL); |
7f323236 DW |
3366 | } |
3367 | ||
ff8a8a7a | 3368 | DEFUN_YANG (no_bgp_graceful_shutdown, |
7f323236 DW |
3369 | no_bgp_graceful_shutdown_cmd, |
3370 | "no bgp graceful-shutdown", | |
3371 | NO_STR | |
3372 | BGP_STR | |
3373 | "Graceful shutdown parameters\n") | |
3374 | { | |
05bd726c | 3375 | if (vty->node == CONFIG_NODE) |
3376 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3377 | ||
87ce2564 CS |
3378 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3379 | NB_OP_MODIFY, "false"); | |
05bd726c | 3380 | |
ff8a8a7a CS |
3381 | return nb_cli_apply_changes(vty, NULL); |
3382 | } | |
7f323236 | 3383 | |
ff8a8a7a CS |
3384 | void cli_show_router_bgp_graceful_shutdown(struct vty *vty, |
3385 | struct lyd_node *dnode, | |
3386 | bool show_defaults) | |
3387 | { | |
3388 | if (yang_dnode_get_bool(dnode, NULL)) | |
3389 | vty_out(vty, " bgp graceful-shutdown\n"); | |
7f323236 DW |
3390 | } |
3391 | ||
718e3744 | 3392 | /* "bgp fast-external-failover" configuration. */ |
ff8a8a7a | 3393 | DEFUN_YANG (bgp_fast_external_failover, |
718e3744 | 3394 | bgp_fast_external_failover_cmd, |
3395 | "bgp fast-external-failover", | |
3396 | BGP_STR | |
3397 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3398 | { | |
87ce2564 CS |
3399 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3400 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3401 | |
3402 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 3403 | } |
3404 | ||
ff8a8a7a | 3405 | DEFUN_YANG (no_bgp_fast_external_failover, |
718e3744 | 3406 | no_bgp_fast_external_failover_cmd, |
3407 | "no bgp fast-external-failover", | |
3408 | NO_STR | |
3409 | BGP_STR | |
3410 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3411 | { | |
87ce2564 CS |
3412 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3413 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3414 | |
3415 | return nb_cli_apply_changes(vty, NULL); | |
3416 | } | |
3417 | ||
3418 | void cli_show_router_bgp_fast_external_failover(struct vty *vty, | |
3419 | struct lyd_node *dnode, | |
3420 | bool show_defaults) | |
3421 | { | |
3422 | if (!yang_dnode_get_bool(dnode, NULL)) | |
3423 | vty_out(vty, " no bgp fast-external-failover\n"); | |
718e3744 | 3424 | } |
6b0655a2 | 3425 | |
718e3744 | 3426 | /* "bgp bestpath compare-routerid" configuration. */ |
ff8a8a7a CS |
3427 | DEFUN_YANG(bgp_bestpath_compare_router_id, |
3428 | bgp_bestpath_compare_router_id_cmd, | |
3429 | "bgp bestpath compare-routerid", | |
3430 | "BGP specific commands\n" | |
3431 | "Change the default bestpath selection\n" | |
3432 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3433 | { |
ff8a8a7a | 3434 | nb_cli_enqueue_change( |
87ce2564 CS |
3435 | vty, |
3436 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3437 | NB_OP_MODIFY, "true"); |
7aafcaca | 3438 | |
ff8a8a7a | 3439 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3440 | } |
3441 | ||
ff8a8a7a CS |
3442 | DEFUN_YANG(no_bgp_bestpath_compare_router_id, |
3443 | no_bgp_bestpath_compare_router_id_cmd, | |
3444 | "no bgp bestpath compare-routerid", | |
3445 | NO_STR | |
3446 | "BGP specific commands\n" | |
3447 | "Change the default bestpath selection\n" | |
3448 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3449 | { |
ff8a8a7a | 3450 | nb_cli_enqueue_change( |
87ce2564 CS |
3451 | vty, |
3452 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3453 | NB_OP_MODIFY, "false"); |
7aafcaca | 3454 | |
ff8a8a7a | 3455 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3456 | } |
6b0655a2 | 3457 | |
718e3744 | 3458 | /* "bgp bestpath as-path ignore" configuration. */ |
ff8a8a7a CS |
3459 | DEFUN_YANG(bgp_bestpath_aspath_ignore, |
3460 | bgp_bestpath_aspath_ignore_cmd, | |
3461 | "bgp bestpath as-path ignore", | |
3462 | "BGP specific commands\n" | |
3463 | "Change the default bestpath selection\n" | |
3464 | "AS-path attribute\n" | |
3465 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3466 | { |
87ce2564 CS |
3467 | nb_cli_enqueue_change( |
3468 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3469 | NB_OP_MODIFY, "true"); | |
7aafcaca | 3470 | |
ff8a8a7a | 3471 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3472 | } |
3473 | ||
ff8a8a7a CS |
3474 | DEFUN_YANG(no_bgp_bestpath_aspath_ignore, |
3475 | no_bgp_bestpath_aspath_ignore_cmd, | |
3476 | "no bgp bestpath as-path ignore", | |
3477 | NO_STR | |
3478 | "BGP specific commands\n" | |
3479 | "Change the default bestpath selection\n" | |
3480 | "AS-path attribute\n" | |
3481 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3482 | { |
87ce2564 CS |
3483 | nb_cli_enqueue_change( |
3484 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3485 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3486 | |
ff8a8a7a | 3487 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3488 | } |
6b0655a2 | 3489 | |
6811845b | 3490 | /* "bgp bestpath as-path confed" configuration. */ |
ff8a8a7a | 3491 | DEFUN_YANG (bgp_bestpath_aspath_confed, |
6811845b | 3492 | bgp_bestpath_aspath_confed_cmd, |
3493 | "bgp bestpath as-path confed", | |
3494 | "BGP specific commands\n" | |
3495 | "Change the default bestpath selection\n" | |
3496 | "AS-path attribute\n" | |
3497 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3498 | { | |
87ce2564 CS |
3499 | nb_cli_enqueue_change(vty, |
3500 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3501 | NB_OP_MODIFY, "true"); |
7aafcaca | 3502 | |
ff8a8a7a | 3503 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3504 | } |
3505 | ||
ff8a8a7a | 3506 | DEFUN_YANG (no_bgp_bestpath_aspath_confed, |
6811845b | 3507 | no_bgp_bestpath_aspath_confed_cmd, |
3508 | "no bgp bestpath as-path confed", | |
3509 | NO_STR | |
3510 | "BGP specific commands\n" | |
3511 | "Change the default bestpath selection\n" | |
3512 | "AS-path attribute\n" | |
3513 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3514 | { | |
87ce2564 CS |
3515 | nb_cli_enqueue_change(vty, |
3516 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3517 | NB_OP_MODIFY, "false"); |
7aafcaca | 3518 | |
ff8a8a7a | 3519 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3520 | } |
6b0655a2 | 3521 | |
2fdd455c | 3522 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
ff8a8a7a | 3523 | DEFUN_YANG (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3524 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3525 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3526 | "BGP specific commands\n" |
3527 | "Change the default bestpath selection\n" | |
3528 | "AS-path attribute\n" | |
3529 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3530 | "Generate an AS_SET\n" |
16fc1eec DS |
3531 | "Do not generate an AS_SET\n") |
3532 | { | |
d62a17ae | 3533 | int idx = 0; |
219178b6 | 3534 | |
87ce2564 CS |
3535 | nb_cli_enqueue_change( |
3536 | vty, "./global/route-selection-options/allow-multiple-as", | |
3537 | NB_OP_MODIFY, "true"); | |
d62a17ae | 3538 | if (argv_find(argv, argc, "as-set", &idx)) |
ff8a8a7a | 3539 | nb_cli_enqueue_change( |
87ce2564 CS |
3540 | vty, |
3541 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3542 | NB_OP_MODIFY, "true"); |
d62a17ae | 3543 | else |
ff8a8a7a | 3544 | nb_cli_enqueue_change( |
87ce2564 CS |
3545 | vty, |
3546 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3547 | NB_OP_MODIFY, "false"); |
7aafcaca | 3548 | |
ff8a8a7a | 3549 | return nb_cli_apply_changes(vty, NULL); |
16fc1eec DS |
3550 | } |
3551 | ||
ff8a8a7a | 3552 | DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3553 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3554 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3555 | NO_STR |
3556 | "BGP specific commands\n" | |
3557 | "Change the default bestpath selection\n" | |
3558 | "AS-path attribute\n" | |
3559 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3560 | "Generate an AS_SET\n" |
16fc1eec DS |
3561 | "Do not generate an AS_SET\n") |
3562 | { | |
87ce2564 CS |
3563 | nb_cli_enqueue_change( |
3564 | vty, "./global/route-selection-options/allow-multiple-as", | |
3565 | NB_OP_MODIFY, "false"); | |
3566 | nb_cli_enqueue_change( | |
3567 | vty, "./global/route-selection-options/multi-path-as-set", | |
3568 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3569 | |
ff8a8a7a | 3570 | return nb_cli_apply_changes(vty, NULL); |
2fdd455c | 3571 | } |
6b0655a2 | 3572 | |
848973c7 | 3573 | /* "bgp log-neighbor-changes" configuration. */ |
ff8a8a7a CS |
3574 | DEFUN_YANG(bgp_log_neighbor_changes, |
3575 | bgp_log_neighbor_changes_cmd, | |
3576 | "bgp log-neighbor-changes", | |
3577 | "BGP specific commands\n" | |
3578 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3579 | { |
87ce2564 CS |
3580 | nb_cli_enqueue_change( |
3581 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3582 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3583 | |
3584 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3585 | } |
3586 | ||
ff8a8a7a CS |
3587 | DEFUN_YANG(no_bgp_log_neighbor_changes, |
3588 | no_bgp_log_neighbor_changes_cmd, | |
3589 | "no bgp log-neighbor-changes", | |
3590 | NO_STR | |
3591 | "BGP specific commands\n" | |
3592 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3593 | { |
87ce2564 CS |
3594 | nb_cli_enqueue_change( |
3595 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3596 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3597 | |
3598 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3599 | } |
6b0655a2 | 3600 | |
718e3744 | 3601 | /* "bgp bestpath med" configuration. */ |
ff8a8a7a | 3602 | DEFUN_YANG (bgp_bestpath_med, |
718e3744 | 3603 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3604 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3605 | "BGP specific commands\n" |
3606 | "Change the default bestpath selection\n" | |
3607 | "MED attribute\n" | |
3608 | "Compare MED among confederation paths\n" | |
838758ac DW |
3609 | "Treat missing MED as the least preferred one\n" |
3610 | "Treat missing MED as the least preferred one\n" | |
3611 | "Compare MED among confederation paths\n") | |
718e3744 | 3612 | { |
d62a17ae | 3613 | int idx = 0; |
ff8a8a7a CS |
3614 | bool confed = false; |
3615 | bool worst_med = false; | |
3616 | ||
3617 | ||
d62a17ae | 3618 | if (argv_find(argv, argc, "confed", &idx)) |
ff8a8a7a CS |
3619 | confed = true; |
3620 | ||
87ce2564 CS |
3621 | nb_cli_enqueue_change(vty, |
3622 | "./global/route-selection-options/confed-med", | |
ff8a8a7a CS |
3623 | NB_OP_MODIFY, confed ? "true" : "false"); |
3624 | ||
d62a17ae | 3625 | idx = 0; |
3626 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3627 | worst_med = true; |
e52702f2 | 3628 | |
87ce2564 CS |
3629 | nb_cli_enqueue_change( |
3630 | vty, "./global/route-selection-options/missing-as-worst-med", | |
3631 | NB_OP_MODIFY, worst_med ? "true" : "false"); | |
7aafcaca | 3632 | |
ff8a8a7a | 3633 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3634 | } |
3635 | ||
ff8a8a7a | 3636 | DEFUN_YANG (no_bgp_bestpath_med, |
718e3744 | 3637 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3638 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3639 | NO_STR |
3640 | "BGP specific commands\n" | |
3641 | "Change the default bestpath selection\n" | |
3642 | "MED attribute\n" | |
3643 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3644 | "Treat missing MED as the least preferred one\n" |
3645 | "Treat missing MED as the least preferred one\n" | |
3646 | "Compare MED among confederation paths\n") | |
718e3744 | 3647 | { |
d62a17ae | 3648 | int idx = 0; |
ff8a8a7a | 3649 | |
d62a17ae | 3650 | if (argv_find(argv, argc, "confed", &idx)) |
87ce2564 CS |
3651 | nb_cli_enqueue_change( |
3652 | vty, "./global/route-selection-options/confed-med", | |
3653 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 3654 | |
d62a17ae | 3655 | idx = 0; |
3656 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3657 | nb_cli_enqueue_change( |
87ce2564 CS |
3658 | vty, |
3659 | "./global/route-selection-options/missing-as-worst-med", | |
ff8a8a7a | 3660 | NB_OP_MODIFY, "false"); |
718e3744 | 3661 | |
ff8a8a7a | 3662 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3663 | } |
3664 | ||
f7e1c681 | 3665 | /* "bgp bestpath bandwidth" configuration. */ |
3666 | DEFPY (bgp_bestpath_bw, | |
3667 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3668 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 3669 | "BGP specific commands\n" |
3670 | "Change the default bestpath selection\n" | |
3671 | "Link Bandwidth attribute\n" | |
3672 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3673 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3674 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3675 | { | |
3676 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3677 | afi_t afi; | |
3678 | safi_t safi; | |
3679 | ||
ad36d216 DS |
3680 | if (!bw_cfg) { |
3681 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3682 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3683 | } |
ad36d216 DS |
3684 | if (!strcmp(bw_cfg, "ignore")) |
3685 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3686 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3687 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3688 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3689 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3690 | else | |
3691 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3692 | |
3693 | /* This config is used in route install, so redo that. */ | |
3694 | FOREACH_AFI_SAFI (afi, safi) { | |
3695 | if (!bgp_fibupd_safi(safi)) | |
3696 | continue; | |
3697 | bgp_zebra_announce_table(bgp, afi, safi); | |
3698 | } | |
3699 | ||
3700 | return CMD_SUCCESS; | |
3701 | } | |
3702 | ||
ad36d216 DS |
3703 | DEFPY (no_bgp_bestpath_bw, |
3704 | no_bgp_bestpath_bw_cmd, | |
3705 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3706 | NO_STR | |
3707 | "BGP specific commands\n" | |
3708 | "Change the default bestpath selection\n" | |
3709 | "Link Bandwidth attribute\n" | |
3710 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3711 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3712 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3713 | { | |
3714 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3715 | afi_t afi; | |
3716 | safi_t safi; | |
3717 | ||
3718 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3719 | ||
3720 | /* This config is used in route install, so redo that. */ | |
3721 | FOREACH_AFI_SAFI (afi, safi) { | |
3722 | if (!bgp_fibupd_safi(safi)) | |
3723 | continue; | |
3724 | bgp_zebra_announce_table(bgp, afi, safi); | |
3725 | } | |
3726 | return CMD_SUCCESS; | |
3727 | } | |
3728 | ||
718e3744 | 3729 | /* "no bgp default ipv4-unicast". */ |
3730 | DEFUN (no_bgp_default_ipv4_unicast, | |
3731 | no_bgp_default_ipv4_unicast_cmd, | |
3732 | "no bgp default ipv4-unicast", | |
3733 | NO_STR | |
3734 | "BGP specific commands\n" | |
3735 | "Configure BGP defaults\n" | |
3736 | "Activate ipv4-unicast for a peer by default\n") | |
3737 | { | |
d62a17ae | 3738 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3739 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3740 | return CMD_SUCCESS; |
718e3744 | 3741 | } |
3742 | ||
3743 | DEFUN (bgp_default_ipv4_unicast, | |
3744 | bgp_default_ipv4_unicast_cmd, | |
3745 | "bgp default ipv4-unicast", | |
3746 | "BGP specific commands\n" | |
3747 | "Configure BGP defaults\n" | |
3748 | "Activate ipv4-unicast for a peer by default\n") | |
3749 | { | |
d62a17ae | 3750 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3751 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3752 | return CMD_SUCCESS; |
718e3744 | 3753 | } |
6b0655a2 | 3754 | |
04b6bdc0 | 3755 | /* Display hostname in certain command outputs */ |
ff8a8a7a | 3756 | DEFUN_YANG (bgp_default_show_hostname, |
04b6bdc0 DW |
3757 | bgp_default_show_hostname_cmd, |
3758 | "bgp default show-hostname", | |
3759 | "BGP specific commands\n" | |
3760 | "Configure BGP defaults\n" | |
0437e105 | 3761 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3762 | { |
87ce2564 CS |
3763 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3764 | "true"); | |
ff8a8a7a CS |
3765 | |
3766 | return nb_cli_apply_changes(vty, NULL); | |
04b6bdc0 DW |
3767 | } |
3768 | ||
ff8a8a7a CS |
3769 | DEFUN_YANG(no_bgp_default_show_hostname, |
3770 | no_bgp_default_show_hostname_cmd, | |
3771 | "no bgp default show-hostname", | |
3772 | NO_STR | |
3773 | "BGP specific commands\n" | |
3774 | "Configure BGP defaults\n" | |
3775 | "Show hostname in certain command outputs\n") | |
04b6bdc0 | 3776 | { |
87ce2564 CS |
3777 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3778 | "false"); | |
ff8a8a7a CS |
3779 | |
3780 | return nb_cli_apply_changes(vty, NULL); | |
3781 | } | |
3782 | ||
3783 | void cli_show_router_bgp_show_hostname(struct vty *vty, struct lyd_node *dnode, | |
3784 | bool show_defaults) | |
3785 | { | |
3786 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3787 | vty_out(vty, " bgp default show-hostname\n"); | |
04b6bdc0 DW |
3788 | } |
3789 | ||
aef999a2 | 3790 | /* Display hostname in certain command outputs */ |
232c75cd CS |
3791 | DEFUN_YANG(bgp_default_show_nexthop_hostname, |
3792 | bgp_default_show_nexthop_hostname_cmd, | |
3793 | "bgp default show-nexthop-hostname", | |
3794 | "BGP specific commands\n" | |
3795 | "Configure BGP defaults\n" | |
3796 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3797 | { |
87ce2564 CS |
3798 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3799 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3800 | |
3801 | return nb_cli_apply_changes(vty, NULL); | |
aef999a2 DA |
3802 | } |
3803 | ||
3804 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3805 | no_bgp_default_show_nexthop_hostname_cmd, | |
3806 | "no bgp default show-nexthop-hostname", | |
3807 | NO_STR | |
3808 | "BGP specific commands\n" | |
3809 | "Configure BGP defaults\n" | |
3810 | "Show hostname for nexthop in certain command outputs\n") | |
3811 | { | |
87ce2564 CS |
3812 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3813 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3814 | |
3815 | return nb_cli_apply_changes(vty, NULL); | |
3816 | } | |
3817 | ||
3818 | void cli_show_router_bgp_show_nexthop_hostname(struct vty *vty, | |
3819 | struct lyd_node *dnode, | |
3820 | bool show_defaults) | |
3821 | { | |
3822 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3823 | vty_out(vty, " bgp default show-nexthop-hostname\n"); | |
aef999a2 DA |
3824 | } |
3825 | ||
8233ef81 | 3826 | /* "bgp network import-check" configuration. */ |
ff8a8a7a CS |
3827 | DEFUN_YANG(bgp_network_import_check, |
3828 | bgp_network_import_check_cmd, | |
3829 | "bgp network import-check", | |
3830 | "BGP specific commands\n" | |
3831 | "BGP network command\n" | |
3832 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3833 | { |
87ce2564 CS |
3834 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3835 | "true"); | |
078430f6 | 3836 | |
ff8a8a7a | 3837 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3838 | } |
3839 | ||
d62a17ae | 3840 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3841 | "bgp network import-check exact", | |
3842 | "BGP specific commands\n" | |
3843 | "BGP network command\n" | |
3844 | "Check BGP network route exists in IGP\n" | |
3845 | "Match route precisely\n") | |
8233ef81 | 3846 | |
ff8a8a7a CS |
3847 | DEFUN_YANG(no_bgp_network_import_check, |
3848 | no_bgp_network_import_check_cmd, | |
3849 | "no bgp network import-check", | |
3850 | NO_STR | |
3851 | "BGP specific commands\n" | |
3852 | "BGP network command\n" | |
3853 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3854 | { |
87ce2564 CS |
3855 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3856 | "false"); | |
5623e905 | 3857 | |
ff8a8a7a | 3858 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3859 | } |
6b0655a2 | 3860 | |
ff8a8a7a CS |
3861 | void cli_show_router_bgp_import_check(struct vty *vty, struct lyd_node *dnode, |
3862 | bool show_defaults) | |
718e3744 | 3863 | { |
ff8a8a7a CS |
3864 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_IMPORT_CHECK) |
3865 | vty_out(vty, " bgp network import-check\n"); | |
3866 | } | |
718e3744 | 3867 | |
ff8a8a7a CS |
3868 | DEFUN_YANG(bgp_default_local_preference, |
3869 | bgp_default_local_preference_cmd, | |
3870 | "bgp default local-preference (0-4294967295)", | |
3871 | "BGP specific commands\n" | |
3872 | "Configure BGP defaults\n" | |
3873 | "local preference (higher=more preferred)\n" | |
3874 | "Configure default local preference value\n") | |
3875 | { | |
3876 | int idx_number = 3; | |
718e3744 | 3877 | |
87ce2564 | 3878 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, |
ff8a8a7a | 3879 | argv[idx_number]->arg); |
718e3744 | 3880 | |
ff8a8a7a | 3881 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3882 | } |
3883 | ||
ff8a8a7a CS |
3884 | DEFUN_YANG(no_bgp_default_local_preference, |
3885 | no_bgp_default_local_preference_cmd, | |
3886 | "no bgp default local-preference [(0-4294967295)]", | |
3887 | NO_STR | |
3888 | "BGP specific commands\n" | |
3889 | "Configure BGP defaults\n" | |
3890 | "local preference (higher=more preferred)\n" | |
3891 | "Configure default local preference value\n") | |
718e3744 | 3892 | { |
87ce2564 | 3893 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, NULL); |
7aafcaca | 3894 | |
ff8a8a7a | 3895 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3896 | } |
3897 | ||
ff8a8a7a CS |
3898 | void cli_show_router_bgp_local_pref(struct vty *vty, struct lyd_node *dnode, |
3899 | bool show_defaults) | |
3900 | { | |
3901 | vty_out(vty, " bgp default local-preference %u\n", | |
3902 | yang_dnode_get_uint32(dnode, NULL)); | |
3903 | } | |
6b0655a2 | 3904 | |
ff8a8a7a CS |
3905 | |
3906 | DEFUN_YANG(bgp_default_subgroup_pkt_queue_max, | |
3907 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3908 | "bgp default subgroup-pkt-queue-max (20-100)", | |
3909 | "BGP specific commands\n" | |
3910 | "Configure BGP defaults\n" | |
3911 | "subgroup-pkt-queue-max\n" | |
3912 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3913 | { |
d62a17ae | 3914 | int idx_number = 3; |
3f9c7369 | 3915 | |
ff8a8a7a | 3916 | nb_cli_enqueue_change( |
87ce2564 CS |
3917 | vty, |
3918 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a | 3919 | NB_OP_MODIFY, argv[idx_number]->arg); |
3f9c7369 | 3920 | |
ff8a8a7a | 3921 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
3922 | } |
3923 | ||
ff8a8a7a CS |
3924 | DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max, |
3925 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3926 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3927 | NO_STR | |
3928 | "BGP specific commands\n" | |
3929 | "Configure BGP defaults\n" | |
3930 | "subgroup-pkt-queue-max\n" | |
3931 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3932 | { |
ff8a8a7a | 3933 | nb_cli_enqueue_change( |
87ce2564 CS |
3934 | vty, |
3935 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a CS |
3936 | NB_OP_MODIFY, NULL); |
3937 | ||
3938 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3939 | } |
3940 | ||
ff8a8a7a CS |
3941 | void cli_show_router_global_update_group_config_subgroup_pkt_queue_size( |
3942 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3943 | { | |
3944 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
3945 | yang_dnode_get_uint32(dnode, NULL)); | |
3946 | } | |
813d4307 | 3947 | |
ff8a8a7a CS |
3948 | DEFUN_YANG(bgp_rr_allow_outbound_policy, |
3949 | bgp_rr_allow_outbound_policy_cmd, | |
3950 | "bgp route-reflector allow-outbound-policy", | |
3951 | "BGP specific commands\n" | |
3952 | "Allow modifications made by out route-map\n" | |
3953 | "on ibgp neighbors\n") | |
8bd9d948 | 3954 | { |
87ce2564 CS |
3955 | nb_cli_enqueue_change(vty, |
3956 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a | 3957 | NB_OP_MODIFY, "true"); |
8bd9d948 | 3958 | |
ff8a8a7a CS |
3959 | return nb_cli_apply_changes(vty, NULL); |
3960 | } | |
8bd9d948 | 3961 | |
ff8a8a7a CS |
3962 | DEFUN_YANG(no_bgp_rr_allow_outbound_policy, |
3963 | no_bgp_rr_allow_outbound_policy_cmd, | |
3964 | "no bgp route-reflector allow-outbound-policy", | |
3965 | NO_STR | |
3966 | "BGP specific commands\n" | |
3967 | "Allow modifications made by out route-map\n" | |
3968 | "on ibgp neighbors\n") | |
3969 | { | |
87ce2564 CS |
3970 | nb_cli_enqueue_change(vty, |
3971 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a CS |
3972 | NB_OP_MODIFY, "false"); |
3973 | ||
3974 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3975 | } |
3976 | ||
ff8a8a7a CS |
3977 | |
3978 | void cli_show_router_global_neighbor_config(struct vty *vty, | |
3979 | struct lyd_node *dnode, | |
3980 | bool show_defaults) | |
8bd9d948 | 3981 | { |
ff8a8a7a CS |
3982 | uint32_t write_quanta, read_quanta; |
3983 | ||
3984 | if (yang_dnode_get_bool(dnode, "./log-neighbor-changes")) | |
3985 | vty_out(vty, " bgp log-neighbor-changes\n"); | |
8bd9d948 | 3986 | |
ff8a8a7a CS |
3987 | if (yang_dnode_exists(dnode, "./dynamic-neighbors-limit")) { |
3988 | uint32_t listen_limit = yang_dnode_get_uint32( | |
3989 | dnode, "./dynamic-neighbors-limit"); | |
3990 | vty_out(vty, " bgp listen limit %u\n", listen_limit); | |
d62a17ae | 3991 | } |
8bd9d948 | 3992 | |
ff8a8a7a CS |
3993 | write_quanta = yang_dnode_get_uint32( |
3994 | dnode, "./packet-quanta-config/wpkt-quanta"); | |
3995 | if (write_quanta != BGP_WRITE_PACKET_MAX) | |
3996 | vty_out(vty, " write-quanta %d\n", write_quanta); | |
3997 | ||
3998 | read_quanta = yang_dnode_get_uint32( | |
3999 | dnode, "./packet-quanta-config/rpkt-quanta"); | |
4000 | ||
4001 | if (read_quanta != BGP_READ_PACKET_MAX) | |
4002 | vty_out(vty, " read-quanta %d\n", read_quanta); | |
8bd9d948 DS |
4003 | } |
4004 | ||
ff8a8a7a CS |
4005 | DEFUN_YANG(bgp_listen_limit, |
4006 | bgp_listen_limit_cmd, | |
4007 | "bgp listen limit (1-5000)", | |
4008 | "BGP specific commands\n" | |
4009 | "BGP Dynamic Neighbors listen commands\n" | |
4010 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4011 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4012 | { |
d62a17ae | 4013 | int idx_number = 3; |
f14e6fdb | 4014 | |
ff8a8a7a | 4015 | nb_cli_enqueue_change( |
87ce2564 | 4016 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a | 4017 | NB_OP_MODIFY, argv[idx_number]->arg); |
f14e6fdb | 4018 | |
ff8a8a7a | 4019 | return nb_cli_apply_changes(vty, NULL); |
f14e6fdb DS |
4020 | } |
4021 | ||
ff8a8a7a CS |
4022 | DEFUN_YANG(no_bgp_listen_limit, |
4023 | no_bgp_listen_limit_cmd, | |
4024 | "no bgp listen limit [(1-5000)]", | |
4025 | NO_STR | |
4026 | "BGP specific commands\n" | |
4027 | "BGP Dynamic Neighbors listen commands\n" | |
4028 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4029 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4030 | { |
ff8a8a7a | 4031 | nb_cli_enqueue_change( |
87ce2564 | 4032 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a CS |
4033 | NB_OP_DESTROY, NULL); |
4034 | ||
4035 | return nb_cli_apply_changes(vty, NULL); | |
f14e6fdb DS |
4036 | } |
4037 | ||
4038 | ||
20eb8864 | 4039 | /* |
4040 | * Check if this listen range is already configured. Check for exact | |
4041 | * match or overlap based on input. | |
4042 | */ | |
d62a17ae | 4043 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
4044 | struct prefix *range, int exact) | |
4045 | { | |
4046 | struct listnode *node, *nnode; | |
4047 | struct listnode *node1, *nnode1; | |
4048 | struct peer_group *group; | |
4049 | struct prefix *lr; | |
4050 | afi_t afi; | |
4051 | int match; | |
4052 | ||
4053 | afi = family2afi(range->family); | |
4054 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4055 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4056 | lr)) { | |
4057 | if (exact) | |
4058 | match = prefix_same(range, lr); | |
4059 | else | |
4060 | match = (prefix_match(range, lr) | |
4061 | || prefix_match(lr, range)); | |
4062 | if (match) | |
4063 | return group; | |
4064 | } | |
4065 | } | |
4066 | ||
4067 | return NULL; | |
20eb8864 | 4068 | } |
4069 | ||
f14e6fdb DS |
4070 | DEFUN (bgp_listen_range, |
4071 | bgp_listen_range_cmd, | |
d7b9898c | 4072 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 4073 | "BGP specific commands\n" |
d7fa34c1 QY |
4074 | "Configure BGP dynamic neighbors listen range\n" |
4075 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
4076 | NEIGHBOR_ADDR_STR |
4077 | "Member of the peer-group\n" | |
4078 | "Peer-group name\n") | |
f14e6fdb | 4079 | { |
d62a17ae | 4080 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4081 | struct prefix range; | |
4082 | struct peer_group *group, *existing_group; | |
4083 | afi_t afi; | |
4084 | int ret; | |
4085 | int idx = 0; | |
4086 | ||
4087 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4088 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4089 | char *prefix = argv[idx]->arg; | |
d7b9898c | 4090 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4091 | char *peergroup = argv[idx]->arg; |
4092 | ||
4093 | /* Convert IP prefix string to struct prefix. */ | |
4094 | ret = str2prefix(prefix, &range); | |
4095 | if (!ret) { | |
4096 | vty_out(vty, "%% Malformed listen range\n"); | |
4097 | return CMD_WARNING_CONFIG_FAILED; | |
4098 | } | |
4099 | ||
4100 | afi = family2afi(range.family); | |
4101 | ||
4102 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4103 | vty_out(vty, | |
4104 | "%% Malformed listen range (link-local address)\n"); | |
4105 | return CMD_WARNING_CONFIG_FAILED; | |
4106 | } | |
4107 | ||
4108 | apply_mask(&range); | |
4109 | ||
4110 | /* Check if same listen range is already configured. */ | |
4111 | existing_group = listen_range_exists(bgp, &range, 1); | |
4112 | if (existing_group) { | |
4113 | if (strcmp(existing_group->name, peergroup) == 0) | |
4114 | return CMD_SUCCESS; | |
4115 | else { | |
4116 | vty_out(vty, | |
4117 | "%% Same listen range is attached to peer-group %s\n", | |
4118 | existing_group->name); | |
4119 | return CMD_WARNING_CONFIG_FAILED; | |
4120 | } | |
4121 | } | |
4122 | ||
4123 | /* Check if an overlapping listen range exists. */ | |
4124 | if (listen_range_exists(bgp, &range, 0)) { | |
4125 | vty_out(vty, | |
4126 | "%% Listen range overlaps with existing listen range\n"); | |
4127 | return CMD_WARNING_CONFIG_FAILED; | |
4128 | } | |
4129 | ||
4130 | group = peer_group_lookup(bgp, peergroup); | |
4131 | if (!group) { | |
4132 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4133 | return CMD_WARNING_CONFIG_FAILED; | |
4134 | } | |
4135 | ||
4136 | ret = peer_group_listen_range_add(group, &range); | |
4137 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4138 | } |
4139 | ||
4140 | DEFUN (no_bgp_listen_range, | |
4141 | no_bgp_listen_range_cmd, | |
d7b9898c | 4142 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4143 | NO_STR |
f14e6fdb | 4144 | "BGP specific commands\n" |
d7fa34c1 QY |
4145 | "Unconfigure BGP dynamic neighbors listen range\n" |
4146 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4147 | NEIGHBOR_ADDR_STR | |
4148 | "Member of the peer-group\n" | |
4149 | "Peer-group name\n") | |
f14e6fdb | 4150 | { |
d62a17ae | 4151 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4152 | struct prefix range; | |
4153 | struct peer_group *group; | |
4154 | afi_t afi; | |
4155 | int ret; | |
4156 | int idx = 0; | |
4157 | ||
4158 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4159 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4160 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4161 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4162 | char *peergroup = argv[idx]->arg; |
4163 | ||
4164 | /* Convert IP prefix string to struct prefix. */ | |
4165 | ret = str2prefix(prefix, &range); | |
4166 | if (!ret) { | |
4167 | vty_out(vty, "%% Malformed listen range\n"); | |
4168 | return CMD_WARNING_CONFIG_FAILED; | |
4169 | } | |
4170 | ||
4171 | afi = family2afi(range.family); | |
4172 | ||
4173 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4174 | vty_out(vty, | |
4175 | "%% Malformed listen range (link-local address)\n"); | |
4176 | return CMD_WARNING_CONFIG_FAILED; | |
4177 | } | |
4178 | ||
4179 | apply_mask(&range); | |
4180 | ||
4181 | group = peer_group_lookup(bgp, peergroup); | |
4182 | if (!group) { | |
4183 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4184 | return CMD_WARNING_CONFIG_FAILED; | |
4185 | } | |
4186 | ||
4187 | ret = peer_group_listen_range_del(group, &range); | |
4188 | return bgp_vty_return(vty, ret); | |
4189 | } | |
4190 | ||
2b791107 | 4191 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4192 | { |
4193 | struct peer_group *group; | |
4194 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4195 | struct prefix *range; | |
4196 | afi_t afi; | |
d62a17ae | 4197 | |
4198 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4199 | vty_out(vty, " bgp listen limit %d\n", | |
4200 | bgp->dynamic_neighbors_limit); | |
4201 | ||
4202 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4203 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4204 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4205 | nrnode, range)) { | |
d62a17ae | 4206 | vty_out(vty, |
2dbe669b DA |
4207 | " bgp listen range %pFX peer-group %s\n", |
4208 | range, group->name); | |
d62a17ae | 4209 | } |
4210 | } | |
4211 | } | |
f14e6fdb DS |
4212 | } |
4213 | ||
4214 | ||
ff8a8a7a CS |
4215 | DEFUN_YANG(bgp_disable_connected_route_check, |
4216 | bgp_disable_connected_route_check_cmd, | |
4217 | "bgp disable-ebgp-connected-route-check", | |
4218 | "BGP specific commands\n" | |
4219 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 4220 | { |
87ce2564 CS |
4221 | nb_cli_enqueue_change(vty, |
4222 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 4223 | NB_OP_MODIFY, "true"); |
7aafcaca | 4224 | |
ff8a8a7a | 4225 | return nb_cli_apply_changes(vty, NULL); |
907f92c8 DS |
4226 | } |
4227 | ||
ff8a8a7a CS |
4228 | DEFUN_YANG(no_bgp_disable_connected_route_check, |
4229 | no_bgp_disable_connected_route_check_cmd, | |
4230 | "no bgp disable-ebgp-connected-route-check", | |
4231 | NO_STR | |
4232 | "BGP specific commands\n" | |
4233 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 4234 | { |
87ce2564 CS |
4235 | nb_cli_enqueue_change(vty, |
4236 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 4237 | NB_OP_MODIFY, "false"); |
d62a17ae | 4238 | |
ff8a8a7a | 4239 | return nb_cli_apply_changes(vty, NULL); |
d62a17ae | 4240 | } |
4241 | ||
ff8a8a7a CS |
4242 | void cli_show_router_global_ebgp_multihop_connected_route_check( |
4243 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
4244 | { | |
4245 | if (yang_dnode_get_bool(dnode, NULL)) | |
4246 | vty_out(vty, " bgp disable-ebgp-connected-route-check\n"); | |
4247 | } | |
d62a17ae | 4248 | |
ff8a8a7a CS |
4249 | DEFUN_YANG(bgp_default_shutdown, |
4250 | bgp_default_shutdown_cmd, | |
4251 | "[no] bgp default shutdown", | |
4252 | NO_STR BGP_STR | |
4253 | "Configure BGP defaults\n" | |
4254 | "Apply administrative shutdown to newly configured peers\n") | |
f26845f9 | 4255 | { |
87ce2564 | 4256 | nb_cli_enqueue_change(vty, "./global/default-shutdown", NB_OP_MODIFY, |
ff8a8a7a CS |
4257 | strmatch(argv[0]->text, "no") ? "false" : "true"); |
4258 | ||
4259 | return nb_cli_apply_changes(vty, NULL); | |
4260 | } | |
4261 | ||
4262 | void cli_show_router_bgp_default_shutdown(struct vty *vty, | |
4263 | struct lyd_node *dnode, | |
4264 | bool show_defaults) | |
4265 | { | |
4266 | if (yang_dnode_get_bool(dnode, NULL)) | |
4267 | vty_out(vty, " bgp default shutdown\n"); | |
f26845f9 QY |
4268 | } |
4269 | ||
736b68f3 DS |
4270 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4271 | BGP_STR | |
9ddf4b81 | 4272 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4273 | "Add a shutdown message (RFC 8203)\n" |
4274 | "Shutdown message\n") | |
9cf59432 | 4275 | { |
736b68f3 | 4276 | char *msgstr = NULL; |
8389c83a | 4277 | |
9cf59432 DS |
4278 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4279 | ||
8389c83a | 4280 | if (argc > 3) |
f80e35b6 | 4281 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4282 | |
4283 | bgp_shutdown_enable(bgp, msgstr); | |
4284 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4285 | |
4286 | return CMD_SUCCESS; | |
4287 | } | |
4288 | ||
736b68f3 | 4289 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4290 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4291 | { |
4292 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4293 | ||
4294 | bgp_shutdown_enable(bgp, NULL); | |
4295 | ||
4296 | return CMD_SUCCESS; | |
4297 | } | |
8389c83a | 4298 | |
736b68f3 | 4299 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4300 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4301 | { |
4302 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4303 | ||
4304 | bgp_shutdown_disable(bgp); | |
4305 | ||
4306 | return CMD_SUCCESS; | |
4307 | } | |
4308 | ||
9ddf4b81 | 4309 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4310 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4311 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4312 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4313 | |
f4b8ec07 CS |
4314 | DEFUN_YANG(neighbor_remote_as, |
4315 | neighbor_remote_as_cmd, | |
4316 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4317 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4318 | "Specify a BGP neighbor\n" AS_STR | |
4319 | "Internal BGP peer\n" | |
4320 | "External BGP peer\n") | |
718e3744 | 4321 | { |
d62a17ae | 4322 | int idx_peer = 1; |
4323 | int idx_remote_as = 3; | |
f4b8ec07 CS |
4324 | char base_xpath[XPATH_MAXLEN]; |
4325 | char unnbr_xpath[XPATH_MAXLEN]; | |
4326 | char prgrp_xpath[XPATH_MAXLEN]; | |
4327 | union sockunion su; | |
4328 | const char *as_type_str = "as-specified"; | |
4329 | ||
4330 | if (str2sockunion(argv[idx_peer]->arg, &su) < 0) { | |
4331 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4332 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4333 | ||
4334 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4335 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4336 | ||
4337 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4338 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4339 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4340 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
4341 | "%s%s", VTY_CURR_XPATH, | |
4342 | prgrp_xpath + 1)) { | |
4343 | snprintf(base_xpath, sizeof(base_xpath), | |
4344 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, | |
4345 | ""); | |
4346 | } else { | |
4347 | vty_out(vty, | |
4348 | "%% Create the peer-group or interface first\n"); | |
4349 | return CMD_WARNING_CONFIG_FAILED; | |
4350 | } | |
4351 | } else { | |
4352 | snprintf(base_xpath, sizeof(base_xpath), | |
4353 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
4354 | } | |
4355 | ||
4356 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4357 | as_type_str = "internal"; | |
4358 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4359 | as_type_str = "external"; | |
4360 | } else { | |
4361 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4362 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4363 | } | |
4364 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4365 | NB_OP_MODIFY, as_type_str); | |
4366 | ||
4367 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 4368 | } |
4369 | ||
f4b8ec07 CS |
4370 | int peer_conf_interface_create(struct bgp *bgp, const char *conf_if, afi_t afi, |
4371 | safi_t safi, bool v6only, | |
4372 | const char *peer_group_name, int as_type, | |
4373 | as_t as, char *errmsg, size_t errmsg_len) | |
d62a17ae | 4374 | { |
d62a17ae | 4375 | struct peer *peer; |
4376 | struct peer_group *group; | |
4377 | int ret = 0; | |
d62a17ae | 4378 | |
4379 | group = peer_group_lookup(bgp, conf_if); | |
4380 | ||
4381 | if (group) { | |
f4b8ec07 CS |
4382 | snprintf(errmsg, errmsg_len, |
4383 | "Name conflict with peer-group \n"); | |
4384 | return -1; | |
d62a17ae | 4385 | } |
4386 | ||
4387 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4388 | if (peer) { | |
f4b8ec07 | 4389 | if (as_type != AS_UNSPECIFIED) |
cc4d4ce8 | 4390 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 4391 | afi, safi); |
4392 | } else { | |
892fedb6 | 4393 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 4394 | && afi == AFI_IP && safi == SAFI_UNICAST) |
4395 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4396 | as_type, 0, 0, NULL); | |
4397 | else | |
4398 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4399 | as_type, afi, safi, NULL); | |
4400 | ||
4401 | if (!peer) { | |
f4b8ec07 CS |
4402 | snprintf(errmsg, errmsg_len, |
4403 | "BGP failed to create peer\n"); | |
4404 | return -1; | |
d62a17ae | 4405 | } |
4406 | ||
4407 | if (v6only) | |
527de3dc | 4408 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4409 | |
4410 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4411 | * this | |
4412 | * any unnumbered peer in order to not worry about run-time | |
4413 | * transitions | |
4414 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4415 | * address | |
4416 | * gets deleted later etc.) | |
4417 | */ | |
4418 | if (peer->ifp) | |
4419 | bgp_zebra_initiate_radv(bgp, peer); | |
4420 | } | |
4421 | ||
4422 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4423 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4424 | if (v6only) | |
527de3dc | 4425 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4426 | else |
527de3dc | 4427 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4428 | |
4429 | /* v6only flag changed. Reset bgp seesion */ | |
4430 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4431 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4432 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4433 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4434 | } else | |
4435 | bgp_session_reset(peer); | |
4436 | } | |
4437 | ||
9fb964de PM |
4438 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4439 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4440 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4441 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4442 | } |
d62a17ae | 4443 | |
4444 | if (peer_group_name) { | |
4445 | group = peer_group_lookup(bgp, peer_group_name); | |
4446 | if (!group) { | |
f4b8ec07 CS |
4447 | snprintf(errmsg, errmsg_len, |
4448 | "Configure the peer-group first\n"); | |
4449 | return -1; | |
d62a17ae | 4450 | } |
4451 | ||
8395c1f8 | 4452 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4453 | } |
4454 | ||
f4b8ec07 | 4455 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); |
a80beece DS |
4456 | } |
4457 | ||
232c75cd CS |
4458 | DEFUN_YANG(neighbor_interface_config, |
4459 | neighbor_interface_config_cmd, | |
f4b8ec07 CS |
4460 | "neighbor WORD interface [peer-group PGNAME]", |
4461 | NEIGHBOR_STR | |
4462 | "Interface name or neighbor tag\n" | |
4463 | "Enable BGP on interface\n" | |
4464 | "Member of the peer-group\n" | |
4465 | "Peer-group name\n") | |
4c48cf63 | 4466 | { |
d62a17ae | 4467 | int idx_word = 1; |
4468 | int idx_peer_group_word = 4; | |
f4b8ec07 CS |
4469 | char base_xpath[XPATH_MAXLEN]; |
4470 | ||
4471 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4472 | argv[idx_word]->arg, ""); | |
31500417 | 4473 | |
f4b8ec07 | 4474 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4475 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4476 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4477 | argv[idx_peer_group_word]->arg); | |
4478 | ||
4479 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4480 | } |
4481 | ||
f4b8ec07 CS |
4482 | DEFUN_YANG(neighbor_interface_config_v6only, |
4483 | neighbor_interface_config_v6only_cmd, | |
4484 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4485 | NEIGHBOR_STR | |
4486 | "Interface name or neighbor tag\n" | |
4487 | "Enable BGP on interface\n" | |
4488 | "Enable BGP with v6 link-local only\n" | |
4489 | "Member of the peer-group\n" | |
4490 | "Peer-group name\n") | |
4c48cf63 | 4491 | { |
d62a17ae | 4492 | int idx_word = 1; |
4493 | int idx_peer_group_word = 5; | |
f4b8ec07 CS |
4494 | char base_xpath[XPATH_MAXLEN]; |
4495 | ||
4496 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4497 | argv[idx_word]->arg, ""); | |
31500417 | 4498 | |
f4b8ec07 | 4499 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4500 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4501 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4502 | argv[idx_peer_group_word]->arg); | |
31500417 | 4503 | |
f4b8ec07 CS |
4504 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); |
4505 | ||
4506 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4507 | } |
4508 | ||
a80beece | 4509 | |
f4b8ec07 CS |
4510 | DEFUN_YANG( |
4511 | neighbor_interface_config_remote_as, | |
4512 | neighbor_interface_config_remote_as_cmd, | |
4513 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4514 | NEIGHBOR_STR | |
4515 | "Interface name or neighbor tag\n" | |
4516 | "Enable BGP on interface\n" | |
4517 | "Specify a BGP neighbor\n" AS_STR | |
4518 | "Internal BGP peer\n" | |
4519 | "External BGP peer\n") | |
b3a39dc5 | 4520 | { |
d62a17ae | 4521 | int idx_word = 1; |
4522 | int idx_remote_as = 4; | |
f4b8ec07 CS |
4523 | char base_xpath[XPATH_MAXLEN]; |
4524 | const char *as_type_str = "as-specified"; | |
4525 | ||
4526 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4527 | argv[idx_word]->arg, ""); | |
4528 | ||
4529 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4530 | ||
4531 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4532 | as_type_str = "internal"; | |
4533 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4534 | as_type_str = "external"; | |
4535 | } else { | |
4536 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4537 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4538 | } | |
4539 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4540 | NB_OP_MODIFY, as_type_str); | |
4541 | ||
4542 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4543 | } |
4544 | ||
f4b8ec07 CS |
4545 | DEFUN_YANG( |
4546 | neighbor_interface_v6only_config_remote_as, | |
4547 | neighbor_interface_v6only_config_remote_as_cmd, | |
4548 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4549 | NEIGHBOR_STR | |
4550 | "Interface name or neighbor tag\n" | |
4551 | "Enable BGP with v6 link-local only\n" | |
4552 | "Enable BGP on interface\n" | |
4553 | "Specify a BGP neighbor\n" AS_STR | |
4554 | "Internal BGP peer\n" | |
4555 | "External BGP peer\n") | |
b3a39dc5 | 4556 | { |
d62a17ae | 4557 | int idx_word = 1; |
4558 | int idx_remote_as = 5; | |
f4b8ec07 CS |
4559 | char base_xpath[XPATH_MAXLEN]; |
4560 | const char *as_type_str = "as-specified"; | |
4561 | ||
4562 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4563 | argv[idx_word]->arg, ""); | |
4564 | ||
4565 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4566 | ||
4567 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); | |
4568 | ||
4569 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4570 | as_type_str = "internal"; | |
4571 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4572 | as_type_str = "external"; | |
4573 | } else { | |
4574 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4575 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4576 | } | |
4577 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4578 | NB_OP_MODIFY, as_type_str); | |
4579 | ||
4580 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4581 | } |
4582 | ||
f4b8ec07 CS |
4583 | DEFUN_YANG(neighbor_peer_group, neighbor_peer_group_cmd, |
4584 | "neighbor WORD peer-group", | |
4585 | NEIGHBOR_STR | |
4586 | "Interface name or neighbor tag\n" | |
4587 | "Configure peer-group\n") | |
718e3744 | 4588 | { |
f4b8ec07 | 4589 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4590 | int idx_word = 1; |
718e3744 | 4591 | |
f4b8ec07 CS |
4592 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4593 | argv[idx_word]->arg, ""); | |
718e3744 | 4594 | |
f4b8ec07 | 4595 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
718e3744 | 4596 | |
f4b8ec07 | 4597 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 4598 | } |
4599 | ||
232c75cd CS |
4600 | DEFUN_YANG(no_neighbor, |
4601 | no_neighbor_cmd, | |
4602 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4603 | NO_STR NEIGHBOR_STR | |
4604 | NEIGHBOR_ADDR_STR2 | |
4605 | "Specify a BGP neighbor\n" AS_STR | |
4606 | "Internal BGP peer\n" | |
4607 | "External BGP peer\n") | |
718e3744 | 4608 | { |
d62a17ae | 4609 | int idx_peer = 2; |
f4b8ec07 CS |
4610 | char base_xpath[XPATH_MAXLEN]; |
4611 | char num_xpath[XPATH_MAXLEN]; | |
4612 | char unnbr_xpath[XPATH_MAXLEN]; | |
4613 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4614 | union sockunion su; |
d62a17ae | 4615 | |
f4b8ec07 CS |
4616 | if (str2sockunion(argv[idx_peer]->arg, &su) == 0) { |
4617 | snprintf(num_xpath, sizeof(num_xpath), | |
4618 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
4619 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4620 | VTY_CURR_XPATH, num_xpath + 1)) { | |
4621 | strlcpy(base_xpath, num_xpath, sizeof(base_xpath)); | |
d62a17ae | 4622 | } |
f4b8ec07 CS |
4623 | } else { |
4624 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4625 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4626 | ||
4627 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4628 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4629 | ||
4630 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4631 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4632 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4633 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
4634 | "%s%s", VTY_CURR_XPATH, | |
4635 | prgrp_xpath + 1)) { | |
4636 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); | |
4e2786df | 4637 | } else { |
f4b8ec07 CS |
4638 | vty_out(vty, |
4639 | "%% Create the peer-group or interface first\n"); | |
d62a17ae | 4640 | return CMD_WARNING_CONFIG_FAILED; |
4641 | } | |
1ff9a340 | 4642 | } |
718e3744 | 4643 | |
f4b8ec07 CS |
4644 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); |
4645 | ||
4646 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 4647 | } |
4648 | ||
f4b8ec07 CS |
4649 | DEFUN_YANG(no_neighbor_interface_config, |
4650 | no_neighbor_interface_config_cmd, | |
4651 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4652 | NO_STR NEIGHBOR_STR | |
4653 | "Interface name\n" | |
4654 | "Configure BGP on interface\n" | |
4655 | "Enable BGP with v6 link-local only\n" | |
4656 | "Member of the peer-group\n" | |
4657 | "Peer-group name\n" | |
4658 | "Specify a BGP neighbor\n" AS_STR | |
4659 | "Internal BGP peer\n" | |
4660 | "External BGP peer\n") | |
a80beece | 4661 | { |
d62a17ae | 4662 | int idx_word = 2; |
f4b8ec07 | 4663 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4664 | |
f4b8ec07 CS |
4665 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4666 | argv[idx_word]->arg, ""); | |
4667 | ||
4668 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4669 | ||
4670 | return nb_cli_apply_changes(vty, base_xpath); | |
a80beece DS |
4671 | } |
4672 | ||
f4b8ec07 CS |
4673 | DEFUN_YANG(no_neighbor_peer_group, |
4674 | no_neighbor_peer_group_cmd, | |
4675 | "no neighbor WORD peer-group", | |
4676 | NO_STR NEIGHBOR_STR | |
4677 | "Neighbor tag\n" | |
4678 | "Configure peer-group\n") | |
718e3744 | 4679 | { |
f4b8ec07 | 4680 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4681 | int idx_word = 2; |
718e3744 | 4682 | |
f4b8ec07 CS |
4683 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4684 | argv[idx_word]->arg, ""); | |
4685 | ||
4686 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4687 | ||
4688 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4689 | } |
4690 | ||
f4b8ec07 CS |
4691 | DEFUN_YANG(no_neighbor_interface_peer_group_remote_as, |
4692 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4693 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4694 | NO_STR NEIGHBOR_STR | |
4695 | "Interface name or neighbor tag\n" | |
4696 | "Specify a BGP neighbor\n" AS_STR | |
4697 | "Internal BGP peer\n" | |
4698 | "External BGP peer\n") | |
718e3744 | 4699 | { |
f4b8ec07 CS |
4700 | int idx_peer = 2; |
4701 | char base_xpath[XPATH_MAXLEN]; | |
4702 | char unnbr_xpath[XPATH_MAXLEN]; | |
4703 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4704 | |
f4b8ec07 CS |
4705 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4706 | argv[idx_peer]->arg, ""); | |
d62a17ae | 4707 | |
f4b8ec07 CS |
4708 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4709 | argv[idx_peer]->arg, ""); | |
4710 | ||
4711 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4712 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
4713 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); | |
4714 | } else if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
4715 | VTY_CURR_XPATH, prgrp_xpath + 1)) { | |
4716 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); | |
4717 | } else { | |
d62a17ae | 4718 | vty_out(vty, "%% Create the peer-group or interface first\n"); |
4719 | return CMD_WARNING_CONFIG_FAILED; | |
4720 | } | |
f4b8ec07 CS |
4721 | |
4722 | strlcat(base_xpath, "/neighbor-remote-as/remote-as-type", | |
4723 | sizeof(base_xpath)); | |
4724 | ||
4725 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); | |
4726 | ||
4727 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 4728 | } |
6b0655a2 | 4729 | |
f4b8ec07 CS |
4730 | DEFUN_YANG(neighbor_local_as, |
4731 | neighbor_local_as_cmd, | |
4732 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4734 | "Specify a local-as number\n" | |
4735 | "AS number used as local AS\n") | |
718e3744 | 4736 | { |
d62a17ae | 4737 | int idx_peer = 1; |
4738 | int idx_number = 3; | |
f4b8ec07 | 4739 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4740 | |
f4b8ec07 CS |
4741 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4742 | sizeof(base_xpath), NULL) | |
4743 | < 0) | |
d62a17ae | 4744 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4745 | |
f4b8ec07 CS |
4746 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4747 | argv[idx_number]->arg); | |
4748 | ||
4749 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4750 | } |
4751 | ||
f4b8ec07 CS |
4752 | DEFUN_YANG( |
4753 | neighbor_local_as_no_prepend, neighbor_local_as_no_prepend_cmd, | |
4754 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4755 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4756 | "Specify a local-as number\n" | |
4757 | "AS number used as local AS\n" | |
4758 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4759 | { |
d62a17ae | 4760 | int idx_peer = 1; |
4761 | int idx_number = 3; | |
f4b8ec07 | 4762 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4763 | |
f4b8ec07 CS |
4764 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4765 | sizeof(base_xpath), NULL) | |
4766 | < 0) | |
d62a17ae | 4767 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4768 | |
f4b8ec07 CS |
4769 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4770 | argv[idx_number]->arg); | |
4771 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4772 | "true"); | |
4773 | ||
4774 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4775 | } |
4776 | ||
f4b8ec07 CS |
4777 | DEFUN_YANG( |
4778 | neighbor_local_as_no_prepend_replace_as, | |
4779 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4780 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4781 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4782 | "Specify a local-as number\n" | |
4783 | "AS number used as local AS\n" | |
4784 | "Do not prepend local-as to updates from ebgp peers\n" | |
4785 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4786 | { |
d62a17ae | 4787 | int idx_peer = 1; |
4788 | int idx_number = 3; | |
f4b8ec07 | 4789 | char base_xpath[XPATH_MAXLEN]; |
9d3f9705 | 4790 | |
f4b8ec07 CS |
4791 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4792 | sizeof(base_xpath), NULL) | |
4793 | < 0) | |
d62a17ae | 4794 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4795 | |
f4b8ec07 CS |
4796 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4797 | argv[idx_number]->arg); | |
4798 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4799 | "true"); | |
4800 | nb_cli_enqueue_change(vty, "./local-as/no-replace-as", NB_OP_MODIFY, | |
4801 | "true"); | |
4802 | ||
4803 | return nb_cli_apply_changes(vty, base_xpath); | |
9d3f9705 AC |
4804 | } |
4805 | ||
f4b8ec07 CS |
4806 | DEFUN_YANG(no_neighbor_local_as, |
4807 | no_neighbor_local_as_cmd, | |
4808 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4809 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4810 | "Specify a local-as number\n" | |
4811 | "AS number used as local AS\n" | |
4812 | "Do not prepend local-as to updates from ebgp peers\n" | |
4813 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4814 | { |
d62a17ae | 4815 | int idx_peer = 2; |
f4b8ec07 | 4816 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4817 | |
f4b8ec07 CS |
4818 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4819 | sizeof(base_xpath), NULL) | |
4820 | < 0) | |
d62a17ae | 4821 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4822 | |
f4b8ec07 CS |
4823 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_DESTROY, NULL); |
4824 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4825 | "false"); | |
4826 | nb_cli_enqueue_change(vty, "./local-as/no-replace-as", NB_OP_MODIFY, | |
4827 | "false"); | |
4828 | ||
4829 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4830 | } |
4831 | ||
718e3744 | 4832 | |
3f9c7369 DS |
4833 | DEFUN (neighbor_solo, |
4834 | neighbor_solo_cmd, | |
9ccf14f7 | 4835 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4836 | NEIGHBOR_STR |
4837 | NEIGHBOR_ADDR_STR2 | |
4838 | "Solo peer - part of its own update group\n") | |
4839 | { | |
d62a17ae | 4840 | int idx_peer = 1; |
4841 | struct peer *peer; | |
4842 | int ret; | |
3f9c7369 | 4843 | |
d62a17ae | 4844 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4845 | if (!peer) | |
4846 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4847 | |
d62a17ae | 4848 | ret = update_group_adjust_soloness(peer, 1); |
4849 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4850 | } |
4851 | ||
4852 | DEFUN (no_neighbor_solo, | |
4853 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4854 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4855 | NO_STR |
4856 | NEIGHBOR_STR | |
4857 | NEIGHBOR_ADDR_STR2 | |
4858 | "Solo peer - part of its own update group\n") | |
4859 | { | |
d62a17ae | 4860 | int idx_peer = 2; |
4861 | struct peer *peer; | |
4862 | int ret; | |
3f9c7369 | 4863 | |
d62a17ae | 4864 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4865 | if (!peer) | |
4866 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4867 | |
d62a17ae | 4868 | ret = update_group_adjust_soloness(peer, 0); |
4869 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4870 | } |
4871 | ||
f4b8ec07 CS |
4872 | DEFUN_YANG(neighbor_password, |
4873 | neighbor_password_cmd, | |
4874 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4875 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4876 | "Set a password\n" | |
4877 | "The password\n") | |
0df7c91f | 4878 | { |
d62a17ae | 4879 | int idx_peer = 1; |
4880 | int idx_line = 3; | |
f4b8ec07 | 4881 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 4882 | |
f4b8ec07 CS |
4883 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4884 | sizeof(base_xpath), NULL) | |
4885 | < 0) | |
d62a17ae | 4886 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4887 | |
f4b8ec07 CS |
4888 | nb_cli_enqueue_change(vty, "./password", NB_OP_MODIFY, |
4889 | argv[idx_line]->arg); | |
4890 | ||
4891 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f PJ |
4892 | } |
4893 | ||
f4b8ec07 CS |
4894 | DEFUN_YANG(no_neighbor_password, |
4895 | no_neighbor_password_cmd, | |
4896 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4897 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4898 | "Set a password\n" | |
4899 | "The password\n") | |
0df7c91f | 4900 | { |
d62a17ae | 4901 | int idx_peer = 2; |
f4b8ec07 | 4902 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 4903 | |
f4b8ec07 CS |
4904 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4905 | sizeof(base_xpath), NULL) | |
4906 | < 0) | |
d62a17ae | 4907 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4908 | |
f4b8ec07 CS |
4909 | nb_cli_enqueue_change(vty, "./password", NB_OP_DESTROY, NULL); |
4910 | ||
4911 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f | 4912 | } |
6b0655a2 | 4913 | |
f4b8ec07 CS |
4914 | DEFUN_YANG(neighbor_activate, |
4915 | neighbor_activate_cmd, | |
4916 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4917 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4918 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4919 | { |
d62a17ae | 4920 | int idx_peer = 1; |
f4b8ec07 | 4921 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
4922 | char af_xpath[XPATH_MAXLEN]; |
4923 | afi_t afi = bgp_node_afi(vty); | |
4924 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 4925 | |
f4b8ec07 CS |
4926 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
4927 | yang_afi_safi_value2identity(afi, safi)); | |
555c8ab7 CS |
4928 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4929 | sizeof(base_xpath), af_xpath) | |
f4b8ec07 | 4930 | < 0) |
d62a17ae | 4931 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4932 | |
555c8ab7 | 4933 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "true"); |
f4b8ec07 CS |
4934 | |
4935 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4936 | } |
4937 | ||
d62a17ae | 4938 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4939 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4940 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4941 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4942 | |
f4b8ec07 CS |
4943 | DEFUN_YANG(no_neighbor_activate, |
4944 | no_neighbor_activate_cmd, | |
4945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4946 | NO_STR NEIGHBOR_STR | |
4947 | NEIGHBOR_ADDR_STR2 | |
4948 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4949 | { |
d62a17ae | 4950 | int idx_peer = 2; |
f4b8ec07 CS |
4951 | char base_xpath[XPATH_MAXLEN]; |
4952 | char af_xpath[XPATH_MAXLEN]; | |
4953 | afi_t afi = bgp_node_afi(vty); | |
4954 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 4955 | |
f4b8ec07 CS |
4956 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
4957 | yang_afi_safi_value2identity(afi, safi)); | |
4958 | ||
4959 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
4960 | sizeof(base_xpath), af_xpath) | |
4961 | < 0) | |
d62a17ae | 4962 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4963 | |
f4b8ec07 CS |
4964 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "false"); |
4965 | ||
4966 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4967 | } |
6b0655a2 | 4968 | |
d62a17ae | 4969 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4970 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4971 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4972 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4973 | |
2a059a54 DS |
4974 | DEFUN (neighbor_set_peer_group, |
4975 | neighbor_set_peer_group_cmd, | |
4976 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4977 | NEIGHBOR_STR | |
4978 | NEIGHBOR_ADDR_STR2 | |
4979 | "Member of the peer-group\n" | |
4980 | "Peer-group name\n") | |
718e3744 | 4981 | { |
2a059a54 | 4982 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4983 | int idx_peer = 1; |
4984 | int idx_word = 3; | |
2a059a54 DS |
4985 | int ret; |
4986 | as_t as; | |
4987 | union sockunion su; | |
4988 | struct peer *peer; | |
4989 | struct peer_group *group; | |
d62a17ae | 4990 | |
2a059a54 DS |
4991 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4992 | if (ret < 0) { | |
4993 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4994 | if (!peer) { | |
4995 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4996 | argv[idx_peer]->arg); | |
4997 | return CMD_WARNING_CONFIG_FAILED; | |
4998 | } | |
4999 | } else { | |
5000 | if (peer_address_self_check(bgp, &su)) { | |
5001 | vty_out(vty, | |
5002 | "%% Can not configure the local system as neighbor\n"); | |
5003 | return CMD_WARNING_CONFIG_FAILED; | |
5004 | } | |
5005 | ||
5006 | /* Disallow for dynamic neighbor. */ | |
5007 | peer = peer_lookup(bgp, &su); | |
5008 | if (peer && peer_dynamic_neighbor(peer)) { | |
5009 | vty_out(vty, | |
5010 | "%% Operation not allowed on a dynamic neighbor\n"); | |
5011 | return CMD_WARNING_CONFIG_FAILED; | |
5012 | } | |
5013 | } | |
5014 | ||
5015 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5016 | if (!group) { | |
5017 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 5018 | return CMD_WARNING_CONFIG_FAILED; |
2a059a54 | 5019 | } |
d62a17ae | 5020 | |
2a059a54 | 5021 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
d62a17ae | 5022 | |
2a059a54 DS |
5023 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { |
5024 | vty_out(vty, | |
5025 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
5026 | as); | |
5027 | return CMD_WARNING_CONFIG_FAILED; | |
5028 | } | |
5029 | ||
5030 | return bgp_vty_return(vty, ret); | |
d62a17ae | 5031 | } |
5032 | ||
5033 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 5034 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5035 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5036 | "Member of the peer-group\n" | |
5037 | "Peer-group name\n") | |
596c17ba | 5038 | |
f4b8ec07 CS |
5039 | DEFUN_YANG (no_neighbor_set_peer_group, |
5040 | no_neighbor_set_peer_group_cmd, | |
2cbd181a | 5041 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group [PGNAME]", |
f4b8ec07 CS |
5042 | NO_STR |
5043 | NEIGHBOR_STR | |
5044 | NEIGHBOR_ADDR_STR2 | |
5045 | "Member of the peer-group\n" | |
5046 | "Peer-group name\n") | |
718e3744 | 5047 | { |
d62a17ae | 5048 | int idx_peer = 2; |
f4b8ec07 | 5049 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 5050 | |
f4b8ec07 CS |
5051 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5052 | sizeof(base_xpath), NULL) | |
5053 | < 0) | |
d62a17ae | 5054 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 5055 | |
f4b8ec07 | 5056 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_DESTROY, NULL); |
718e3744 | 5057 | |
f4b8ec07 | 5058 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 5059 | } |
6b0655a2 | 5060 | |
d62a17ae | 5061 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
2cbd181a | 5062 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group [PGNAME]", |
d62a17ae | 5063 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5064 | "Member of the peer-group\n" | |
5065 | "Peer-group name\n") | |
596c17ba | 5066 | |
d62a17ae | 5067 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5068 | uint32_t flag, int set) |
718e3744 | 5069 | { |
d62a17ae | 5070 | int ret; |
5071 | struct peer *peer; | |
718e3744 | 5072 | |
d62a17ae | 5073 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5074 | if (!peer) | |
5075 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5076 | |
7ebe625c QY |
5077 | /* |
5078 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5079 | * we should not accept disable-connected-check. | |
5080 | */ | |
5081 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5082 | vty_out(vty, | |
3efd0893 | 5083 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
5084 | ip_str); |
5085 | return CMD_WARNING_CONFIG_FAILED; | |
5086 | } | |
5087 | ||
d62a17ae | 5088 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
5089 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 5090 | |
d62a17ae | 5091 | if (set) |
5092 | ret = peer_flag_set(peer, flag); | |
5093 | else | |
5094 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 5095 | |
d62a17ae | 5096 | return bgp_vty_return(vty, ret); |
718e3744 | 5097 | } |
5098 | ||
47cbc09b | 5099 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 5100 | { |
d62a17ae | 5101 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5102 | } |
5103 | ||
d62a17ae | 5104 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5105 | uint32_t flag) |
718e3744 | 5106 | { |
d62a17ae | 5107 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5108 | } |
5109 | ||
f4b8ec07 CS |
5110 | int peer_flag_modify_nb(struct bgp *bgp, const char *ip_str, struct peer *peer, |
5111 | uint32_t flag, bool set, char *errmsg, | |
5112 | size_t errmsg_len) | |
5113 | { | |
5114 | int ret; | |
5115 | ||
5116 | /* | |
5117 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5118 | * we should not accept disable-connected-check. | |
5119 | */ | |
5120 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5121 | snprintf( | |
5122 | errmsg, errmsg_len, | |
5123 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
5124 | ip_str); | |
5125 | return -1; | |
5126 | } | |
5127 | ||
5128 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
5129 | peer_tx_shutdown_message_unset(peer); | |
5130 | ||
5131 | if (set) | |
5132 | ret = peer_flag_set(peer, flag); | |
5133 | else | |
5134 | ret = peer_flag_unset(peer, flag); | |
5135 | ||
5136 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
5137 | } | |
5138 | ||
718e3744 | 5139 | /* neighbor passive. */ |
f4b8ec07 CS |
5140 | DEFUN_YANG(neighbor_passive, |
5141 | neighbor_passive_cmd, | |
5142 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5143 | NEIGHBOR_STR | |
5144 | NEIGHBOR_ADDR_STR2 | |
5145 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5146 | { |
d62a17ae | 5147 | int idx_peer = 1; |
f4b8ec07 CS |
5148 | char base_xpath[XPATH_MAXLEN]; |
5149 | ||
5150 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5151 | sizeof(base_xpath), NULL) | |
5152 | < 0) | |
5153 | return CMD_WARNING_CONFIG_FAILED; | |
5154 | ||
5155 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "true"); | |
5156 | ||
5157 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5158 | } |
5159 | ||
f4b8ec07 CS |
5160 | DEFUN_YANG(no_neighbor_passive, |
5161 | no_neighbor_passive_cmd, | |
5162 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5163 | NO_STR NEIGHBOR_STR | |
5164 | NEIGHBOR_ADDR_STR2 | |
5165 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5166 | { |
d62a17ae | 5167 | int idx_peer = 2; |
f4b8ec07 CS |
5168 | char base_xpath[XPATH_MAXLEN]; |
5169 | ||
5170 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5171 | sizeof(base_xpath), NULL) | |
5172 | < 0) | |
5173 | return CMD_WARNING_CONFIG_FAILED; | |
5174 | ||
5175 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "false"); | |
5176 | ||
5177 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5178 | } |
6b0655a2 | 5179 | |
718e3744 | 5180 | /* neighbor shutdown. */ |
f4b8ec07 CS |
5181 | DEFUN_YANG(neighbor_shutdown_msg, |
5182 | neighbor_shutdown_msg_cmd, | |
5183 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5184 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5185 | "Administratively shut down this neighbor\n" | |
5186 | "Add a shutdown message (RFC 8203)\n" | |
5187 | "Shutdown message\n") | |
718e3744 | 5188 | { |
d62a17ae | 5189 | int idx_peer = 1; |
f4b8ec07 CS |
5190 | char base_xpath[XPATH_MAXLEN]; |
5191 | ||
5192 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5193 | sizeof(base_xpath), NULL) | |
5194 | < 0) | |
5195 | return CMD_WARNING_CONFIG_FAILED; | |
73d70fa6 | 5196 | |
d62a17ae | 5197 | if (argc >= 5) { |
d62a17ae | 5198 | char *message; |
73d70fa6 | 5199 | |
d62a17ae | 5200 | message = argv_concat(argv, argc, 4); |
f4b8ec07 CS |
5201 | nb_cli_enqueue_change(vty, "./admin-shutdown/message", |
5202 | NB_OP_MODIFY, message); | |
d62a17ae | 5203 | } |
73d70fa6 | 5204 | |
f4b8ec07 CS |
5205 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, |
5206 | "true"); | |
5207 | ||
5208 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5209 | } |
5210 | ||
232c75cd | 5211 | ALIAS_YANG(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5212 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5213 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5214 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5215 | |
f4b8ec07 CS |
5216 | DEFUN_YANG(no_neighbor_shutdown_msg, |
5217 | no_neighbor_shutdown_msg_cmd, | |
5218 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5219 | NO_STR NEIGHBOR_STR | |
5220 | NEIGHBOR_ADDR_STR2 | |
5221 | "Administratively shut down this neighbor\n" | |
5222 | "Remove a shutdown message (RFC 8203)\n" | |
5223 | "Shutdown message\n") | |
718e3744 | 5224 | { |
d62a17ae | 5225 | int idx_peer = 2; |
f4b8ec07 | 5226 | char base_xpath[XPATH_MAXLEN]; |
73d70fa6 | 5227 | |
f4b8ec07 CS |
5228 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5229 | sizeof(base_xpath), NULL) | |
5230 | < 0) | |
5231 | return CMD_WARNING_CONFIG_FAILED; | |
5232 | ||
5233 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, | |
5234 | "false"); | |
5235 | ||
5236 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5237 | } |
6b0655a2 | 5238 | |
232c75cd | 5239 | ALIAS_YANG(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5240 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5241 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5242 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5243 | |
8336c896 DA |
5244 | DEFUN(neighbor_shutdown_rtt, |
5245 | neighbor_shutdown_rtt_cmd, | |
5246 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5247 | NEIGHBOR_STR | |
5248 | NEIGHBOR_ADDR_STR2 | |
5249 | "Administratively shut down this neighbor\n" | |
5250 | "Shutdown if round-trip-time is higher than expected\n" | |
5251 | "Round-trip-time in milliseconds\n" | |
5252 | "Specify the number of keepalives before shutdown\n" | |
5253 | "The number of keepalives with higher RTT to shutdown\n") | |
5254 | { | |
5255 | int idx_peer = 1; | |
5256 | int idx_rtt = 4; | |
5257 | int idx_count = 0; | |
5258 | struct peer *peer; | |
5259 | ||
5260 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5261 | ||
5262 | if (!peer) | |
5263 | return CMD_WARNING_CONFIG_FAILED; | |
5264 | ||
5265 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5266 | ||
5267 | if (argv_find(argv, argc, "count", &idx_count)) | |
5268 | peer->rtt_keepalive_conf = | |
5269 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5270 | ||
5271 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5272 | PEER_FLAG_RTT_SHUTDOWN); | |
5273 | } | |
5274 | ||
5275 | DEFUN(no_neighbor_shutdown_rtt, | |
5276 | no_neighbor_shutdown_rtt_cmd, | |
5277 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5278 | NO_STR | |
5279 | NEIGHBOR_STR | |
5280 | NEIGHBOR_ADDR_STR2 | |
5281 | "Administratively shut down this neighbor\n" | |
5282 | "Shutdown if round-trip-time is higher than expected\n" | |
5283 | "Round-trip-time in milliseconds\n" | |
5284 | "Specify the number of keepalives before shutdown\n" | |
5285 | "The number of keepalives with higher RTT to shutdown\n") | |
5286 | { | |
5287 | int idx_peer = 2; | |
5288 | struct peer *peer; | |
5289 | ||
5290 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5291 | ||
5292 | if (!peer) | |
5293 | return CMD_WARNING_CONFIG_FAILED; | |
5294 | ||
5295 | peer->rtt_expected = 0; | |
5296 | peer->rtt_keepalive_conf = 1; | |
5297 | ||
5298 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5299 | PEER_FLAG_RTT_SHUTDOWN); | |
5300 | } | |
5301 | ||
718e3744 | 5302 | /* neighbor capability dynamic. */ |
f4b8ec07 CS |
5303 | DEFUN_YANG (neighbor_capability_dynamic, |
5304 | neighbor_capability_dynamic_cmd, | |
5305 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5306 | NEIGHBOR_STR | |
5307 | NEIGHBOR_ADDR_STR2 | |
5308 | "Advertise capability to the peer\n" | |
5309 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5310 | { |
d62a17ae | 5311 | int idx_peer = 1; |
f4b8ec07 CS |
5312 | char base_xpath[XPATH_MAXLEN]; |
5313 | ||
5314 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5315 | sizeof(base_xpath), NULL) | |
5316 | < 0) | |
5317 | return CMD_WARNING_CONFIG_FAILED; | |
5318 | ||
5319 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5320 | NB_OP_MODIFY, "true"); | |
5321 | ||
5322 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5323 | } |
5324 | ||
f4b8ec07 CS |
5325 | DEFUN_YANG (no_neighbor_capability_dynamic, |
5326 | no_neighbor_capability_dynamic_cmd, | |
5327 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5328 | NO_STR | |
5329 | NEIGHBOR_STR | |
5330 | NEIGHBOR_ADDR_STR2 | |
5331 | "Advertise capability to the peer\n" | |
5332 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5333 | { |
d62a17ae | 5334 | int idx_peer = 2; |
f4b8ec07 CS |
5335 | char base_xpath[XPATH_MAXLEN]; |
5336 | ||
5337 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5338 | sizeof(base_xpath), NULL) | |
5339 | < 0) | |
5340 | return CMD_WARNING_CONFIG_FAILED; | |
5341 | ||
5342 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5343 | NB_OP_MODIFY, "false"); | |
5344 | ||
5345 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5346 | } |
6b0655a2 | 5347 | |
718e3744 | 5348 | /* neighbor dont-capability-negotiate */ |
5349 | DEFUN (neighbor_dont_capability_negotiate, | |
5350 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5351 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5352 | NEIGHBOR_STR |
5353 | NEIGHBOR_ADDR_STR2 | |
5354 | "Do not perform capability negotiation\n") | |
5355 | { | |
d62a17ae | 5356 | int idx_peer = 1; |
5357 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5358 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5359 | } |
5360 | ||
5361 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5362 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5363 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5364 | NO_STR |
5365 | NEIGHBOR_STR | |
5366 | NEIGHBOR_ADDR_STR2 | |
5367 | "Do not perform capability negotiation\n") | |
5368 | { | |
d62a17ae | 5369 | int idx_peer = 2; |
5370 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5371 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5372 | } |
6b0655a2 | 5373 | |
8a92a8a0 | 5374 | /* neighbor capability extended next hop encoding */ |
f4b8ec07 CS |
5375 | DEFUN_YANG (neighbor_capability_enhe, |
5376 | neighbor_capability_enhe_cmd, | |
5377 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5378 | NEIGHBOR_STR | |
5379 | NEIGHBOR_ADDR_STR2 | |
5380 | "Advertise capability to the peer\n" | |
5381 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5382 | { |
d62a17ae | 5383 | int idx_peer = 1; |
f4b8ec07 CS |
5384 | char base_xpath[XPATH_MAXLEN]; |
5385 | ||
5386 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5387 | sizeof(base_xpath), NULL) | |
5388 | < 0) | |
5389 | return CMD_WARNING_CONFIG_FAILED; | |
5390 | ||
5391 | nb_cli_enqueue_change( | |
5392 | vty, "./capability-options/extended-nexthop-capability", | |
5393 | NB_OP_MODIFY, "true"); | |
5394 | ||
5395 | return nb_cli_apply_changes(vty, base_xpath); | |
8a92a8a0 DS |
5396 | } |
5397 | ||
f4b8ec07 CS |
5398 | DEFUN_YANG (no_neighbor_capability_enhe, |
5399 | no_neighbor_capability_enhe_cmd, | |
5400 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5401 | NO_STR | |
5402 | NEIGHBOR_STR | |
5403 | NEIGHBOR_ADDR_STR2 | |
5404 | "Advertise capability to the peer\n" | |
5405 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5406 | { |
d62a17ae | 5407 | int idx_peer = 2; |
f4b8ec07 CS |
5408 | char base_xpath[XPATH_MAXLEN]; |
5409 | ||
5410 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5411 | sizeof(base_xpath), NULL) | |
5412 | < 0) | |
5413 | return CMD_WARNING_CONFIG_FAILED; | |
5414 | ||
5415 | nb_cli_enqueue_change( | |
5416 | vty, "./capability-options/extended-nexthop-capability", | |
5417 | NB_OP_MODIFY, "false"); | |
5418 | ||
5419 | return nb_cli_apply_changes(vty, base_xpath); | |
5420 | } | |
5421 | ||
5422 | int peer_af_flag_modify_nb(struct peer *peer, afi_t afi, safi_t safi, | |
5423 | uint32_t flag, int set, char *errmsg, | |
5424 | size_t errmsg_len) | |
5425 | { | |
5426 | int ret; | |
5427 | ||
5428 | if (set) | |
5429 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5430 | else | |
5431 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
5432 | ||
5433 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
8a92a8a0 DS |
5434 | } |
5435 | ||
d62a17ae | 5436 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5437 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5438 | int set) |
718e3744 | 5439 | { |
d62a17ae | 5440 | int ret; |
5441 | struct peer *peer; | |
718e3744 | 5442 | |
d62a17ae | 5443 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5444 | if (!peer) | |
5445 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5446 | |
d62a17ae | 5447 | if (set) |
5448 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5449 | else | |
5450 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5451 | |
d62a17ae | 5452 | return bgp_vty_return(vty, ret); |
718e3744 | 5453 | } |
5454 | ||
d62a17ae | 5455 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5456 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5457 | { |
d62a17ae | 5458 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5459 | } |
5460 | ||
d62a17ae | 5461 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5462 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5463 | { |
d62a17ae | 5464 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5465 | } |
6b0655a2 | 5466 | |
718e3744 | 5467 | /* neighbor capability orf prefix-list. */ |
5468 | DEFUN (neighbor_capability_orf_prefix, | |
5469 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5470 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5471 | NEIGHBOR_STR |
5472 | NEIGHBOR_ADDR_STR2 | |
5473 | "Advertise capability to the peer\n" | |
5474 | "Advertise ORF capability to the peer\n" | |
5475 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5476 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5477 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5478 | "Capability to SEND the ORF to this neighbor\n") | |
5479 | { | |
d62a17ae | 5480 | int idx_send_recv = 5; |
db45f64d DS |
5481 | char *peer_str = argv[1]->arg; |
5482 | struct peer *peer; | |
5483 | afi_t afi = bgp_node_afi(vty); | |
5484 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5485 | |
db45f64d DS |
5486 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5487 | if (!peer) | |
d62a17ae | 5488 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5489 | |
db45f64d DS |
5490 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5491 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5492 | PEER_FLAG_ORF_PREFIX_SM); | |
5493 | ||
5494 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5495 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5496 | PEER_FLAG_ORF_PREFIX_RM); | |
5497 | ||
5498 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5499 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5500 | PEER_FLAG_ORF_PREFIX_SM) | |
5501 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5502 | PEER_FLAG_ORF_PREFIX_RM); | |
5503 | ||
5504 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5505 | } |
5506 | ||
5507 | ALIAS_HIDDEN( | |
5508 | neighbor_capability_orf_prefix, | |
5509 | neighbor_capability_orf_prefix_hidden_cmd, | |
5510 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5511 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5512 | "Advertise capability to the peer\n" | |
5513 | "Advertise ORF capability to the peer\n" | |
5514 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5515 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5516 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5517 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5518 | |
718e3744 | 5519 | DEFUN (no_neighbor_capability_orf_prefix, |
5520 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5522 | NO_STR |
5523 | NEIGHBOR_STR | |
5524 | NEIGHBOR_ADDR_STR2 | |
5525 | "Advertise capability to the peer\n" | |
5526 | "Advertise ORF capability to the peer\n" | |
5527 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5528 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5529 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5530 | "Capability to SEND the ORF to this neighbor\n") | |
5531 | { | |
d62a17ae | 5532 | int idx_send_recv = 6; |
db45f64d DS |
5533 | char *peer_str = argv[2]->arg; |
5534 | struct peer *peer; | |
5535 | afi_t afi = bgp_node_afi(vty); | |
5536 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5537 | |
db45f64d DS |
5538 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5539 | if (!peer) | |
d62a17ae | 5540 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5541 | |
db45f64d DS |
5542 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5543 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5544 | PEER_FLAG_ORF_PREFIX_SM); | |
5545 | ||
5546 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5547 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5548 | PEER_FLAG_ORF_PREFIX_RM); | |
5549 | ||
5550 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5551 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5552 | PEER_FLAG_ORF_PREFIX_SM) | |
5553 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5554 | PEER_FLAG_ORF_PREFIX_RM); | |
5555 | ||
5556 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5557 | } |
5558 | ||
5559 | ALIAS_HIDDEN( | |
5560 | no_neighbor_capability_orf_prefix, | |
5561 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5562 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5563 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5564 | "Advertise capability to the peer\n" | |
5565 | "Advertise ORF capability to the peer\n" | |
5566 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5567 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5568 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5569 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5570 | |
718e3744 | 5571 | /* neighbor next-hop-self. */ |
f4b8ec07 CS |
5572 | DEFUN_YANG (neighbor_nexthop_self, |
5573 | neighbor_nexthop_self_cmd, | |
5574 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5575 | NEIGHBOR_STR | |
5576 | NEIGHBOR_ADDR_STR2 | |
5577 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5578 | { |
d62a17ae | 5579 | int idx_peer = 1; |
f4b8ec07 CS |
5580 | char base_xpath[XPATH_MAXLEN]; |
5581 | char af_xpath[XPATH_MAXLEN]; | |
5582 | char attr_xpath[XPATH_MAXLEN]; | |
5583 | afi_t afi = bgp_node_afi(vty); | |
5584 | safi_t safi = bgp_node_safi(vty); | |
5585 | ||
f4b8ec07 CS |
5586 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5587 | yang_afi_safi_value2identity(afi, safi)); | |
5588 | ||
5589 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5590 | sizeof(base_xpath), af_xpath) | |
5591 | < 0) | |
5592 | return CMD_WARNING_CONFIG_FAILED; | |
5593 | ||
5594 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5595 | "./%s/nexthop-self/next-hop-self", | |
5596 | bgp_afi_safi_get_container_str(afi, safi)); | |
5597 | ||
5598 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5599 | ||
5600 | return nb_cli_apply_changes(vty, base_xpath); | |
a538debe | 5601 | } |
9e7a53c1 | 5602 | |
d62a17ae | 5603 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5604 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5605 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5606 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5607 | |
f4b8ec07 CS |
5608 | /* neighbor next-hop-self. */ |
5609 | DEFUN_YANG(neighbor_nexthop_self_force, | |
5610 | neighbor_nexthop_self_force_cmd, | |
5611 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5612 | NEIGHBOR_STR | |
5613 | NEIGHBOR_ADDR_STR2 | |
5614 | "Disable the next hop calculation for this neighbor\n" | |
5615 | "Set the next hop to self for reflected routes\n") | |
5616 | { | |
5617 | int idx_peer = 1; | |
5618 | char base_xpath[XPATH_MAXLEN]; | |
5619 | char af_xpath[XPATH_MAXLEN]; | |
5620 | char attr_xpath[XPATH_MAXLEN]; | |
5621 | afi_t afi = bgp_node_afi(vty); | |
5622 | safi_t safi = bgp_node_safi(vty); | |
5623 | ||
f4b8ec07 CS |
5624 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5625 | yang_afi_safi_value2identity(afi, safi)); | |
5626 | ||
5627 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5628 | sizeof(base_xpath), af_xpath) | |
5629 | < 0) | |
5630 | return CMD_WARNING_CONFIG_FAILED; | |
5631 | ||
5632 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5633 | "./%s/nexthop-self/next-hop-self-force", | |
5634 | bgp_afi_safi_get_container_str(afi, safi)); | |
5635 | ||
5636 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5637 | ||
5638 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5639 | } |
5640 | ||
d62a17ae | 5641 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5642 | neighbor_nexthop_self_force_hidden_cmd, | |
5643 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5644 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5645 | "Disable the next hop calculation for this neighbor\n" | |
5646 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5647 | |
1bc4e531 DA |
5648 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5649 | neighbor_nexthop_self_all_hidden_cmd, | |
5650 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5651 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5652 | "Disable the next hop calculation for this neighbor\n" | |
5653 | "Set the next hop to self for reflected routes\n") | |
5654 | ||
f4b8ec07 CS |
5655 | DEFUN_YANG (no_neighbor_nexthop_self, |
5656 | no_neighbor_nexthop_self_cmd, | |
5657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5658 | NO_STR | |
5659 | NEIGHBOR_STR | |
5660 | NEIGHBOR_ADDR_STR2 | |
5661 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5662 | { |
d62a17ae | 5663 | int idx_peer = 2; |
f4b8ec07 CS |
5664 | char base_xpath[XPATH_MAXLEN]; |
5665 | char af_xpath[XPATH_MAXLEN]; | |
5666 | char attr_xpath[XPATH_MAXLEN]; | |
5667 | afi_t afi = bgp_node_afi(vty); | |
5668 | safi_t safi = bgp_node_safi(vty); | |
5669 | ||
5670 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5671 | yang_afi_safi_value2identity(afi, safi)); | |
5672 | ||
5673 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5674 | sizeof(base_xpath), af_xpath) | |
5675 | < 0) | |
5676 | return CMD_WARNING_CONFIG_FAILED; | |
5677 | ||
5678 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5679 | "./%s/nexthop-self/next-hop-self", | |
5680 | bgp_afi_safi_get_container_str(afi, safi)); | |
5681 | ||
5682 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5683 | ||
5684 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5685 | } |
6b0655a2 | 5686 | |
d62a17ae | 5687 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5688 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5689 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5690 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5691 | |
f4b8ec07 CS |
5692 | DEFUN_YANG (no_neighbor_nexthop_self_force, |
5693 | no_neighbor_nexthop_self_force_cmd, | |
5694 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5695 | NO_STR | |
5696 | NEIGHBOR_STR | |
5697 | NEIGHBOR_ADDR_STR2 | |
5698 | "Disable the next hop calculation for this neighbor\n" | |
5699 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5700 | { |
d62a17ae | 5701 | int idx_peer = 2; |
f4b8ec07 CS |
5702 | char base_xpath[XPATH_MAXLEN]; |
5703 | char af_xpath[XPATH_MAXLEN]; | |
5704 | char attr_xpath[XPATH_MAXLEN]; | |
5705 | afi_t afi = bgp_node_afi(vty); | |
5706 | safi_t safi = bgp_node_safi(vty); | |
5707 | ||
f4b8ec07 CS |
5708 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5709 | yang_afi_safi_value2identity(afi, safi)); | |
5710 | ||
5711 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5712 | sizeof(base_xpath), af_xpath) | |
5713 | < 0) | |
5714 | return CMD_WARNING_CONFIG_FAILED; | |
5715 | ||
5716 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5717 | "./%s/nexthop-self/next-hop-self-force", | |
5718 | bgp_afi_safi_get_container_str(afi, safi)); | |
5719 | ||
5720 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5721 | ||
5722 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5723 | } |
a538debe | 5724 | |
d62a17ae | 5725 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5726 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5727 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5728 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5729 | "Disable the next hop calculation for this neighbor\n" | |
5730 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5731 | |
1bc4e531 DA |
5732 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5733 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5735 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5736 | "Disable the next hop calculation for this neighbor\n" | |
5737 | "Set the next hop to self for reflected routes\n") | |
5738 | ||
c7122e14 | 5739 | /* neighbor as-override */ |
f4b8ec07 CS |
5740 | DEFUN_YANG (neighbor_as_override, |
5741 | neighbor_as_override_cmd, | |
5742 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5743 | NEIGHBOR_STR | |
5744 | NEIGHBOR_ADDR_STR2 | |
5745 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5746 | { |
d62a17ae | 5747 | int idx_peer = 1; |
f4b8ec07 CS |
5748 | char base_xpath[XPATH_MAXLEN]; |
5749 | char af_xpath[XPATH_MAXLEN]; | |
5750 | char attr_xpath[XPATH_MAXLEN]; | |
5751 | afi_t afi = bgp_node_afi(vty); | |
5752 | safi_t safi = bgp_node_safi(vty); | |
5753 | ||
5754 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5755 | yang_afi_safi_value2identity(afi, safi)); | |
5756 | ||
5757 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5758 | sizeof(base_xpath), af_xpath) | |
5759 | < 0) | |
5760 | return CMD_WARNING_CONFIG_FAILED; | |
5761 | ||
5762 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5763 | "./%s/as-path-options/replace-peer-as", | |
5764 | bgp_afi_safi_get_container_str(afi, safi)); | |
5765 | ||
5766 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5767 | ||
5768 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5769 | } |
5770 | ||
d62a17ae | 5771 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5772 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5773 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5774 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5775 | |
f4b8ec07 CS |
5776 | DEFUN_YANG (no_neighbor_as_override, |
5777 | no_neighbor_as_override_cmd, | |
5778 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5779 | NO_STR | |
5780 | NEIGHBOR_STR | |
5781 | NEIGHBOR_ADDR_STR2 | |
5782 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5783 | { |
d62a17ae | 5784 | int idx_peer = 2; |
f4b8ec07 CS |
5785 | char base_xpath[XPATH_MAXLEN]; |
5786 | char af_xpath[XPATH_MAXLEN]; | |
5787 | char attr_xpath[XPATH_MAXLEN]; | |
5788 | afi_t afi = bgp_node_afi(vty); | |
5789 | safi_t safi = bgp_node_safi(vty); | |
5790 | ||
5791 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5792 | yang_afi_safi_value2identity(afi, safi)); | |
5793 | ||
5794 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5795 | sizeof(base_xpath), af_xpath) | |
5796 | < 0) | |
5797 | return CMD_WARNING_CONFIG_FAILED; | |
5798 | ||
5799 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5800 | "./%s/as-path-options/replace-peer-as", | |
5801 | bgp_afi_safi_get_container_str(afi, safi)); | |
5802 | ||
5803 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5804 | ||
5805 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5806 | } |
5807 | ||
d62a17ae | 5808 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5810 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5811 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5812 | |
718e3744 | 5813 | /* neighbor remove-private-AS. */ |
f4b8ec07 CS |
5814 | DEFUN_YANG (neighbor_remove_private_as, |
5815 | neighbor_remove_private_as_cmd, | |
5816 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5817 | NEIGHBOR_STR | |
5818 | NEIGHBOR_ADDR_STR2 | |
5819 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5820 | { |
d62a17ae | 5821 | int idx_peer = 1; |
f4b8ec07 CS |
5822 | char base_xpath[XPATH_MAXLEN]; |
5823 | char af_xpath[XPATH_MAXLEN]; | |
5824 | char attr_xpath[XPATH_MAXLEN]; | |
5825 | afi_t afi = bgp_node_afi(vty); | |
5826 | safi_t safi = bgp_node_safi(vty); | |
5827 | ||
5828 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5829 | yang_afi_safi_value2identity(afi, safi)); | |
5830 | ||
5831 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5832 | sizeof(base_xpath), af_xpath) | |
5833 | < 0) | |
5834 | return CMD_WARNING_CONFIG_FAILED; | |
5835 | ||
5836 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5837 | "./%s/private-as/remove-private-as", | |
5838 | bgp_afi_safi_get_container_str(afi, safi)); | |
5839 | ||
5840 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5841 | ||
5842 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5843 | } |
5844 | ||
d62a17ae | 5845 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5846 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5847 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5848 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5849 | |
f4b8ec07 CS |
5850 | DEFUN_YANG (neighbor_remove_private_as_all, |
5851 | neighbor_remove_private_as_all_cmd, | |
5852 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5853 | NEIGHBOR_STR | |
5854 | NEIGHBOR_ADDR_STR2 | |
5855 | "Remove private ASNs in outbound updates\n" | |
5856 | "Apply to all AS numbers\n") | |
5000f21c | 5857 | { |
d62a17ae | 5858 | int idx_peer = 1; |
f4b8ec07 CS |
5859 | char base_xpath[XPATH_MAXLEN]; |
5860 | char af_xpath[XPATH_MAXLEN]; | |
5861 | char attr_xpath[XPATH_MAXLEN]; | |
5862 | afi_t afi = bgp_node_afi(vty); | |
5863 | safi_t safi = bgp_node_safi(vty); | |
5864 | ||
f4b8ec07 CS |
5865 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5866 | yang_afi_safi_value2identity(afi, safi)); | |
5867 | ||
5868 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5869 | sizeof(base_xpath), af_xpath) | |
5870 | < 0) | |
5871 | return CMD_WARNING_CONFIG_FAILED; | |
5872 | ||
5873 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5874 | "./%s/private-as/remove-private-as-all", | |
5875 | bgp_afi_safi_get_container_str(afi, safi)); | |
5876 | ||
5877 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5878 | ||
5879 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5880 | } |
5881 | ||
d62a17ae | 5882 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5883 | neighbor_remove_private_as_all_hidden_cmd, | |
5884 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5885 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5886 | "Remove private ASNs in outbound updates\n" | |
5887 | "Apply to all AS numbers") | |
596c17ba | 5888 | |
f4b8ec07 CS |
5889 | DEFUN_YANG (neighbor_remove_private_as_replace_as, |
5890 | neighbor_remove_private_as_replace_as_cmd, | |
5891 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5892 | NEIGHBOR_STR | |
5893 | NEIGHBOR_ADDR_STR2 | |
5894 | "Remove private ASNs in outbound updates\n" | |
5895 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5896 | { |
d62a17ae | 5897 | int idx_peer = 1; |
f4b8ec07 CS |
5898 | char base_xpath[XPATH_MAXLEN]; |
5899 | char af_xpath[XPATH_MAXLEN]; | |
5900 | char attr_xpath[XPATH_MAXLEN]; | |
5901 | afi_t afi = bgp_node_afi(vty); | |
5902 | safi_t safi = bgp_node_safi(vty); | |
5903 | ||
f4b8ec07 CS |
5904 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5905 | yang_afi_safi_value2identity(afi, safi)); | |
5906 | ||
5907 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5908 | sizeof(base_xpath), af_xpath) | |
5909 | < 0) | |
5910 | return CMD_WARNING_CONFIG_FAILED; | |
5911 | ||
5912 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5913 | "./%s/private-as/remove-private-as-replace", | |
5914 | bgp_afi_safi_get_container_str(afi, safi)); | |
5915 | ||
5916 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5917 | ||
5918 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5919 | } |
5920 | ||
d62a17ae | 5921 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5922 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5923 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5924 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5925 | "Remove private ASNs in outbound updates\n" | |
5926 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5927 | |
f4b8ec07 CS |
5928 | DEFUN_YANG (neighbor_remove_private_as_all_replace_as, |
5929 | neighbor_remove_private_as_all_replace_as_cmd, | |
5930 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5931 | NEIGHBOR_STR | |
5932 | NEIGHBOR_ADDR_STR2 | |
5933 | "Remove private ASNs in outbound updates\n" | |
5934 | "Apply to all AS numbers\n" | |
5935 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5936 | { |
d62a17ae | 5937 | int idx_peer = 1; |
f4b8ec07 CS |
5938 | char base_xpath[XPATH_MAXLEN]; |
5939 | char af_xpath[XPATH_MAXLEN]; | |
5940 | char attr_xpath[XPATH_MAXLEN]; | |
5941 | afi_t afi = bgp_node_afi(vty); | |
5942 | safi_t safi = bgp_node_safi(vty); | |
5943 | ||
f4b8ec07 CS |
5944 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5945 | yang_afi_safi_value2identity(afi, safi)); | |
5946 | ||
5947 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5948 | sizeof(base_xpath), af_xpath) | |
5949 | < 0) | |
5950 | return CMD_WARNING_CONFIG_FAILED; | |
5951 | ||
5952 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5953 | "./%s/private-as/remove-private-as-all-replace", | |
5954 | bgp_afi_safi_get_container_str(afi, safi)); | |
5955 | ||
5956 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5957 | ||
5958 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
5959 | } |
5960 | ||
d62a17ae | 5961 | ALIAS_HIDDEN( |
5962 | neighbor_remove_private_as_all_replace_as, | |
5963 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5964 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5965 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5966 | "Remove private ASNs in outbound updates\n" | |
5967 | "Apply to all AS numbers\n" | |
5968 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5969 | |
f4b8ec07 CS |
5970 | DEFUN_YANG (no_neighbor_remove_private_as, |
5971 | no_neighbor_remove_private_as_cmd, | |
5972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5973 | NO_STR | |
5974 | NEIGHBOR_STR | |
5975 | NEIGHBOR_ADDR_STR2 | |
5976 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5977 | { |
d62a17ae | 5978 | int idx_peer = 2; |
f4b8ec07 CS |
5979 | char base_xpath[XPATH_MAXLEN]; |
5980 | char af_xpath[XPATH_MAXLEN]; | |
5981 | char attr_xpath[XPATH_MAXLEN]; | |
5982 | afi_t afi = bgp_node_afi(vty); | |
5983 | safi_t safi = bgp_node_safi(vty); | |
5984 | ||
5985 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5986 | yang_afi_safi_value2identity(afi, safi)); | |
5987 | ||
5988 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5989 | sizeof(base_xpath), af_xpath) | |
5990 | < 0) | |
5991 | return CMD_WARNING_CONFIG_FAILED; | |
5992 | ||
5993 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5994 | "./%s/private-as/remove-private-as", | |
5995 | bgp_afi_safi_get_container_str(afi, safi)); | |
5996 | ||
5997 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5998 | ||
5999 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6000 | } |
6b0655a2 | 6001 | |
d62a17ae | 6002 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
6003 | no_neighbor_remove_private_as_hidden_cmd, | |
6004 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
6005 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6006 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 6007 | |
f4b8ec07 CS |
6008 | DEFUN_YANG (no_neighbor_remove_private_as_all, |
6009 | no_neighbor_remove_private_as_all_cmd, | |
6010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6011 | NO_STR | |
6012 | NEIGHBOR_STR | |
6013 | NEIGHBOR_ADDR_STR2 | |
6014 | "Remove private ASNs in outbound updates\n" | |
6015 | "Apply to all AS numbers\n") | |
88b8ed8d | 6016 | { |
d62a17ae | 6017 | int idx_peer = 2; |
f4b8ec07 CS |
6018 | char base_xpath[XPATH_MAXLEN]; |
6019 | char af_xpath[XPATH_MAXLEN]; | |
6020 | char attr_xpath[XPATH_MAXLEN]; | |
6021 | afi_t afi = bgp_node_afi(vty); | |
6022 | safi_t safi = bgp_node_safi(vty); | |
6023 | ||
f4b8ec07 CS |
6024 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6025 | yang_afi_safi_value2identity(afi, safi)); | |
6026 | ||
6027 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6028 | sizeof(base_xpath), af_xpath) | |
6029 | < 0) | |
6030 | return CMD_WARNING_CONFIG_FAILED; | |
6031 | ||
6032 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6033 | "./%s/private-as/remove-private-as-all", | |
6034 | bgp_afi_safi_get_container_str(afi, safi)); | |
6035 | ||
6036 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6037 | ||
6038 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 6039 | } |
5000f21c | 6040 | |
d62a17ae | 6041 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
6042 | no_neighbor_remove_private_as_all_hidden_cmd, | |
6043 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6044 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6045 | "Remove private ASNs in outbound updates\n" | |
6046 | "Apply to all AS numbers\n") | |
596c17ba | 6047 | |
f4b8ec07 CS |
6048 | DEFUN_YANG (no_neighbor_remove_private_as_replace_as, |
6049 | no_neighbor_remove_private_as_replace_as_cmd, | |
6050 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6051 | NO_STR | |
6052 | NEIGHBOR_STR | |
6053 | NEIGHBOR_ADDR_STR2 | |
6054 | "Remove private ASNs in outbound updates\n" | |
6055 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 6056 | { |
d62a17ae | 6057 | int idx_peer = 2; |
f4b8ec07 CS |
6058 | char base_xpath[XPATH_MAXLEN]; |
6059 | char af_xpath[XPATH_MAXLEN]; | |
6060 | char attr_xpath[XPATH_MAXLEN]; | |
6061 | afi_t afi = bgp_node_afi(vty); | |
6062 | safi_t safi = bgp_node_safi(vty); | |
6063 | ||
f4b8ec07 CS |
6064 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6065 | yang_afi_safi_value2identity(afi, safi)); | |
6066 | ||
6067 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6068 | sizeof(base_xpath), af_xpath) | |
6069 | < 0) | |
6070 | return CMD_WARNING_CONFIG_FAILED; | |
6071 | ||
6072 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6073 | "./%s/private-as/remove-private-as-replace", | |
6074 | bgp_afi_safi_get_container_str(afi, safi)); | |
6075 | ||
6076 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6077 | ||
6078 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 6079 | } |
5000f21c | 6080 | |
d62a17ae | 6081 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
6082 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
6083 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6084 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6085 | "Remove private ASNs in outbound updates\n" | |
6086 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6087 | |
f4b8ec07 CS |
6088 | DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as, |
6089 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
6090 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6091 | NO_STR | |
6092 | NEIGHBOR_STR | |
6093 | NEIGHBOR_ADDR_STR2 | |
6094 | "Remove private ASNs in outbound updates\n" | |
6095 | "Apply to all AS numbers\n" | |
6096 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 6097 | { |
d62a17ae | 6098 | int idx_peer = 2; |
f4b8ec07 CS |
6099 | char base_xpath[XPATH_MAXLEN]; |
6100 | char af_xpath[XPATH_MAXLEN]; | |
6101 | char attr_xpath[XPATH_MAXLEN]; | |
6102 | afi_t afi = bgp_node_afi(vty); | |
6103 | safi_t safi = bgp_node_safi(vty); | |
6104 | ||
f4b8ec07 CS |
6105 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6106 | yang_afi_safi_value2identity(afi, safi)); | |
6107 | ||
6108 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6109 | sizeof(base_xpath), af_xpath) | |
6110 | < 0) | |
6111 | return CMD_WARNING_CONFIG_FAILED; | |
6112 | ||
6113 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6114 | "./%s/private-as/remove-private-as-all-replace", | |
6115 | bgp_afi_safi_get_container_str(afi, safi)); | |
6116 | ||
6117 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6118 | ||
6119 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 6120 | } |
5000f21c | 6121 | |
d62a17ae | 6122 | ALIAS_HIDDEN( |
6123 | no_neighbor_remove_private_as_all_replace_as, | |
6124 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
6125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6126 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6127 | "Remove private ASNs in outbound updates\n" | |
6128 | "Apply to all AS numbers\n" | |
6129 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6130 | |
5000f21c | 6131 | |
718e3744 | 6132 | /* neighbor send-community. */ |
f4b8ec07 CS |
6133 | DEFUN_YANG (neighbor_send_community, |
6134 | neighbor_send_community_cmd, | |
6135 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6136 | NEIGHBOR_STR | |
6137 | NEIGHBOR_ADDR_STR2 | |
6138 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6139 | { |
d62a17ae | 6140 | int idx_peer = 1; |
27c05d4d | 6141 | |
d62a17ae | 6142 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6143 | bgp_node_safi(vty), | |
6144 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6145 | } |
6146 | ||
d62a17ae | 6147 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
6148 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6149 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6150 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6151 | |
f4b8ec07 CS |
6152 | DEFUN_YANG (no_neighbor_send_community, |
6153 | no_neighbor_send_community_cmd, | |
6154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6155 | NO_STR | |
6156 | NEIGHBOR_STR | |
6157 | NEIGHBOR_ADDR_STR2 | |
6158 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6159 | { |
d62a17ae | 6160 | int idx_peer = 2; |
27c05d4d | 6161 | |
d62a17ae | 6162 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6163 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6164 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6165 | } |
6b0655a2 | 6166 | |
d62a17ae | 6167 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6168 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6169 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6170 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6171 | |
718e3744 | 6172 | /* neighbor send-community extended. */ |
f4b8ec07 CS |
6173 | DEFUN_YANG (neighbor_send_community_type, |
6174 | neighbor_send_community_type_cmd, | |
6175 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6176 | NEIGHBOR_STR | |
6177 | NEIGHBOR_ADDR_STR2 | |
6178 | "Send Community attribute to this neighbor\n" | |
6179 | "Send Standard and Extended Community attributes\n" | |
6180 | "Send Standard, Large and Extended Community attributes\n" | |
6181 | "Send Extended Community attributes\n" | |
6182 | "Send Standard Community attributes\n" | |
6183 | "Send Large Community attributes\n") | |
718e3744 | 6184 | { |
27c05d4d | 6185 | const char *type = argv[argc - 1]->text; |
db45f64d | 6186 | char *peer_str = argv[1]->arg; |
f4b8ec07 CS |
6187 | char base_xpath[XPATH_MAXLEN]; |
6188 | char af_xpath[XPATH_MAXLEN]; | |
6189 | char std_xpath[XPATH_MAXLEN]; | |
6190 | char ext_xpath[XPATH_MAXLEN]; | |
6191 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6192 | afi_t afi = bgp_node_afi(vty); |
6193 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 6194 | |
f4b8ec07 CS |
6195 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6196 | yang_afi_safi_value2identity(afi, safi)); | |
6197 | ||
6198 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6199 | sizeof(base_xpath), af_xpath) | |
6200 | < 0) | |
db45f64d | 6201 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6202 | |
f4b8ec07 CS |
6203 | if (strmatch(type, "standard")) { |
6204 | snprintf(std_xpath, sizeof(std_xpath), | |
6205 | "./%s/send-community/send-community", | |
6206 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6207 | |
f4b8ec07 CS |
6208 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); |
6209 | } | |
db45f64d | 6210 | |
f4b8ec07 CS |
6211 | if (strmatch(type, "extended")) { |
6212 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6213 | "./%s/send-community/send-ext-community", | |
6214 | bgp_afi_safi_get_container_str(afi, safi)); | |
6215 | ||
6216 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6217 | } | |
6218 | ||
6219 | if (strmatch(type, "large")) { | |
6220 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6221 | "./%s/send-community/send-large-community", | |
6222 | bgp_afi_safi_get_container_str(afi, safi)); | |
6223 | ||
6224 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6225 | } | |
db45f64d DS |
6226 | |
6227 | if (strmatch(type, "both")) { | |
f4b8ec07 CS |
6228 | snprintf(std_xpath, sizeof(std_xpath), |
6229 | "./%s/send-community/send-community", | |
6230 | bgp_afi_safi_get_container_str(afi, safi)); | |
6231 | ||
6232 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6233 | ||
6234 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6235 | "./%s/send-community/send-ext-community", | |
6236 | bgp_afi_safi_get_container_str(afi, safi)); | |
6237 | ||
6238 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
db45f64d | 6239 | } |
f4b8ec07 CS |
6240 | |
6241 | if (strmatch(type, "all")) { | |
6242 | snprintf(std_xpath, sizeof(std_xpath), | |
6243 | "./%s/send-community/send-community", | |
6244 | bgp_afi_safi_get_container_str(afi, safi)); | |
6245 | ||
6246 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6247 | ||
6248 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6249 | "./%s/send-community/send-ext-community", | |
6250 | bgp_afi_safi_get_container_str(afi, safi)); | |
6251 | ||
6252 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6253 | ||
6254 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6255 | "./%s/send-community/send-large-community", | |
6256 | bgp_afi_safi_get_container_str(afi, safi)); | |
6257 | ||
6258 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6259 | } | |
6260 | ||
6261 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 6262 | } |
6263 | ||
6264 | ALIAS_HIDDEN( | |
6265 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6266 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6267 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6268 | "Send Community attribute to this neighbor\n" | |
6269 | "Send Standard and Extended Community attributes\n" | |
6270 | "Send Standard, Large and Extended Community attributes\n" | |
6271 | "Send Extended Community attributes\n" | |
6272 | "Send Standard Community attributes\n" | |
6273 | "Send Large Community attributes\n") | |
596c17ba | 6274 | |
f4b8ec07 CS |
6275 | DEFUN_YANG (no_neighbor_send_community_type, |
6276 | no_neighbor_send_community_type_cmd, | |
6277 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6278 | NO_STR | |
6279 | NEIGHBOR_STR | |
6280 | NEIGHBOR_ADDR_STR2 | |
6281 | "Send Community attribute to this neighbor\n" | |
6282 | "Send Standard and Extended Community attributes\n" | |
6283 | "Send Standard, Large and Extended Community attributes\n" | |
6284 | "Send Extended Community attributes\n" | |
6285 | "Send Standard Community attributes\n" | |
6286 | "Send Large Community attributes\n") | |
718e3744 | 6287 | { |
d62a17ae | 6288 | const char *type = argv[argc - 1]->text; |
db45f64d | 6289 | char *peer_str = argv[2]->arg; |
f4b8ec07 CS |
6290 | char base_xpath[XPATH_MAXLEN]; |
6291 | char af_xpath[XPATH_MAXLEN]; | |
6292 | char std_xpath[XPATH_MAXLEN]; | |
6293 | char ext_xpath[XPATH_MAXLEN]; | |
6294 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6295 | afi_t afi = bgp_node_afi(vty); |
6296 | safi_t safi = bgp_node_safi(vty); | |
6297 | ||
f4b8ec07 CS |
6298 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6299 | yang_afi_safi_value2identity(afi, safi)); | |
6300 | ||
6301 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6302 | sizeof(base_xpath), af_xpath) | |
6303 | < 0) | |
6304 | return CMD_WARNING_CONFIG_FAILED; | |
6305 | ||
6306 | if (strmatch(type, "standard")) { | |
6307 | snprintf(std_xpath, sizeof(std_xpath), | |
6308 | "./%s/send-community/send-community", | |
6309 | bgp_afi_safi_get_container_str(afi, safi)); | |
6310 | ||
6311 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6312 | } | |
6313 | ||
6314 | if (strmatch(type, "extended")) { | |
6315 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6316 | "./%s/send-community/send-ext-community", | |
6317 | bgp_afi_safi_get_container_str(afi, safi)); | |
6318 | ||
6319 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6320 | } | |
6321 | ||
6322 | if (strmatch(type, "large")) { | |
6323 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6324 | "./%s/send-community/send-large-community", | |
6325 | bgp_afi_safi_get_container_str(afi, safi)); | |
6326 | ||
6327 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); | |
6328 | } | |
6329 | ||
6330 | if (strmatch(type, "both")) { | |
6331 | snprintf(std_xpath, sizeof(std_xpath), | |
6332 | "./%s/send-community/send-community", | |
6333 | bgp_afi_safi_get_container_str(afi, safi)); | |
6334 | ||
6335 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6336 | ||
6337 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6338 | "./%s/send-community/send-ext-community", | |
6339 | bgp_afi_safi_get_container_str(afi, safi)); | |
6340 | ||
6341 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6342 | } | |
6343 | ||
6344 | if (strmatch(type, "all")) { | |
6345 | snprintf(std_xpath, sizeof(std_xpath), | |
6346 | "./%s/send-community/send-community", | |
6347 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6348 | |
f4b8ec07 | 6349 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6350 | |
f4b8ec07 CS |
6351 | snprintf(ext_xpath, sizeof(ext_xpath), |
6352 | "./%s/send-community/send-ext-community", | |
6353 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6354 | |
f4b8ec07 | 6355 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6356 | |
f4b8ec07 CS |
6357 | snprintf(lrg_xpath, sizeof(lrg_xpath), |
6358 | "./%s/send-community/send-large-community", | |
6359 | bgp_afi_safi_get_container_str(afi, safi)); | |
d62a17ae | 6360 | |
f4b8ec07 | 6361 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); |
27c05d4d PM |
6362 | } |
6363 | ||
f4b8ec07 | 6364 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6365 | } |
6366 | ||
6367 | ALIAS_HIDDEN( | |
6368 | no_neighbor_send_community_type, | |
6369 | no_neighbor_send_community_type_hidden_cmd, | |
6370 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6371 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6372 | "Send Community attribute to this neighbor\n" | |
6373 | "Send Standard and Extended Community attributes\n" | |
6374 | "Send Standard, Large and Extended Community attributes\n" | |
6375 | "Send Extended Community attributes\n" | |
6376 | "Send Standard Community attributes\n" | |
6377 | "Send Large Community attributes\n") | |
596c17ba | 6378 | |
718e3744 | 6379 | /* neighbor soft-reconfig. */ |
f4b8ec07 CS |
6380 | DEFUN_YANG (neighbor_soft_reconfiguration, |
6381 | neighbor_soft_reconfiguration_cmd, | |
6382 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6383 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6384 | "Per neighbor soft reconfiguration\n" | |
6385 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6386 | { |
d62a17ae | 6387 | int idx_peer = 1; |
f4b8ec07 CS |
6388 | char base_xpath[XPATH_MAXLEN]; |
6389 | char af_xpath[XPATH_MAXLEN]; | |
6390 | char soft_xpath[XPATH_MAXLEN]; | |
6391 | afi_t afi = bgp_node_afi(vty); | |
6392 | safi_t safi = bgp_node_safi(vty); | |
6393 | ||
f4b8ec07 CS |
6394 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6395 | yang_afi_safi_value2identity(afi, safi)); | |
6396 | ||
6397 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6398 | sizeof(base_xpath), af_xpath) | |
6399 | < 0) | |
6400 | return CMD_WARNING_CONFIG_FAILED; | |
6401 | ||
6402 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6403 | bgp_afi_safi_get_container_str(afi, safi)); | |
6404 | ||
6405 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "true"); | |
6406 | ||
6407 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6408 | } |
6409 | ||
d62a17ae | 6410 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6411 | neighbor_soft_reconfiguration_hidden_cmd, | |
6412 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6413 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6414 | "Per neighbor soft reconfiguration\n" | |
6415 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6416 | |
f4b8ec07 CS |
6417 | DEFUN_YANG (no_neighbor_soft_reconfiguration, |
6418 | no_neighbor_soft_reconfiguration_cmd, | |
6419 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6420 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6421 | "Per neighbor soft reconfiguration\n" | |
6422 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6423 | { |
d62a17ae | 6424 | int idx_peer = 2; |
f4b8ec07 CS |
6425 | char base_xpath[XPATH_MAXLEN]; |
6426 | char af_xpath[XPATH_MAXLEN]; | |
6427 | char soft_xpath[XPATH_MAXLEN]; | |
6428 | afi_t afi = bgp_node_afi(vty); | |
6429 | safi_t safi = bgp_node_safi(vty); | |
6430 | ||
6431 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6432 | yang_afi_safi_value2identity(afi, safi)); | |
6433 | ||
6434 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6435 | bgp_afi_safi_get_container_str(afi, safi)); | |
6436 | ||
6437 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6438 | sizeof(base_xpath), af_xpath) | |
6439 | < 0) | |
6440 | return CMD_WARNING_CONFIG_FAILED; | |
6441 | ||
6442 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "false"); | |
6443 | ||
6444 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6445 | } |
6b0655a2 | 6446 | |
d62a17ae | 6447 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6448 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6449 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6450 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6451 | "Per neighbor soft reconfiguration\n" | |
6452 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6453 | |
f4b8ec07 CS |
6454 | DEFUN_YANG (neighbor_route_reflector_client, |
6455 | neighbor_route_reflector_client_cmd, | |
6456 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6457 | NEIGHBOR_STR | |
6458 | NEIGHBOR_ADDR_STR2 | |
6459 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6460 | { |
d62a17ae | 6461 | int idx_peer = 1; |
f4b8ec07 CS |
6462 | char base_xpath[XPATH_MAXLEN]; |
6463 | char af_xpath[XPATH_MAXLEN]; | |
6464 | char attr_xpath[XPATH_MAXLEN]; | |
6465 | afi_t afi = bgp_node_afi(vty); | |
6466 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 6467 | |
f4b8ec07 CS |
6468 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6469 | yang_afi_safi_value2identity(afi, safi)); | |
718e3744 | 6470 | |
f4b8ec07 CS |
6471 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6472 | sizeof(base_xpath), af_xpath) | |
6473 | < 0) | |
d62a17ae | 6474 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6475 | |
f4b8ec07 CS |
6476 | snprintf(attr_xpath, sizeof(attr_xpath), |
6477 | "./%s/route-reflector/route-reflector-client", | |
6478 | bgp_afi_safi_get_container_str(afi, safi)); | |
6479 | ||
6480 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6481 | ||
6482 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6483 | } |
6484 | ||
d62a17ae | 6485 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6486 | neighbor_route_reflector_client_hidden_cmd, | |
6487 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6488 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6489 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6490 | |
f4b8ec07 CS |
6491 | DEFUN_YANG (no_neighbor_route_reflector_client, |
6492 | no_neighbor_route_reflector_client_cmd, | |
6493 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6494 | NO_STR | |
6495 | NEIGHBOR_STR | |
6496 | NEIGHBOR_ADDR_STR2 | |
6497 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6498 | { |
d62a17ae | 6499 | int idx_peer = 2; |
f4b8ec07 CS |
6500 | char base_xpath[XPATH_MAXLEN]; |
6501 | char af_xpath[XPATH_MAXLEN]; | |
6502 | char attr_xpath[XPATH_MAXLEN]; | |
6503 | afi_t afi = bgp_node_afi(vty); | |
6504 | safi_t safi = bgp_node_safi(vty); | |
6505 | ||
6506 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6507 | yang_afi_safi_value2identity(afi, safi)); | |
6508 | ||
6509 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6510 | sizeof(base_xpath), af_xpath) | |
6511 | < 0) | |
6512 | return CMD_WARNING_CONFIG_FAILED; | |
6513 | ||
6514 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6515 | "./%s/route-reflector/route-reflector-client", | |
6516 | bgp_afi_safi_get_container_str(afi, safi)); | |
6517 | ||
6518 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6519 | ||
6520 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6521 | } |
6b0655a2 | 6522 | |
d62a17ae | 6523 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6524 | no_neighbor_route_reflector_client_hidden_cmd, | |
6525 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6526 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6527 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6528 | |
718e3744 | 6529 | /* neighbor route-server-client. */ |
f4b8ec07 CS |
6530 | DEFUN_YANG (neighbor_route_server_client, |
6531 | neighbor_route_server_client_cmd, | |
6532 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6533 | NEIGHBOR_STR | |
6534 | NEIGHBOR_ADDR_STR2 | |
6535 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6536 | { |
d62a17ae | 6537 | int idx_peer = 1; |
f4b8ec07 CS |
6538 | char base_xpath[XPATH_MAXLEN]; |
6539 | char af_xpath[XPATH_MAXLEN]; | |
6540 | char attr_xpath[XPATH_MAXLEN]; | |
6541 | afi_t afi = bgp_node_afi(vty); | |
6542 | safi_t safi = bgp_node_safi(vty); | |
2a3d5731 | 6543 | |
f4b8ec07 CS |
6544 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6545 | yang_afi_safi_value2identity(afi, safi)); | |
6546 | ||
6547 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6548 | sizeof(base_xpath), af_xpath) | |
6549 | < 0) | |
d62a17ae | 6550 | return CMD_WARNING_CONFIG_FAILED; |
f4b8ec07 CS |
6551 | |
6552 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6553 | "./%s/route-server/route-server-client", | |
6554 | bgp_afi_safi_get_container_str(afi, safi)); | |
6555 | ||
6556 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6557 | ||
6558 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6559 | } |
6560 | ||
d62a17ae | 6561 | ALIAS_HIDDEN(neighbor_route_server_client, |
6562 | neighbor_route_server_client_hidden_cmd, | |
6563 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6564 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6565 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6566 | |
f4b8ec07 CS |
6567 | DEFUN_YANG (no_neighbor_route_server_client, |
6568 | no_neighbor_route_server_client_cmd, | |
6569 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6570 | NO_STR | |
6571 | NEIGHBOR_STR | |
6572 | NEIGHBOR_ADDR_STR2 | |
6573 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6574 | { |
d62a17ae | 6575 | int idx_peer = 2; |
f4b8ec07 CS |
6576 | char base_xpath[XPATH_MAXLEN]; |
6577 | char af_xpath[XPATH_MAXLEN]; | |
6578 | char attr_xpath[XPATH_MAXLEN]; | |
6579 | afi_t afi = bgp_node_afi(vty); | |
6580 | safi_t safi = bgp_node_safi(vty); | |
6581 | ||
6582 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6583 | yang_afi_safi_value2identity(afi, safi)); | |
6584 | ||
6585 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6586 | sizeof(base_xpath), af_xpath) | |
6587 | < 0) | |
6588 | return CMD_WARNING_CONFIG_FAILED; | |
6589 | ||
6590 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6591 | "./%s/route-server/route-server-client", | |
6592 | bgp_afi_safi_get_container_str(afi, safi)); | |
6593 | ||
6594 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6595 | ||
6596 | return nb_cli_apply_changes(vty, base_xpath); | |
fee0f4c6 | 6597 | } |
6b0655a2 | 6598 | |
d62a17ae | 6599 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6600 | no_neighbor_route_server_client_hidden_cmd, | |
6601 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6602 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6603 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6604 | |
fee0f4c6 | 6605 | DEFUN (neighbor_nexthop_local_unchanged, |
6606 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6607 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6608 | NEIGHBOR_STR |
6609 | NEIGHBOR_ADDR_STR2 | |
6610 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6611 | "Leave link-local nexthop unchanged for this peer\n") | |
6612 | { | |
d62a17ae | 6613 | int idx_peer = 1; |
6614 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6615 | bgp_node_safi(vty), | |
6616 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6617 | } |
6b0655a2 | 6618 | |
fee0f4c6 | 6619 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6620 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6621 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6622 | NO_STR |
6623 | NEIGHBOR_STR | |
6624 | NEIGHBOR_ADDR_STR2 | |
6625 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6626 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6627 | { |
d62a17ae | 6628 | int idx_peer = 2; |
6629 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6630 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6631 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6632 | } |
6b0655a2 | 6633 | |
f4b8ec07 CS |
6634 | DEFUN_YANG (neighbor_attr_unchanged, |
6635 | neighbor_attr_unchanged_cmd, | |
6636 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6637 | NEIGHBOR_STR | |
6638 | NEIGHBOR_ADDR_STR2 | |
6639 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6640 | "As-path attribute\n" | |
6641 | "Nexthop attribute\n" | |
6642 | "Med attribute\n") | |
718e3744 | 6643 | { |
d62a17ae | 6644 | int idx = 0; |
8eeb0335 | 6645 | char *peer_str = argv[1]->arg; |
db45f64d DS |
6646 | bool aspath = false; |
6647 | bool nexthop = false; | |
6648 | bool med = false; | |
8eeb0335 DW |
6649 | afi_t afi = bgp_node_afi(vty); |
6650 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6651 | char base_xpath[XPATH_MAXLEN]; |
6652 | char af_xpath[XPATH_MAXLEN]; | |
6653 | char as_xpath[XPATH_MAXLEN]; | |
6654 | char nxthop_xpath[XPATH_MAXLEN]; | |
6655 | char med_xpath[XPATH_MAXLEN]; | |
8eeb0335 | 6656 | |
f4b8ec07 CS |
6657 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6658 | yang_afi_safi_value2identity(afi, safi)); | |
6659 | ||
6660 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6661 | sizeof(base_xpath), af_xpath) | |
6662 | < 0) | |
8eeb0335 | 6663 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6664 | |
6665 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6666 | aspath = true; |
6667 | ||
d62a17ae | 6668 | idx = 0; |
6669 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6670 | nexthop = true; |
6671 | ||
d62a17ae | 6672 | idx = 0; |
6673 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6674 | med = true; |
d62a17ae | 6675 | |
f4b8ec07 CS |
6676 | snprintf(as_xpath, sizeof(as_xpath), |
6677 | "./%s/attr-unchanged/as-path-unchanged", | |
6678 | bgp_afi_safi_get_container_str(afi, safi)); | |
6679 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6680 | "./%s/attr-unchanged/next-hop-unchanged", | |
6681 | bgp_afi_safi_get_container_str(afi, safi)); | |
6682 | snprintf(med_xpath, sizeof(med_xpath), | |
6683 | "./%s/attr-unchanged/med-unchanged", | |
6684 | bgp_afi_safi_get_container_str(afi, safi)); | |
6685 | ||
8eeb0335 | 6686 | /* no flags means all of them! */ |
db45f64d | 6687 | if (!aspath && !nexthop && !med) { |
f4b8ec07 CS |
6688 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "true"); |
6689 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "true"); | |
6690 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "true"); | |
8eeb0335 | 6691 | } else { |
f4b8ec07 CS |
6692 | if (!aspath) |
6693 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6694 | "false"); | |
6695 | else | |
6696 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6697 | "true"); | |
6698 | ||
6699 | if (!nexthop) | |
6700 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6701 | "false"); | |
6702 | else | |
6703 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6704 | "true"); | |
6705 | ||
6706 | if (!med) | |
6707 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6708 | "false"); | |
6709 | else | |
6710 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6711 | "true"); | |
d62a17ae | 6712 | } |
6713 | ||
f4b8ec07 | 6714 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6715 | } |
6716 | ||
6717 | ALIAS_HIDDEN( | |
6718 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6719 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6720 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6721 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6722 | "As-path attribute\n" | |
6723 | "Nexthop attribute\n" | |
6724 | "Med attribute\n") | |
596c17ba | 6725 | |
f4b8ec07 CS |
6726 | DEFUN_YANG (no_neighbor_attr_unchanged, |
6727 | no_neighbor_attr_unchanged_cmd, | |
6728 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6729 | NO_STR | |
6730 | NEIGHBOR_STR | |
6731 | NEIGHBOR_ADDR_STR2 | |
6732 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6733 | "As-path attribute\n" | |
6734 | "Nexthop attribute\n" | |
6735 | "Med attribute\n") | |
718e3744 | 6736 | { |
d62a17ae | 6737 | int idx = 0; |
db45f64d | 6738 | char *peer_str = argv[2]->arg; |
db45f64d DS |
6739 | bool aspath = false; |
6740 | bool nexthop = false; | |
6741 | bool med = false; | |
6742 | afi_t afi = bgp_node_afi(vty); | |
6743 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6744 | char base_xpath[XPATH_MAXLEN]; |
6745 | char af_xpath[XPATH_MAXLEN]; | |
6746 | char as_xpath[XPATH_MAXLEN]; | |
6747 | char nxthop_xpath[XPATH_MAXLEN]; | |
6748 | char med_xpath[XPATH_MAXLEN]; | |
db45f64d | 6749 | |
f4b8ec07 CS |
6750 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6751 | yang_afi_safi_value2identity(afi, safi)); | |
6752 | ||
6753 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6754 | sizeof(base_xpath), af_xpath) | |
6755 | < 0) | |
db45f64d | 6756 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6757 | |
6758 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6759 | aspath = true; |
6760 | ||
d62a17ae | 6761 | idx = 0; |
6762 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6763 | nexthop = true; |
6764 | ||
d62a17ae | 6765 | idx = 0; |
6766 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6767 | med = true; |
d62a17ae | 6768 | |
f4b8ec07 CS |
6769 | snprintf(as_xpath, sizeof(as_xpath), |
6770 | "./%s/attr-unchanged/as-path-unchanged", | |
6771 | bgp_afi_safi_get_container_str(afi, safi)); | |
6772 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6773 | "./%s/attr-unchanged/next-hop-unchanged", | |
6774 | bgp_afi_safi_get_container_str(afi, safi)); | |
6775 | snprintf(med_xpath, sizeof(med_xpath), | |
6776 | "./%s/attr-unchanged/med-unchanged", | |
6777 | bgp_afi_safi_get_container_str(afi, safi)); | |
6778 | ||
6779 | /* no flags means all of them! */ | |
6780 | if (!aspath && !nexthop && !med) { | |
6781 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); | |
6782 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); | |
6783 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); | |
6784 | } | |
db45f64d DS |
6785 | |
6786 | if (aspath) | |
f4b8ec07 | 6787 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); |
db45f64d DS |
6788 | |
6789 | if (nexthop) | |
f4b8ec07 | 6790 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); |
d62a17ae | 6791 | |
db45f64d | 6792 | if (med) |
f4b8ec07 | 6793 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6794 | |
f4b8ec07 | 6795 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6796 | } |
6797 | ||
6798 | ALIAS_HIDDEN( | |
6799 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6800 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6801 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6802 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6803 | "As-path attribute\n" | |
6804 | "Nexthop attribute\n" | |
6805 | "Med attribute\n") | |
718e3744 | 6806 | |
f4b8ec07 CS |
6807 | /* neighbor ebgp-multihop. */ |
6808 | DEFUN_YANG (neighbor_ebgp_multihop, | |
6809 | neighbor_ebgp_multihop_cmd, | |
6810 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6811 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6812 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6813 | { |
f4b8ec07 CS |
6814 | int idx_peer = 1; |
6815 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6816 | |
f4b8ec07 CS |
6817 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6818 | sizeof(base_xpath), NULL) | |
6819 | < 0) | |
d62a17ae | 6820 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6821 | |
f4b8ec07 CS |
6822 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", NB_OP_MODIFY, |
6823 | "true"); | |
718e3744 | 6824 | |
f4b8ec07 | 6825 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6826 | } |
6827 | ||
f4b8ec07 CS |
6828 | DEFUN_YANG (neighbor_ebgp_multihop_ttl, |
6829 | neighbor_ebgp_multihop_ttl_cmd, | |
6830 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6831 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6832 | "Allow EBGP neighbors not on directly connected networks\n" | |
6833 | "maximum hop count\n") | |
718e3744 | 6834 | { |
f4b8ec07 CS |
6835 | int idx_peer = 1; |
6836 | int idx_number = 3; | |
6837 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6838 | |
f4b8ec07 CS |
6839 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6840 | sizeof(base_xpath), NULL) | |
6841 | < 0) | |
d62a17ae | 6842 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6843 | |
f4b8ec07 CS |
6844 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY, |
6845 | argv[idx_number]->arg); | |
718e3744 | 6846 | |
f4b8ec07 | 6847 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6848 | } |
6849 | ||
f4b8ec07 CS |
6850 | DEFUN_YANG (no_neighbor_ebgp_multihop, |
6851 | no_neighbor_ebgp_multihop_cmd, | |
6852 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6853 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6854 | "Allow EBGP neighbors not on directly connected networks\n" | |
6855 | "maximum hop count\n") | |
718e3744 | 6856 | { |
d62a17ae | 6857 | int idx_peer = 2; |
f4b8ec07 CS |
6858 | char base_xpath[XPATH_MAXLEN]; |
6859 | ||
6860 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6861 | sizeof(base_xpath), NULL) | |
6862 | < 0) | |
6863 | return CMD_WARNING_CONFIG_FAILED; | |
6864 | ||
6865 | if (argc > 4) | |
6866 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", | |
6867 | NB_OP_DESTROY, NULL); | |
6868 | else | |
6869 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", | |
6870 | NB_OP_MODIFY, "false"); | |
6871 | ||
6872 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6873 | } |
6874 | ||
6b0655a2 | 6875 | |
6ffd2079 | 6876 | /* disable-connected-check */ |
f4b8ec07 CS |
6877 | DEFUN_YANG (neighbor_disable_connected_check, |
6878 | neighbor_disable_connected_check_cmd, | |
6879 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6880 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6881 | "one-hop away EBGP peer using loopback address\n" | |
6882 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6883 | { |
d62a17ae | 6884 | int idx_peer = 1; |
f4b8ec07 CS |
6885 | char base_xpath[XPATH_MAXLEN]; |
6886 | ||
6887 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6888 | sizeof(base_xpath), NULL) | |
6889 | < 0) | |
6890 | return CMD_WARNING_CONFIG_FAILED; | |
6891 | ||
6892 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
6893 | NB_OP_MODIFY, "true"); | |
6894 | ||
6895 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 6896 | } |
6897 | ||
f4b8ec07 CS |
6898 | DEFUN_YANG (no_neighbor_disable_connected_check, |
6899 | no_neighbor_disable_connected_check_cmd, | |
6900 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6901 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6902 | "one-hop away EBGP peer using loopback address\n" | |
6903 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6904 | { |
d62a17ae | 6905 | int idx_peer = 2; |
f4b8ec07 CS |
6906 | char base_xpath[XPATH_MAXLEN]; |
6907 | ||
6908 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6909 | sizeof(base_xpath), NULL) | |
6910 | < 0) | |
6911 | return CMD_WARNING_CONFIG_FAILED; | |
6912 | ||
6913 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
6914 | NB_OP_MODIFY, "false"); | |
6915 | ||
6916 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 6917 | } |
6918 | ||
47cbc09b PM |
6919 | |
6920 | /* enforce-first-as */ | |
f4b8ec07 CS |
6921 | DEFUN_YANG (neighbor_enforce_first_as, |
6922 | neighbor_enforce_first_as_cmd, | |
6923 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6924 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6925 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6926 | { |
6927 | int idx_peer = 1; | |
f4b8ec07 | 6928 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 6929 | |
f4b8ec07 CS |
6930 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6931 | sizeof(base_xpath), NULL) | |
6932 | < 0) | |
6933 | return CMD_WARNING_CONFIG_FAILED; | |
6934 | ||
6935 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "true"); | |
6936 | ||
6937 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
6938 | } |
6939 | ||
f4b8ec07 CS |
6940 | DEFUN_YANG (no_neighbor_enforce_first_as, |
6941 | no_neighbor_enforce_first_as_cmd, | |
6942 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6943 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6944 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6945 | { |
6946 | int idx_peer = 2; | |
f4b8ec07 | 6947 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 6948 | |
f4b8ec07 CS |
6949 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6950 | sizeof(base_xpath), NULL) | |
6951 | < 0) | |
6952 | return CMD_WARNING_CONFIG_FAILED; | |
6953 | ||
6954 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "false"); | |
6955 | ||
6956 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
6957 | } |
6958 | ||
f4b8ec07 CS |
6959 | static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str, |
6960 | char *base_xpath, int xpath_len, | |
6961 | char *xpath) | |
6962 | { | |
6963 | union sockunion su; | |
6964 | char num_xpath[XPATH_MAXLEN]; | |
6965 | char unnbr_xpath[XPATH_MAXLEN]; | |
6966 | char prgrp_xpath[XPATH_MAXLEN]; | |
6967 | ||
6968 | if (str2sockunion(peer_str, &su) == 0) { | |
6969 | snprintf(num_xpath, sizeof(num_xpath), | |
6970 | "/neighbors/neighbor[remote-address='%s']", peer_str); | |
6971 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
6972 | VTY_CURR_XPATH, num_xpath)) { | |
6973 | snprintf(base_xpath, xpath_len, | |
6974 | FRR_BGP_NEIGHBOR_NUM_XPATH, peer_str, | |
6975 | xpath ? xpath : ""); | |
6976 | } else { | |
6977 | vty_out(vty, | |
6978 | "%% Specify remote-as or peer-group commands first\n"); | |
6979 | return -1; | |
6980 | } | |
6981 | ||
6982 | } else { | |
6983 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
6984 | "/neighbors/unnumbered-neighbor[interface='%s']", | |
6985 | peer_str); | |
6986 | ||
6987 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
6988 | "/peer-groups/peer-group[peer-group-name='%s']", | |
6989 | peer_str); | |
6990 | ||
6991 | if (yang_dnode_exists(vty->candidate_config->dnode, "%s%s", | |
6992 | VTY_CURR_XPATH, unnbr_xpath)) { | |
6993 | snprintf(base_xpath, xpath_len, | |
6994 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, peer_str, | |
6995 | xpath ? xpath : ""); | |
6996 | } else if (yang_dnode_exists(vty->candidate_config->dnode, | |
6997 | "%s%s", VTY_CURR_XPATH, | |
6998 | prgrp_xpath)) { | |
6999 | snprintf(base_xpath, xpath_len, | |
7000 | FRR_BGP_PEER_GROUP_XPATH, peer_str, | |
7001 | xpath ? xpath : ""); | |
7002 | } else { | |
7003 | vty_out(vty, | |
7004 | "%% Create the peer-group or interface first\n"); | |
7005 | return -1; | |
7006 | } | |
7007 | } | |
7008 | ||
7009 | return 0; | |
7010 | } | |
47cbc09b | 7011 | |
f4b8ec07 CS |
7012 | DEFUN_YANG (neighbor_description, |
7013 | neighbor_description_cmd, | |
7014 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
7015 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7016 | "Neighbor specific description\n" | |
7017 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 7018 | { |
d62a17ae | 7019 | int idx_peer = 1; |
7020 | int idx_line = 3; | |
f4b8ec07 CS |
7021 | int ret; |
7022 | char base_xpath[XPATH_MAXLEN]; | |
d62a17ae | 7023 | char *str; |
718e3744 | 7024 | |
f4b8ec07 CS |
7025 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7026 | sizeof(base_xpath), NULL) | |
7027 | < 0) | |
d62a17ae | 7028 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7029 | |
d62a17ae | 7030 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 7031 | |
f4b8ec07 CS |
7032 | nb_cli_enqueue_change(vty, "./description", NB_OP_MODIFY, str); |
7033 | ||
7034 | ret = nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7035 | |
d62a17ae | 7036 | XFREE(MTYPE_TMP, str); |
718e3744 | 7037 | |
f4b8ec07 | 7038 | return ret; |
718e3744 | 7039 | } |
7040 | ||
f4b8ec07 CS |
7041 | DEFUN_YANG (no_neighbor_description, |
7042 | no_neighbor_description_cmd, | |
7043 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
7044 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7045 | "Neighbor specific description\n") | |
718e3744 | 7046 | { |
d62a17ae | 7047 | int idx_peer = 2; |
f4b8ec07 CS |
7048 | char base_xpath[XPATH_MAXLEN]; |
7049 | ||
7050 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7051 | sizeof(base_xpath), NULL) | |
7052 | < 0) | |
d62a17ae | 7053 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7054 | |
f4b8ec07 | 7055 | nb_cli_enqueue_change(vty, "./description", NB_OP_DESTROY, NULL); |
718e3744 | 7056 | |
f4b8ec07 | 7057 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7058 | } |
7059 | ||
232c75cd | 7060 | ALIAS_YANG(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
7061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
7062 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7063 | "Neighbor specific description\n" | |
7064 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 7065 | |
d62a17ae | 7066 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
7067 | "IPv4 address\n" \ | |
7068 | "IPv6 address\n" \ | |
7069 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 7070 | |
f4b8ec07 CS |
7071 | DEFUN_YANG (neighbor_update_source, |
7072 | neighbor_update_source_cmd, | |
7073 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
7074 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7075 | "Source of routing updates\n" | |
7076 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 7077 | { |
d62a17ae | 7078 | int idx_peer = 1; |
7079 | int idx_peer_2 = 3; | |
f4b8ec07 CS |
7080 | union sockunion su; |
7081 | char base_xpath[XPATH_MAXLEN]; | |
7082 | ||
7083 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7084 | sizeof(base_xpath), NULL) | |
7085 | < 0) | |
7086 | return CMD_WARNING_CONFIG_FAILED; | |
7087 | ||
f4b8ec07 CS |
7088 | if (str2sockunion(argv[idx_peer_2]->arg, &su) == 0) |
7089 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_MODIFY, | |
d62a17ae | 7090 | argv[idx_peer_2]->arg); |
f4b8ec07 CS |
7091 | else |
7092 | nb_cli_enqueue_change(vty, "./update-source/interface", | |
7093 | NB_OP_MODIFY, argv[idx_peer_2]->arg); | |
7094 | ||
7095 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7096 | } |
7097 | ||
f4b8ec07 CS |
7098 | DEFUN_YANG (no_neighbor_update_source, |
7099 | no_neighbor_update_source_cmd, | |
7100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
7101 | NO_STR NEIGHBOR_STR | |
7102 | NEIGHBOR_ADDR_STR2 | |
7103 | "Source of routing updates\n" | |
7104 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 7105 | { |
d62a17ae | 7106 | int idx_peer = 2; |
f4b8ec07 | 7107 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
7108 | |
7109 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7110 | sizeof(base_xpath), NULL) | |
7111 | < 0) | |
7112 | return CMD_WARNING_CONFIG_FAILED; | |
7113 | ||
555c8ab7 CS |
7114 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_DESTROY, NULL); |
7115 | nb_cli_enqueue_change(vty, "./update-source/interface", NB_OP_DESTROY, | |
7116 | NULL); | |
f4b8ec07 CS |
7117 | |
7118 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7119 | } |
6b0655a2 | 7120 | |
d62a17ae | 7121 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
7122 | afi_t afi, safi_t safi, | |
7123 | const char *rmap, int set) | |
718e3744 | 7124 | { |
d62a17ae | 7125 | int ret; |
7126 | struct peer *peer; | |
80912664 | 7127 | struct route_map *route_map = NULL; |
718e3744 | 7128 | |
d62a17ae | 7129 | peer = peer_and_group_lookup_vty(vty, peer_str); |
7130 | if (!peer) | |
7131 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7132 | |
1de27621 | 7133 | if (set) { |
80912664 DS |
7134 | if (rmap) |
7135 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
7136 | ret = peer_default_originate_set(peer, afi, safi, |
7137 | rmap, route_map); | |
7138 | } else | |
d62a17ae | 7139 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 7140 | |
d62a17ae | 7141 | return bgp_vty_return(vty, ret); |
718e3744 | 7142 | } |
7143 | ||
7144 | /* neighbor default-originate. */ | |
7145 | DEFUN (neighbor_default_originate, | |
7146 | neighbor_default_originate_cmd, | |
9ccf14f7 | 7147 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 7148 | NEIGHBOR_STR |
7149 | NEIGHBOR_ADDR_STR2 | |
7150 | "Originate default route to this neighbor\n") | |
7151 | { | |
d62a17ae | 7152 | int idx_peer = 1; |
7153 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7154 | bgp_node_afi(vty), | |
7155 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 7156 | } |
7157 | ||
d62a17ae | 7158 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
7159 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
7160 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7161 | "Originate default route to this neighbor\n") | |
596c17ba | 7162 | |
718e3744 | 7163 | DEFUN (neighbor_default_originate_rmap, |
7164 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 7165 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 7166 | NEIGHBOR_STR |
7167 | NEIGHBOR_ADDR_STR2 | |
7168 | "Originate default route to this neighbor\n" | |
7169 | "Route-map to specify criteria to originate default\n" | |
7170 | "route-map name\n") | |
7171 | { | |
d62a17ae | 7172 | int idx_peer = 1; |
7173 | int idx_word = 4; | |
7174 | return peer_default_originate_set_vty( | |
7175 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7176 | argv[idx_word]->arg, 1); | |
718e3744 | 7177 | } |
7178 | ||
d62a17ae | 7179 | ALIAS_HIDDEN( |
7180 | neighbor_default_originate_rmap, | |
7181 | neighbor_default_originate_rmap_hidden_cmd, | |
7182 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
7183 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7184 | "Originate default route to this neighbor\n" | |
7185 | "Route-map to specify criteria to originate default\n" | |
7186 | "route-map name\n") | |
596c17ba | 7187 | |
718e3744 | 7188 | DEFUN (no_neighbor_default_originate, |
7189 | no_neighbor_default_originate_cmd, | |
a636c635 | 7190 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 7191 | NO_STR |
7192 | NEIGHBOR_STR | |
7193 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
7194 | "Originate default route to this neighbor\n" |
7195 | "Route-map to specify criteria to originate default\n" | |
7196 | "route-map name\n") | |
718e3744 | 7197 | { |
d62a17ae | 7198 | int idx_peer = 2; |
7199 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7200 | bgp_node_afi(vty), | |
7201 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 7202 | } |
7203 | ||
d62a17ae | 7204 | ALIAS_HIDDEN( |
7205 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
7206 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
7207 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7208 | "Originate default route to this neighbor\n" | |
7209 | "Route-map to specify criteria to originate default\n" | |
7210 | "route-map name\n") | |
596c17ba | 7211 | |
6b0655a2 | 7212 | |
f418446b | 7213 | /* Set specified peer's BGP port. */ |
f4b8ec07 CS |
7214 | DEFUN_YANG (neighbor_port, |
7215 | neighbor_port_cmd, | |
7216 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
7217 | NEIGHBOR_STR | |
7218 | NEIGHBOR_ADDR_STR | |
7219 | "Neighbor's BGP port\n" | |
7220 | "TCP port number\n") | |
718e3744 | 7221 | { |
d62a17ae | 7222 | int idx_ip = 1; |
7223 | int idx_number = 3; | |
f4b8ec07 | 7224 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 7225 | |
f4b8ec07 CS |
7226 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7227 | argv[idx_ip]->arg, ""); | |
718e3744 | 7228 | |
f4b8ec07 CS |
7229 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_MODIFY, |
7230 | argv[idx_number]->arg); | |
7231 | ||
7232 | return nb_cli_apply_changes(vty, base_xpath); | |
7233 | } | |
6b0655a2 | 7234 | |
f4b8ec07 CS |
7235 | DEFUN_YANG (no_neighbor_port, |
7236 | no_neighbor_port_cmd, | |
7237 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
7238 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7239 | "Neighbor's BGP port\n" | |
7240 | "TCP port number\n") | |
718e3744 | 7241 | { |
f4b8ec07 CS |
7242 | int idx_ip = 2; |
7243 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7244 | |
f4b8ec07 CS |
7245 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7246 | argv[idx_ip]->arg, ""); | |
718e3744 | 7247 | |
f4b8ec07 | 7248 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_DESTROY, NULL); |
718e3744 | 7249 | |
f4b8ec07 | 7250 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7251 | } |
7252 | ||
f4b8ec07 CS |
7253 | DEFUN_YANG (neighbor_weight, |
7254 | neighbor_weight_cmd, | |
7255 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7256 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7257 | "Set default weight for routes from this neighbor\n" | |
7258 | "default weight\n") | |
718e3744 | 7259 | { |
f4b8ec07 CS |
7260 | int idx_peer = 1; |
7261 | int idx_number = 3; | |
7262 | char base_xpath[XPATH_MAXLEN]; | |
7263 | char af_xpath[XPATH_MAXLEN]; | |
7264 | char attr_xpath[XPATH_MAXLEN]; | |
7265 | afi_t afi = bgp_node_afi(vty); | |
7266 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 7267 | |
f4b8ec07 CS |
7268 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
7269 | yang_afi_safi_value2identity(afi, safi)); | |
7270 | ||
7271 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7272 | sizeof(base_xpath), af_xpath) | |
7273 | < 0) | |
d62a17ae | 7274 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7275 | |
f4b8ec07 CS |
7276 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", |
7277 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 7278 | |
f4b8ec07 CS |
7279 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, |
7280 | argv[idx_number]->arg); | |
7281 | ||
7282 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7283 | } |
7284 | ||
d62a17ae | 7285 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7286 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7287 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7288 | "Set default weight for routes from this neighbor\n" | |
7289 | "default weight\n") | |
596c17ba | 7290 | |
f4b8ec07 CS |
7291 | DEFUN_YANG (no_neighbor_weight, |
7292 | no_neighbor_weight_cmd, | |
7293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7294 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7295 | "Set default weight for routes from this neighbor\n" | |
7296 | "default weight\n") | |
718e3744 | 7297 | { |
d62a17ae | 7298 | int idx_peer = 2; |
f4b8ec07 CS |
7299 | char base_xpath[XPATH_MAXLEN]; |
7300 | char af_xpath[XPATH_MAXLEN]; | |
7301 | char attr_xpath[XPATH_MAXLEN]; | |
7302 | afi_t afi = bgp_node_afi(vty); | |
7303 | safi_t safi = bgp_node_safi(vty); | |
7304 | ||
7305 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
7306 | yang_afi_safi_value2identity(afi, safi)); | |
7307 | ||
7308 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7309 | sizeof(base_xpath), af_xpath) | |
7310 | < 0) | |
7311 | return CMD_WARNING_CONFIG_FAILED; | |
7312 | ||
7313 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", | |
7314 | bgp_afi_safi_get_container_str(afi, safi)); | |
7315 | ||
7316 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_DESTROY, NULL); | |
7317 | ||
7318 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7319 | } |
7320 | ||
d62a17ae | 7321 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7322 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7323 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7324 | "Set default weight for routes from this neighbor\n" | |
7325 | "default weight\n") | |
596c17ba | 7326 | |
6b0655a2 | 7327 | |
718e3744 | 7328 | /* Override capability negotiation. */ |
8611c7f3 CS |
7329 | DEFUN_YANG (neighbor_override_capability, |
7330 | neighbor_override_capability_cmd, | |
7331 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7332 | NEIGHBOR_STR | |
7333 | NEIGHBOR_ADDR_STR2 | |
7334 | "Override capability negotiation result\n") | |
718e3744 | 7335 | { |
d62a17ae | 7336 | int idx_peer = 1; |
8611c7f3 CS |
7337 | char base_xpath[XPATH_MAXLEN]; |
7338 | ||
7339 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7340 | sizeof(base_xpath), NULL) | |
7341 | < 0) | |
7342 | return CMD_WARNING_CONFIG_FAILED; | |
7343 | ||
7344 | nb_cli_enqueue_change( | |
7345 | vty, "./capability-options/override-capability", | |
7346 | NB_OP_MODIFY, "true"); | |
7347 | ||
7348 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7349 | } |
7350 | ||
8611c7f3 CS |
7351 | DEFUN_YANG (no_neighbor_override_capability, |
7352 | no_neighbor_override_capability_cmd, | |
7353 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7354 | NO_STR | |
7355 | NEIGHBOR_STR | |
7356 | NEIGHBOR_ADDR_STR2 | |
7357 | "Override capability negotiation result\n") | |
718e3744 | 7358 | { |
d62a17ae | 7359 | int idx_peer = 2; |
8611c7f3 CS |
7360 | char base_xpath[XPATH_MAXLEN]; |
7361 | ||
7362 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7363 | sizeof(base_xpath), NULL) | |
7364 | < 0) | |
7365 | return CMD_WARNING_CONFIG_FAILED; | |
7366 | ||
7367 | nb_cli_enqueue_change( | |
7368 | vty, "./capability-options/override-capability", | |
7369 | NB_OP_MODIFY, "false"); | |
7370 | ||
7371 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7372 | } |
6b0655a2 | 7373 | |
8611c7f3 CS |
7374 | DEFUN_YANG (neighbor_strict_capability, |
7375 | neighbor_strict_capability_cmd, | |
7376 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7377 | NEIGHBOR_STR | |
7378 | NEIGHBOR_ADDR_STR2 | |
7379 | "Strict capability negotiation match\n") | |
718e3744 | 7380 | { |
9fb964de | 7381 | int idx_peer = 1; |
8611c7f3 | 7382 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7383 | |
8611c7f3 CS |
7384 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7385 | sizeof(base_xpath), NULL) | |
7386 | < 0) | |
7387 | return CMD_WARNING_CONFIG_FAILED; | |
7388 | ||
7389 | nb_cli_enqueue_change( | |
7390 | vty, "./capability-options/strict-capability", | |
7391 | NB_OP_MODIFY, "true"); | |
7392 | ||
7393 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7394 | } |
7395 | ||
8611c7f3 CS |
7396 | DEFUN_YANG (no_neighbor_strict_capability, |
7397 | no_neighbor_strict_capability_cmd, | |
7398 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7399 | NO_STR | |
7400 | NEIGHBOR_STR | |
7401 | NEIGHBOR_ADDR_STR2 | |
7402 | "Strict capability negotiation match\n") | |
718e3744 | 7403 | { |
9fb964de | 7404 | int idx_peer = 2; |
8611c7f3 | 7405 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7406 | |
8611c7f3 CS |
7407 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7408 | sizeof(base_xpath), NULL) | |
7409 | < 0) | |
7410 | return CMD_WARNING_CONFIG_FAILED; | |
7411 | ||
7412 | nb_cli_enqueue_change( | |
7413 | vty, "./capability-options/strict-capability", | |
7414 | NB_OP_MODIFY, "false"); | |
7415 | ||
7416 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7417 | } |
6b0655a2 | 7418 | |
f4b8ec07 CS |
7419 | DEFUN_YANG (neighbor_timers, |
7420 | neighbor_timers_cmd, | |
7421 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7422 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7423 | "BGP per neighbor timers\n" | |
7424 | "Keepalive interval\n" | |
7425 | "Holdtime\n") | |
718e3744 | 7426 | { |
f4b8ec07 CS |
7427 | int idx_peer = 1; |
7428 | int idx_number = 3; | |
7429 | int idx_number_2 = 4; | |
7430 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7431 | |
f4b8ec07 CS |
7432 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7433 | sizeof(base_xpath), NULL) | |
7434 | < 0) | |
d62a17ae | 7435 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7436 | |
f4b8ec07 CS |
7437 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_MODIFY, |
7438 | argv[idx_number]->arg); | |
718e3744 | 7439 | |
f4b8ec07 CS |
7440 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_MODIFY, |
7441 | argv[idx_number_2]->arg); | |
718e3744 | 7442 | |
f4b8ec07 | 7443 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7444 | } |
6b0655a2 | 7445 | |
f4b8ec07 CS |
7446 | DEFUN_YANG (no_neighbor_timers, |
7447 | no_neighbor_timers_cmd, | |
7448 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7449 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7450 | "BGP per neighbor timers\n" | |
7451 | "Keepalive interval\n" | |
7452 | "Holdtime\n") | |
718e3744 | 7453 | { |
f4b8ec07 CS |
7454 | int idx_peer = 2; |
7455 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7456 | |
f4b8ec07 CS |
7457 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7458 | sizeof(base_xpath), NULL) | |
7459 | < 0) | |
d62a17ae | 7460 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7461 | |
f4b8ec07 | 7462 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_DESTROY, NULL); |
718e3744 | 7463 | |
f4b8ec07 | 7464 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_DESTROY, NULL); |
718e3744 | 7465 | |
f4b8ec07 | 7466 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7467 | } |
6b0655a2 | 7468 | |
f4b8ec07 CS |
7469 | DEFUN_YANG (neighbor_timers_connect, |
7470 | neighbor_timers_connect_cmd, | |
7471 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7472 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7473 | "BGP per neighbor timers\n" | |
7474 | "BGP connect timer\n" | |
7475 | "Connect timer\n") | |
718e3744 | 7476 | { |
f4b8ec07 CS |
7477 | int idx_peer = 1; |
7478 | int idx_number = 4; | |
7479 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7480 | |
f4b8ec07 CS |
7481 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7482 | sizeof(base_xpath), NULL) | |
7483 | < 0) | |
d62a17ae | 7484 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7485 | |
f4b8ec07 CS |
7486 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_MODIFY, |
7487 | argv[idx_number]->arg); | |
718e3744 | 7488 | |
f4b8ec07 | 7489 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7490 | } |
7491 | ||
f4b8ec07 CS |
7492 | DEFUN_YANG (no_neighbor_timers_connect, |
7493 | no_neighbor_timers_connect_cmd, | |
7494 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7495 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7496 | "BGP per neighbor timers\n" | |
7497 | "BGP connect timer\n" | |
7498 | "Connect timer\n") | |
718e3744 | 7499 | { |
f4b8ec07 CS |
7500 | int idx_peer = 2; |
7501 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7502 | |
f4b8ec07 CS |
7503 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7504 | sizeof(base_xpath), NULL) | |
7505 | < 0) | |
d62a17ae | 7506 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7507 | |
f4b8ec07 CS |
7508 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_DESTROY, |
7509 | NULL); | |
718e3744 | 7510 | |
f4b8ec07 | 7511 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7512 | } |
7513 | ||
d43114f3 DS |
7514 | DEFPY (neighbor_timers_delayopen, |
7515 | neighbor_timers_delayopen_cmd, | |
7516 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7517 | NEIGHBOR_STR | |
7518 | NEIGHBOR_ADDR_STR2 | |
7519 | "BGP per neighbor timers\n" | |
7520 | "RFC 4271 DelayOpenTimer\n" | |
7521 | "DelayOpenTime timer interval\n") | |
7522 | { | |
7523 | struct peer *peer; | |
7524 | ||
7525 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7526 | if (!peer) | |
7527 | return CMD_WARNING_CONFIG_FAILED; | |
7528 | ||
7529 | if (!interval) { | |
7530 | if (peer_timers_delayopen_unset(peer)) | |
7531 | return CMD_WARNING_CONFIG_FAILED; | |
7532 | } else { | |
7533 | if (peer_timers_delayopen_set(peer, interval)) | |
7534 | return CMD_WARNING_CONFIG_FAILED; | |
7535 | } | |
7536 | ||
7537 | return CMD_SUCCESS; | |
7538 | } | |
7539 | ||
7540 | DEFPY (no_neighbor_timers_delayopen, | |
7541 | no_neighbor_timers_delayopen_cmd, | |
7542 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7543 | NO_STR | |
7544 | NEIGHBOR_STR | |
7545 | NEIGHBOR_ADDR_STR2 | |
7546 | "BGP per neighbor timers\n" | |
7547 | "RFC 4271 DelayOpenTimer\n" | |
7548 | "DelayOpenTime timer interval\n") | |
7549 | { | |
7550 | struct peer *peer; | |
7551 | ||
7552 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7553 | if (!peer) | |
7554 | return CMD_WARNING_CONFIG_FAILED; | |
7555 | ||
7556 | if (peer_timers_delayopen_unset(peer)) | |
7557 | return CMD_WARNING_CONFIG_FAILED; | |
7558 | ||
7559 | return CMD_SUCCESS; | |
7560 | } | |
7561 | ||
f4b8ec07 CS |
7562 | DEFUN_YANG (neighbor_advertise_interval, |
7563 | neighbor_advertise_interval_cmd, | |
7564 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7565 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7566 | "Minimum interval between sending BGP routing updates\n" | |
7567 | "time in seconds\n") | |
718e3744 | 7568 | { |
d62a17ae | 7569 | int idx_peer = 1; |
f4b8ec07 CS |
7570 | int idx_number = 3; |
7571 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7572 | |
f4b8ec07 CS |
7573 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7574 | sizeof(base_xpath), NULL) | |
7575 | < 0) | |
d62a17ae | 7576 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7577 | |
f4b8ec07 CS |
7578 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_MODIFY, |
7579 | argv[idx_number]->arg); | |
718e3744 | 7580 | |
f4b8ec07 | 7581 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7582 | } |
7583 | ||
f4b8ec07 CS |
7584 | DEFUN_YANG (no_neighbor_advertise_interval, |
7585 | no_neighbor_advertise_interval_cmd, | |
7586 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7587 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7588 | "Minimum interval between sending BGP routing updates\n" | |
7589 | "time in seconds\n") | |
718e3744 | 7590 | { |
d62a17ae | 7591 | int idx_peer = 2; |
f4b8ec07 CS |
7592 | char base_xpath[XPATH_MAXLEN]; |
7593 | ||
7594 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7595 | sizeof(base_xpath), NULL) | |
7596 | < 0) | |
7597 | return CMD_WARNING_CONFIG_FAILED; | |
7598 | ||
7599 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_DESTROY, | |
7600 | NULL); | |
7601 | ||
7602 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7603 | } |
7604 | ||
6b0655a2 | 7605 | |
518f0eb1 DS |
7606 | /* Time to wait before processing route-map updates */ |
7607 | DEFUN (bgp_set_route_map_delay_timer, | |
7608 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7609 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7610 | SET_STR |
7611 | "BGP route-map delay timer\n" | |
7612 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7613 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7614 | { |
d62a17ae | 7615 | int idx_number = 3; |
d7c0a89a | 7616 | uint32_t rmap_delay_timer; |
d62a17ae | 7617 | |
7618 | if (argv[idx_number]->arg) { | |
7619 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7620 | bm->rmap_update_timer = rmap_delay_timer; | |
7621 | ||
7622 | /* if the dynamic update handling is being disabled, and a timer | |
7623 | * is | |
7624 | * running, stop the timer and act as if the timer has already | |
7625 | * fired. | |
7626 | */ | |
7627 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7628 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7629 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7630 | NULL, 0); | |
7631 | } | |
7632 | return CMD_SUCCESS; | |
7633 | } else { | |
7634 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7635 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7636 | } |
518f0eb1 DS |
7637 | } |
7638 | ||
7639 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7640 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7641 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7642 | NO_STR |
3a2d747c | 7643 | BGP_STR |
518f0eb1 | 7644 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7645 | "Reset to default time to wait for processing route-map changes\n" |
7646 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7647 | { |
518f0eb1 | 7648 | |
d62a17ae | 7649 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7650 | |
d62a17ae | 7651 | return CMD_SUCCESS; |
518f0eb1 DS |
7652 | } |
7653 | ||
f4b8ec07 CS |
7654 | DEFUN_YANG (neighbor_interface, |
7655 | neighbor_interface_cmd, | |
7656 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7657 | NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7658 | "Interface\n" | |
7659 | "Interface name\n") | |
718e3744 | 7660 | { |
f4b8ec07 CS |
7661 | int idx_ip = 1; |
7662 | int idx_word = 3; | |
7663 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7664 | |
f4b8ec07 CS |
7665 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7666 | argv[idx_ip]->arg, ""); | |
718e3744 | 7667 | |
f4b8ec07 CS |
7668 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_MODIFY, |
7669 | argv[idx_word]->arg); | |
718e3744 | 7670 | |
f4b8ec07 | 7671 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7672 | } |
7673 | ||
f4b8ec07 CS |
7674 | DEFUN_YANG (no_neighbor_interface, |
7675 | no_neighbor_interface_cmd, | |
7676 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", | |
7677 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7678 | "Interface\n" | |
7679 | "Interface name\n") | |
718e3744 | 7680 | { |
d62a17ae | 7681 | int idx_peer = 2; |
f4b8ec07 CS |
7682 | char base_xpath[XPATH_MAXLEN]; |
7683 | ||
7684 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, | |
7685 | argv[idx_peer]->arg, ""); | |
7686 | ||
7687 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_DESTROY, NULL); | |
7688 | ||
7689 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7690 | } |
6b0655a2 | 7691 | |
718e3744 | 7692 | DEFUN (neighbor_distribute_list, |
7693 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 7694 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7695 | NEIGHBOR_STR |
7696 | NEIGHBOR_ADDR_STR2 | |
7697 | "Filter updates to/from this neighbor\n" | |
7698 | "IP access-list number\n" | |
7699 | "IP access-list number (expanded range)\n" | |
7700 | "IP Access-list name\n" | |
7701 | "Filter incoming updates\n" | |
7702 | "Filter outgoing updates\n") | |
7703 | { | |
d62a17ae | 7704 | int idx_peer = 1; |
7705 | int idx_acl = 3; | |
7706 | int direct, ret; | |
7707 | struct peer *peer; | |
a8206004 | 7708 | |
d62a17ae | 7709 | const char *pstr = argv[idx_peer]->arg; |
7710 | const char *acl = argv[idx_acl]->arg; | |
7711 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7712 | |
d62a17ae | 7713 | peer = peer_and_group_lookup_vty(vty, pstr); |
7714 | if (!peer) | |
7715 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7716 | |
d62a17ae | 7717 | /* Check filter direction. */ |
7718 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7719 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7720 | direct, acl); | |
a8206004 | 7721 | |
d62a17ae | 7722 | return bgp_vty_return(vty, ret); |
718e3744 | 7723 | } |
7724 | ||
d62a17ae | 7725 | ALIAS_HIDDEN( |
7726 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
7727 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7728 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7729 | "Filter updates to/from this neighbor\n" | |
7730 | "IP access-list number\n" | |
7731 | "IP access-list number (expanded range)\n" | |
7732 | "IP Access-list name\n" | |
7733 | "Filter incoming updates\n" | |
7734 | "Filter outgoing updates\n") | |
596c17ba | 7735 | |
718e3744 | 7736 | DEFUN (no_neighbor_distribute_list, |
7737 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 7738 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7739 | NO_STR |
7740 | NEIGHBOR_STR | |
7741 | NEIGHBOR_ADDR_STR2 | |
7742 | "Filter updates to/from this neighbor\n" | |
7743 | "IP access-list number\n" | |
7744 | "IP access-list number (expanded range)\n" | |
7745 | "IP Access-list name\n" | |
7746 | "Filter incoming updates\n" | |
7747 | "Filter outgoing updates\n") | |
7748 | { | |
d62a17ae | 7749 | int idx_peer = 2; |
7750 | int direct, ret; | |
7751 | struct peer *peer; | |
a8206004 | 7752 | |
d62a17ae | 7753 | const char *pstr = argv[idx_peer]->arg; |
7754 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7755 | |
d62a17ae | 7756 | peer = peer_and_group_lookup_vty(vty, pstr); |
7757 | if (!peer) | |
7758 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7759 | |
d62a17ae | 7760 | /* Check filter direction. */ |
7761 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7762 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7763 | direct); | |
a8206004 | 7764 | |
d62a17ae | 7765 | return bgp_vty_return(vty, ret); |
718e3744 | 7766 | } |
6b0655a2 | 7767 | |
d62a17ae | 7768 | ALIAS_HIDDEN( |
7769 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7770 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7771 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7772 | "Filter updates to/from this neighbor\n" | |
7773 | "IP access-list number\n" | |
7774 | "IP access-list number (expanded range)\n" | |
7775 | "IP Access-list name\n" | |
7776 | "Filter incoming updates\n" | |
7777 | "Filter outgoing updates\n") | |
596c17ba | 7778 | |
718e3744 | 7779 | /* Set prefix list to the peer. */ |
d9986d26 CS |
7780 | DEFPY_YANG( |
7781 | neighbor_prefix_list, neighbor_prefix_list_cmd, | |
7782 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str prefix-list WORD$prefix_str <in|out>$direction", | |
7783 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7784 | "Filter updates to/from this neighbor\n" | |
7785 | "Name of a prefix list\n" | |
7786 | "Filter incoming updates\n" | |
7787 | "Filter outgoing updates\n") | |
718e3744 | 7788 | { |
d9986d26 CS |
7789 | char base_xpath[XPATH_MAXLEN]; |
7790 | char af_xpath[XPATH_MAXLEN]; | |
c6685575 | 7791 | char plist_xpath[XPATH_MAXLEN]; |
d9986d26 CS |
7792 | afi_t afi = bgp_node_afi(vty); |
7793 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 7794 | |
d9986d26 CS |
7795 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
7796 | yang_afi_safi_value2identity(afi, safi)); | |
7797 | if (peer_and_group_lookup_nb(vty, neighbor_str, base_xpath, | |
7798 | sizeof(base_xpath), af_xpath) | |
7799 | < 0) | |
d62a17ae | 7800 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7801 | |
d9986d26 CS |
7802 | if (strmatch(direction, "in")) |
7803 | snprintf(plist_xpath, sizeof(plist_xpath), | |
7804 | "./%s/filter-config/plist-import", | |
7805 | bgp_afi_safi_get_container_str(afi, safi)); | |
7806 | else if (strmatch(direction, "out")) | |
7807 | snprintf(plist_xpath, sizeof(plist_xpath), | |
7808 | "./%s/filter-config/plist-export", | |
7809 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 7810 | |
d9986d26 CS |
7811 | if (!no) |
7812 | nb_cli_enqueue_change(vty, plist_xpath, NB_OP_MODIFY, | |
7813 | prefix_str); | |
7814 | else | |
7815 | nb_cli_enqueue_change(vty, plist_xpath, NB_OP_DESTROY, NULL); | |
718e3744 | 7816 | |
d9986d26 | 7817 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7818 | } |
7819 | ||
d62a17ae | 7820 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7821 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7822 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7823 | "Filter updates to/from this neighbor\n" | |
7824 | "Name of a prefix list\n" | |
7825 | "Filter incoming updates\n" | |
7826 | "Filter outgoing updates\n") | |
596c17ba | 7827 | |
d62a17ae | 7828 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7829 | safi_t safi, const char *name_str, | |
7830 | const char *direct_str) | |
718e3744 | 7831 | { |
d62a17ae | 7832 | int ret; |
7833 | struct peer *peer; | |
7834 | int direct = FILTER_IN; | |
718e3744 | 7835 | |
d62a17ae | 7836 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7837 | if (!peer) | |
7838 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7839 | |
d62a17ae | 7840 | /* Check filter direction. */ |
7841 | if (strncmp(direct_str, "i", 1) == 0) | |
7842 | direct = FILTER_IN; | |
7843 | else if (strncmp(direct_str, "o", 1) == 0) | |
7844 | direct = FILTER_OUT; | |
718e3744 | 7845 | |
d62a17ae | 7846 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7847 | |
d62a17ae | 7848 | return bgp_vty_return(vty, ret); |
718e3744 | 7849 | } |
7850 | ||
d62a17ae | 7851 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7852 | safi_t safi, const char *direct_str) | |
718e3744 | 7853 | { |
d62a17ae | 7854 | int ret; |
7855 | struct peer *peer; | |
7856 | int direct = FILTER_IN; | |
718e3744 | 7857 | |
d62a17ae | 7858 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7859 | if (!peer) | |
7860 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7861 | |
d62a17ae | 7862 | /* Check filter direction. */ |
7863 | if (strncmp(direct_str, "i", 1) == 0) | |
7864 | direct = FILTER_IN; | |
7865 | else if (strncmp(direct_str, "o", 1) == 0) | |
7866 | direct = FILTER_OUT; | |
718e3744 | 7867 | |
d62a17ae | 7868 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7869 | |
d62a17ae | 7870 | return bgp_vty_return(vty, ret); |
718e3744 | 7871 | } |
7872 | ||
7873 | DEFUN (neighbor_filter_list, | |
7874 | neighbor_filter_list_cmd, | |
9ccf14f7 | 7875 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7876 | NEIGHBOR_STR |
7877 | NEIGHBOR_ADDR_STR2 | |
7878 | "Establish BGP filters\n" | |
7879 | "AS path access-list name\n" | |
7880 | "Filter incoming routes\n" | |
7881 | "Filter outgoing routes\n") | |
7882 | { | |
d62a17ae | 7883 | int idx_peer = 1; |
7884 | int idx_word = 3; | |
7885 | int idx_in_out = 4; | |
7886 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7887 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7888 | argv[idx_in_out]->arg); | |
718e3744 | 7889 | } |
7890 | ||
d62a17ae | 7891 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7892 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7893 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7894 | "Establish BGP filters\n" | |
7895 | "AS path access-list name\n" | |
7896 | "Filter incoming routes\n" | |
7897 | "Filter outgoing routes\n") | |
596c17ba | 7898 | |
718e3744 | 7899 | DEFUN (no_neighbor_filter_list, |
7900 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7901 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7902 | NO_STR |
7903 | NEIGHBOR_STR | |
7904 | NEIGHBOR_ADDR_STR2 | |
7905 | "Establish BGP filters\n" | |
7906 | "AS path access-list name\n" | |
7907 | "Filter incoming routes\n" | |
7908 | "Filter outgoing routes\n") | |
7909 | { | |
d62a17ae | 7910 | int idx_peer = 2; |
7911 | int idx_in_out = 5; | |
7912 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7913 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7914 | argv[idx_in_out]->arg); | |
718e3744 | 7915 | } |
6b0655a2 | 7916 | |
d62a17ae | 7917 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7918 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7919 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7920 | "Establish BGP filters\n" | |
7921 | "AS path access-list name\n" | |
7922 | "Filter incoming routes\n" | |
7923 | "Filter outgoing routes\n") | |
596c17ba | 7924 | |
7f7940e6 MK |
7925 | /* Set advertise-map to the peer. */ |
7926 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7927 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7928 | const char *advertise_str, |
7929 | const char *condition_str, bool condition, | |
7930 | bool set) | |
7f7940e6 MK |
7931 | { |
7932 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7933 | struct peer *peer; | |
7934 | struct route_map *advertise_map; | |
7935 | struct route_map *condition_map; | |
7936 | ||
7937 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7938 | if (!peer) | |
7939 | return ret; | |
7940 | ||
7941 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7942 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7943 | ||
cf2ad4d8 MK |
7944 | if (set) |
7945 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7946 | advertise_map, condition_str, | |
7947 | condition_map, condition); | |
7948 | else | |
7949 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7950 | advertise_map, condition_str, | |
7951 | condition_map, condition); | |
7f7940e6 MK |
7952 | |
7953 | return bgp_vty_return(vty, ret); | |
7954 | } | |
7955 | ||
cf2ad4d8 | 7956 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7957 | neighbor_advertise_map_cmd, |
52b84062 | 7958 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str", |
cf2ad4d8 | 7959 | NO_STR |
7f7940e6 MK |
7960 | NEIGHBOR_STR |
7961 | NEIGHBOR_ADDR_STR2 | |
7962 | "Route-map to conditionally advertise routes\n" | |
7963 | "Name of advertise map\n" | |
7964 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7965 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7966 | "Name of the exist or non exist map\n") |
7f7940e6 | 7967 | { |
7f7940e6 MK |
7968 | bool condition = CONDITION_EXIST; |
7969 | ||
52b84062 | 7970 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7971 | condition = CONDITION_NON_EXIST; |
7972 | ||
52b84062 MK |
7973 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7974 | bgp_node_safi(vty), advertise_str, | |
7975 | condition_str, condition, !no); | |
7f7940e6 MK |
7976 | } |
7977 | ||
7978 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7979 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str", |
7f7940e6 MK |
7980 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7981 | "Route-map to conditionally advertise routes\n" | |
7982 | "Name of advertise map\n" | |
7983 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7984 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7985 | "Name of the exist or non exist map\n") |
7f7940e6 | 7986 | |
718e3744 | 7987 | /* Set route-map to the peer. */ |
c6685575 CS |
7988 | DEFPY_YANG( |
7989 | neighbor_route_map, neighbor_route_map_cmd, | |
7990 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str route-map WORD$rmap_str <in|out>$direction", | |
7991 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7992 | "Apply route map to neighbor\n" | |
7993 | "Name of route map\n" | |
7994 | "Apply map to incoming routes\n" | |
7995 | "Apply map to outbound routes\n") | |
718e3744 | 7996 | { |
c6685575 CS |
7997 | char base_xpath[XPATH_MAXLEN]; |
7998 | char af_xpath[XPATH_MAXLEN]; | |
7999 | char rmap_xpath[XPATH_MAXLEN]; | |
8000 | afi_t afi = bgp_node_afi(vty); | |
8001 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 8002 | |
c6685575 CS |
8003 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8004 | yang_afi_safi_value2identity(afi, safi)); | |
8005 | if (peer_and_group_lookup_nb(vty, neighbor_str, base_xpath, | |
8006 | sizeof(base_xpath), af_xpath) | |
8007 | < 0) | |
d62a17ae | 8008 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 8009 | |
c6685575 CS |
8010 | if (strmatch(direction, "in")) |
8011 | snprintf(rmap_xpath, sizeof(rmap_xpath), | |
8012 | "./%s/filter-config/rmap-import", | |
8013 | bgp_afi_safi_get_container_str(afi, safi)); | |
8014 | else if (strmatch(direction, "out")) | |
8015 | snprintf(rmap_xpath, sizeof(rmap_xpath), | |
8016 | "./%s/filter-config/rmap-export", | |
8017 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 8018 | |
c6685575 CS |
8019 | if (!no) { |
8020 | if (!yang_dnode_exists( | |
8021 | vty->candidate_config->dnode, | |
8022 | "/frr-route-map:lib/route-map[name='%s']", | |
8023 | rmap_str)) { | |
8024 | if (vty_shell_serv(vty)) | |
8025 | vty_out(vty, | |
8026 | "The route-map '%s' does not exist.\n", | |
8027 | rmap_str); | |
8028 | } | |
8029 | nb_cli_enqueue_change(vty, rmap_xpath, NB_OP_MODIFY, rmap_str); | |
8030 | } else | |
8031 | nb_cli_enqueue_change(vty, rmap_xpath, NB_OP_DESTROY, NULL); | |
718e3744 | 8032 | |
c6685575 | 8033 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8034 | } |
8035 | ||
718e3744 | 8036 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 8037 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
8038 | afi_t afi, safi_t safi, | |
8039 | const char *name_str) | |
718e3744 | 8040 | { |
d62a17ae | 8041 | int ret; |
8042 | struct peer *peer; | |
1de27621 | 8043 | struct route_map *route_map; |
718e3744 | 8044 | |
d62a17ae | 8045 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8046 | if (!peer) | |
8047 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8048 | |
1de27621 DA |
8049 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
8050 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 8051 | |
d62a17ae | 8052 | return bgp_vty_return(vty, ret); |
718e3744 | 8053 | } |
8054 | ||
8055 | /* Unset route-map from the peer. */ | |
d62a17ae | 8056 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
8057 | afi_t afi, safi_t safi) | |
718e3744 | 8058 | { |
d62a17ae | 8059 | int ret; |
8060 | struct peer *peer; | |
718e3744 | 8061 | |
d62a17ae | 8062 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8063 | if (!peer) | |
8064 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8065 | |
d62a17ae | 8066 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 8067 | |
d62a17ae | 8068 | return bgp_vty_return(vty, ret); |
718e3744 | 8069 | } |
8070 | ||
8071 | DEFUN (neighbor_unsuppress_map, | |
8072 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8073 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8074 | NEIGHBOR_STR |
8075 | NEIGHBOR_ADDR_STR2 | |
8076 | "Route-map to selectively unsuppress suppressed routes\n" | |
8077 | "Name of route map\n") | |
8078 | { | |
d62a17ae | 8079 | int idx_peer = 1; |
8080 | int idx_word = 3; | |
8081 | return peer_unsuppress_map_set_vty( | |
8082 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8083 | argv[idx_word]->arg); | |
718e3744 | 8084 | } |
8085 | ||
d62a17ae | 8086 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
8087 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8088 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8089 | "Route-map to selectively unsuppress suppressed routes\n" | |
8090 | "Name of route map\n") | |
596c17ba | 8091 | |
718e3744 | 8092 | DEFUN (no_neighbor_unsuppress_map, |
8093 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8095 | NO_STR |
8096 | NEIGHBOR_STR | |
8097 | NEIGHBOR_ADDR_STR2 | |
8098 | "Route-map to selectively unsuppress suppressed routes\n" | |
8099 | "Name of route map\n") | |
8100 | { | |
d62a17ae | 8101 | int idx_peer = 2; |
8102 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8103 | bgp_node_afi(vty), | |
8104 | bgp_node_safi(vty)); | |
718e3744 | 8105 | } |
6b0655a2 | 8106 | |
d62a17ae | 8107 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8108 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8109 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8110 | "Route-map to selectively unsuppress suppressed routes\n" | |
8111 | "Name of route map\n") | |
596c17ba | 8112 | |
fde246e8 | 8113 | /* Maximum number of prefix to be sent to the neighbor. */ |
232c75cd CS |
8114 | DEFUN_YANG(neighbor_maximum_prefix_out, |
8115 | neighbor_maximum_prefix_out_cmd, | |
8116 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8117 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8118 | "Maximum number of prefixes to be sent to this peer\n" | |
8119 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8120 | { |
04261dec CS |
8121 | char base_xpath[XPATH_MAXLEN]; |
8122 | char af_xpath[XPATH_MAXLEN]; | |
8123 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 DA |
8124 | int idx_peer = 1; |
8125 | int idx_number = 3; | |
fde246e8 DA |
8126 | afi_t afi = bgp_node_afi(vty); |
8127 | safi_t safi = bgp_node_safi(vty); | |
8128 | ||
04261dec CS |
8129 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8130 | yang_afi_safi_value2identity(afi, safi)); | |
8131 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8132 | sizeof(base_xpath), af_xpath) | |
8133 | < 0) | |
fde246e8 DA |
8134 | return CMD_WARNING_CONFIG_FAILED; |
8135 | ||
04261dec CS |
8136 | snprintf(attr_xpath, sizeof(attr_xpath), |
8137 | "/%s/prefix-limit/direction-list[direction='out']", | |
8138 | bgp_afi_safi_get_container_str(afi, safi)); | |
8139 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
fde246e8 | 8140 | |
04261dec | 8141 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
fde246e8 | 8142 | |
04261dec CS |
8143 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8144 | argv[idx_number]->arg); | |
8145 | ||
8146 | return nb_cli_apply_changes(vty, base_xpath); | |
fde246e8 DA |
8147 | } |
8148 | ||
232c75cd CS |
8149 | DEFUN_YANG(no_neighbor_maximum_prefix_out, |
8150 | no_neighbor_maximum_prefix_out_cmd, | |
8151 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
8152 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8153 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 | 8154 | { |
04261dec CS |
8155 | char base_xpath[XPATH_MAXLEN]; |
8156 | char af_xpath[XPATH_MAXLEN]; | |
8157 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 | 8158 | int idx_peer = 2; |
fde246e8 DA |
8159 | afi_t afi = bgp_node_afi(vty); |
8160 | safi_t safi = bgp_node_safi(vty); | |
8161 | ||
04261dec CS |
8162 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8163 | yang_afi_safi_value2identity(afi, safi)); | |
8164 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8165 | sizeof(base_xpath), af_xpath) | |
8166 | < 0) | |
fde246e8 DA |
8167 | return CMD_WARNING_CONFIG_FAILED; |
8168 | ||
04261dec CS |
8169 | snprintf(attr_xpath, sizeof(attr_xpath), |
8170 | "/%s/prefix-limit/direction-list[direction='out']", | |
8171 | bgp_afi_safi_get_container_str(afi, safi)); | |
8172 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8173 | ||
8174 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
fde246e8 | 8175 | |
04261dec | 8176 | return nb_cli_apply_changes(vty, base_xpath); |
fde246e8 DA |
8177 | } |
8178 | ||
9cbd06e0 DA |
8179 | /* Maximum number of prefix configuration. Prefix count is different |
8180 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8181 | each peer configuration. */ |
232c75cd CS |
8182 | DEFUN_YANG(neighbor_maximum_prefix, |
8183 | neighbor_maximum_prefix_cmd, | |
8184 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8185 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8186 | "Maximum number of prefix accept from this peer\n" | |
8187 | "maximum no. of prefix limit\n" | |
8188 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8189 | { |
d62a17ae | 8190 | int idx_peer = 1; |
8191 | int idx_number = 3; | |
9cbd06e0 | 8192 | int idx_force = 0; |
04261dec CS |
8193 | char base_xpath[XPATH_MAXLEN]; |
8194 | char af_xpath[XPATH_MAXLEN]; | |
8195 | char attr_xpath[XPATH_MAXLEN]; | |
8196 | afi_t afi = bgp_node_afi(vty); | |
8197 | safi_t safi = bgp_node_safi(vty); | |
8198 | ||
8199 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8200 | yang_afi_safi_value2identity(afi, safi)); | |
8201 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8202 | sizeof(base_xpath), af_xpath) | |
8203 | < 0) | |
8204 | return CMD_WARNING_CONFIG_FAILED; | |
8205 | ||
8206 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8207 | "/%s/prefix-limit/direction-list[direction='in']", | |
8208 | bgp_afi_safi_get_container_str(afi, safi)); | |
8209 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8210 | ||
8211 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
9cbd06e0 | 8212 | |
04261dec CS |
8213 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8214 | argv[idx_number]->arg); | |
9cbd06e0 | 8215 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8216 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8217 | "true"); | |
9cbd06e0 | 8218 | |
04261dec | 8219 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8220 | } |
8221 | ||
d62a17ae | 8222 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8223 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8224 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8225 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8226 | "maximum no. of prefix limit\n" |
8227 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8228 | |
232c75cd CS |
8229 | DEFUN_YANG(neighbor_maximum_prefix_threshold, |
8230 | neighbor_maximum_prefix_threshold_cmd, | |
8231 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8232 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8233 | "Maximum number of prefix accept from this peer\n" | |
8234 | "maximum no. of prefix limit\n" | |
8235 | "Threshold value (%) at which to generate a warning msg\n" | |
8236 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8237 | { |
d62a17ae | 8238 | int idx_peer = 1; |
8239 | int idx_number = 3; | |
8240 | int idx_number_2 = 4; | |
9cbd06e0 | 8241 | int idx_force = 0; |
04261dec CS |
8242 | char base_xpath[XPATH_MAXLEN]; |
8243 | char af_xpath[XPATH_MAXLEN]; | |
8244 | char attr_xpath[XPATH_MAXLEN]; | |
8245 | afi_t afi = bgp_node_afi(vty); | |
8246 | safi_t safi = bgp_node_safi(vty); | |
8247 | ||
8248 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8249 | yang_afi_safi_value2identity(afi, safi)); | |
8250 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8251 | sizeof(base_xpath), af_xpath) | |
8252 | < 0) | |
8253 | return CMD_WARNING_CONFIG_FAILED; | |
8254 | ||
8255 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8256 | "/%s/prefix-limit/direction-list[direction='in']", | |
8257 | bgp_afi_safi_get_container_str(afi, safi)); | |
8258 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8259 | ||
8260 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8261 | ||
8262 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8263 | argv[idx_number]->arg); | |
8264 | ||
8265 | nb_cli_enqueue_change(vty, "./options/shutdown-threshold-pct", | |
8266 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
9cbd06e0 DA |
8267 | |
8268 | if (argv_find(argv, argc, "force", &idx_force)) | |
04261dec CS |
8269 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8270 | "true"); | |
9cbd06e0 | 8271 | |
04261dec | 8272 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8273 | } |
e0701b79 | 8274 | |
d62a17ae | 8275 | ALIAS_HIDDEN( |
8276 | neighbor_maximum_prefix_threshold, | |
8277 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8278 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8279 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8280 | "Maximum number of prefix accept from this peer\n" | |
8281 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8282 | "Threshold value (%) at which to generate a warning msg\n" |
8283 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8284 | |
232c75cd CS |
8285 | DEFUN_YANG(neighbor_maximum_prefix_warning, |
8286 | neighbor_maximum_prefix_warning_cmd, | |
8287 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8288 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8289 | "Maximum number of prefix accept from this peer\n" | |
8290 | "maximum no. of prefix limit\n" | |
8291 | "Only give warning message when limit is exceeded\n" | |
8292 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8293 | { |
d62a17ae | 8294 | int idx_peer = 1; |
8295 | int idx_number = 3; | |
9cbd06e0 | 8296 | int idx_force = 0; |
04261dec CS |
8297 | char base_xpath[XPATH_MAXLEN]; |
8298 | char af_xpath[XPATH_MAXLEN]; | |
8299 | char attr_xpath[XPATH_MAXLEN]; | |
8300 | afi_t afi = bgp_node_afi(vty); | |
8301 | safi_t safi = bgp_node_safi(vty); | |
8302 | ||
8303 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8304 | yang_afi_safi_value2identity(afi, safi)); | |
8305 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8306 | sizeof(base_xpath), af_xpath) | |
8307 | < 0) | |
8308 | return CMD_WARNING_CONFIG_FAILED; | |
9cbd06e0 | 8309 | |
04261dec CS |
8310 | snprintf(attr_xpath, sizeof(attr_xpath), |
8311 | "/%s/prefix-limit/direction-list[direction='in']", | |
8312 | bgp_afi_safi_get_container_str(afi, safi)); | |
8313 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8314 | ||
8315 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8316 | ||
8317 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8318 | argv[idx_number]->arg); | |
8319 | ||
8320 | nb_cli_enqueue_change(vty, "./options/warning-only", NB_OP_MODIFY, | |
8321 | "true"); | |
9cbd06e0 | 8322 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8323 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8324 | "true"); | |
9cbd06e0 | 8325 | |
04261dec | 8326 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8327 | } |
8328 | ||
d62a17ae | 8329 | ALIAS_HIDDEN( |
8330 | neighbor_maximum_prefix_warning, | |
8331 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8332 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8333 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8334 | "Maximum number of prefix accept from this peer\n" | |
8335 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8336 | "Only give warning message when limit is exceeded\n" |
8337 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8338 | |
232c75cd CS |
8339 | DEFUN_YANG(neighbor_maximum_prefix_threshold_warning, |
8340 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8341 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8342 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8343 | "Maximum number of prefix accept from this peer\n" | |
8344 | "maximum no. of prefix limit\n" | |
8345 | "Threshold value (%) at which to generate a warning msg\n" | |
8346 | "Only give warning message when limit is exceeded\n" | |
8347 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8348 | { |
d62a17ae | 8349 | int idx_peer = 1; |
8350 | int idx_number = 3; | |
8351 | int idx_number_2 = 4; | |
9cbd06e0 | 8352 | int idx_force = 0; |
04261dec CS |
8353 | char base_xpath[XPATH_MAXLEN]; |
8354 | char af_xpath[XPATH_MAXLEN]; | |
8355 | char attr_xpath[XPATH_MAXLEN]; | |
8356 | afi_t afi = bgp_node_afi(vty); | |
8357 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8358 | |
04261dec CS |
8359 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8360 | yang_afi_safi_value2identity(afi, safi)); | |
8361 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8362 | sizeof(base_xpath), af_xpath) | |
8363 | < 0) | |
8364 | return CMD_WARNING_CONFIG_FAILED; | |
8365 | ||
8366 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8367 | "/%s/prefix-limit/direction-list[direction='in']", | |
8368 | bgp_afi_safi_get_container_str(afi, safi)); | |
8369 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8370 | ||
8371 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8372 | ||
8373 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8374 | argv[idx_number]->arg); | |
8375 | nb_cli_enqueue_change(vty, "./options/tw-shutdown-threshold-pct", | |
8376 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8377 | nb_cli_enqueue_change(vty, "./options/tw-warning-only", NB_OP_MODIFY, | |
8378 | "true"); | |
9cbd06e0 | 8379 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8380 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8381 | "true"); | |
9cbd06e0 | 8382 | |
04261dec | 8383 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8384 | } |
8385 | ||
d62a17ae | 8386 | ALIAS_HIDDEN( |
8387 | neighbor_maximum_prefix_threshold_warning, | |
8388 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8389 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8390 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8391 | "Maximum number of prefix accept from this peer\n" | |
8392 | "maximum no. of prefix limit\n" | |
8393 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8394 | "Only give warning message when limit is exceeded\n" |
8395 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8396 | |
232c75cd CS |
8397 | DEFUN_YANG(neighbor_maximum_prefix_restart, |
8398 | neighbor_maximum_prefix_restart_cmd, | |
8399 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8400 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8401 | "Maximum number of prefix accept from this peer\n" | |
8402 | "maximum no. of prefix limit\n" | |
8403 | "Restart bgp connection after limit is exceeded\n" | |
8404 | "Restart interval in minutes\n" | |
8405 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8406 | { |
d62a17ae | 8407 | int idx_peer = 1; |
8408 | int idx_number = 3; | |
8409 | int idx_number_2 = 5; | |
9cbd06e0 | 8410 | int idx_force = 0; |
04261dec CS |
8411 | char base_xpath[XPATH_MAXLEN]; |
8412 | char af_xpath[XPATH_MAXLEN]; | |
8413 | char attr_xpath[XPATH_MAXLEN]; | |
8414 | afi_t afi = bgp_node_afi(vty); | |
8415 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8416 | |
04261dec CS |
8417 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8418 | yang_afi_safi_value2identity(afi, safi)); | |
8419 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8420 | sizeof(base_xpath), af_xpath) | |
8421 | < 0) | |
8422 | return CMD_WARNING_CONFIG_FAILED; | |
8423 | ||
8424 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8425 | "/%s/prefix-limit/direction-list[direction='in']", | |
8426 | bgp_afi_safi_get_container_str(afi, safi)); | |
8427 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8428 | ||
8429 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8430 | ||
8431 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8432 | argv[idx_number]->arg); | |
8433 | nb_cli_enqueue_change(vty, "./options/restart-timer", NB_OP_MODIFY, | |
8434 | argv[idx_number_2]->arg); | |
9cbd06e0 | 8435 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8436 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8437 | "true"); | |
9cbd06e0 | 8438 | |
04261dec | 8439 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8440 | } |
8441 | ||
d62a17ae | 8442 | ALIAS_HIDDEN( |
8443 | neighbor_maximum_prefix_restart, | |
8444 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8445 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8446 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8447 | "Maximum number of prefix accept from this peer\n" | |
8448 | "maximum no. of prefix limit\n" | |
8449 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8450 | "Restart interval in minutes\n" |
8451 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8452 | |
232c75cd CS |
8453 | DEFUN_YANG(neighbor_maximum_prefix_threshold_restart, |
8454 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8455 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8456 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8457 | "Maximum number of prefixes to accept from this peer\n" | |
8458 | "maximum no. of prefix limit\n" | |
8459 | "Threshold value (%) at which to generate a warning msg\n" | |
8460 | "Restart bgp connection after limit is exceeded\n" | |
8461 | "Restart interval in minutes\n" | |
8462 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8463 | { |
d62a17ae | 8464 | int idx_peer = 1; |
8465 | int idx_number = 3; | |
8466 | int idx_number_2 = 4; | |
8467 | int idx_number_3 = 6; | |
9cbd06e0 | 8468 | int idx_force = 0; |
04261dec CS |
8469 | char base_xpath[XPATH_MAXLEN]; |
8470 | char af_xpath[XPATH_MAXLEN]; | |
8471 | char attr_xpath[XPATH_MAXLEN]; | |
8472 | afi_t afi = bgp_node_afi(vty); | |
8473 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8474 | |
04261dec CS |
8475 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8476 | yang_afi_safi_value2identity(afi, safi)); | |
8477 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8478 | sizeof(base_xpath), af_xpath) | |
8479 | < 0) | |
8480 | return CMD_WARNING_CONFIG_FAILED; | |
8481 | ||
8482 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8483 | "/%s/prefix-limit/direction-list[direction='in']", | |
8484 | bgp_afi_safi_get_container_str(afi, safi)); | |
8485 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8486 | ||
8487 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8488 | ||
8489 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8490 | argv[idx_number]->arg); | |
8491 | nb_cli_enqueue_change(vty, "./options/tr-shutdown-threshold-pct", | |
8492 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8493 | nb_cli_enqueue_change(vty, "./options/tr-restart-timer", NB_OP_MODIFY, | |
8494 | argv[idx_number_3]->arg); | |
9cbd06e0 | 8495 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8496 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8497 | "true"); | |
9cbd06e0 | 8498 | |
04261dec | 8499 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 8500 | } |
8501 | ||
8502 | ALIAS_HIDDEN( | |
8503 | neighbor_maximum_prefix_threshold_restart, | |
8504 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8505 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8506 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8507 | "Maximum number of prefixes to accept from this peer\n" | |
8508 | "maximum no. of prefix limit\n" | |
8509 | "Threshold value (%) at which to generate a warning msg\n" | |
8510 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8511 | "Restart interval in minutes\n" |
8512 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8513 | |
232c75cd CS |
8514 | DEFUN_YANG(no_neighbor_maximum_prefix, |
8515 | no_neighbor_maximum_prefix_cmd, | |
8516 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8517 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8518 | "Maximum number of prefixes to accept from this peer\n" | |
8519 | "maximum no. of prefix limit\n" | |
8520 | "Threshold value (%) at which to generate a warning msg\n" | |
8521 | "Restart bgp connection after limit is exceeded\n" | |
8522 | "Restart interval in minutes\n" | |
8523 | "Only give warning message when limit is exceeded\n" | |
8524 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8525 | { |
d62a17ae | 8526 | int idx_peer = 2; |
04261dec CS |
8527 | char base_xpath[XPATH_MAXLEN]; |
8528 | char af_xpath[XPATH_MAXLEN]; | |
8529 | char attr_xpath[XPATH_MAXLEN]; | |
8530 | afi_t afi = bgp_node_afi(vty); | |
8531 | safi_t safi = bgp_node_safi(vty); | |
8532 | ||
8533 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8534 | yang_afi_safi_value2identity(afi, safi)); | |
8535 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8536 | sizeof(base_xpath), af_xpath) | |
8537 | < 0) | |
8538 | return CMD_WARNING_CONFIG_FAILED; | |
8539 | ||
8540 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8541 | "/%s/prefix-limit/direction-list[direction='in']", | |
8542 | bgp_afi_safi_get_container_str(afi, safi)); | |
8543 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8544 | ||
8545 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
8546 | ||
8547 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 8548 | } |
e52702f2 | 8549 | |
d62a17ae | 8550 | ALIAS_HIDDEN( |
8551 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8552 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8553 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8554 | "Maximum number of prefixes to accept from this peer\n" | |
8555 | "maximum no. of prefix limit\n" | |
8556 | "Threshold value (%) at which to generate a warning msg\n" | |
8557 | "Restart bgp connection after limit is exceeded\n" | |
8558 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8559 | "Only give warning message when limit is exceeded\n" |
8560 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8561 | |
718e3744 | 8562 | |
718e3744 | 8563 | /* "neighbor allowas-in" */ |
8564 | DEFUN (neighbor_allowas_in, | |
8565 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8566 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8567 | NEIGHBOR_STR |
8568 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8569 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8570 | "Number of occurrences of AS number\n" |
fd8503f5 | 8571 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8572 | { |
d62a17ae | 8573 | int idx_peer = 1; |
8574 | int idx_number_origin = 3; | |
8575 | int ret; | |
8576 | int origin = 0; | |
8577 | struct peer *peer; | |
8578 | int allow_num = 0; | |
8579 | ||
8580 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8581 | if (!peer) | |
8582 | return CMD_WARNING_CONFIG_FAILED; | |
8583 | ||
8584 | if (argc <= idx_number_origin) | |
8585 | allow_num = 3; | |
8586 | else { | |
8587 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8588 | origin = 1; | |
8589 | else | |
8590 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8591 | } | |
8592 | ||
8593 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8594 | allow_num, origin); | |
8595 | ||
8596 | return bgp_vty_return(vty, ret); | |
8597 | } | |
8598 | ||
8599 | ALIAS_HIDDEN( | |
8600 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8601 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8602 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8603 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8604 | "Number of occurrences of AS number\n" |
d62a17ae | 8605 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8606 | |
718e3744 | 8607 | DEFUN (no_neighbor_allowas_in, |
8608 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8610 | NO_STR |
8611 | NEIGHBOR_STR | |
8612 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8613 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8614 | "Number of occurrences of AS number\n" |
fd8503f5 | 8615 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8616 | { |
d62a17ae | 8617 | int idx_peer = 2; |
8618 | int ret; | |
8619 | struct peer *peer; | |
718e3744 | 8620 | |
d62a17ae | 8621 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8622 | if (!peer) | |
8623 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8624 | |
d62a17ae | 8625 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8626 | bgp_node_safi(vty)); | |
718e3744 | 8627 | |
d62a17ae | 8628 | return bgp_vty_return(vty, ret); |
718e3744 | 8629 | } |
6b0655a2 | 8630 | |
d62a17ae | 8631 | ALIAS_HIDDEN( |
8632 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8633 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8634 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8635 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8636 | "Number of occurrences of AS number\n" |
d62a17ae | 8637 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8638 | |
f4b8ec07 CS |
8639 | DEFUN_YANG (neighbor_ttl_security, |
8640 | neighbor_ttl_security_cmd, | |
8641 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8642 | NEIGHBOR_STR | |
8643 | NEIGHBOR_ADDR_STR2 | |
8644 | "BGP ttl-security parameters\n" | |
8645 | "Specify the maximum number of hops to the BGP peer\n" | |
8646 | "Number of hops to BGP peer\n") | |
fa411a21 | 8647 | { |
d62a17ae | 8648 | int idx_peer = 1; |
8649 | int idx_number = 4; | |
f4b8ec07 | 8650 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 8651 | |
f4b8ec07 CS |
8652 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8653 | sizeof(base_xpath), NULL) | |
8654 | < 0) | |
d62a17ae | 8655 | return CMD_WARNING_CONFIG_FAILED; |
8656 | ||
f4b8ec07 CS |
8657 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_MODIFY, |
8658 | argv[idx_number]->arg); | |
7ebe625c | 8659 | |
f4b8ec07 | 8660 | return nb_cli_apply_changes(vty, base_xpath); |
fa411a21 NH |
8661 | } |
8662 | ||
232c75cd CS |
8663 | DEFUN_YANG(no_neighbor_ttl_security, |
8664 | no_neighbor_ttl_security_cmd, | |
8665 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8666 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8667 | "BGP ttl-security parameters\n" | |
8668 | "Specify the maximum number of hops to the BGP peer\n" | |
8669 | "Number of hops to BGP peer\n") | |
fa411a21 | 8670 | { |
d62a17ae | 8671 | int idx_peer = 2; |
f4b8ec07 | 8672 | char base_xpath[XPATH_MAXLEN]; |
fa411a21 | 8673 | |
f4b8ec07 CS |
8674 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8675 | sizeof(base_xpath), NULL) | |
8676 | < 0) | |
d62a17ae | 8677 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8678 | |
f4b8ec07 CS |
8679 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_DESTROY, NULL); |
8680 | ||
8681 | return nb_cli_apply_changes(vty, base_xpath); | |
fa411a21 | 8682 | } |
6b0655a2 | 8683 | |
adbac85e DW |
8684 | DEFUN (neighbor_addpath_tx_all_paths, |
8685 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8686 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8687 | NEIGHBOR_STR |
8688 | NEIGHBOR_ADDR_STR2 | |
8689 | "Use addpath to advertise all paths to a neighbor\n") | |
8690 | { | |
d62a17ae | 8691 | int idx_peer = 1; |
8692 | struct peer *peer; | |
adbac85e | 8693 | |
d62a17ae | 8694 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8695 | if (!peer) | |
8696 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8697 | |
dcc68b5e MS |
8698 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8699 | BGP_ADDPATH_ALL); | |
8700 | return CMD_SUCCESS; | |
adbac85e DW |
8701 | } |
8702 | ||
d62a17ae | 8703 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8704 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8705 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8706 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8707 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8708 | |
adbac85e DW |
8709 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8710 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8711 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8712 | NO_STR |
8713 | NEIGHBOR_STR | |
8714 | NEIGHBOR_ADDR_STR2 | |
8715 | "Use addpath to advertise all paths to a neighbor\n") | |
8716 | { | |
d62a17ae | 8717 | int idx_peer = 2; |
dcc68b5e MS |
8718 | struct peer *peer; |
8719 | ||
8720 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8721 | if (!peer) | |
8722 | return CMD_WARNING_CONFIG_FAILED; | |
8723 | ||
8724 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8725 | != BGP_ADDPATH_ALL) { | |
8726 | vty_out(vty, | |
8727 | "%% Peer not currently configured to transmit all paths."); | |
8728 | return CMD_WARNING_CONFIG_FAILED; | |
8729 | } | |
8730 | ||
8731 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8732 | BGP_ADDPATH_NONE); | |
8733 | ||
8734 | return CMD_SUCCESS; | |
adbac85e DW |
8735 | } |
8736 | ||
d62a17ae | 8737 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8738 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8740 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8741 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8742 | |
06370dac DW |
8743 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8744 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8745 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8746 | NEIGHBOR_STR |
8747 | NEIGHBOR_ADDR_STR2 | |
8748 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8749 | { | |
d62a17ae | 8750 | int idx_peer = 1; |
8751 | struct peer *peer; | |
06370dac | 8752 | |
d62a17ae | 8753 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8754 | if (!peer) | |
8755 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8756 | |
dcc68b5e MS |
8757 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8758 | BGP_ADDPATH_BEST_PER_AS); | |
8759 | ||
8760 | return CMD_SUCCESS; | |
06370dac DW |
8761 | } |
8762 | ||
d62a17ae | 8763 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8764 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8765 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8766 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8767 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8768 | |
06370dac DW |
8769 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8770 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8771 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8772 | NO_STR |
8773 | NEIGHBOR_STR | |
8774 | NEIGHBOR_ADDR_STR2 | |
8775 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8776 | { | |
d62a17ae | 8777 | int idx_peer = 2; |
dcc68b5e MS |
8778 | struct peer *peer; |
8779 | ||
8780 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8781 | if (!peer) | |
8782 | return CMD_WARNING_CONFIG_FAILED; | |
8783 | ||
8784 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8785 | != BGP_ADDPATH_BEST_PER_AS) { | |
8786 | vty_out(vty, | |
8787 | "%% Peer not currently configured to transmit all best path per as."); | |
8788 | return CMD_WARNING_CONFIG_FAILED; | |
8789 | } | |
8790 | ||
8791 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8792 | BGP_ADDPATH_NONE); | |
8793 | ||
8794 | return CMD_SUCCESS; | |
06370dac DW |
8795 | } |
8796 | ||
d62a17ae | 8797 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8798 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8800 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8801 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8802 | |
2b31007c RZ |
8803 | DEFPY( |
8804 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8805 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8806 | NEIGHBOR_STR | |
8807 | NEIGHBOR_ADDR_STR2 | |
8808 | "Detect AS loops before sending to neighbor\n") | |
8809 | { | |
8810 | struct peer *peer; | |
8811 | ||
8812 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8813 | if (!peer) | |
8814 | return CMD_WARNING_CONFIG_FAILED; | |
8815 | ||
8816 | peer->as_path_loop_detection = true; | |
8817 | ||
8818 | return CMD_SUCCESS; | |
8819 | } | |
8820 | ||
8821 | DEFPY( | |
8822 | no_neighbor_aspath_loop_detection, | |
8823 | no_neighbor_aspath_loop_detection_cmd, | |
8824 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8825 | NO_STR | |
8826 | NEIGHBOR_STR | |
8827 | NEIGHBOR_ADDR_STR2 | |
8828 | "Detect AS loops before sending to neighbor\n") | |
8829 | { | |
8830 | struct peer *peer; | |
8831 | ||
8832 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8833 | if (!peer) | |
8834 | return CMD_WARNING_CONFIG_FAILED; | |
8835 | ||
8836 | peer->as_path_loop_detection = false; | |
8837 | ||
8838 | return CMD_SUCCESS; | |
8839 | } | |
8840 | ||
0221327c DS |
8841 | DEFPY(neighbor_damp, |
8842 | neighbor_damp_cmd, | |
8843 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]", | |
8844 | NEIGHBOR_STR | |
8845 | NEIGHBOR_ADDR_STR2 | |
8846 | "Enable neighbor route-flap dampening\n" | |
8847 | "Half-life time for the penalty\n" | |
8848 | "Value to start reusing a route\n" | |
8849 | "Value to start suppressing a route\n" | |
8850 | "Maximum duration to suppress a stable route\n") | |
8851 | { | |
8852 | struct peer *peer = peer_and_group_lookup_vty(vty, neighbor); | |
8853 | ||
8854 | if (!peer) | |
8855 | return CMD_WARNING_CONFIG_FAILED; | |
8856 | if (!half) | |
8857 | half = DEFAULT_HALF_LIFE; | |
8858 | if (!reuse) { | |
8859 | reuse = DEFAULT_REUSE; | |
8860 | suppress = DEFAULT_SUPPRESS; | |
8861 | max = half * 4; | |
8862 | } | |
8863 | if (suppress < reuse) { | |
8864 | vty_out(vty, | |
8865 | "Suppress value cannot be less than reuse value\n"); | |
8866 | return CMD_WARNING_CONFIG_FAILED; | |
8867 | } | |
8868 | bgp_peer_damp_enable(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8869 | half * 60, reuse, suppress, max * 60); | |
8870 | return CMD_SUCCESS; | |
8871 | } | |
8872 | ||
8873 | DEFPY(no_neighbor_damp, | |
8874 | no_neighbor_damp_cmd, | |
8875 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]", | |
8876 | NO_STR | |
8877 | NEIGHBOR_STR | |
8878 | NEIGHBOR_ADDR_STR2 | |
8879 | "Enable neighbor route-flap dampening\n" | |
8880 | "Half-life time for the penalty\n" | |
8881 | "Value to start reusing a route\n" | |
8882 | "Value to start suppressing a route\n" | |
8883 | "Maximum duration to suppress a stable route\n") | |
8884 | { | |
8885 | struct peer *peer = peer_and_group_lookup_vty(vty, neighbor); | |
8886 | ||
8887 | if (!peer) | |
8888 | return CMD_WARNING_CONFIG_FAILED; | |
8889 | bgp_peer_damp_disable(peer, bgp_node_afi(vty), bgp_node_safi(vty)); | |
8890 | return CMD_SUCCESS; | |
8891 | } | |
8892 | ||
8893 | DEFPY (show_ip_bgp_neighbor_damp_param, | |
8894 | show_ip_bgp_neighbor_damp_param_cmd, | |
8895 | "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json", | |
8896 | SHOW_STR | |
8897 | IP_STR | |
8898 | BGP_STR | |
8899 | BGP_AFI_HELP_STR | |
8900 | "Address Family modifier\n" | |
8901 | NEIGHBOR_STR | |
8902 | NEIGHBOR_ADDR_STR2 | |
8903 | "Neighbor route-flap dampening information\n" | |
8904 | "Display detail of configured dampening parameters\n" | |
8905 | JSON_STR) | |
8906 | { | |
8907 | bool use_json = false; | |
8908 | int idx = 0; | |
8909 | afi_t afi = AFI_IP; | |
8910 | safi_t safi = SAFI_UNICAST; | |
8911 | struct peer *peer; | |
8912 | ||
8913 | if (argv_find(argv, argc, "ip", &idx)) | |
8914 | afi = AFI_IP; | |
8915 | if (argv_find(argv, argc, "ipv4", &idx)) | |
8916 | afi = AFI_IP; | |
8917 | if (argv_find(argv, argc, "ipv6", &idx)) | |
8918 | afi = AFI_IP6; | |
8919 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8920 | if (!peer) | |
8921 | return CMD_WARNING; | |
8922 | if (json) | |
8923 | use_json = true; | |
8924 | bgp_show_peer_dampening_parameters(vty, peer, afi, safi, use_json); | |
8925 | return CMD_SUCCESS; | |
8926 | } | |
8927 | ||
b9c7bc5a | 8928 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8929 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8930 | { |
b9c7bc5a PZ |
8931 | struct ecommunity *ecom = NULL; |
8932 | struct ecommunity *ecomadd; | |
ddb5b488 | 8933 | |
b9c7bc5a | 8934 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8935 | if (is_rt6) |
8936 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8937 | ECOMMUNITY_ROUTE_TARGET, | |
8938 | 0); | |
8939 | else | |
8940 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8941 | ECOMMUNITY_ROUTE_TARGET, | |
8942 | 0); | |
b9c7bc5a PZ |
8943 | if (!ecomadd) { |
8944 | vty_out(vty, "Malformed community-list value\n"); | |
8945 | if (ecom) | |
8946 | ecommunity_free(&ecom); | |
8947 | return CMD_WARNING_CONFIG_FAILED; | |
8948 | } | |
ddb5b488 | 8949 | |
b9c7bc5a PZ |
8950 | if (ecom) { |
8951 | ecommunity_merge(ecom, ecomadd); | |
8952 | ecommunity_free(&ecomadd); | |
8953 | } else { | |
8954 | ecom = ecomadd; | |
8955 | } | |
8956 | } | |
8957 | ||
8958 | if (*list) { | |
8959 | ecommunity_free(&*list); | |
ddb5b488 | 8960 | } |
b9c7bc5a PZ |
8961 | *list = ecom; |
8962 | ||
8963 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8964 | } |
8965 | ||
37a87b8f CS |
8966 | bool vpn_policy_check_import(struct bgp *bgp, afi_t afi, safi_t safi, |
8967 | bool v2vimport, char *errmsg, size_t errmsg_len) | |
8968 | { | |
8969 | if (!v2vimport) { | |
8970 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8971 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8972 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8973 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8974 | snprintf( | |
8975 | errmsg, errmsg_len, "%s", | |
8976 | "%% error: Please unconfigure import vrf commands before using vpn commands"); | |
8977 | return false; | |
8978 | } | |
8979 | } else { | |
8980 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8981 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8982 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8983 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8984 | snprintf( | |
8985 | errmsg, errmsg_len, "%s", | |
8986 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands"); | |
8987 | return false; | |
8988 | } | |
8989 | } | |
8990 | return true; | |
8991 | } | |
8992 | ||
0ca70ba5 DS |
8993 | /* |
8994 | * v2vimport is true if we are handling a `import vrf ...` command | |
8995 | */ | |
8996 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8997 | { |
0ca70ba5 DS |
8998 | afi_t afi; |
8999 | ||
ddb5b488 | 9000 | switch (vty->node) { |
b9c7bc5a | 9001 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
9002 | afi = AFI_IP; |
9003 | break; | |
b9c7bc5a | 9004 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
9005 | afi = AFI_IP6; |
9006 | break; | |
ddb5b488 PZ |
9007 | default: |
9008 | vty_out(vty, | |
b9c7bc5a | 9009 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 9010 | return AFI_MAX; |
ddb5b488 | 9011 | } |
69b07479 | 9012 | |
0ca70ba5 DS |
9013 | if (!v2vimport) { |
9014 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9015 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
9016 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9017 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
9018 | vty_out(vty, | |
9019 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
9020 | return AFI_MAX; | |
9021 | } | |
9022 | } else { | |
9023 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9024 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
9025 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9026 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
9027 | vty_out(vty, | |
9028 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
9029 | return AFI_MAX; | |
9030 | } | |
9031 | } | |
9032 | return afi; | |
ddb5b488 PZ |
9033 | } |
9034 | ||
37a87b8f CS |
9035 | DEFPY_YANG( |
9036 | af_rd_vpn_export, | |
9037 | af_rd_vpn_export_cmd, | |
9038 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
9039 | NO_STR | |
9040 | "Specify route distinguisher\n" | |
9041 | "Between current address-family and vpn\n" | |
9042 | "For routes leaked from current address-family to vpn\n" | |
9043 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 9044 | { |
37a87b8f | 9045 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9046 | afi_t afi; |
37a87b8f | 9047 | safi_t safi; |
b9c7bc5a | 9048 | int idx = 0; |
b9c7bc5a | 9049 | |
37a87b8f CS |
9050 | afi = bgp_node_afi(vty); |
9051 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9052 | |
37a87b8f CS |
9053 | snprintf( |
9054 | base_xpath, sizeof(base_xpath), | |
9055 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9056 | yang_afi_safi_value2identity(afi, safi), | |
9057 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 9058 | |
37a87b8f CS |
9059 | if (argv_find(argv, argc, "no", &idx)) |
9060 | nb_cli_enqueue_change(vty, "./rd", NB_OP_DESTROY, NULL); | |
9061 | else | |
9062 | nb_cli_enqueue_change(vty, "./rd", NB_OP_MODIFY, rd_str); | |
ddb5b488 | 9063 | |
37a87b8f CS |
9064 | return nb_cli_apply_changes(vty, base_xpath); |
9065 | } | |
ddb5b488 | 9066 | |
37a87b8f CS |
9067 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd( |
9068 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9069 | { | |
9070 | int indent = 2; | |
69b07479 | 9071 | |
37a87b8f CS |
9072 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
9073 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9074 | } |
9075 | ||
b9c7bc5a PZ |
9076 | ALIAS (af_rd_vpn_export, |
9077 | af_no_rd_vpn_export_cmd, | |
9078 | "no rd vpn export", | |
ddb5b488 | 9079 | NO_STR |
b9c7bc5a PZ |
9080 | "Specify route distinguisher\n" |
9081 | "Between current address-family and vpn\n" | |
9082 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9083 | |
b9c7bc5a PZ |
9084 | DEFPY (af_label_vpn_export, |
9085 | af_label_vpn_export_cmd, | |
e70e9f8e | 9086 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 9087 | NO_STR |
ddb5b488 | 9088 | "label value for VRF\n" |
b9c7bc5a PZ |
9089 | "Between current address-family and vpn\n" |
9090 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
9091 | "Label Value <0-1048575>\n" |
9092 | "Automatically assign a label\n") | |
ddb5b488 PZ |
9093 | { |
9094 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 9095 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 9096 | afi_t afi; |
b9c7bc5a | 9097 | int idx = 0; |
c6423c31 | 9098 | bool yes = true; |
b9c7bc5a PZ |
9099 | |
9100 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9101 | yes = false; |
ddb5b488 | 9102 | |
21a16cc2 PZ |
9103 | /* If "no ...", squash trailing parameter */ |
9104 | if (!yes) | |
9105 | label_auto = NULL; | |
9106 | ||
e70e9f8e PZ |
9107 | if (yes) { |
9108 | if (!label_auto) | |
9109 | label = label_val; /* parser should force unsigned */ | |
9110 | } | |
ddb5b488 | 9111 | |
0ca70ba5 | 9112 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9113 | if (afi == AFI_MAX) |
9114 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 9115 | |
e70e9f8e | 9116 | |
69b07479 DS |
9117 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
9118 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
9119 | /* no change */ | |
9120 | return CMD_SUCCESS; | |
e70e9f8e | 9121 | |
69b07479 DS |
9122 | /* |
9123 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9124 | */ | |
9125 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9126 | bgp_get_default(), bgp); | |
9127 | ||
9128 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9129 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
9130 | ||
9131 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
9132 | ||
9133 | /* | |
9134 | * label has previously been automatically | |
9135 | * assigned by labelpool: release it | |
9136 | * | |
9137 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
9138 | * means the automatic assignment is in flight | |
9139 | * and therefore the labelpool callback must | |
9140 | * detect that the auto label is not needed. | |
9141 | */ | |
9142 | ||
9143 | bgp_lp_release(LP_TYPE_VRF, | |
9144 | &bgp->vpn_policy[afi], | |
9145 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 9146 | } |
69b07479 DS |
9147 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
9148 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9149 | } | |
ddb5b488 | 9150 | |
69b07479 DS |
9151 | bgp->vpn_policy[afi].tovpn_label = label; |
9152 | if (label_auto) { | |
9153 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9154 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9155 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
9156 | vpn_leak_label_callback); | |
ddb5b488 PZ |
9157 | } |
9158 | ||
69b07479 DS |
9159 | /* post-change: re-export vpn routes */ |
9160 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9161 | bgp_get_default(), bgp); | |
9162 | ||
0d020cd6 | 9163 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
9164 | return CMD_SUCCESS; |
9165 | } | |
9166 | ||
b9c7bc5a PZ |
9167 | ALIAS (af_label_vpn_export, |
9168 | af_no_label_vpn_export_cmd, | |
9169 | "no label vpn export", | |
9170 | NO_STR | |
9171 | "label value for VRF\n" | |
9172 | "Between current address-family and vpn\n" | |
9173 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9174 | |
37a87b8f | 9175 | DEFPY_YANG (af_nexthop_vpn_export, |
b9c7bc5a | 9176 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9177 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9178 | NO_STR |
ddb5b488 | 9179 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9180 | "Between current address-family and vpn\n" |
9181 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9182 | "IPv4 prefix\n" |
9183 | "IPv6 prefix\n") | |
9184 | { | |
37a87b8f | 9185 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9186 | afi_t afi; |
37a87b8f CS |
9187 | safi_t safi; |
9188 | int idx = 0; | |
ddb5b488 PZ |
9189 | struct prefix p; |
9190 | ||
8c85ca28 QY |
9191 | if (!no) { |
9192 | if (!nexthop_su) { | |
9193 | vty_out(vty, "%% Nexthop required\n"); | |
9194 | return CMD_WARNING_CONFIG_FAILED; | |
9195 | } | |
8c85ca28 | 9196 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9197 | return CMD_WARNING_CONFIG_FAILED; |
9198 | } | |
ddb5b488 | 9199 | |
37a87b8f CS |
9200 | afi = bgp_node_afi(vty); |
9201 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9202 | |
37a87b8f CS |
9203 | snprintf( |
9204 | base_xpath, sizeof(base_xpath), | |
9205 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9206 | yang_afi_safi_value2identity(afi, safi), | |
9207 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 9208 | |
37a87b8f CS |
9209 | if (argv_find(argv, argc, "no", &idx)) |
9210 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_DESTROY, NULL); | |
9211 | else | |
9212 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_MODIFY, | |
9213 | nexthop_su_str); | |
ddb5b488 | 9214 | |
37a87b8f CS |
9215 | return nb_cli_apply_changes(vty, base_xpath); |
9216 | } | |
69b07479 | 9217 | |
37a87b8f CS |
9218 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop( |
9219 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9220 | { | |
9221 | int indent = 2; | |
9222 | ||
9223 | vty_out(vty, "%*snexthop vpn export %s\n", indent, "", | |
9224 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9225 | } |
9226 | ||
b9c7bc5a | 9227 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9228 | { |
b9c7bc5a PZ |
9229 | if (!strcmp(dstr, "import")) { |
9230 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9231 | } else if (!strcmp(dstr, "export")) { | |
9232 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9233 | } else if (!strcmp(dstr, "both")) { | |
9234 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9235 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9236 | } else { | |
9237 | vty_out(vty, "%% direction parse error\n"); | |
9238 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9239 | } |
ddb5b488 PZ |
9240 | return CMD_SUCCESS; |
9241 | } | |
9242 | ||
b9c7bc5a PZ |
9243 | DEFPY (af_rt_vpn_imexport, |
9244 | af_rt_vpn_imexport_cmd, | |
9245 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9246 | NO_STR | |
9247 | "Specify route target list\n" | |
ddb5b488 | 9248 | "Specify route target list\n" |
b9c7bc5a PZ |
9249 | "Between current address-family and vpn\n" |
9250 | "For routes leaked from vpn to current address-family: match any\n" | |
9251 | "For routes leaked from current address-family to vpn: set\n" | |
9252 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9253 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9254 | { | |
9255 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9256 | int ret; | |
9257 | struct ecommunity *ecom = NULL; | |
9258 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
9259 | vpn_policy_direction_t dir; |
9260 | afi_t afi; | |
9261 | int idx = 0; | |
c6423c31 | 9262 | bool yes = true; |
ddb5b488 | 9263 | |
b9c7bc5a | 9264 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9265 | yes = false; |
b9c7bc5a | 9266 | |
0ca70ba5 | 9267 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9268 | if (afi == AFI_MAX) |
9269 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9270 | |
b9c7bc5a | 9271 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9272 | if (ret != CMD_SUCCESS) |
9273 | return ret; | |
9274 | ||
b9c7bc5a PZ |
9275 | if (yes) { |
9276 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9277 | vty_out(vty, "%% Missing RTLIST\n"); | |
9278 | return CMD_WARNING_CONFIG_FAILED; | |
9279 | } | |
c6423c31 | 9280 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9281 | if (ret != CMD_SUCCESS) { |
9282 | return ret; | |
9283 | } | |
ddb5b488 PZ |
9284 | } |
9285 | ||
69b07479 DS |
9286 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9287 | if (!dodir[dir]) | |
ddb5b488 | 9288 | continue; |
ddb5b488 | 9289 | |
69b07479 | 9290 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9291 | |
69b07479 DS |
9292 | if (yes) { |
9293 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9294 | ecommunity_free( | |
9295 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9296 | bgp->vpn_policy[afi].rtlist[dir] = | |
9297 | ecommunity_dup(ecom); | |
9298 | } else { | |
9299 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9300 | ecommunity_free( | |
9301 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9302 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9303 | } |
69b07479 DS |
9304 | |
9305 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9306 | } |
69b07479 | 9307 | |
d555f3e9 PZ |
9308 | if (ecom) |
9309 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9310 | |
9311 | return CMD_SUCCESS; | |
9312 | } | |
9313 | ||
b9c7bc5a PZ |
9314 | ALIAS (af_rt_vpn_imexport, |
9315 | af_no_rt_vpn_imexport_cmd, | |
9316 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9317 | NO_STR |
9318 | "Specify route target list\n" | |
b9c7bc5a PZ |
9319 | "Specify route target list\n" |
9320 | "Between current address-family and vpn\n" | |
9321 | "For routes leaked from vpn to current address-family\n" | |
9322 | "For routes leaked from current address-family to vpn\n" | |
9323 | "both import and export\n") | |
9324 | ||
37a87b8f | 9325 | DEFPY_YANG (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9326 | af_route_map_vpn_imexport_cmd, |
9327 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9328 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9329 | NO_STR | |
ddb5b488 | 9330 | "Specify route map\n" |
b9c7bc5a PZ |
9331 | "Between current address-family and vpn\n" |
9332 | "For routes leaked from vpn to current address-family\n" | |
9333 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9334 | "name of route-map\n") |
9335 | { | |
37a87b8f | 9336 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9337 | afi_t afi; |
37a87b8f | 9338 | safi_t safi; |
ddb5b488 | 9339 | int idx = 0; |
ddb5b488 | 9340 | |
37a87b8f CS |
9341 | afi = bgp_node_afi(vty); |
9342 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9343 | |
37a87b8f CS |
9344 | snprintf( |
9345 | base_xpath, sizeof(base_xpath), | |
9346 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9347 | yang_afi_safi_value2identity(afi, safi), | |
9348 | bgp_afi_safi_get_container_str(afi, safi)); | |
9349 | ||
9350 | if (argv_find(argv, argc, "no", &idx)) { | |
9351 | if (!strcmp(direction_str, "import")) | |
9352 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9353 | NB_OP_DESTROY, NULL); | |
9354 | else if (!strcmp(direction_str, "export")) | |
9355 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9356 | NB_OP_DESTROY, NULL); | |
9357 | } else { | |
9358 | if (!strcmp(direction_str, "import")) | |
9359 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9360 | NB_OP_MODIFY, rmap_str); | |
9361 | if (!strcmp(direction_str, "export")) | |
9362 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9363 | NB_OP_MODIFY, rmap_str); | |
9364 | } | |
9365 | return nb_cli_apply_changes(vty, base_xpath); | |
9366 | } | |
ddb5b488 | 9367 | |
37a87b8f CS |
9368 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import( |
9369 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9370 | { | |
9371 | int indent = 2; | |
ddb5b488 | 9372 | |
37a87b8f CS |
9373 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9374 | yang_dnode_get_string(dnode, NULL)); | |
9375 | } | |
69b07479 | 9376 | |
37a87b8f CS |
9377 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export( |
9378 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9379 | { | |
9380 | int indent = 2; | |
ddb5b488 | 9381 | |
37a87b8f CS |
9382 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9383 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9384 | } |
9385 | ||
b9c7bc5a PZ |
9386 | ALIAS (af_route_map_vpn_imexport, |
9387 | af_no_route_map_vpn_imexport_cmd, | |
9388 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9389 | NO_STR |
9390 | "Specify route map\n" | |
b9c7bc5a PZ |
9391 | "Between current address-family and vpn\n" |
9392 | "For routes leaked from vpn to current address-family\n" | |
9393 | "For routes leaked from current address-family to vpn\n") | |
9394 | ||
bb4f6190 | 9395 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9396 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9397 | "Import routes from another VRF\n" |
9398 | "Vrf routes being filtered\n" | |
9399 | "Specify route map\n" | |
9400 | "name of route-map\n") | |
9401 | { | |
9402 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
9403 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
9404 | afi_t afi; | |
bb4f6190 DS |
9405 | struct bgp *bgp_default; |
9406 | ||
0ca70ba5 | 9407 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9408 | if (afi == AFI_MAX) |
9409 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9410 | |
9411 | bgp_default = bgp_get_default(); | |
9412 | if (!bgp_default) { | |
9413 | int32_t ret; | |
9414 | as_t as = bgp->as; | |
9415 | ||
9416 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9417 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9418 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9419 | |
9420 | if (ret) { | |
9421 | vty_out(vty, | |
9422 | "VRF default is not configured as a bgp instance\n"); | |
9423 | return CMD_WARNING; | |
9424 | } | |
9425 | } | |
9426 | ||
69b07479 | 9427 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9428 | |
ae6a6fb4 DS |
9429 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9430 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9431 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9432 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9433 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9434 | bgp->vpn_policy[afi].rmap[dir] = | |
9435 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9436 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9437 | return CMD_SUCCESS; | |
9438 | ||
9439 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9440 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9441 | |
69b07479 DS |
9442 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9443 | ||
bb4f6190 DS |
9444 | return CMD_SUCCESS; |
9445 | } | |
9446 | ||
ae6a6fb4 DS |
9447 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9448 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9449 | NO_STR |
9450 | "Import routes from another VRF\n" | |
9451 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9452 | "Specify route map\n" |
9453 | "name of route-map\n") | |
9454 | { | |
9455 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9456 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
9457 | afi_t afi; | |
9458 | ||
9459 | afi = vpn_policy_getafi(vty, bgp, true); | |
9460 | if (afi == AFI_MAX) | |
9461 | return CMD_WARNING_CONFIG_FAILED; | |
9462 | ||
9463 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9464 | ||
9465 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9466 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9467 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9468 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9469 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9470 | ||
9471 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9472 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9473 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9474 | ||
9475 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9476 | ||
9477 | return CMD_SUCCESS; | |
9478 | } | |
bb4f6190 | 9479 | |
37a87b8f CS |
9480 | DEFPY_YANG(bgp_imexport_vrf, |
9481 | bgp_imexport_vrf_cmd, | |
9482 | "[no] import vrf VIEWVRFNAME$import_name", | |
9483 | NO_STR | |
9484 | "Import routes from another VRF\n" | |
9485 | "VRF to import from\n" | |
9486 | "The name of the VRF\n") | |
12a844a5 | 9487 | { |
37a87b8f | 9488 | char base_xpath[XPATH_MAXLEN]; |
12a844a5 DS |
9489 | safi_t safi; |
9490 | afi_t afi; | |
37a87b8f | 9491 | int32_t idx = 0; |
12a844a5 | 9492 | |
867f0cca | 9493 | if (import_name == NULL) { |
9494 | vty_out(vty, "%% Missing import name\n"); | |
9495 | return CMD_WARNING; | |
9496 | } | |
9497 | ||
ae6a6fb4 DS |
9498 | if (strcmp(import_name, "route-map") == 0) { |
9499 | vty_out(vty, "%% Must include route-map name\n"); | |
9500 | return CMD_WARNING; | |
9501 | } | |
9502 | ||
37a87b8f | 9503 | afi = bgp_node_afi(vty); |
12a844a5 DS |
9504 | safi = bgp_node_safi(vty); |
9505 | ||
37a87b8f CS |
9506 | snprintf( |
9507 | base_xpath, sizeof(base_xpath), | |
9508 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']", | |
9509 | yang_afi_safi_value2identity(afi, safi), | |
9510 | bgp_afi_safi_get_container_str(afi, safi), import_name); | |
25679caa | 9511 | |
37a87b8f CS |
9512 | if (argv_find(argv, argc, "no", &idx)) |
9513 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9514 | else | |
9515 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
12a844a5 | 9516 | |
37a87b8f CS |
9517 | return nb_cli_apply_changes(vty, base_xpath); |
9518 | } | |
12a844a5 | 9519 | |
37a87b8f CS |
9520 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs( |
9521 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9522 | { | |
9523 | vty_out(vty, " import vrf %s\n", | |
9524 | yang_dnode_get_string(dnode, "./vrf")); | |
12a844a5 DS |
9525 | } |
9526 | ||
b9c7bc5a | 9527 | /* This command is valid only in a bgp vrf instance or the default instance */ |
37a87b8f | 9528 | DEFPY_YANG (bgp_imexport_vpn, |
b9c7bc5a PZ |
9529 | bgp_imexport_vpn_cmd, |
9530 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9531 | NO_STR |
9532 | "Import routes to this address-family\n" | |
9533 | "Export routes from this address-family\n" | |
9534 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9535 | { |
37a87b8f | 9536 | char base_xpath[XPATH_MAXLEN]; |
b9c7bc5a | 9537 | safi_t safi; |
37a87b8f CS |
9538 | afi_t afi; |
9539 | int32_t idx = 0; | |
ddb5b488 | 9540 | |
b9c7bc5a PZ |
9541 | afi = bgp_node_afi(vty); |
9542 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9543 | |
b9c7bc5a | 9544 | if (!strcmp(direction_str, "import")) { |
37a87b8f CS |
9545 | snprintf( |
9546 | base_xpath, sizeof(base_xpath), | |
9547 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn", | |
9548 | yang_afi_safi_value2identity(afi, safi), | |
9549 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a | 9550 | } else if (!strcmp(direction_str, "export")) { |
37a87b8f CS |
9551 | snprintf( |
9552 | base_xpath, sizeof(base_xpath), | |
9553 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn", | |
9554 | yang_afi_safi_value2identity(afi, safi), | |
9555 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a PZ |
9556 | } else { |
9557 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9558 | return CMD_WARNING_CONFIG_FAILED; | |
9559 | } | |
9560 | ||
37a87b8f CS |
9561 | if (argv_find(argv, argc, "no", &idx)) |
9562 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9563 | else | |
9564 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, "true"); | |
ddb5b488 | 9565 | |
37a87b8f CS |
9566 | return nb_cli_apply_changes(vty, base_xpath); |
9567 | } | |
ddb5b488 | 9568 | |
37a87b8f CS |
9569 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn( |
9570 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9571 | { | |
9572 | if (yang_dnode_get_bool(dnode, NULL)) | |
9573 | vty_out(vty, " import vpn\n"); | |
9574 | } | |
9575 | ||
9576 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn( | |
9577 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9578 | { | |
9579 | if (yang_dnode_get_bool(dnode, NULL)) | |
9580 | vty_out(vty, " export vpn\n"); | |
ddb5b488 PZ |
9581 | } |
9582 | ||
301ad80a PG |
9583 | DEFPY (af_routetarget_import, |
9584 | af_routetarget_import_cmd, | |
9a659715 | 9585 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9586 | NO_STR |
9587 | "Specify route target list\n" | |
9588 | "Specify route target list\n" | |
9a659715 PG |
9589 | "Specify route target list\n" |
9590 | "Specify route target list\n" | |
301ad80a PG |
9591 | "Flow-spec redirect type route target\n" |
9592 | "Import routes to this address-family\n" | |
9a659715 | 9593 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9594 | { |
9595 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9596 | int ret; | |
9597 | struct ecommunity *ecom = NULL; | |
301ad80a | 9598 | afi_t afi; |
9a659715 | 9599 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9600 | bool yes = true; |
9601 | bool rt6 = false; | |
301ad80a PG |
9602 | |
9603 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9604 | yes = false; |
301ad80a | 9605 | |
9a659715 PG |
9606 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9607 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9608 | rt6 = true; |
301ad80a | 9609 | |
0ca70ba5 | 9610 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9611 | if (afi == AFI_MAX) |
9612 | return CMD_WARNING_CONFIG_FAILED; | |
9613 | ||
9a659715 PG |
9614 | if (rt6 && afi != AFI_IP6) |
9615 | return CMD_WARNING_CONFIG_FAILED; | |
9616 | ||
301ad80a PG |
9617 | if (yes) { |
9618 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9619 | vty_out(vty, "%% Missing RTLIST\n"); | |
9620 | return CMD_WARNING_CONFIG_FAILED; | |
9621 | } | |
9a659715 | 9622 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9623 | if (ret != CMD_SUCCESS) |
9624 | return ret; | |
9625 | } | |
69b07479 DS |
9626 | |
9627 | if (yes) { | |
9628 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9629 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9630 | .import_redirect_rtlist); |
69b07479 DS |
9631 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9632 | ecommunity_dup(ecom); | |
9633 | } else { | |
9634 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9635 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9636 | .import_redirect_rtlist); |
69b07479 | 9637 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9638 | } |
69b07479 | 9639 | |
301ad80a PG |
9640 | if (ecom) |
9641 | ecommunity_free(&ecom); | |
9642 | ||
9643 | return CMD_SUCCESS; | |
9644 | } | |
9645 | ||
37a87b8f CS |
9646 | void cli_show_bgp_global_afi_safi_header(struct vty *vty, |
9647 | struct lyd_node *dnode, | |
9648 | bool show_defaults) | |
9649 | { | |
9650 | const char *af_name; | |
9651 | afi_t afi; | |
9652 | safi_t safi; | |
9653 | ||
9654 | af_name = yang_dnode_get_string(dnode, "./afi-safi-name"); | |
9655 | yang_afi_safi_identity2value(af_name, &afi, &safi); | |
9656 | ||
9657 | vty_out(vty, " !\n address-family "); | |
9658 | if (afi == AFI_IP) { | |
9659 | if (safi == SAFI_UNICAST) | |
9660 | vty_out(vty, "ipv4 unicast"); | |
9661 | else if (safi == SAFI_LABELED_UNICAST) | |
9662 | vty_out(vty, "ipv4 labeled-unicast"); | |
9663 | else if (safi == SAFI_MULTICAST) | |
9664 | vty_out(vty, "ipv4 multicast"); | |
9665 | else if (safi == SAFI_MPLS_VPN) | |
9666 | vty_out(vty, "ipv4 vpn"); | |
9667 | else if (safi == SAFI_ENCAP) | |
9668 | vty_out(vty, "ipv4 encap"); | |
9669 | else if (safi == SAFI_FLOWSPEC) | |
9670 | vty_out(vty, "ipv4 flowspec"); | |
9671 | } else if (afi == AFI_IP6) { | |
9672 | if (safi == SAFI_UNICAST) | |
9673 | vty_out(vty, "ipv6 unicast"); | |
9674 | else if (safi == SAFI_LABELED_UNICAST) | |
9675 | vty_out(vty, "ipv6 labeled-unicast"); | |
9676 | else if (safi == SAFI_MULTICAST) | |
9677 | vty_out(vty, "ipv6 multicast"); | |
9678 | else if (safi == SAFI_MPLS_VPN) | |
9679 | vty_out(vty, "ipv6 vpn"); | |
9680 | else if (safi == SAFI_ENCAP) | |
9681 | vty_out(vty, "ipv6 encap"); | |
9682 | else if (safi == SAFI_FLOWSPEC) | |
9683 | vty_out(vty, "ipv6 flowspec"); | |
9684 | } else if (afi == AFI_L2VPN) { | |
9685 | if (safi == SAFI_EVPN) | |
9686 | vty_out(vty, "l2vpn evpn"); | |
9687 | } | |
9688 | vty_out(vty, "\n"); | |
9689 | } | |
9690 | ||
505e5056 | 9691 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9692 | address_family_ipv4_safi_cmd, |
9693 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9694 | "Enter Address Family command mode\n" | |
9695 | "Address Family\n" | |
9696 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9697 | { |
f51bae9c | 9698 | |
37a87b8f CS |
9699 | safi_t safi = SAFI_UNICAST; |
9700 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9701 | const char *vrf_name = NULL; | |
9702 | ||
d62a17ae | 9703 | if (argc == 3) { |
37a87b8f CS |
9704 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9705 | ||
9706 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9707 | VTY_CURR_XPATH); | |
9708 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9709 | "control-plane-protocol"); | |
9710 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9711 | ||
9712 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9713 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9714 | && safi != SAFI_EVPN) { |
31947174 MK |
9715 | vty_out(vty, |
9716 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9717 | return CMD_WARNING_CONFIG_FAILED; |
9718 | } | |
37a87b8f CS |
9719 | } |
9720 | vty->node = bgp_node_type(AFI_IP, safi); | |
718e3744 | 9721 | |
d62a17ae | 9722 | return CMD_SUCCESS; |
718e3744 | 9723 | } |
9724 | ||
505e5056 | 9725 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9726 | address_family_ipv6_safi_cmd, |
9727 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9728 | "Enter Address Family command mode\n" | |
9729 | "Address Family\n" | |
9730 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9731 | { |
37a87b8f CS |
9732 | safi_t safi = SAFI_UNICAST; |
9733 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9734 | const char *vrf_name = NULL; | |
9735 | ||
d62a17ae | 9736 | if (argc == 3) { |
37a87b8f CS |
9737 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9738 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9739 | VTY_CURR_XPATH); | |
9740 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9741 | "control-plane-protocol"); | |
9742 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9743 | ||
9744 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9745 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9746 | && safi != SAFI_EVPN) { |
31947174 MK |
9747 | vty_out(vty, |
9748 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9749 | return CMD_WARNING_CONFIG_FAILED; |
9750 | } | |
37a87b8f CS |
9751 | } |
9752 | vty->node = bgp_node_type(AFI_IP6, safi); | |
25ffbdc1 | 9753 | |
d62a17ae | 9754 | return CMD_SUCCESS; |
25ffbdc1 | 9755 | } |
718e3744 | 9756 | |
d6902373 | 9757 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9758 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9759 | address_family_vpnv4_cmd, |
8334fd5a | 9760 | "address-family vpnv4 [unicast]", |
718e3744 | 9761 | "Enter Address Family command mode\n" |
8c3deaae | 9762 | "Address Family\n" |
3a2d747c | 9763 | "Address Family modifier\n") |
718e3744 | 9764 | { |
d62a17ae | 9765 | vty->node = BGP_VPNV4_NODE; |
9766 | return CMD_SUCCESS; | |
718e3744 | 9767 | } |
9768 | ||
505e5056 | 9769 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9770 | address_family_vpnv6_cmd, |
8334fd5a | 9771 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9772 | "Enter Address Family command mode\n" |
8c3deaae | 9773 | "Address Family\n" |
3a2d747c | 9774 | "Address Family modifier\n") |
8ecd3266 | 9775 | { |
d62a17ae | 9776 | vty->node = BGP_VPNV6_NODE; |
9777 | return CMD_SUCCESS; | |
8ecd3266 | 9778 | } |
64e4a6c5 | 9779 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9780 | |
505e5056 | 9781 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9782 | address_family_evpn_cmd, |
7111c1a0 | 9783 | "address-family l2vpn evpn", |
4e0b7b6d | 9784 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9785 | "Address Family\n" |
9786 | "Address Family modifier\n") | |
4e0b7b6d | 9787 | { |
2131d5cf | 9788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9789 | vty->node = BGP_EVPN_NODE; |
9790 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9791 | } |
9792 | ||
505e5056 | 9793 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9794 | exit_address_family_cmd, |
9795 | "exit-address-family", | |
9796 | "Exit from Address Family configuration mode\n") | |
9797 | { | |
d62a17ae | 9798 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9799 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9800 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9801 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9802 | || vty->node == BGP_EVPN_NODE |
9803 | || vty->node == BGP_FLOWSPECV4_NODE | |
9804 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9805 | vty->node = BGP_NODE; |
9806 | return CMD_SUCCESS; | |
718e3744 | 9807 | } |
6b0655a2 | 9808 | |
37a87b8f CS |
9809 | void cli_show_bgp_global_afi_safi_header_end(struct vty *vty, |
9810 | struct lyd_node *dnode | |
9811 | __attribute__((__unused__))) | |
9812 | { | |
9813 | vty_out(vty, " exit-address-family\n"); | |
9814 | } | |
9815 | ||
8ad7271d | 9816 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9817 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9818 | const char *ip_str, afi_t afi, safi_t safi, | |
9819 | struct prefix_rd *prd) | |
9820 | { | |
9821 | int ret; | |
9822 | struct prefix match; | |
9bcb3eef DS |
9823 | struct bgp_dest *dest; |
9824 | struct bgp_dest *rm; | |
d62a17ae | 9825 | struct bgp *bgp; |
9826 | struct bgp_table *table; | |
9827 | struct bgp_table *rib; | |
9828 | ||
9829 | /* BGP structure lookup. */ | |
9830 | if (view_name) { | |
9831 | bgp = bgp_lookup_by_name(view_name); | |
9832 | if (bgp == NULL) { | |
9833 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9834 | view_name); | |
9835 | return CMD_WARNING; | |
9836 | } | |
9837 | } else { | |
9838 | bgp = bgp_get_default(); | |
9839 | if (bgp == NULL) { | |
9840 | vty_out(vty, "%% No BGP process is configured\n"); | |
9841 | return CMD_WARNING; | |
9842 | } | |
9843 | } | |
9844 | ||
9845 | /* Check IP address argument. */ | |
9846 | ret = str2prefix(ip_str, &match); | |
9847 | if (!ret) { | |
9848 | vty_out(vty, "%% address is malformed\n"); | |
9849 | return CMD_WARNING; | |
9850 | } | |
9851 | ||
9852 | match.family = afi2family(afi); | |
9853 | rib = bgp->rib[afi][safi]; | |
9854 | ||
9855 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9856 | for (dest = bgp_table_top(rib); dest; |
9857 | dest = bgp_route_next(dest)) { | |
9858 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9859 | |
9bcb3eef | 9860 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9861 | continue; |
9862 | ||
9bcb3eef | 9863 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9864 | if (table == NULL) |
9865 | continue; | |
9866 | ||
9867 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
9868 | const struct prefix *rm_p = | |
9bcb3eef | 9869 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9870 | |
9871 | if (rm_p->prefixlen == match.prefixlen) { | |
9872 | SET_FLAG(rm->flags, | |
9873 | BGP_NODE_USER_CLEAR); | |
9874 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9875 | } |
9bcb3eef | 9876 | bgp_dest_unlock_node(rm); |
d62a17ae | 9877 | } |
9878 | } | |
9879 | } else { | |
9bcb3eef DS |
9880 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
9881 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9882 | |
9bcb3eef DS |
9883 | if (dest_p->prefixlen == match.prefixlen) { |
9884 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9885 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9886 | } |
9bcb3eef | 9887 | bgp_dest_unlock_node(dest); |
d62a17ae | 9888 | } |
9889 | } | |
9890 | ||
9891 | return CMD_SUCCESS; | |
8ad7271d DS |
9892 | } |
9893 | ||
b09b5ae0 | 9894 | /* one clear bgp command to rule them all */ |
718e3744 | 9895 | DEFUN (clear_ip_bgp_all, |
9896 | clear_ip_bgp_all_cmd, | |
453c92f6 | 9897 | "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 | 9898 | CLEAR_STR |
9899 | IP_STR | |
9900 | BGP_STR | |
838758ac | 9901 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9902 | BGP_AFI_HELP_STR |
fd5e7b70 | 9903 | "Address Family\n" |
510afcd6 | 9904 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9905 | "Address Family modifier\n" |
b09b5ae0 | 9906 | "Clear all peers\n" |
453c92f6 | 9907 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9908 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9909 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9910 | "Clear peers with the AS number\n" |
9911 | "Clear all external peers\n" | |
718e3744 | 9912 | "Clear all members of peer-group\n" |
b09b5ae0 | 9913 | "BGP peer-group name\n" |
b09b5ae0 DW |
9914 | BGP_SOFT_STR |
9915 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9916 | BGP_SOFT_OUT_STR |
9917 | BGP_SOFT_IN_STR | |
9918 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 9919 | BGP_SOFT_OUT_STR) |
718e3744 | 9920 | { |
d62a17ae | 9921 | char *vrf = NULL; |
9922 | ||
dc912615 DS |
9923 | afi_t afi = AFI_UNSPEC; |
9924 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9925 | enum clear_sort clr_sort = clear_peer; |
9926 | enum bgp_clear_type clr_type; | |
9927 | char *clr_arg = NULL; | |
9928 | ||
9929 | int idx = 0; | |
ff8a8a7a CS |
9930 | char errmsg[BUFSIZ] = {'\0'}; |
9931 | int ret; | |
d62a17ae | 9932 | |
9933 | /* clear [ip] bgp */ | |
9934 | if (argv_find(argv, argc, "ip", &idx)) | |
9935 | afi = AFI_IP; | |
9936 | ||
9a8bdf1c PG |
9937 | /* [<vrf> VIEWVRFNAME] */ |
9938 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9939 | vrf = argv[idx + 1]->arg; | |
9940 | idx += 2; | |
9941 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9942 | vrf = NULL; | |
9943 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9944 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9945 | vrf = argv[idx + 1]->arg; |
9946 | idx += 2; | |
9947 | } | |
d62a17ae | 9948 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9949 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9950 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9951 | ||
d7b9898c | 9952 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9953 | if (argv_find(argv, argc, "*", &idx)) { |
9954 | clr_sort = clear_all; | |
9955 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9956 | clr_sort = clear_peer; | |
9957 | clr_arg = argv[idx]->arg; | |
9958 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9959 | clr_sort = clear_peer; | |
9960 | clr_arg = argv[idx]->arg; | |
9961 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9962 | clr_sort = clear_group; | |
9963 | idx++; | |
9964 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9965 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9966 | clr_sort = clear_peer; |
9967 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9968 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9969 | clr_sort = clear_peer; | |
9970 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9971 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9972 | clr_sort = clear_as; | |
9973 | clr_arg = argv[idx]->arg; | |
9974 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9975 | clr_sort = clear_external; | |
9976 | } | |
9977 | ||
9978 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
9979 | if (argv_find(argv, argc, "soft", &idx)) { | |
9980 | if (argv_find(argv, argc, "in", &idx) | |
9981 | || argv_find(argv, argc, "out", &idx)) | |
9982 | clr_type = strmatch(argv[idx]->text, "in") | |
9983 | ? BGP_CLEAR_SOFT_IN | |
9984 | : BGP_CLEAR_SOFT_OUT; | |
9985 | else | |
9986 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9987 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9988 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9989 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9990 | : BGP_CLEAR_SOFT_IN; | |
9991 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9992 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9993 | } else | |
9994 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9995 | ||
ff8a8a7a CS |
9996 | ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg, |
9997 | sizeof(errmsg)); | |
9998 | if (ret != NB_OK) | |
9999 | vty_out(vty, "Error description: %s\n", errmsg); | |
10000 | ||
10001 | return ret; | |
838758ac | 10002 | } |
01080f7c | 10003 | |
8ad7271d DS |
10004 | DEFUN (clear_ip_bgp_prefix, |
10005 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 10006 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
10007 | CLEAR_STR |
10008 | IP_STR | |
10009 | BGP_STR | |
838758ac | 10010 | BGP_INSTANCE_HELP_STR |
8ad7271d | 10011 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10012 | "IPv4 prefix\n") |
8ad7271d | 10013 | { |
d62a17ae | 10014 | char *vrf = NULL; |
10015 | char *prefix = NULL; | |
8ad7271d | 10016 | |
d62a17ae | 10017 | int idx = 0; |
01080f7c | 10018 | |
d62a17ae | 10019 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
10020 | if (argv_find(argv, argc, "vrf", &idx)) { |
10021 | vrf = argv[idx + 1]->arg; | |
10022 | idx += 2; | |
10023 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10024 | vrf = NULL; | |
10025 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10026 | /* [<view> VIEWVRFNAME] */ | |
10027 | vrf = argv[idx + 1]->arg; | |
10028 | idx += 2; | |
10029 | } | |
0c7b1b01 | 10030 | |
d62a17ae | 10031 | prefix = argv[argc - 1]->arg; |
8ad7271d | 10032 | |
d62a17ae | 10033 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 10034 | } |
8ad7271d | 10035 | |
b09b5ae0 DW |
10036 | DEFUN (clear_bgp_ipv6_safi_prefix, |
10037 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 10038 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10039 | CLEAR_STR |
3a2d747c | 10040 | IP_STR |
718e3744 | 10041 | BGP_STR |
8c3deaae | 10042 | "Address Family\n" |
46f296b4 | 10043 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10044 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10045 | "IPv6 prefix\n") |
718e3744 | 10046 | { |
9b475e76 PG |
10047 | int idx_safi = 0; |
10048 | int idx_ipv6_prefix = 0; | |
10049 | safi_t safi = SAFI_UNICAST; | |
10050 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10051 | argv[idx_ipv6_prefix]->arg : NULL; | |
10052 | ||
10053 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 10054 | return bgp_clear_prefix( |
9b475e76 PG |
10055 | vty, NULL, prefix, AFI_IP6, |
10056 | safi, NULL); | |
838758ac | 10057 | } |
01080f7c | 10058 | |
b09b5ae0 DW |
10059 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
10060 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 10061 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10062 | CLEAR_STR |
3a2d747c | 10063 | IP_STR |
718e3744 | 10064 | BGP_STR |
838758ac | 10065 | BGP_INSTANCE_HELP_STR |
8c3deaae | 10066 | "Address Family\n" |
46f296b4 | 10067 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10068 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10069 | "IPv6 prefix\n") |
718e3744 | 10070 | { |
9b475e76 | 10071 | int idx_safi = 0; |
9a8bdf1c | 10072 | int idx_vrfview = 0; |
9b475e76 PG |
10073 | int idx_ipv6_prefix = 0; |
10074 | safi_t safi = SAFI_UNICAST; | |
10075 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10076 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 10077 | char *vrfview = NULL; |
9b475e76 | 10078 | |
9a8bdf1c PG |
10079 | /* [<view|vrf> VIEWVRFNAME] */ |
10080 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
10081 | vrfview = argv[idx_vrfview + 1]->arg; | |
10082 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
10083 | vrfview = NULL; | |
10084 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
10085 | /* [<view> VIEWVRFNAME] */ | |
10086 | vrfview = argv[idx_vrfview + 1]->arg; | |
10087 | } | |
9b475e76 PG |
10088 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
10089 | ||
d62a17ae | 10090 | return bgp_clear_prefix( |
9b475e76 PG |
10091 | vty, vrfview, prefix, |
10092 | AFI_IP6, safi, NULL); | |
718e3744 | 10093 | } |
10094 | ||
b09b5ae0 DW |
10095 | DEFUN (show_bgp_views, |
10096 | show_bgp_views_cmd, | |
d6e3c605 | 10097 | "show [ip] bgp views", |
b09b5ae0 | 10098 | SHOW_STR |
d6e3c605 | 10099 | IP_STR |
01080f7c | 10100 | BGP_STR |
b09b5ae0 | 10101 | "Show the defined BGP views\n") |
01080f7c | 10102 | { |
d62a17ae | 10103 | struct list *inst = bm->bgp; |
10104 | struct listnode *node; | |
10105 | struct bgp *bgp; | |
01080f7c | 10106 | |
d62a17ae | 10107 | vty_out(vty, "Defined BGP views:\n"); |
10108 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10109 | /* Skip VRFs. */ | |
10110 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
10111 | continue; | |
10112 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
10113 | bgp->as); | |
10114 | } | |
e52702f2 | 10115 | |
d62a17ae | 10116 | return CMD_SUCCESS; |
e0081f70 ML |
10117 | } |
10118 | ||
8386ac43 | 10119 | DEFUN (show_bgp_vrfs, |
10120 | show_bgp_vrfs_cmd, | |
d6e3c605 | 10121 | "show [ip] bgp vrfs [json]", |
8386ac43 | 10122 | SHOW_STR |
d6e3c605 | 10123 | IP_STR |
8386ac43 | 10124 | BGP_STR |
10125 | "Show BGP VRFs\n" | |
9973d184 | 10126 | JSON_STR) |
8386ac43 | 10127 | { |
fe1dc5a3 | 10128 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 10129 | struct list *inst = bm->bgp; |
10130 | struct listnode *node; | |
10131 | struct bgp *bgp; | |
9f049418 | 10132 | bool uj = use_json(argc, argv); |
d62a17ae | 10133 | json_object *json = NULL; |
10134 | json_object *json_vrfs = NULL; | |
10135 | int count = 0; | |
d62a17ae | 10136 | |
d62a17ae | 10137 | if (uj) { |
10138 | json = json_object_new_object(); | |
10139 | json_vrfs = json_object_new_object(); | |
10140 | } | |
10141 | ||
10142 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10143 | const char *name, *type; | |
10144 | struct peer *peer; | |
7fe96307 | 10145 | struct listnode *node2, *nnode2; |
d62a17ae | 10146 | int peers_cfg, peers_estb; |
10147 | json_object *json_vrf = NULL; | |
d62a17ae | 10148 | |
10149 | /* Skip Views. */ | |
10150 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
10151 | continue; | |
10152 | ||
10153 | count++; | |
efb4077a | 10154 | if (!uj && count == 1) { |
fe1dc5a3 | 10155 | vty_out(vty, |
efb4077a | 10156 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10157 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10158 | "#PeersEstb", "Name"); |
10159 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10160 | "L3-VNI", "RouterMAC", "Interface"); | |
10161 | } | |
d62a17ae | 10162 | |
10163 | peers_cfg = peers_estb = 0; | |
10164 | if (uj) | |
10165 | json_vrf = json_object_new_object(); | |
10166 | ||
10167 | ||
7fe96307 | 10168 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 10169 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10170 | continue; | |
10171 | peers_cfg++; | |
10172 | if (peer->status == Established) | |
10173 | peers_estb++; | |
10174 | } | |
10175 | ||
10176 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 10177 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10178 | type = "DFLT"; |
10179 | } else { | |
10180 | name = bgp->name; | |
10181 | type = "VRF"; | |
10182 | } | |
10183 | ||
a8bf7d9c | 10184 | |
d62a17ae | 10185 | if (uj) { |
a4d82a8a PZ |
10186 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10187 | ? -1 | |
10188 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
10189 | char buf[BUFSIZ] = {0}; |
10190 | ||
d62a17ae | 10191 | json_object_string_add(json_vrf, "type", type); |
10192 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
10193 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
10194 | inet_ntop(AF_INET, |
10195 | &bgp->router_id, buf, | |
10196 | sizeof(buf))); | |
d62a17ae | 10197 | json_object_int_add(json_vrf, "numConfiguredPeers", |
10198 | peers_cfg); | |
10199 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
10200 | peers_estb); | |
10201 | ||
fe1dc5a3 | 10202 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
10203 | json_object_string_add( |
10204 | json_vrf, "rmac", | |
10205 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
10206 | json_object_string_add(json_vrf, "interface", |
10207 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10208 | bgp->vrf_id)); | |
d62a17ae | 10209 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 10210 | } else { |
23d0a753 | 10211 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
10212 | type, |
10213 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10214 | : (int)bgp->vrf_id, | |
23d0a753 | 10215 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
10216 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
10217 | bgp->l3vni, | |
10218 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
10219 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10220 | bgp->vrf_id)); | |
10221 | } | |
d62a17ae | 10222 | } |
10223 | ||
10224 | if (uj) { | |
10225 | json_object_object_add(json, "vrfs", json_vrfs); | |
10226 | ||
10227 | json_object_int_add(json, "totalVrfs", count); | |
10228 | ||
996c9314 LB |
10229 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10230 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10231 | json_object_free(json); |
10232 | } else { | |
10233 | if (count) | |
10234 | vty_out(vty, | |
10235 | "\nTotal number of VRFs (including default): %d\n", | |
10236 | count); | |
10237 | } | |
10238 | ||
10239 | return CMD_SUCCESS; | |
8386ac43 | 10240 | } |
10241 | ||
48ecf8f5 DS |
10242 | DEFUN (show_bgp_mac_hash, |
10243 | show_bgp_mac_hash_cmd, | |
10244 | "show bgp mac hash", | |
10245 | SHOW_STR | |
10246 | BGP_STR | |
10247 | "Mac Address\n" | |
10248 | "Mac Address database\n") | |
10249 | { | |
10250 | bgp_mac_dump_table(vty); | |
10251 | ||
10252 | return CMD_SUCCESS; | |
10253 | } | |
acf71666 | 10254 | |
e3b78da8 | 10255 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10256 | { |
0291c246 | 10257 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10258 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10259 | |
23d0a753 | 10260 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10261 | } |
10262 | ||
10263 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10264 | { | |
10265 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10266 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10267 | |
10268 | vty_out(vty, "Tunnel-ip database:\n"); | |
10269 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10270 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10271 | vty); |
10272 | } | |
10273 | ||
15c81ca4 DS |
10274 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10275 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10276 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10277 | "martian next-hops\n" |
10278 | "martian next-hop database\n") | |
acf71666 | 10279 | { |
0291c246 | 10280 | struct bgp *bgp = NULL; |
15c81ca4 | 10281 | int idx = 0; |
9a8bdf1c PG |
10282 | char *name = NULL; |
10283 | ||
10284 | /* [<vrf> VIEWVRFNAME] */ | |
10285 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10286 | name = argv[idx + 1]->arg; | |
10287 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10288 | name = NULL; | |
10289 | } else if (argv_find(argv, argc, "view", &idx)) | |
10290 | /* [<view> VIEWVRFNAME] */ | |
10291 | name = argv[idx + 1]->arg; | |
10292 | if (name) | |
10293 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10294 | else |
10295 | bgp = bgp_get_default(); | |
acf71666 | 10296 | |
acf71666 MK |
10297 | if (!bgp) { |
10298 | vty_out(vty, "%% No BGP process is configured\n"); | |
10299 | return CMD_WARNING; | |
10300 | } | |
10301 | bgp_show_martian_nexthops(vty, bgp); | |
10302 | ||
10303 | return CMD_SUCCESS; | |
10304 | } | |
10305 | ||
f412b39a | 10306 | DEFUN (show_bgp_memory, |
4bf6a362 | 10307 | show_bgp_memory_cmd, |
7fa12b13 | 10308 | "show [ip] bgp memory", |
4bf6a362 | 10309 | SHOW_STR |
3a2d747c | 10310 | IP_STR |
4bf6a362 PJ |
10311 | BGP_STR |
10312 | "Global BGP memory statistics\n") | |
10313 | { | |
d62a17ae | 10314 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10315 | unsigned long count; | |
10316 | ||
10317 | /* RIB related usage stats */ | |
10318 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10319 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10320 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10321 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10322 | |
10323 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10324 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10325 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10326 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10327 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10328 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10329 | count, | |
4b7e6066 DS |
10330 | mtype_memstr( |
10331 | memstrbuf, sizeof(memstrbuf), | |
10332 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10333 | |
10334 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10335 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10336 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10337 | count * sizeof(struct bgp_static))); | |
10338 | ||
10339 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10340 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10341 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10342 | count * sizeof(struct bpacket))); | |
10343 | ||
10344 | /* Adj-In/Out */ | |
10345 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10346 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10347 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10348 | count * sizeof(struct bgp_adj_in))); | |
10349 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10350 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10351 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10352 | count * sizeof(struct bgp_adj_out))); | |
10353 | ||
10354 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10355 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10356 | count, | |
10357 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10358 | count * sizeof(struct bgp_nexthop_cache))); | |
10359 | ||
10360 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10361 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10362 | count, | |
10363 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10364 | count * sizeof(struct bgp_damp_info))); | |
10365 | ||
10366 | /* Attributes */ | |
10367 | count = attr_count(); | |
10368 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10369 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10370 | count * sizeof(struct attr))); | |
10371 | ||
10372 | if ((count = attr_unknown_count())) | |
10373 | vty_out(vty, "%ld unknown attributes\n", count); | |
10374 | ||
10375 | /* AS_PATH attributes */ | |
10376 | count = aspath_count(); | |
10377 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10378 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10379 | count * sizeof(struct aspath))); | |
10380 | ||
10381 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10382 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10383 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10384 | count * sizeof(struct assegment))); | |
10385 | ||
10386 | /* Other attributes */ | |
10387 | if ((count = community_count())) | |
10388 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10389 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10390 | count * sizeof(struct community))); | |
d62a17ae | 10391 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
10392 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10393 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10394 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10395 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10396 | vty_out(vty, | |
10397 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10398 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10399 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10400 | |
10401 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10402 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10403 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10404 | count * sizeof(struct cluster_list))); | |
10405 | ||
10406 | /* Peer related usage */ | |
10407 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10408 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10409 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10410 | count * sizeof(struct peer))); | |
10411 | ||
10412 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10413 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10414 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10415 | count * sizeof(struct peer_group))); | |
10416 | ||
10417 | /* Other */ | |
d62a17ae | 10418 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10419 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10420 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10421 | count * sizeof(regex_t))); | |
d62a17ae | 10422 | return CMD_SUCCESS; |
4bf6a362 | 10423 | } |
fee0f4c6 | 10424 | |
57a9c8a8 DS |
10425 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10426 | { | |
10427 | json_object *bestpath = json_object_new_object(); | |
10428 | ||
892fedb6 | 10429 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10430 | json_object_string_add(bestpath, "asPath", "ignore"); |
10431 | ||
892fedb6 | 10432 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10433 | json_object_string_add(bestpath, "asPath", "confed"); |
10434 | ||
892fedb6 DA |
10435 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10436 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10437 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10438 | "as-set"); |
10439 | else | |
a4d82a8a | 10440 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10441 | "true"); |
10442 | } else | |
a4d82a8a | 10443 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10444 | |
892fedb6 | 10445 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10446 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10447 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10448 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10449 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10450 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10451 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10452 | json_object_string_add(bestpath, "med", |
10453 | "missing-as-worst"); | |
10454 | else | |
10455 | json_object_string_add(bestpath, "med", "true"); | |
10456 | } | |
10457 | ||
10458 | json_object_object_add(json, "bestPath", bestpath); | |
10459 | } | |
10460 | ||
3577f1c5 DD |
10461 | /* Print the error code/subcode for why the peer is down */ |
10462 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10463 | json_object *json_peer, bool use_json) | |
10464 | { | |
10465 | const char *code_str; | |
10466 | const char *subcode_str; | |
10467 | ||
10468 | if (use_json) { | |
10469 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10470 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10471 | char errorcodesubcode_hexstr[5]; | |
10472 | char errorcodesubcode_str[256]; | |
10473 | ||
10474 | code_str = bgp_notify_code_str(peer->notify.code); | |
10475 | subcode_str = bgp_notify_subcode_str( | |
10476 | peer->notify.code, | |
10477 | peer->notify.subcode); | |
10478 | ||
772270f3 QY |
10479 | snprintf(errorcodesubcode_hexstr, |
10480 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10481 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10482 | json_object_string_add(json_peer, |
10483 | "lastErrorCodeSubcode", | |
10484 | errorcodesubcode_hexstr); | |
10485 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10486 | code_str, subcode_str); | |
10487 | json_object_string_add(json_peer, | |
10488 | "lastNotificationReason", | |
10489 | errorcodesubcode_str); | |
10490 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10491 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10492 | && (peer->notify.subcode | |
10493 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10494 | || peer->notify.subcode | |
10495 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10496 | && peer->notify.length) { | |
10497 | char msgbuf[1024]; | |
10498 | const char *msg_str; | |
10499 | ||
10500 | msg_str = bgp_notify_admin_message( | |
10501 | msgbuf, sizeof(msgbuf), | |
10502 | (uint8_t *)peer->notify.data, | |
10503 | peer->notify.length); | |
10504 | if (msg_str) | |
10505 | json_object_string_add( | |
10506 | json_peer, | |
10507 | "lastShutdownDescription", | |
10508 | msg_str); | |
10509 | } | |
10510 | ||
c258527b | 10511 | } |
3577f1c5 DD |
10512 | json_object_string_add(json_peer, "lastResetDueTo", |
10513 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10514 | json_object_int_add(json_peer, "lastResetCode", |
10515 | peer->last_reset); | |
3577f1c5 DD |
10516 | } else { |
10517 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10518 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10519 | code_str = bgp_notify_code_str(peer->notify.code); | |
10520 | subcode_str = | |
10521 | bgp_notify_subcode_str(peer->notify.code, | |
10522 | peer->notify.subcode); | |
10523 | vty_out(vty, " Notification %s (%s%s)\n", | |
10524 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10525 | ? "sent" | |
10526 | : "received", | |
10527 | code_str, subcode_str); | |
10528 | } else { | |
e91c24c8 | 10529 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10530 | peer_down_str[(int)peer->last_reset]); |
10531 | } | |
10532 | } | |
10533 | } | |
10534 | ||
10535 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10536 | safi_t safi) | |
10537 | { | |
10538 | return ((peer->status != Established) || | |
10539 | !peer->afc_recv[afi][safi]); | |
10540 | } | |
10541 | ||
10542 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10543 | struct peer *peer, json_object *json_peer, | |
10544 | int max_neighbor_width, bool use_json) | |
10545 | { | |
10546 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10547 | int len; | |
10548 | ||
10549 | if (use_json) { | |
10550 | if (peer_dynamic_neighbor(peer)) | |
10551 | json_object_boolean_true_add(json_peer, | |
10552 | "dynamicPeer"); | |
10553 | if (peer->hostname) | |
10554 | json_object_string_add(json_peer, "hostname", | |
10555 | peer->hostname); | |
10556 | ||
10557 | if (peer->domainname) | |
10558 | json_object_string_add(json_peer, "domainname", | |
10559 | peer->domainname); | |
10560 | json_object_int_add(json_peer, "connectionsEstablished", | |
10561 | peer->established); | |
10562 | json_object_int_add(json_peer, "connectionsDropped", | |
10563 | peer->dropped); | |
10564 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10565 | use_json, json_peer); | |
10566 | if (peer->status == Established) | |
10567 | json_object_string_add(json_peer, "lastResetDueTo", | |
10568 | "AFI/SAFI Not Negotiated"); | |
10569 | else | |
10570 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10571 | } else { | |
10572 | dn_flag[1] = '\0'; | |
10573 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10574 | if (peer->hostname | |
892fedb6 | 10575 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10576 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10577 | peer->hostname, peer->host); | |
10578 | else | |
10579 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10580 | ||
10581 | /* pad the neighbor column with spaces */ | |
10582 | if (len < max_neighbor_width) | |
10583 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10584 | " "); | |
e91c24c8 | 10585 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10586 | peer->dropped, |
10587 | peer_uptime(peer->uptime, timebuf, | |
10588 | BGP_UPTIME_LEN, 0, NULL)); | |
10589 | if (peer->status == Established) | |
10590 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
10591 | else | |
10592 | bgp_show_peer_reset(vty, peer, NULL, | |
10593 | false); | |
10594 | } | |
10595 | } | |
c258527b | 10596 | |
cb75bb31 DA |
10597 | /* If the peer's description includes whitespaces |
10598 | * then return the first occurrence. Also strip description | |
10599 | * to the given size if needed. | |
10600 | */ | |
10601 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) | |
10602 | { | |
10603 | static char stripped[BUFSIZ]; | |
10604 | char *pnt; | |
10605 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; | |
10606 | ||
10607 | pnt = strchr(desc, ' '); | |
10608 | if (pnt) | |
10609 | len = size > (uint32_t)(pnt - desc) ? (uint32_t)(pnt - desc) | |
10610 | : size; | |
10611 | ||
10612 | strlcpy(stripped, desc, len + 1); | |
10613 | ||
10614 | return stripped; | |
10615 | } | |
3577f1c5 | 10616 | |
718e3744 | 10617 | /* Show BGP peer's summary information. */ |
d62a17ae | 10618 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
85eeb029 | 10619 | uint8_t show_flags) |
d62a17ae | 10620 | { |
10621 | struct peer *peer; | |
10622 | struct listnode *node, *nnode; | |
10623 | unsigned int count = 0, dn_count = 0; | |
10624 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10625 | char neighbor_buf[VTY_BUFSIZ]; | |
10626 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10627 | int len, failed_count = 0; |
d62a17ae | 10628 | int max_neighbor_width = 0; |
10629 | int pfx_rcd_safi; | |
3c13337d | 10630 | json_object *json = NULL; |
d62a17ae | 10631 | json_object *json_peer = NULL; |
10632 | json_object *json_peers = NULL; | |
50e05855 | 10633 | struct peer_af *paf; |
d3ada366 | 10634 | struct bgp_filter *filter; |
85eeb029 DA |
10635 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10636 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10637 | bool show_established = | |
10638 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10639 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
d62a17ae | 10640 | |
10641 | /* labeled-unicast routes are installed in the unicast table so in order | |
10642 | * to | |
10643 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10644 | */ | |
3577f1c5 | 10645 | |
d62a17ae | 10646 | if (safi == SAFI_LABELED_UNICAST) |
10647 | pfx_rcd_safi = SAFI_UNICAST; | |
10648 | else | |
10649 | pfx_rcd_safi = safi; | |
10650 | ||
10651 | if (use_json) { | |
3c13337d | 10652 | json = json_object_new_object(); |
d62a17ae | 10653 | json_peers = json_object_new_object(); |
3577f1c5 DD |
10654 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10655 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10656 | continue; | |
10657 | ||
10658 | if (peer->afc[afi][safi]) { | |
10659 | /* See if we have at least a single failed peer */ | |
10660 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10661 | failed_count++; | |
10662 | count++; | |
10663 | } | |
10664 | if (peer_dynamic_neighbor(peer)) | |
10665 | dn_count++; | |
10666 | } | |
c258527b | 10667 | |
d62a17ae | 10668 | } else { |
10669 | /* Loop over all neighbors that will be displayed to determine | |
10670 | * how many | |
10671 | * characters are needed for the Neighbor column | |
10672 | */ | |
10673 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10674 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10675 | continue; | |
10676 | ||
10677 | if (peer->afc[afi][safi]) { | |
10678 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10679 | if (peer_dynamic_neighbor(peer)) | |
10680 | dn_flag[0] = '*'; | |
10681 | ||
10682 | if (peer->hostname | |
892fedb6 DA |
10683 | && CHECK_FLAG(bgp->flags, |
10684 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10685 | snprintf(neighbor_buf, |
10686 | sizeof(neighbor_buf), | |
10687 | "%s%s(%s) ", dn_flag, | |
10688 | peer->hostname, peer->host); | |
d62a17ae | 10689 | else |
772270f3 QY |
10690 | snprintf(neighbor_buf, |
10691 | sizeof(neighbor_buf), "%s%s ", | |
10692 | dn_flag, peer->host); | |
d62a17ae | 10693 | |
10694 | len = strlen(neighbor_buf); | |
10695 | ||
10696 | if (len > max_neighbor_width) | |
10697 | max_neighbor_width = len; | |
c258527b | 10698 | |
3577f1c5 DD |
10699 | /* See if we have at least a single failed peer */ |
10700 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10701 | failed_count++; | |
10702 | count++; | |
d62a17ae | 10703 | } |
10704 | } | |
f933309e | 10705 | |
d62a17ae | 10706 | /* Originally we displayed the Neighbor column as 16 |
10707 | * characters wide so make that the default | |
10708 | */ | |
10709 | if (max_neighbor_width < neighbor_col_default_width) | |
10710 | max_neighbor_width = neighbor_col_default_width; | |
10711 | } | |
f933309e | 10712 | |
3577f1c5 DD |
10713 | if (show_failed && !failed_count) { |
10714 | if (use_json) { | |
10715 | json_object_int_add(json, "failedPeersCount", 0); | |
10716 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10717 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
10718 | |
10719 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
10720 | json, JSON_C_TO_STRING_PRETTY)); | |
10721 | json_object_free(json); | |
10722 | } else { | |
10723 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
10724 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
10725 | } | |
10726 | return CMD_SUCCESS; | |
10727 | } | |
c258527b | 10728 | |
3577f1c5 | 10729 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 10730 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10731 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10732 | continue; | |
10733 | ||
ea47320b DL |
10734 | if (!peer->afc[afi][safi]) |
10735 | continue; | |
d62a17ae | 10736 | |
ea47320b DL |
10737 | if (!count) { |
10738 | unsigned long ents; | |
10739 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10740 | int64_t vrf_id_ui; |
d62a17ae | 10741 | |
a4d82a8a PZ |
10742 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10743 | ? -1 | |
10744 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10745 | |
10746 | /* Usage summary and header */ | |
10747 | if (use_json) { | |
23d0a753 DA |
10748 | char buf[BUFSIZ] = {0}; |
10749 | ||
ea47320b DL |
10750 | json_object_string_add( |
10751 | json, "routerId", | |
23d0a753 DA |
10752 | inet_ntop(AF_INET, &bgp->router_id, buf, |
10753 | sizeof(buf))); | |
60466a63 QY |
10754 | json_object_int_add(json, "as", bgp->as); |
10755 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10756 | json_object_string_add( |
10757 | json, "vrfName", | |
10758 | (bgp->inst_type | |
10759 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10760 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10761 | : bgp->name); |
10762 | } else { | |
10763 | vty_out(vty, | |
23d0a753 DA |
10764 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10765 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10766 | bgp->vrf_id == VRF_UNKNOWN |
10767 | ? -1 | |
10768 | : (int)bgp->vrf_id); | |
ea47320b DL |
10769 | vty_out(vty, "\n"); |
10770 | } | |
d62a17ae | 10771 | |
ea47320b | 10772 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10773 | if (use_json) { |
ea47320b | 10774 | json_object_int_add( |
60466a63 | 10775 | json, "updateDelayLimit", |
ea47320b | 10776 | bgp->v_update_delay); |
d62a17ae | 10777 | |
ea47320b DL |
10778 | if (bgp->v_update_delay |
10779 | != bgp->v_establish_wait) | |
d62a17ae | 10780 | json_object_int_add( |
10781 | json, | |
ea47320b DL |
10782 | "updateDelayEstablishWait", |
10783 | bgp->v_establish_wait); | |
d62a17ae | 10784 | |
60466a63 | 10785 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10786 | json_object_string_add( |
10787 | json, | |
10788 | "updateDelayFirstNeighbor", | |
10789 | bgp->update_delay_begin_time); | |
10790 | json_object_boolean_true_add( | |
10791 | json, | |
10792 | "updateDelayInProgress"); | |
10793 | } else { | |
10794 | if (bgp->update_delay_over) { | |
d62a17ae | 10795 | json_object_string_add( |
10796 | json, | |
10797 | "updateDelayFirstNeighbor", | |
10798 | bgp->update_delay_begin_time); | |
ea47320b | 10799 | json_object_string_add( |
d62a17ae | 10800 | json, |
ea47320b DL |
10801 | "updateDelayBestpathResumed", |
10802 | bgp->update_delay_end_time); | |
10803 | json_object_string_add( | |
d62a17ae | 10804 | json, |
ea47320b DL |
10805 | "updateDelayZebraUpdateResume", |
10806 | bgp->update_delay_zebra_resume_time); | |
10807 | json_object_string_add( | |
10808 | json, | |
10809 | "updateDelayPeerUpdateResume", | |
10810 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10811 | } |
ea47320b DL |
10812 | } |
10813 | } else { | |
10814 | vty_out(vty, | |
10815 | "Read-only mode update-delay limit: %d seconds\n", | |
10816 | bgp->v_update_delay); | |
10817 | if (bgp->v_update_delay | |
10818 | != bgp->v_establish_wait) | |
d62a17ae | 10819 | vty_out(vty, |
ea47320b DL |
10820 | " Establish wait: %d seconds\n", |
10821 | bgp->v_establish_wait); | |
d62a17ae | 10822 | |
60466a63 | 10823 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10824 | vty_out(vty, |
10825 | " First neighbor established: %s\n", | |
10826 | bgp->update_delay_begin_time); | |
10827 | vty_out(vty, | |
10828 | " Delay in progress\n"); | |
10829 | } else { | |
10830 | if (bgp->update_delay_over) { | |
d62a17ae | 10831 | vty_out(vty, |
10832 | " First neighbor established: %s\n", | |
10833 | bgp->update_delay_begin_time); | |
10834 | vty_out(vty, | |
ea47320b DL |
10835 | " Best-paths resumed: %s\n", |
10836 | bgp->update_delay_end_time); | |
10837 | vty_out(vty, | |
10838 | " zebra update resumed: %s\n", | |
10839 | bgp->update_delay_zebra_resume_time); | |
10840 | vty_out(vty, | |
10841 | " peers update resumed: %s\n", | |
10842 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10843 | } |
10844 | } | |
10845 | } | |
ea47320b | 10846 | } |
d62a17ae | 10847 | |
ea47320b DL |
10848 | if (use_json) { |
10849 | if (bgp_maxmed_onstartup_configured(bgp) | |
10850 | && bgp->maxmed_active) | |
10851 | json_object_boolean_true_add( | |
60466a63 | 10852 | json, "maxMedOnStartup"); |
ea47320b DL |
10853 | if (bgp->v_maxmed_admin) |
10854 | json_object_boolean_true_add( | |
60466a63 | 10855 | json, "maxMedAdministrative"); |
d62a17ae | 10856 | |
ea47320b DL |
10857 | json_object_int_add( |
10858 | json, "tableVersion", | |
60466a63 | 10859 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10860 | |
60466a63 QY |
10861 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10862 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10863 | json_object_int_add( |
10864 | json, "ribMemory", | |
9bcb3eef | 10865 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10866 | |
210ec2a0 | 10867 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10868 | json_object_int_add(json, "peerCount", ents); |
10869 | json_object_int_add(json, "peerMemory", | |
10870 | ents * sizeof(struct peer)); | |
d62a17ae | 10871 | |
ea47320b DL |
10872 | if ((ents = listcount(bgp->group))) { |
10873 | json_object_int_add( | |
60466a63 | 10874 | json, "peerGroupCount", ents); |
ea47320b DL |
10875 | json_object_int_add( |
10876 | json, "peerGroupMemory", | |
996c9314 LB |
10877 | ents * sizeof(struct |
10878 | peer_group)); | |
ea47320b | 10879 | } |
d62a17ae | 10880 | |
ea47320b DL |
10881 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10882 | BGP_CONFIG_DAMPENING)) | |
10883 | json_object_boolean_true_add( | |
60466a63 | 10884 | json, "dampeningEnabled"); |
ea47320b DL |
10885 | } else { |
10886 | if (bgp_maxmed_onstartup_configured(bgp) | |
10887 | && bgp->maxmed_active) | |
d62a17ae | 10888 | vty_out(vty, |
ea47320b DL |
10889 | "Max-med on-startup active\n"); |
10890 | if (bgp->v_maxmed_admin) | |
d62a17ae | 10891 | vty_out(vty, |
ea47320b | 10892 | "Max-med administrative active\n"); |
d62a17ae | 10893 | |
60466a63 QY |
10894 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
10895 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 10896 | |
60466a63 | 10897 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
10898 | vty_out(vty, |
10899 | "RIB entries %ld, using %s of memory\n", | |
10900 | ents, | |
9bcb3eef DS |
10901 | mtype_memstr( |
10902 | memstrbuf, sizeof(memstrbuf), | |
10903 | ents | |
10904 | * sizeof(struct | |
10905 | bgp_dest))); | |
ea47320b DL |
10906 | |
10907 | /* Peer related usage */ | |
210ec2a0 | 10908 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 10909 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
10910 | ents, |
10911 | mtype_memstr( | |
60466a63 QY |
10912 | memstrbuf, sizeof(memstrbuf), |
10913 | ents * sizeof(struct peer))); | |
ea47320b DL |
10914 | |
10915 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 10916 | vty_out(vty, |
ea47320b | 10917 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 10918 | ents, |
10919 | mtype_memstr( | |
10920 | memstrbuf, | |
10921 | sizeof(memstrbuf), | |
996c9314 LB |
10922 | ents * sizeof(struct |
10923 | peer_group))); | |
d62a17ae | 10924 | |
ea47320b DL |
10925 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10926 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 10927 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 10928 | vty_out(vty, "\n"); |
d62a17ae | 10929 | |
ea47320b DL |
10930 | /* Subtract 8 here because 'Neighbor' is |
10931 | * 8 characters */ | |
10932 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
10933 | vty_out(vty, "%*s", max_neighbor_width - 8, |
10934 | " "); | |
3577f1c5 | 10935 | if (show_failed) |
85eeb029 DA |
10936 | vty_out(vty, |
10937 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
3577f1c5 DD |
10938 | else |
10939 | vty_out(vty, | |
85eeb029 DA |
10940 | show_wide |
10941 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10942 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
d62a17ae | 10943 | } |
ea47320b | 10944 | } |
d62a17ae | 10945 | |
d55811cc | 10946 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10947 | filter = &peer->filter[afi][safi]; |
db92d226 | 10948 | |
ea47320b | 10949 | count++; |
3577f1c5 DD |
10950 | /* Works for both failed & successful cases */ |
10951 | if (peer_dynamic_neighbor(peer)) | |
10952 | dn_count++; | |
d62a17ae | 10953 | |
ea47320b | 10954 | if (use_json) { |
3577f1c5 DD |
10955 | json_peer = NULL; |
10956 | ||
10957 | if (show_failed && | |
10958 | bgp_has_peer_failed(peer, afi, safi)) { | |
10959 | json_peer = json_object_new_object(); | |
10960 | bgp_show_failed_summary(vty, bgp, peer, | |
10961 | json_peer, 0, use_json); | |
10962 | } else if (!show_failed) { | |
10b49f14 DA |
10963 | if (show_established |
10964 | && bgp_has_peer_failed(peer, afi, safi)) | |
10965 | continue; | |
10966 | ||
3577f1c5 DD |
10967 | json_peer = json_object_new_object(); |
10968 | if (peer_dynamic_neighbor(peer)) { | |
10969 | json_object_boolean_true_add(json_peer, | |
10970 | "dynamicPeer"); | |
10971 | } | |
d62a17ae | 10972 | |
3577f1c5 DD |
10973 | if (peer->hostname) |
10974 | json_object_string_add(json_peer, "hostname", | |
10975 | peer->hostname); | |
10976 | ||
10977 | if (peer->domainname) | |
10978 | json_object_string_add(json_peer, "domainname", | |
10979 | peer->domainname); | |
10980 | ||
10981 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
10982 | json_object_int_add( |
10983 | json_peer, "localAs", | |
10984 | peer->change_local_as | |
10985 | ? peer->change_local_as | |
10986 | : peer->local_as); | |
3577f1c5 DD |
10987 | json_object_int_add(json_peer, "version", 4); |
10988 | json_object_int_add(json_peer, "msgRcvd", | |
10989 | PEER_TOTAL_RX(peer)); | |
10990 | json_object_int_add(json_peer, "msgSent", | |
10991 | PEER_TOTAL_TX(peer)); | |
10992 | ||
43aa5965 QY |
10993 | atomic_size_t outq_count, inq_count; |
10994 | outq_count = atomic_load_explicit( | |
10995 | &peer->obuf->count, | |
10996 | memory_order_relaxed); | |
10997 | inq_count = atomic_load_explicit( | |
10998 | &peer->ibuf->count, | |
10999 | memory_order_relaxed); | |
11000 | ||
3577f1c5 DD |
11001 | json_object_int_add(json_peer, "tableVersion", |
11002 | peer->version[afi][safi]); | |
11003 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
11004 | outq_count); |
11005 | json_object_int_add(json_peer, "inq", | |
11006 | inq_count); | |
3577f1c5 DD |
11007 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
11008 | use_json, json_peer); | |
11009 | ||
3577f1c5 DD |
11010 | json_object_int_add(json_peer, "pfxRcd", |
11011 | peer->pcount[afi][pfx_rcd_safi]); | |
11012 | ||
3577f1c5 | 11013 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
11014 | json_object_int_add( |
11015 | json_peer, "pfxSnt", | |
11016 | (PAF_SUBGRP(paf))->scount); | |
11017 | else | |
11018 | json_object_int_add(json_peer, "pfxSnt", | |
11019 | 0); | |
0e1f8ab5 DA |
11020 | |
11021 | /* BGP FSM state */ | |
cb9196e7 | 11022 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
11023 | || CHECK_FLAG(peer->bgp->flags, |
11024 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
11025 | json_object_string_add(json_peer, |
11026 | "state", | |
3577f1c5 DD |
11027 | "Idle (Admin)"); |
11028 | else if (peer->afc_recv[afi][safi]) | |
11029 | json_object_string_add( | |
0e1f8ab5 DA |
11030 | json_peer, "state", |
11031 | lookup_msg(bgp_status_msg, | |
11032 | peer->status, NULL)); | |
11033 | else if (CHECK_FLAG( | |
11034 | peer->sflags, | |
11035 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11036 | json_object_string_add(json_peer, | |
11037 | "state", | |
3577f1c5 DD |
11038 | "Idle (PfxCt)"); |
11039 | else | |
11040 | json_object_string_add( | |
0e1f8ab5 DA |
11041 | json_peer, "state", |
11042 | lookup_msg(bgp_status_msg, | |
11043 | peer->status, NULL)); | |
11044 | ||
11045 | /* BGP peer state */ | |
11046 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
11047 | || CHECK_FLAG(peer->bgp->flags, | |
11048 | BGP_FLAG_SHUTDOWN)) | |
11049 | json_object_string_add(json_peer, | |
11050 | "peerState", | |
11051 | "Admin"); | |
11052 | else if (CHECK_FLAG( | |
11053 | peer->sflags, | |
11054 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11055 | json_object_string_add(json_peer, | |
11056 | "peerState", | |
11057 | "PfxCt"); | |
11058 | else if (CHECK_FLAG(peer->flags, | |
11059 | PEER_FLAG_PASSIVE)) | |
11060 | json_object_string_add(json_peer, | |
11061 | "peerState", | |
11062 | "Passive"); | |
11063 | else if (CHECK_FLAG(peer->sflags, | |
11064 | PEER_STATUS_NSF_WAIT)) | |
11065 | json_object_string_add(json_peer, | |
11066 | "peerState", | |
11067 | "NSF passive"); | |
11068 | else if (CHECK_FLAG( | |
11069 | peer->bgp->flags, | |
11070 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11071 | && (!bgp_inbound_policy_exists(peer, | |
11072 | filter) | |
11073 | || !bgp_outbound_policy_exists( | |
11074 | peer, filter))) | |
11075 | json_object_string_add(json_peer, | |
11076 | "peerState", | |
11077 | "Policy"); | |
11078 | else | |
11079 | json_object_string_add( | |
11080 | json_peer, "peerState", "OK"); | |
11081 | ||
200116db DD |
11082 | json_object_int_add(json_peer, "connectionsEstablished", |
11083 | peer->established); | |
11084 | json_object_int_add(json_peer, "connectionsDropped", | |
11085 | peer->dropped); | |
aa72bd7e PG |
11086 | if (peer->desc) |
11087 | json_object_string_add( | |
11088 | json_peer, "desc", peer->desc); | |
b4e9dcba | 11089 | } |
3577f1c5 DD |
11090 | /* Avoid creating empty peer dicts in JSON */ |
11091 | if (json_peer == NULL) | |
11092 | continue; | |
ea47320b DL |
11093 | |
11094 | if (peer->conf_if) | |
60466a63 | 11095 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
11096 | "interface"); |
11097 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
11098 | json_object_string_add(json_peer, "idType", |
11099 | "ipv4"); | |
ea47320b | 11100 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
11101 | json_object_string_add(json_peer, "idType", |
11102 | "ipv6"); | |
ea47320b DL |
11103 | json_object_object_add(json_peers, peer->host, |
11104 | json_peer); | |
11105 | } else { | |
3577f1c5 DD |
11106 | if (show_failed && |
11107 | bgp_has_peer_failed(peer, afi, safi)) { | |
11108 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
11109 | max_neighbor_width, | |
11110 | use_json); | |
11111 | } else if (!show_failed) { | |
10b49f14 DA |
11112 | if (show_established |
11113 | && bgp_has_peer_failed(peer, afi, safi)) | |
11114 | continue; | |
11115 | ||
3577f1c5 DD |
11116 | memset(dn_flag, '\0', sizeof(dn_flag)); |
11117 | if (peer_dynamic_neighbor(peer)) { | |
11118 | dn_flag[0] = '*'; | |
11119 | } | |
d62a17ae | 11120 | |
3577f1c5 | 11121 | if (peer->hostname |
892fedb6 DA |
11122 | && CHECK_FLAG(bgp->flags, |
11123 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 11124 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
11125 | peer->hostname, |
11126 | peer->host); | |
d62a17ae | 11127 | else |
3577f1c5 DD |
11128 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
11129 | ||
11130 | /* pad the neighbor column with spaces */ | |
11131 | if (len < max_neighbor_width) | |
11132 | vty_out(vty, "%*s", max_neighbor_width - len, | |
11133 | " "); | |
11134 | ||
43aa5965 QY |
11135 | atomic_size_t outq_count, inq_count; |
11136 | outq_count = atomic_load_explicit( | |
11137 | &peer->obuf->count, | |
11138 | memory_order_relaxed); | |
11139 | inq_count = atomic_load_explicit( | |
11140 | &peer->ibuf->count, | |
11141 | memory_order_relaxed); | |
11142 | ||
85eeb029 DA |
11143 | if (show_wide) |
11144 | vty_out(vty, | |
11145 | "4 %10u %10u %9u %9u %8" PRIu64 | |
11146 | " %4zu %4zu %8s", | |
11147 | peer->as, | |
11148 | peer->change_local_as | |
11149 | ? peer->change_local_as | |
11150 | : peer->local_as, | |
11151 | PEER_TOTAL_RX(peer), | |
11152 | PEER_TOTAL_TX(peer), | |
11153 | peer->version[afi][safi], | |
11154 | inq_count, outq_count, | |
11155 | peer_uptime(peer->uptime, | |
11156 | timebuf, | |
11157 | BGP_UPTIME_LEN, 0, | |
11158 | NULL)); | |
11159 | else | |
11160 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
11161 | " %4zu %4zu %8s", | |
11162 | peer->as, PEER_TOTAL_RX(peer), | |
11163 | PEER_TOTAL_TX(peer), | |
11164 | peer->version[afi][safi], | |
11165 | inq_count, outq_count, | |
11166 | peer_uptime(peer->uptime, | |
11167 | timebuf, | |
11168 | BGP_UPTIME_LEN, 0, | |
11169 | NULL)); | |
3577f1c5 | 11170 | |
db92d226 | 11171 | if (peer->status == Established) { |
d3ada366 DA |
11172 | if (peer->afc_recv[afi][safi]) { |
11173 | if (CHECK_FLAG( | |
11174 | bgp->flags, | |
11175 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11176 | && !bgp_inbound_policy_exists( | |
11177 | peer, filter)) | |
11178 | vty_out(vty, " %12s", | |
11179 | "(Policy)"); | |
11180 | else | |
11181 | vty_out(vty, | |
6cde4b45 | 11182 | " %12u", |
d3ada366 DA |
11183 | peer->pcount |
11184 | [afi] | |
11185 | [pfx_rcd_safi]); | |
11186 | } else { | |
749d0f27 | 11187 | vty_out(vty, " NoNeg"); |
d3ada366 | 11188 | } |
db92d226 | 11189 | |
d3ada366 DA |
11190 | if (paf && PAF_SUBGRP(paf)) { |
11191 | if (CHECK_FLAG( | |
11192 | bgp->flags, | |
11193 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11194 | && !bgp_outbound_policy_exists( | |
11195 | peer, filter)) | |
11196 | vty_out(vty, " %8s", | |
11197 | "(Policy)"); | |
11198 | else | |
11199 | vty_out(vty, | |
6cde4b45 | 11200 | " %8u", |
d3ada366 DA |
11201 | (PAF_SUBGRP( |
11202 | paf)) | |
11203 | ->scount); | |
749d0f27 DA |
11204 | } else { |
11205 | vty_out(vty, " NoNeg"); | |
d3ada366 | 11206 | } |
db92d226 | 11207 | } else { |
736b68f3 DS |
11208 | if (CHECK_FLAG(peer->flags, |
11209 | PEER_FLAG_SHUTDOWN) | |
11210 | || CHECK_FLAG(peer->bgp->flags, | |
11211 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
11212 | vty_out(vty, " Idle (Admin)"); |
11213 | else if (CHECK_FLAG( | |
11214 | peer->sflags, | |
11215 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11216 | vty_out(vty, " Idle (PfxCt)"); | |
11217 | else | |
11218 | vty_out(vty, " %12s", | |
11219 | lookup_msg(bgp_status_msg, | |
11220 | peer->status, NULL)); | |
db92d226 | 11221 | |
6cde4b45 | 11222 | vty_out(vty, " %8u", 0); |
3577f1c5 | 11223 | } |
aa72bd7e | 11224 | if (peer->desc) |
cb75bb31 DA |
11225 | vty_out(vty, " %s", |
11226 | bgp_peer_description_stripped( | |
85eeb029 DA |
11227 | peer->desc, |
11228 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
11229 | else |
11230 | vty_out(vty, " N/A"); | |
3577f1c5 | 11231 | vty_out(vty, "\n"); |
d62a17ae | 11232 | } |
3577f1c5 | 11233 | |
d62a17ae | 11234 | } |
11235 | } | |
f933309e | 11236 | |
d62a17ae | 11237 | if (use_json) { |
11238 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11239 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 11240 | json_object_int_add(json, "totalPeers", count); |
11241 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11242 | ||
3577f1c5 DD |
11243 | if (!show_failed) |
11244 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11245 | |
996c9314 LB |
11246 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11247 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11248 | json_object_free(json); |
11249 | } else { | |
11250 | if (count) | |
11251 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
11252 | else { | |
d6ceaca3 | 11253 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11254 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11255 | } |
b05a1c8b | 11256 | |
d6ceaca3 | 11257 | if (dn_count) { |
d62a17ae | 11258 | vty_out(vty, "* - dynamic neighbor\n"); |
11259 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11260 | dn_count, bgp->dynamic_neighbors_limit); | |
11261 | } | |
11262 | } | |
1ff9a340 | 11263 | |
d62a17ae | 11264 | return CMD_SUCCESS; |
718e3744 | 11265 | } |
11266 | ||
d62a17ae | 11267 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
85eeb029 | 11268 | int safi, uint8_t show_flags) |
d62a17ae | 11269 | { |
11270 | int is_first = 1; | |
11271 | int afi_wildcard = (afi == AFI_MAX); | |
11272 | int safi_wildcard = (safi == SAFI_MAX); | |
11273 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11274 | bool nbr_output = false; |
85eeb029 | 11275 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11276 | |
11277 | if (use_json && is_wildcard) | |
11278 | vty_out(vty, "{\n"); | |
11279 | if (afi_wildcard) | |
11280 | afi = 1; /* AFI_IP */ | |
11281 | while (afi < AFI_MAX) { | |
11282 | if (safi_wildcard) | |
11283 | safi = 1; /* SAFI_UNICAST */ | |
11284 | while (safi < SAFI_MAX) { | |
318cac96 | 11285 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11286 | nbr_output = true; |
f86897b9 | 11287 | |
d62a17ae | 11288 | if (is_wildcard) { |
11289 | /* | |
11290 | * So limit output to those afi/safi | |
11291 | * pairs that | |
11292 | * actualy have something interesting in | |
11293 | * them | |
11294 | */ | |
11295 | if (use_json) { | |
d62a17ae | 11296 | if (!is_first) |
11297 | vty_out(vty, ",\n"); | |
11298 | else | |
11299 | is_first = 0; | |
11300 | ||
11301 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11302 | get_afi_safi_str(afi, |
11303 | safi, | |
11304 | true)); | |
d62a17ae | 11305 | } else { |
11306 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
11307 | get_afi_safi_str(afi, |
11308 | safi, | |
11309 | false)); | |
d62a17ae | 11310 | } |
11311 | } | |
10b49f14 | 11312 | bgp_show_summary(vty, bgp, afi, safi, |
85eeb029 | 11313 | show_flags); |
d62a17ae | 11314 | } |
11315 | safi++; | |
d62a17ae | 11316 | if (!safi_wildcard) |
11317 | safi = SAFI_MAX; | |
11318 | } | |
11319 | afi++; | |
ee851c8c | 11320 | if (!afi_wildcard) |
d62a17ae | 11321 | afi = AFI_MAX; |
11322 | } | |
11323 | ||
11324 | if (use_json && is_wildcard) | |
11325 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11326 | else if (!nbr_output) { |
11327 | if (use_json) | |
11328 | vty_out(vty, "{}\n"); | |
11329 | else | |
11330 | vty_out(vty, "%% No BGP neighbors found\n"); | |
11331 | } | |
d62a17ae | 11332 | } |
11333 | ||
11334 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
85eeb029 | 11335 | safi_t safi, uint8_t show_flags) |
d62a17ae | 11336 | { |
11337 | struct listnode *node, *nnode; | |
11338 | struct bgp *bgp; | |
d62a17ae | 11339 | int is_first = 1; |
9f049418 | 11340 | bool nbr_output = false; |
85eeb029 | 11341 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11342 | |
11343 | if (use_json) | |
11344 | vty_out(vty, "{\n"); | |
11345 | ||
11346 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11347 | nbr_output = true; |
d62a17ae | 11348 | if (use_json) { |
d62a17ae | 11349 | if (!is_first) |
11350 | vty_out(vty, ",\n"); | |
11351 | else | |
11352 | is_first = 0; | |
11353 | ||
11354 | vty_out(vty, "\"%s\":", | |
11355 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11356 | ? VRF_DEFAULT_NAME |
d62a17ae | 11357 | : bgp->name); |
11358 | } else { | |
11359 | vty_out(vty, "\nInstance %s:\n", | |
11360 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11361 | ? VRF_DEFAULT_NAME |
d62a17ae | 11362 | : bgp->name); |
11363 | } | |
85eeb029 | 11364 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_flags); |
d62a17ae | 11365 | } |
11366 | ||
11367 | if (use_json) | |
11368 | vty_out(vty, "}\n"); | |
9f049418 DS |
11369 | else if (!nbr_output) |
11370 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11371 | } |
11372 | ||
11373 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
85eeb029 | 11374 | safi_t safi, uint8_t show_flags) |
d62a17ae | 11375 | { |
11376 | struct bgp *bgp; | |
85eeb029 | 11377 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11378 | |
11379 | if (name) { | |
11380 | if (strmatch(name, "all")) { | |
85eeb029 DA |
11381 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
11382 | show_flags); | |
d62a17ae | 11383 | return CMD_SUCCESS; |
11384 | } else { | |
11385 | bgp = bgp_lookup_by_name(name); | |
11386 | ||
11387 | if (!bgp) { | |
11388 | if (use_json) | |
11389 | vty_out(vty, "{}\n"); | |
11390 | else | |
11391 | vty_out(vty, | |
ca61fd25 | 11392 | "%% BGP instance not found\n"); |
d62a17ae | 11393 | return CMD_WARNING; |
11394 | } | |
11395 | ||
f86897b9 | 11396 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
85eeb029 | 11397 | show_flags); |
d62a17ae | 11398 | return CMD_SUCCESS; |
11399 | } | |
11400 | } | |
11401 | ||
11402 | bgp = bgp_get_default(); | |
11403 | ||
11404 | if (bgp) | |
85eeb029 | 11405 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_flags); |
9f049418 | 11406 | else { |
ca61fd25 DS |
11407 | if (use_json) |
11408 | vty_out(vty, "{}\n"); | |
11409 | else | |
11410 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11411 | return CMD_WARNING; |
11412 | } | |
d62a17ae | 11413 | |
11414 | return CMD_SUCCESS; | |
4fb25c53 DW |
11415 | } |
11416 | ||
716b2d8a | 11417 | /* `show [ip] bgp summary' commands. */ |
96f3485c | 11418 | DEFPY (show_ip_bgp_summary, |
718e3744 | 11419 | show_ip_bgp_summary_cmd, |
85eeb029 | 11420 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [wide] [json$uj]", |
718e3744 | 11421 | SHOW_STR |
11422 | IP_STR | |
11423 | BGP_STR | |
8386ac43 | 11424 | BGP_INSTANCE_HELP_STR |
46f296b4 | 11425 | BGP_AFI_HELP_STR |
dd6bd0f1 | 11426 | BGP_SAFI_WITH_LABEL_HELP_STR |
96f3485c | 11427 | "Display the entries for all address families\n" |
b05a1c8b | 11428 | "Summary of BGP neighbor status\n" |
10b49f14 | 11429 | "Show only sessions in Established state\n" |
3577f1c5 | 11430 | "Show only sessions not in Established state\n" |
85eeb029 | 11431 | "Increase table width for longer output\n" |
9973d184 | 11432 | JSON_STR) |
718e3744 | 11433 | { |
d62a17ae | 11434 | char *vrf = NULL; |
11435 | afi_t afi = AFI_MAX; | |
11436 | safi_t safi = SAFI_MAX; | |
85eeb029 | 11437 | uint8_t show_flags = 0; |
d62a17ae | 11438 | |
11439 | int idx = 0; | |
11440 | ||
11441 | /* show [ip] bgp */ | |
96f3485c | 11442 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11443 | afi = AFI_IP; |
9a8bdf1c PG |
11444 | /* [<vrf> VIEWVRFNAME] */ |
11445 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11446 | vrf = argv[idx + 1]->arg; | |
11447 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11448 | vrf = NULL; | |
11449 | } else if (argv_find(argv, argc, "view", &idx)) | |
11450 | /* [<view> VIEWVRFNAME] */ | |
11451 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11452 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11453 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11454 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11455 | } | |
11456 | ||
3577f1c5 | 11457 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11458 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11459 | ||
10b49f14 | 11460 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11461 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11462 | ||
11463 | if (argv_find(argv, argc, "wide", &idx)) | |
11464 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11465 | ||
11466 | if (argv_find(argv, argc, "json", &idx)) | |
11467 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11468 | |
85eeb029 | 11469 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_flags); |
d62a17ae | 11470 | } |
11471 | ||
5cb5f4d0 | 11472 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11473 | { |
5cb5f4d0 DD |
11474 | if (for_json) |
11475 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11476 | else |
5cb5f4d0 | 11477 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11478 | } |
11479 | ||
d62a17ae | 11480 | |
11481 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11482 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11483 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11484 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11485 | bool use_json, json_object *json_pref) |
d62a17ae | 11486 | { |
11487 | /* Send-Mode */ | |
11488 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11489 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11490 | if (use_json) { | |
11491 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11492 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11493 | json_object_string_add(json_pref, "sendMode", | |
11494 | "advertisedAndReceived"); | |
11495 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11496 | json_object_string_add(json_pref, "sendMode", | |
11497 | "advertised"); | |
11498 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11499 | json_object_string_add(json_pref, "sendMode", | |
11500 | "received"); | |
11501 | } else { | |
11502 | vty_out(vty, " Send-mode: "); | |
11503 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11504 | vty_out(vty, "advertised"); | |
11505 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11506 | vty_out(vty, "%sreceived", | |
11507 | CHECK_FLAG(p->af_cap[afi][safi], | |
11508 | adv_smcap) | |
11509 | ? ", " | |
11510 | : ""); | |
11511 | vty_out(vty, "\n"); | |
11512 | } | |
11513 | } | |
11514 | ||
11515 | /* Receive-Mode */ | |
11516 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11517 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11518 | if (use_json) { | |
11519 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11520 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11521 | json_object_string_add(json_pref, "recvMode", | |
11522 | "advertisedAndReceived"); | |
11523 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11524 | json_object_string_add(json_pref, "recvMode", | |
11525 | "advertised"); | |
11526 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11527 | json_object_string_add(json_pref, "recvMode", | |
11528 | "received"); | |
11529 | } else { | |
11530 | vty_out(vty, " Receive-mode: "); | |
11531 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11532 | vty_out(vty, "advertised"); | |
11533 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11534 | vty_out(vty, "%sreceived", | |
11535 | CHECK_FLAG(p->af_cap[afi][safi], | |
11536 | adv_rmcap) | |
11537 | ? ", " | |
11538 | : ""); | |
11539 | vty_out(vty, "\n"); | |
11540 | } | |
11541 | } | |
11542 | } | |
11543 | ||
13909c4f DS |
11544 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11545 | struct peer *p, | |
11546 | bool use_json, | |
11547 | json_object *json) | |
2986cac2 | 11548 | { |
08c2d52a | 11549 | bool rbit_status = false; |
2986cac2 | 11550 | |
11551 | if (!use_json) | |
a53ca37b | 11552 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11553 | |
13909c4f DS |
11554 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11555 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
11556 | && (p->status == Established)) { | |
2986cac2 | 11557 | |
11558 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11559 | rbit_status = true; |
2986cac2 | 11560 | else |
08c2d52a | 11561 | rbit_status = false; |
2986cac2 | 11562 | } |
11563 | ||
11564 | if (rbit_status) { | |
11565 | if (use_json) | |
13909c4f | 11566 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11567 | else |
11568 | vty_out(vty, "True\n"); | |
11569 | } else { | |
11570 | if (use_json) | |
13909c4f | 11571 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11572 | else |
11573 | vty_out(vty, "False\n"); | |
11574 | } | |
11575 | } | |
11576 | ||
13909c4f DS |
11577 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11578 | struct peer *peer, | |
11579 | bool use_json, | |
11580 | json_object *json) | |
2986cac2 | 11581 | { |
2bb5d39b | 11582 | const char *mode = "NotApplicable"; |
2986cac2 | 11583 | |
11584 | if (!use_json) | |
a53ca37b | 11585 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11586 | |
13909c4f DS |
11587 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11588 | && (peer->status == Established)) { | |
2986cac2 | 11589 | |
13909c4f DS |
11590 | if ((peer->nsf_af_count == 0) |
11591 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11592 | |
2986cac2 | 11593 | mode = "Disable"; |
11594 | ||
13909c4f DS |
11595 | } else if (peer->nsf_af_count == 0 |
11596 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11597 | |
2986cac2 | 11598 | mode = "Helper"; |
11599 | ||
13909c4f DS |
11600 | } else if (peer->nsf_af_count != 0 |
11601 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11602 | |
2986cac2 | 11603 | mode = "Restart"; |
2986cac2 | 11604 | } |
11605 | } | |
11606 | ||
11607 | if (use_json) { | |
13909c4f | 11608 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11609 | } else |
11610 | vty_out(vty, mode, "\n"); | |
11611 | } | |
11612 | ||
13909c4f DS |
11613 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11614 | struct peer *p, | |
11615 | bool use_json, | |
11616 | json_object *json) | |
2986cac2 | 11617 | { |
11618 | const char *mode = "Invalid"; | |
11619 | ||
11620 | if (!use_json) | |
a53ca37b | 11621 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11622 | |
11623 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11624 | mode = "Helper"; | |
11625 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11626 | mode = "Restart"; | |
11627 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11628 | mode = "Disable"; | |
2ba1fe69 | 11629 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11630 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11631 | mode = "Helper*"; | |
11632 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11633 | mode = "Restart*"; | |
11634 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11635 | mode = "Disable*"; | |
11636 | else | |
11637 | mode = "Invalid*"; | |
2ba1fe69 | 11638 | } |
2986cac2 | 11639 | |
11640 | if (use_json) { | |
13909c4f | 11641 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11642 | } else { |
11643 | vty_out(vty, mode, "\n"); | |
11644 | } | |
11645 | } | |
11646 | ||
13909c4f DS |
11647 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11648 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11649 | { |
2ba1fe69 | 11650 | afi_t afi; |
11651 | safi_t safi; | |
2986cac2 | 11652 | json_object *json_afi_safi = NULL; |
11653 | json_object *json_timer = NULL; | |
11654 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11655 | bool eor_flag = false; |
2986cac2 | 11656 | |
11657 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11658 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11659 | if (!peer->afc[afi][safi]) |
11660 | continue; | |
2986cac2 | 11661 | |
13909c4f DS |
11662 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11663 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11664 | continue; | |
9e3b51a7 | 11665 | |
13909c4f DS |
11666 | if (use_json) { |
11667 | json_afi_safi = json_object_new_object(); | |
11668 | json_endofrib_status = json_object_new_object(); | |
11669 | json_timer = json_object_new_object(); | |
11670 | } | |
2986cac2 | 11671 | |
13909c4f DS |
11672 | if (peer->eor_stime[afi][safi] |
11673 | >= peer->pkt_stime[afi][safi]) | |
11674 | eor_flag = true; | |
11675 | else | |
11676 | eor_flag = false; | |
2986cac2 | 11677 | |
13909c4f | 11678 | if (!use_json) { |
a53ca37b | 11679 | vty_out(vty, " %s:\n", |
13909c4f | 11680 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11681 | |
a53ca37b | 11682 | vty_out(vty, " F bit: "); |
698ba8d0 | 11683 | } |
2986cac2 | 11684 | |
13909c4f DS |
11685 | if (peer->nsf[afi][safi] |
11686 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11687 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11688 | |
13909c4f DS |
11689 | if (use_json) { |
11690 | json_object_boolean_true_add( | |
2986cac2 | 11691 | json_afi_safi, "fBit"); |
13909c4f DS |
11692 | } else |
11693 | vty_out(vty, "True\n"); | |
11694 | } else { | |
11695 | if (use_json) | |
11696 | json_object_boolean_false_add( | |
11697 | json_afi_safi, "fBit"); | |
11698 | else | |
11699 | vty_out(vty, "False\n"); | |
11700 | } | |
2986cac2 | 11701 | |
13909c4f | 11702 | if (!use_json) |
a53ca37b | 11703 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11704 | |
13909c4f DS |
11705 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11706 | PEER_STATUS_EOR_SEND)) { | |
11707 | if (use_json) { | |
11708 | json_object_boolean_true_add( | |
2986cac2 | 11709 | json_endofrib_status, |
13909c4f | 11710 | "endOfRibSend"); |
9e3b51a7 | 11711 | |
13909c4f DS |
11712 | PRINT_EOR_JSON(eor_flag); |
11713 | } else { | |
11714 | vty_out(vty, "Yes\n"); | |
11715 | vty_out(vty, | |
a53ca37b | 11716 | " End-of-RIB sent after update: "); |
2986cac2 | 11717 | |
13909c4f DS |
11718 | PRINT_EOR(eor_flag); |
11719 | } | |
11720 | } else { | |
11721 | if (use_json) { | |
11722 | json_object_boolean_false_add( | |
2986cac2 | 11723 | json_endofrib_status, |
13909c4f DS |
11724 | "endOfRibSend"); |
11725 | json_object_boolean_false_add( | |
9e3b51a7 | 11726 | json_endofrib_status, |
13909c4f DS |
11727 | "endOfRibSentAfterUpdate"); |
11728 | } else { | |
11729 | vty_out(vty, "No\n"); | |
11730 | vty_out(vty, | |
a53ca37b | 11731 | " End-of-RIB sent after update: "); |
13909c4f | 11732 | vty_out(vty, "No\n"); |
2986cac2 | 11733 | } |
13909c4f | 11734 | } |
2986cac2 | 11735 | |
a53ca37b DA |
11736 | if (!use_json) |
11737 | vty_out(vty, " End-of-RIB received: "); | |
11738 | ||
11739 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11740 | PEER_STATUS_EOR_RECEIVED)) { | |
11741 | if (use_json) | |
11742 | json_object_boolean_true_add( | |
11743 | json_endofrib_status, | |
11744 | "endOfRibRecv"); | |
11745 | else | |
11746 | vty_out(vty, "Yes\n"); | |
11747 | } else { | |
11748 | if (use_json) | |
11749 | json_object_boolean_false_add( | |
11750 | json_endofrib_status, | |
11751 | "endOfRibRecv"); | |
11752 | else | |
11753 | vty_out(vty, "No\n"); | |
11754 | } | |
11755 | ||
13909c4f DS |
11756 | if (use_json) { |
11757 | json_object_int_add(json_timer, | |
11758 | "stalePathTimer", | |
11759 | peer->bgp->stalepath_time); | |
2986cac2 | 11760 | |
13909c4f DS |
11761 | if (peer->t_gr_stale != NULL) { |
11762 | json_object_int_add( | |
2986cac2 | 11763 | json_timer, |
11764 | "stalePathTimerRemaining", | |
11765 | thread_timer_remain_second( | |
13909c4f DS |
11766 | peer->t_gr_stale)); |
11767 | } | |
3a75afa4 | 11768 | |
13909c4f DS |
11769 | /* Display Configured Selection |
11770 | * Deferral only when when | |
11771 | * Gr mode is enabled. | |
11772 | */ | |
11773 | if (CHECK_FLAG(peer->flags, | |
11774 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11775 | json_object_int_add( | |
3a75afa4 | 11776 | json_timer, |
2986cac2 | 11777 | "selectionDeferralTimer", |
11778 | peer->bgp->stalepath_time); | |
13909c4f | 11779 | } |
2986cac2 | 11780 | |
13909c4f DS |
11781 | if (peer->bgp->gr_info[afi][safi] |
11782 | .t_select_deferral | |
11783 | != NULL) { | |
2986cac2 | 11784 | |
13909c4f | 11785 | json_object_int_add( |
2986cac2 | 11786 | json_timer, |
11787 | "selectionDeferralTimerRemaining", | |
11788 | thread_timer_remain_second( | |
13909c4f DS |
11789 | peer->bgp |
11790 | ->gr_info[afi] | |
11791 | [safi] | |
11792 | .t_select_deferral)); | |
11793 | } | |
11794 | } else { | |
a53ca37b | 11795 | vty_out(vty, " Timers:\n"); |
13909c4f | 11796 | vty_out(vty, |
a53ca37b DA |
11797 | " Configured Stale Path Time(sec): %u\n", |
11798 | peer->bgp->stalepath_time); | |
2986cac2 | 11799 | |
a53ca37b | 11800 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11801 | vty_out(vty, |
a53ca37b | 11802 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11803 | thread_timer_remain_second( |
13909c4f | 11804 | peer->t_gr_stale)); |
13909c4f DS |
11805 | /* Display Configured Selection |
11806 | * Deferral only when when | |
11807 | * Gr mode is enabled. | |
11808 | */ | |
11809 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11810 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11811 | vty_out(vty, |
a53ca37b | 11812 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11813 | peer->bgp->select_defer_time); |
2986cac2 | 11814 | |
13909c4f DS |
11815 | if (peer->bgp->gr_info[afi][safi] |
11816 | .t_select_deferral | |
a53ca37b | 11817 | != NULL) |
13909c4f | 11818 | vty_out(vty, |
a53ca37b | 11819 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11820 | thread_timer_remain_second( |
13909c4f DS |
11821 | peer->bgp |
11822 | ->gr_info[afi] | |
11823 | [safi] | |
11824 | .t_select_deferral)); | |
2986cac2 | 11825 | } |
13909c4f DS |
11826 | if (use_json) { |
11827 | json_object_object_add(json_afi_safi, | |
11828 | "endOfRibStatus", | |
11829 | json_endofrib_status); | |
11830 | json_object_object_add(json_afi_safi, "timers", | |
11831 | json_timer); | |
11832 | json_object_object_add( | |
11833 | json, get_afi_safi_str(afi, safi, true), | |
11834 | json_afi_safi); | |
11835 | } | |
2986cac2 | 11836 | } |
11837 | } | |
11838 | } | |
11839 | ||
36235319 QY |
11840 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11841 | struct peer *p, | |
11842 | bool use_json, | |
11843 | json_object *json) | |
2986cac2 | 11844 | { |
11845 | if (use_json) { | |
11846 | json_object *json_timer = NULL; | |
11847 | ||
11848 | json_timer = json_object_new_object(); | |
11849 | ||
13909c4f DS |
11850 | json_object_int_add(json_timer, "configuredRestartTimer", |
11851 | p->bgp->restart_time); | |
2986cac2 | 11852 | |
13909c4f DS |
11853 | json_object_int_add(json_timer, "receivedRestartTimer", |
11854 | p->v_gr_restart); | |
2986cac2 | 11855 | |
13909c4f DS |
11856 | if (p->t_gr_restart != NULL) |
11857 | json_object_int_add( | |
11858 | json_timer, "restartTimerRemaining", | |
11859 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11860 | |
11861 | json_object_object_add(json, "timers", json_timer); | |
11862 | } else { | |
11863 | ||
a53ca37b DA |
11864 | vty_out(vty, " Timers:\n"); |
11865 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11866 | p->bgp->restart_time); |
2986cac2 | 11867 | |
a53ca37b | 11868 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11869 | p->v_gr_restart); |
11870 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11871 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11872 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11873 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11874 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11875 | thread_timer_remain_second(p->t_gr_restart)); |
11876 | } | |
2986cac2 | 11877 | } |
11878 | } | |
11879 | ||
11880 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11881 | bool use_json, json_object *json) |
2986cac2 | 11882 | { |
11883 | char buf[SU_ADDRSTRLEN] = {0}; | |
11884 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11885 | /* '*' + v6 address of neighbor */ |
11886 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11887 | |
2986cac2 | 11888 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11889 | dn_flag[0] = '*'; | |
11890 | ||
11891 | if (p->conf_if) { | |
11892 | if (use_json) | |
13909c4f DS |
11893 | json_object_string_add( |
11894 | json, "neighborAddr", | |
2986cac2 | 11895 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11896 | ? "none" |
11897 | : sockunion2str(&p->su, buf, | |
11898 | SU_ADDRSTRLEN)); | |
2986cac2 | 11899 | else |
13909c4f | 11900 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11901 | BGP_PEER_SU_UNSPEC(p) |
11902 | ? "none" | |
11903 | : sockunion2str(&p->su, buf, | |
11904 | SU_ADDRSTRLEN)); | |
11905 | } else { | |
772270f3 QY |
11906 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11907 | p->host); | |
2986cac2 | 11908 | |
11909 | if (use_json) | |
36235319 QY |
11910 | json_object_string_add(json, "neighborAddr", |
11911 | neighborAddr); | |
2986cac2 | 11912 | else |
36235319 | 11913 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11914 | } |
11915 | ||
11916 | /* more gr info in new format */ | |
11917 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11918 | } | |
11919 | ||
d62a17ae | 11920 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11921 | safi_t safi, bool use_json, |
d62a17ae | 11922 | json_object *json_neigh) |
11923 | { | |
0291c246 MK |
11924 | struct bgp_filter *filter; |
11925 | struct peer_af *paf; | |
11926 | char orf_pfx_name[BUFSIZ]; | |
11927 | int orf_pfx_count; | |
11928 | json_object *json_af = NULL; | |
11929 | json_object *json_prefA = NULL; | |
11930 | json_object *json_prefB = NULL; | |
11931 | json_object *json_addr = NULL; | |
fa36596c | 11932 | json_object *json_advmap = NULL; |
d62a17ae | 11933 | |
11934 | if (use_json) { | |
11935 | json_addr = json_object_new_object(); | |
11936 | json_af = json_object_new_object(); | |
11937 | filter = &p->filter[afi][safi]; | |
11938 | ||
11939 | if (peer_group_active(p)) | |
11940 | json_object_string_add(json_addr, "peerGroupMember", | |
11941 | p->group->name); | |
11942 | ||
11943 | paf = peer_af_find(p, afi, safi); | |
11944 | if (paf && PAF_SUBGRP(paf)) { | |
11945 | json_object_int_add(json_addr, "updateGroupId", | |
11946 | PAF_UPDGRP(paf)->id); | |
11947 | json_object_int_add(json_addr, "subGroupId", | |
11948 | PAF_SUBGRP(paf)->id); | |
11949 | json_object_int_add(json_addr, "packetQueueLength", | |
11950 | bpacket_queue_virtual_length(paf)); | |
11951 | } | |
11952 | ||
11953 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11954 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11955 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11956 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11957 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11958 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11959 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11960 | json_object_int_add(json_af, "orfType", | |
11961 | ORF_TYPE_PREFIX); | |
11962 | json_prefA = json_object_new_object(); | |
11963 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11964 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11965 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11966 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11967 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11968 | use_json, json_prefA); | |
11969 | json_object_object_add(json_af, "orfPrefixList", | |
11970 | json_prefA); | |
11971 | } | |
11972 | ||
11973 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11974 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11975 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11976 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11977 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11978 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11979 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11980 | json_object_int_add(json_af, "orfOldType", | |
11981 | ORF_TYPE_PREFIX_OLD); | |
11982 | json_prefB = json_object_new_object(); | |
11983 | bgp_show_peer_afi_orf_cap( | |
11984 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11985 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11986 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11987 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11988 | json_prefB); | |
11989 | json_object_object_add(json_af, "orfOldPrefixList", | |
11990 | json_prefB); | |
11991 | } | |
11992 | ||
11993 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11994 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11995 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11996 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11997 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11998 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11999 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12000 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12001 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12002 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12003 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12004 | json_object_object_add(json_addr, "afDependentCap", | |
12005 | json_af); | |
12006 | else | |
12007 | json_object_free(json_af); | |
12008 | ||
772270f3 QY |
12009 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12010 | p->host, afi, safi); | |
d62a17ae | 12011 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12012 | NULL, afi, orf_pfx_name, use_json); | |
12013 | ||
12014 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12015 | PEER_STATUS_ORF_PREFIX_SEND) | |
12016 | || orf_pfx_count) { | |
12017 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12018 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12019 | json_object_boolean_true_add(json_neigh, | |
12020 | "orfSent"); | |
12021 | if (orf_pfx_count) | |
12022 | json_object_int_add(json_addr, "orfRecvCounter", | |
12023 | orf_pfx_count); | |
12024 | } | |
12025 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12026 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12027 | json_object_string_add( | |
12028 | json_addr, "orfFirstUpdate", | |
12029 | "deferredUntilORFOrRouteRefreshRecvd"); | |
12030 | ||
12031 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12032 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12033 | json_object_boolean_true_add(json_addr, | |
12034 | "routeReflectorClient"); | |
12035 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12036 | PEER_FLAG_RSERVER_CLIENT)) | |
12037 | json_object_boolean_true_add(json_addr, | |
12038 | "routeServerClient"); | |
12039 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12040 | json_object_boolean_true_add(json_addr, | |
12041 | "inboundSoftConfigPermit"); | |
12042 | ||
12043 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12044 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12045 | json_object_boolean_true_add( | |
12046 | json_addr, | |
12047 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
12048 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12049 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12050 | json_object_boolean_true_add( | |
12051 | json_addr, | |
12052 | "privateAsNumsReplacedInUpdatesToNbr"); | |
12053 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12054 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12055 | json_object_boolean_true_add( | |
12056 | json_addr, | |
12057 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
12058 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12059 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12060 | json_object_boolean_true_add( | |
12061 | json_addr, | |
12062 | "privateAsNumsRemovedInUpdatesToNbr"); | |
12063 | ||
dcc68b5e MS |
12064 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12065 | json_object_boolean_true_add( | |
12066 | json_addr, | |
12067 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12068 | ->type_json_name); | |
d62a17ae | 12069 | |
12070 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12071 | json_object_string_add(json_addr, | |
12072 | "overrideASNsInOutboundUpdates", | |
12073 | "ifAspathEqualRemoteAs"); | |
12074 | ||
12075 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12076 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12077 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12078 | json_object_boolean_true_add(json_addr, | |
12079 | "routerAlwaysNextHop"); | |
12080 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12081 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12082 | json_object_boolean_true_add( | |
12083 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
12084 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12085 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12086 | json_object_boolean_true_add( | |
12087 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
12088 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12089 | json_object_boolean_true_add( | |
12090 | json_addr, "unchangedMedPropogatedToNbr"); | |
12091 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12092 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12093 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
12094 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12095 | PEER_FLAG_SEND_COMMUNITY) | |
12096 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12097 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12098 | json_object_string_add(json_addr, | |
12099 | "commAttriSentToNbr", | |
12100 | "extendedAndStandard"); | |
12101 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12102 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12103 | json_object_string_add(json_addr, | |
12104 | "commAttriSentToNbr", | |
12105 | "extended"); | |
12106 | else | |
12107 | json_object_string_add(json_addr, | |
12108 | "commAttriSentToNbr", | |
12109 | "standard"); | |
12110 | } | |
12111 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12112 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12113 | if (p->default_rmap[afi][safi].name) | |
12114 | json_object_string_add( | |
12115 | json_addr, "defaultRouteMap", | |
12116 | p->default_rmap[afi][safi].name); | |
12117 | ||
12118 | if (paf && PAF_SUBGRP(paf) | |
12119 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12120 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12121 | json_object_boolean_true_add(json_addr, | |
12122 | "defaultSent"); | |
12123 | else | |
12124 | json_object_boolean_true_add(json_addr, | |
12125 | "defaultNotSent"); | |
12126 | } | |
12127 | ||
dff8f48d | 12128 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 12129 | if (is_evpn_enabled()) |
60466a63 QY |
12130 | json_object_boolean_true_add( |
12131 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
12132 | } |
12133 | ||
d62a17ae | 12134 | if (filter->plist[FILTER_IN].name |
12135 | || filter->dlist[FILTER_IN].name | |
12136 | || filter->aslist[FILTER_IN].name | |
12137 | || filter->map[RMAP_IN].name) | |
12138 | json_object_boolean_true_add(json_addr, | |
12139 | "inboundPathPolicyConfig"); | |
12140 | if (filter->plist[FILTER_OUT].name | |
12141 | || filter->dlist[FILTER_OUT].name | |
12142 | || filter->aslist[FILTER_OUT].name | |
12143 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12144 | json_object_boolean_true_add( | |
12145 | json_addr, "outboundPathPolicyConfig"); | |
12146 | ||
12147 | /* prefix-list */ | |
12148 | if (filter->plist[FILTER_IN].name) | |
12149 | json_object_string_add(json_addr, | |
12150 | "incomingUpdatePrefixFilterList", | |
12151 | filter->plist[FILTER_IN].name); | |
12152 | if (filter->plist[FILTER_OUT].name) | |
12153 | json_object_string_add(json_addr, | |
12154 | "outgoingUpdatePrefixFilterList", | |
12155 | filter->plist[FILTER_OUT].name); | |
12156 | ||
12157 | /* distribute-list */ | |
12158 | if (filter->dlist[FILTER_IN].name) | |
12159 | json_object_string_add( | |
12160 | json_addr, "incomingUpdateNetworkFilterList", | |
12161 | filter->dlist[FILTER_IN].name); | |
12162 | if (filter->dlist[FILTER_OUT].name) | |
12163 | json_object_string_add( | |
12164 | json_addr, "outgoingUpdateNetworkFilterList", | |
12165 | filter->dlist[FILTER_OUT].name); | |
12166 | ||
12167 | /* filter-list. */ | |
12168 | if (filter->aslist[FILTER_IN].name) | |
12169 | json_object_string_add(json_addr, | |
12170 | "incomingUpdateAsPathFilterList", | |
12171 | filter->aslist[FILTER_IN].name); | |
12172 | if (filter->aslist[FILTER_OUT].name) | |
12173 | json_object_string_add(json_addr, | |
12174 | "outgoingUpdateAsPathFilterList", | |
12175 | filter->aslist[FILTER_OUT].name); | |
12176 | ||
12177 | /* route-map. */ | |
12178 | if (filter->map[RMAP_IN].name) | |
12179 | json_object_string_add( | |
12180 | json_addr, "routeMapForIncomingAdvertisements", | |
12181 | filter->map[RMAP_IN].name); | |
12182 | if (filter->map[RMAP_OUT].name) | |
12183 | json_object_string_add( | |
12184 | json_addr, "routeMapForOutgoingAdvertisements", | |
12185 | filter->map[RMAP_OUT].name); | |
12186 | ||
9dac9fc8 | 12187 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12188 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12189 | && !bgp_inbound_policy_exists(p, filter)) |
12190 | json_object_string_add( | |
12191 | json_addr, "inboundEbgpRequiresPolicy", | |
12192 | "Inbound updates discarded due to missing policy"); | |
12193 | ||
12194 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12195 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12196 | && (!bgp_outbound_policy_exists(p, filter))) |
12197 | json_object_string_add( | |
12198 | json_addr, "outboundEbgpRequiresPolicy", | |
12199 | "Outbound updates discarded due to missing policy"); | |
12200 | ||
d62a17ae | 12201 | /* unsuppress-map */ |
12202 | if (filter->usmap.name) | |
12203 | json_object_string_add(json_addr, | |
12204 | "selectiveUnsuppressRouteMap", | |
12205 | filter->usmap.name); | |
12206 | ||
fa36596c MK |
12207 | /* advertise-map */ |
12208 | if (filter->advmap.aname) { | |
12209 | json_advmap = json_object_new_object(); | |
12210 | json_object_string_add(json_advmap, "condition", | |
12211 | filter->advmap.condition | |
12212 | ? "EXIST" | |
12213 | : "NON_EXIST"); | |
12214 | json_object_string_add(json_advmap, "conditionMap", | |
12215 | filter->advmap.cname); | |
12216 | json_object_string_add(json_advmap, "advertiseMap", | |
12217 | filter->advmap.aname); | |
12218 | json_object_string_add(json_advmap, "advertiseStatus", | |
12219 | filter->advmap.update_type | |
12220 | == ADVERTISE | |
12221 | ? "Advertise" | |
12222 | : "Withdraw"); | |
12223 | json_object_object_add(json_addr, "advertiseMap", | |
12224 | json_advmap); | |
12225 | } | |
12226 | ||
d62a17ae | 12227 | /* Receive prefix count */ |
12228 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12229 | p->pcount[afi][safi]); | |
50e05855 AD |
12230 | if (paf && PAF_SUBGRP(paf)) |
12231 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12232 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12233 | |
fde246e8 DA |
12234 | /* Maximum prefix */ |
12235 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12236 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12237 | p->pmax_out[afi][safi]); | |
12238 | ||
d62a17ae | 12239 | /* Maximum prefix */ |
12240 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12241 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12242 | p->pmax[afi][safi]); | |
12243 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12244 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12245 | json_object_boolean_true_add( | |
12246 | json_addr, "prefixAllowedMaxWarning"); | |
12247 | json_object_int_add(json_addr, | |
12248 | "prefixAllowedWarningThresh", | |
12249 | p->pmax_threshold[afi][safi]); | |
12250 | if (p->pmax_restart[afi][safi]) | |
12251 | json_object_int_add( | |
12252 | json_addr, | |
12253 | "prefixAllowedRestartIntervalMsecs", | |
12254 | p->pmax_restart[afi][safi] * 60000); | |
12255 | } | |
2986cac2 | 12256 | json_object_object_add(json_neigh, |
36235319 | 12257 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12258 | json_addr); |
12259 | ||
12260 | } else { | |
12261 | filter = &p->filter[afi][safi]; | |
12262 | ||
12263 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12264 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12265 | |
12266 | if (peer_group_active(p)) | |
12267 | vty_out(vty, " %s peer-group member\n", | |
12268 | p->group->name); | |
12269 | ||
12270 | paf = peer_af_find(p, afi, safi); | |
12271 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12272 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12273 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12274 | vty_out(vty, " Packet Queue length %d\n", | |
12275 | bpacket_queue_virtual_length(paf)); | |
12276 | } else { | |
12277 | vty_out(vty, " Not part of any update group\n"); | |
12278 | } | |
12279 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12280 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12281 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12282 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12283 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12284 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12285 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12286 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12287 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12288 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12289 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12290 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12291 | ||
12292 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12293 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12294 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12295 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12296 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12297 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12298 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12299 | vty_out(vty, | |
12300 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12301 | ORF_TYPE_PREFIX); | |
12302 | bgp_show_peer_afi_orf_cap( | |
12303 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12304 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12305 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12306 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12307 | } | |
12308 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12309 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12310 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12311 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12312 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12313 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12314 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12315 | vty_out(vty, | |
12316 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12317 | ORF_TYPE_PREFIX_OLD); | |
12318 | bgp_show_peer_afi_orf_cap( | |
12319 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12320 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12321 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12322 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12323 | } | |
12324 | ||
772270f3 QY |
12325 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12326 | p->host, afi, safi); | |
d62a17ae | 12327 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12328 | NULL, afi, orf_pfx_name, use_json); | |
12329 | ||
12330 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12331 | PEER_STATUS_ORF_PREFIX_SEND) | |
12332 | || orf_pfx_count) { | |
12333 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12334 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12335 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12336 | vty_out(vty, " sent;"); | |
12337 | if (orf_pfx_count) | |
12338 | vty_out(vty, " received (%d entries)", | |
12339 | orf_pfx_count); | |
12340 | vty_out(vty, "\n"); | |
12341 | } | |
12342 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12343 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12344 | vty_out(vty, | |
12345 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12346 | ||
12347 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12348 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12349 | vty_out(vty, " Route-Reflector Client\n"); | |
12350 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12351 | PEER_FLAG_RSERVER_CLIENT)) | |
12352 | vty_out(vty, " Route-Server Client\n"); | |
12353 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12354 | vty_out(vty, | |
12355 | " Inbound soft reconfiguration allowed\n"); | |
12356 | ||
12357 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12358 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12359 | vty_out(vty, | |
12360 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12361 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12362 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12363 | vty_out(vty, | |
12364 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12365 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12366 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12367 | vty_out(vty, | |
12368 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12369 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12370 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12371 | vty_out(vty, | |
12372 | " Private AS numbers removed in updates to this neighbor\n"); | |
12373 | ||
dcc68b5e MS |
12374 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12375 | vty_out(vty, " %s\n", | |
12376 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12377 | ->human_description); | |
d62a17ae | 12378 | |
12379 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12380 | vty_out(vty, | |
12381 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12382 | ||
12383 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12384 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12385 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12386 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12387 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12388 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12389 | vty_out(vty, | |
12390 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12391 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12392 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12393 | vty_out(vty, | |
12394 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12395 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12396 | vty_out(vty, | |
12397 | " MED is propagated unchanged to this neighbor\n"); | |
12398 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12399 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12400 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12401 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12402 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12403 | vty_out(vty, | |
12404 | " Community attribute sent to this neighbor"); | |
12405 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12406 | PEER_FLAG_SEND_COMMUNITY) | |
12407 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12408 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12409 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12410 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12411 | vty_out(vty, "(all)\n"); | |
12412 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12413 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12414 | vty_out(vty, "(large)\n"); | |
12415 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12416 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12417 | vty_out(vty, "(extended)\n"); | |
12418 | else | |
12419 | vty_out(vty, "(standard)\n"); | |
12420 | } | |
12421 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12422 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12423 | vty_out(vty, " Default information originate,"); | |
12424 | ||
12425 | if (p->default_rmap[afi][safi].name) | |
12426 | vty_out(vty, " default route-map %s%s,", | |
12427 | p->default_rmap[afi][safi].map ? "*" | |
12428 | : "", | |
12429 | p->default_rmap[afi][safi].name); | |
12430 | if (paf && PAF_SUBGRP(paf) | |
12431 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12432 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12433 | vty_out(vty, " default sent\n"); | |
12434 | else | |
12435 | vty_out(vty, " default not sent\n"); | |
12436 | } | |
12437 | ||
dff8f48d MK |
12438 | /* advertise-vni-all */ |
12439 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12440 | if (is_evpn_enabled()) |
dff8f48d MK |
12441 | vty_out(vty, " advertise-all-vni\n"); |
12442 | } | |
12443 | ||
d62a17ae | 12444 | if (filter->plist[FILTER_IN].name |
12445 | || filter->dlist[FILTER_IN].name | |
12446 | || filter->aslist[FILTER_IN].name | |
12447 | || filter->map[RMAP_IN].name) | |
12448 | vty_out(vty, " Inbound path policy configured\n"); | |
12449 | if (filter->plist[FILTER_OUT].name | |
12450 | || filter->dlist[FILTER_OUT].name | |
12451 | || filter->aslist[FILTER_OUT].name | |
12452 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12453 | vty_out(vty, " Outbound path policy configured\n"); | |
12454 | ||
12455 | /* prefix-list */ | |
12456 | if (filter->plist[FILTER_IN].name) | |
12457 | vty_out(vty, | |
12458 | " Incoming update prefix filter list is %s%s\n", | |
12459 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12460 | filter->plist[FILTER_IN].name); | |
12461 | if (filter->plist[FILTER_OUT].name) | |
12462 | vty_out(vty, | |
12463 | " Outgoing update prefix filter list is %s%s\n", | |
12464 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12465 | filter->plist[FILTER_OUT].name); | |
12466 | ||
12467 | /* distribute-list */ | |
12468 | if (filter->dlist[FILTER_IN].name) | |
12469 | vty_out(vty, | |
12470 | " Incoming update network filter list is %s%s\n", | |
12471 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12472 | filter->dlist[FILTER_IN].name); | |
12473 | if (filter->dlist[FILTER_OUT].name) | |
12474 | vty_out(vty, | |
12475 | " Outgoing update network filter list is %s%s\n", | |
12476 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12477 | filter->dlist[FILTER_OUT].name); | |
12478 | ||
12479 | /* filter-list. */ | |
12480 | if (filter->aslist[FILTER_IN].name) | |
12481 | vty_out(vty, | |
12482 | " Incoming update AS path filter list is %s%s\n", | |
12483 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12484 | filter->aslist[FILTER_IN].name); | |
12485 | if (filter->aslist[FILTER_OUT].name) | |
12486 | vty_out(vty, | |
12487 | " Outgoing update AS path filter list is %s%s\n", | |
12488 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12489 | filter->aslist[FILTER_OUT].name); | |
12490 | ||
12491 | /* route-map. */ | |
12492 | if (filter->map[RMAP_IN].name) | |
12493 | vty_out(vty, | |
12494 | " Route map for incoming advertisements is %s%s\n", | |
12495 | filter->map[RMAP_IN].map ? "*" : "", | |
12496 | filter->map[RMAP_IN].name); | |
12497 | if (filter->map[RMAP_OUT].name) | |
12498 | vty_out(vty, | |
12499 | " Route map for outgoing advertisements is %s%s\n", | |
12500 | filter->map[RMAP_OUT].map ? "*" : "", | |
12501 | filter->map[RMAP_OUT].name); | |
12502 | ||
9dac9fc8 | 12503 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12504 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12505 | && !bgp_inbound_policy_exists(p, filter)) |
12506 | vty_out(vty, | |
12507 | " Inbound updates discarded due to missing policy\n"); | |
12508 | ||
12509 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12510 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12511 | && !bgp_outbound_policy_exists(p, filter)) |
12512 | vty_out(vty, | |
12513 | " Outbound updates discarded due to missing policy\n"); | |
12514 | ||
d62a17ae | 12515 | /* unsuppress-map */ |
12516 | if (filter->usmap.name) | |
12517 | vty_out(vty, | |
12518 | " Route map for selective unsuppress is %s%s\n", | |
12519 | filter->usmap.map ? "*" : "", | |
12520 | filter->usmap.name); | |
12521 | ||
7f7940e6 MK |
12522 | /* advertise-map */ |
12523 | if (filter->advmap.aname && filter->advmap.cname) | |
12524 | vty_out(vty, | |
12525 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12526 | filter->advmap.condition ? "EXIST" | |
12527 | : "NON_EXIST", | |
12528 | filter->advmap.cmap ? "*" : "", | |
12529 | filter->advmap.cname, | |
12530 | filter->advmap.amap ? "*" : "", | |
12531 | filter->advmap.aname, | |
fa36596c | 12532 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12533 | ? "Advertise" |
12534 | : "Withdraw"); | |
7f7940e6 | 12535 | |
d62a17ae | 12536 | /* Receive prefix count */ |
6cde4b45 | 12537 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12538 | p->pcount[afi][safi]); |
d62a17ae | 12539 | |
fde246e8 DA |
12540 | /* maximum-prefix-out */ |
12541 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12542 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12543 | vty_out(vty, | |
6cde4b45 | 12544 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12545 | p->pmax_out[afi][safi]); |
12546 | ||
d62a17ae | 12547 | /* Maximum prefix */ |
12548 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12549 | vty_out(vty, |
6cde4b45 | 12550 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12551 | p->pmax[afi][safi], |
12552 | CHECK_FLAG(p->af_flags[afi][safi], | |
12553 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12554 | ? " (warning-only)" | |
12555 | : ""); | |
12556 | vty_out(vty, " Threshold for warning message %d%%", | |
12557 | p->pmax_threshold[afi][safi]); | |
12558 | if (p->pmax_restart[afi][safi]) | |
12559 | vty_out(vty, ", restart interval %d min", | |
12560 | p->pmax_restart[afi][safi]); | |
12561 | vty_out(vty, "\n"); | |
12562 | } | |
12563 | ||
12564 | vty_out(vty, "\n"); | |
12565 | } | |
12566 | } | |
12567 | ||
9f049418 | 12568 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12569 | json_object *json) |
718e3744 | 12570 | { |
d62a17ae | 12571 | struct bgp *bgp; |
12572 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12573 | char timebuf[BGP_UPTIME_LEN]; | |
12574 | char dn_flag[2]; | |
d62a17ae | 12575 | afi_t afi; |
12576 | safi_t safi; | |
d7c0a89a QY |
12577 | uint16_t i; |
12578 | uint8_t *msg; | |
d62a17ae | 12579 | json_object *json_neigh = NULL; |
12580 | time_t epoch_tbuf; | |
718e3744 | 12581 | |
d62a17ae | 12582 | bgp = p->bgp; |
12583 | ||
12584 | if (use_json) | |
12585 | json_neigh = json_object_new_object(); | |
12586 | ||
12587 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12588 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12589 | dn_flag[0] = '*'; | |
12590 | ||
12591 | if (!use_json) { | |
12592 | if (p->conf_if) /* Configured interface name. */ | |
12593 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12594 | BGP_PEER_SU_UNSPEC(p) | |
12595 | ? "None" | |
12596 | : sockunion2str(&p->su, buf, | |
12597 | SU_ADDRSTRLEN)); | |
12598 | else /* Configured IP address. */ | |
12599 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12600 | p->host); | |
12601 | } | |
12602 | ||
12603 | if (use_json) { | |
12604 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12605 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12606 | "none"); | |
12607 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12608 | json_object_string_add( | |
12609 | json_neigh, "bgpNeighborAddr", | |
12610 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12611 | ||
12612 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12613 | ||
12614 | if (p->change_local_as) | |
12615 | json_object_int_add(json_neigh, "localAs", | |
12616 | p->change_local_as); | |
12617 | else | |
12618 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12619 | ||
12620 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12621 | json_object_boolean_true_add(json_neigh, | |
12622 | "localAsNoPrepend"); | |
12623 | ||
12624 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12625 | json_object_boolean_true_add(json_neigh, | |
12626 | "localAsReplaceAs"); | |
12627 | } else { | |
12628 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12629 | || (p->as_type == AS_INTERNAL)) | |
12630 | vty_out(vty, "remote AS %u, ", p->as); | |
12631 | else | |
12632 | vty_out(vty, "remote AS Unspecified, "); | |
12633 | vty_out(vty, "local AS %u%s%s, ", | |
12634 | p->change_local_as ? p->change_local_as : p->local_as, | |
12635 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12636 | ? " no-prepend" | |
12637 | : "", | |
12638 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12639 | ? " replace-as" | |
12640 | : ""); | |
12641 | } | |
faa16034 DS |
12642 | /* peer type internal or confed-internal */ |
12643 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12644 | if (use_json) { |
12645 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12646 | json_object_boolean_true_add( | |
12647 | json_neigh, "nbrConfedInternalLink"); | |
12648 | else | |
12649 | json_object_boolean_true_add(json_neigh, | |
12650 | "nbrInternalLink"); | |
12651 | } else { | |
12652 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12653 | vty_out(vty, "confed-internal link\n"); | |
12654 | else | |
12655 | vty_out(vty, "internal link\n"); | |
12656 | } | |
faa16034 DS |
12657 | /* peer type external or confed-external */ |
12658 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12659 | if (use_json) { |
12660 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12661 | json_object_boolean_true_add( | |
12662 | json_neigh, "nbrConfedExternalLink"); | |
12663 | else | |
12664 | json_object_boolean_true_add(json_neigh, | |
12665 | "nbrExternalLink"); | |
12666 | } else { | |
12667 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12668 | vty_out(vty, "confed-external link\n"); | |
12669 | else | |
12670 | vty_out(vty, "external link\n"); | |
12671 | } | |
faa16034 DS |
12672 | } else { |
12673 | if (use_json) | |
12674 | json_object_boolean_true_add(json_neigh, | |
12675 | "nbrUnspecifiedLink"); | |
12676 | else | |
12677 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12678 | } |
12679 | ||
12680 | /* Description. */ | |
12681 | if (p->desc) { | |
12682 | if (use_json) | |
12683 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12684 | else | |
12685 | vty_out(vty, " Description: %s\n", p->desc); | |
12686 | } | |
12687 | ||
12688 | if (p->hostname) { | |
12689 | if (use_json) { | |
12690 | if (p->hostname) | |
12691 | json_object_string_add(json_neigh, "hostname", | |
12692 | p->hostname); | |
12693 | ||
12694 | if (p->domainname) | |
12695 | json_object_string_add(json_neigh, "domainname", | |
12696 | p->domainname); | |
12697 | } else { | |
12698 | if (p->domainname && (p->domainname[0] != '\0')) | |
12699 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12700 | p->domainname); | |
12701 | else | |
12702 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12703 | } | |
12704 | } | |
12705 | ||
12706 | /* Peer-group */ | |
12707 | if (p->group) { | |
12708 | if (use_json) { | |
12709 | json_object_string_add(json_neigh, "peerGroup", | |
12710 | p->group->name); | |
12711 | ||
12712 | if (dn_flag[0]) { | |
12713 | struct prefix prefix, *range = NULL; | |
12714 | ||
0154d8ce DS |
12715 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12716 | range = peer_group_lookup_dynamic_neighbor_range( | |
12717 | p->group, &prefix); | |
d62a17ae | 12718 | |
12719 | if (range) { | |
12720 | prefix2str(range, buf1, sizeof(buf1)); | |
12721 | json_object_string_add( | |
12722 | json_neigh, | |
12723 | "peerSubnetRangeGroup", buf1); | |
12724 | } | |
12725 | } | |
12726 | } else { | |
12727 | vty_out(vty, | |
12728 | " Member of peer-group %s for session parameters\n", | |
12729 | p->group->name); | |
12730 | ||
12731 | if (dn_flag[0]) { | |
12732 | struct prefix prefix, *range = NULL; | |
12733 | ||
0154d8ce DS |
12734 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12735 | range = peer_group_lookup_dynamic_neighbor_range( | |
12736 | p->group, &prefix); | |
d62a17ae | 12737 | |
12738 | if (range) { | |
d62a17ae | 12739 | vty_out(vty, |
1b78780b DL |
12740 | " Belongs to the subnet range group: %pFX\n", |
12741 | range); | |
d62a17ae | 12742 | } |
12743 | } | |
12744 | } | |
12745 | } | |
12746 | ||
12747 | if (use_json) { | |
12748 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12749 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12750 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12751 | json_object_boolean_true_add(json_neigh, |
12752 | "adminShutDown"); | |
12753 | ||
12754 | /* BGP Version. */ | |
12755 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12756 | json_object_string_add( | |
12757 | json_neigh, "remoteRouterId", | |
12758 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
12759 | json_object_string_add( |
12760 | json_neigh, "localRouterId", | |
12761 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12762 | sizeof(buf1))); | |
d62a17ae | 12763 | |
12764 | /* Confederation */ | |
12765 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12766 | && bgp_confederation_peers_check(bgp, p->as)) | |
12767 | json_object_boolean_true_add(json_neigh, | |
12768 | "nbrCommonAdmin"); | |
12769 | ||
12770 | /* Status. */ | |
12771 | json_object_string_add( | |
12772 | json_neigh, "bgpState", | |
12773 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12774 | ||
12775 | if (p->status == Established) { | |
12776 | time_t uptime; | |
d62a17ae | 12777 | |
12778 | uptime = bgp_clock(); | |
12779 | uptime -= p->uptime; | |
d62a17ae | 12780 | epoch_tbuf = time(NULL) - uptime; |
12781 | ||
d3c7efed DS |
12782 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12783 | uptime * 1000); | |
d62a17ae | 12784 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12785 | peer_uptime(p->uptime, timebuf, | |
12786 | BGP_UPTIME_LEN, 0, | |
12787 | NULL)); | |
12788 | json_object_int_add(json_neigh, | |
12789 | "bgpTimerUpEstablishedEpoch", | |
12790 | epoch_tbuf); | |
12791 | } | |
12792 | ||
12793 | else if (p->status == Active) { | |
12794 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12795 | json_object_string_add(json_neigh, "bgpStateIs", | |
12796 | "passive"); | |
12797 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12798 | json_object_string_add(json_neigh, "bgpStateIs", | |
12799 | "passiveNSF"); | |
12800 | } | |
12801 | ||
12802 | /* read timer */ | |
12803 | time_t uptime; | |
a2700b50 | 12804 | struct tm tm; |
d62a17ae | 12805 | |
12806 | uptime = bgp_clock(); | |
12807 | uptime -= p->readtime; | |
a2700b50 MS |
12808 | gmtime_r(&uptime, &tm); |
12809 | ||
d62a17ae | 12810 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12811 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12812 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12813 | |
12814 | uptime = bgp_clock(); | |
12815 | uptime -= p->last_write; | |
a2700b50 MS |
12816 | gmtime_r(&uptime, &tm); |
12817 | ||
d62a17ae | 12818 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12819 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12820 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12821 | |
12822 | uptime = bgp_clock(); | |
12823 | uptime -= p->update_time; | |
a2700b50 MS |
12824 | gmtime_r(&uptime, &tm); |
12825 | ||
d62a17ae | 12826 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12827 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12828 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12829 | |
12830 | /* Configured timer values. */ | |
12831 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12832 | p->v_holdtime * 1000); | |
12833 | json_object_int_add(json_neigh, | |
12834 | "bgpTimerKeepAliveIntervalMsecs", | |
12835 | p->v_keepalive * 1000); | |
d43114f3 DS |
12836 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
12837 | json_object_int_add(json_neigh, | |
12838 | "bgpTimerDelayOpenTimeMsecs", | |
12839 | p->v_delayopen * 1000); | |
12840 | } | |
12841 | ||
b90a8e13 | 12842 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12843 | json_object_int_add(json_neigh, |
12844 | "bgpTimerConfiguredHoldTimeMsecs", | |
12845 | p->holdtime * 1000); | |
12846 | json_object_int_add( | |
12847 | json_neigh, | |
12848 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12849 | p->keepalive * 1000); | |
5d5393b9 DL |
12850 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12851 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12852 | json_object_int_add(json_neigh, |
12853 | "bgpTimerConfiguredHoldTimeMsecs", | |
12854 | bgp->default_holdtime); | |
12855 | json_object_int_add( | |
12856 | json_neigh, | |
12857 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12858 | bgp->default_keepalive); | |
d62a17ae | 12859 | } |
12860 | } else { | |
12861 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12862 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12863 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12864 | vty_out(vty, " Administratively shut down\n"); |
12865 | ||
12866 | /* BGP Version. */ | |
12867 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12868 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12869 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12870 | vty_out(vty, ", local router ID %s\n", |
12871 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12872 | sizeof(buf1))); | |
d62a17ae | 12873 | |
12874 | /* Confederation */ | |
12875 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12876 | && bgp_confederation_peers_check(bgp, p->as)) | |
12877 | vty_out(vty, | |
12878 | " Neighbor under common administration\n"); | |
12879 | ||
12880 | /* Status. */ | |
12881 | vty_out(vty, " BGP state = %s", | |
12882 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12883 | ||
12884 | if (p->status == Established) | |
12885 | vty_out(vty, ", up for %8s", | |
12886 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12887 | 0, NULL)); | |
12888 | ||
12889 | else if (p->status == Active) { | |
12890 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12891 | vty_out(vty, " (passive)"); | |
12892 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12893 | vty_out(vty, " (NSF passive)"); | |
12894 | } | |
12895 | vty_out(vty, "\n"); | |
12896 | ||
12897 | /* read timer */ | |
12898 | vty_out(vty, " Last read %s", | |
12899 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12900 | NULL)); | |
12901 | vty_out(vty, ", Last write %s\n", | |
12902 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12903 | NULL)); | |
12904 | ||
12905 | /* Configured timer values. */ | |
12906 | vty_out(vty, | |
12907 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12908 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12909 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12910 | vty_out(vty, " Configured hold time is %d", |
12911 | p->holdtime); | |
12912 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12913 | p->keepalive); | |
5d5393b9 DL |
12914 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12915 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12916 | vty_out(vty, " Configured hold time is %d", |
12917 | bgp->default_holdtime); | |
12918 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12919 | bgp->default_keepalive); | |
d62a17ae | 12920 | } |
d43114f3 DS |
12921 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
12922 | vty_out(vty, | |
12923 | " Configured DelayOpenTime is %d seconds\n", | |
12924 | p->delayopen); | |
d62a17ae | 12925 | } |
12926 | /* Capability. */ | |
12927 | if (p->status == Established) { | |
12928 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
12929 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12930 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12931 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12932 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12933 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12934 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12935 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12936 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12937 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12938 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12939 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12940 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12941 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12942 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12943 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12944 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12945 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12946 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12947 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12948 | if (use_json) { | |
12949 | json_object *json_cap = NULL; | |
12950 | ||
12951 | json_cap = json_object_new_object(); | |
12952 | ||
12953 | /* AS4 */ | |
12954 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12955 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12956 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12957 | && CHECK_FLAG(p->cap, | |
12958 | PEER_CAP_AS4_RCV)) | |
12959 | json_object_string_add( | |
12960 | json_cap, "4byteAs", | |
12961 | "advertisedAndReceived"); | |
12962 | else if (CHECK_FLAG(p->cap, | |
12963 | PEER_CAP_AS4_ADV)) | |
12964 | json_object_string_add( | |
12965 | json_cap, "4byteAs", | |
12966 | "advertised"); | |
12967 | else if (CHECK_FLAG(p->cap, | |
12968 | PEER_CAP_AS4_RCV)) | |
12969 | json_object_string_add( | |
12970 | json_cap, "4byteAs", | |
12971 | "received"); | |
12972 | } | |
12973 | ||
ef56aee4 DA |
12974 | /* Extended Message Support */ |
12975 | if (CHECK_FLAG(p->cap, | |
12976 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
12977 | && CHECK_FLAG( | |
12978 | p->cap, | |
12979 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12980 | json_object_string_add( | |
12981 | json_cap, "extendedMessage", | |
12982 | "advertisedAndReceived"); | |
12983 | else if (CHECK_FLAG( | |
12984 | p->cap, | |
12985 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12986 | json_object_string_add( | |
12987 | json_cap, "extendedMessage", | |
12988 | "advertised"); | |
12989 | else if (CHECK_FLAG( | |
12990 | p->cap, | |
12991 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12992 | json_object_string_add( | |
12993 | json_cap, "extendedMessage", | |
12994 | "received"); | |
12995 | ||
d62a17ae | 12996 | /* AddPath */ |
12997 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12998 | || CHECK_FLAG(p->cap, | |
12999 | PEER_CAP_ADDPATH_ADV)) { | |
13000 | json_object *json_add = NULL; | |
13001 | const char *print_store; | |
13002 | ||
13003 | json_add = json_object_new_object(); | |
13004 | ||
05c7a1cc QY |
13005 | FOREACH_AFI_SAFI (afi, safi) { |
13006 | json_object *json_sub = NULL; | |
13007 | json_sub = | |
13008 | json_object_new_object(); | |
5cb5f4d0 DD |
13009 | print_store = get_afi_safi_str( |
13010 | afi, safi, true); | |
d62a17ae | 13011 | |
05c7a1cc QY |
13012 | if (CHECK_FLAG( |
13013 | p->af_cap[afi] | |
13014 | [safi], | |
13015 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13016 | || CHECK_FLAG( | |
13017 | p->af_cap[afi] | |
13018 | [safi], | |
13019 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 13020 | if (CHECK_FLAG( |
13021 | p->af_cap | |
13022 | [afi] | |
13023 | [safi], | |
13024 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 13025 | && CHECK_FLAG( |
d62a17ae | 13026 | p->af_cap |
13027 | [afi] | |
13028 | [safi], | |
05c7a1cc QY |
13029 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
13030 | json_object_boolean_true_add( | |
13031 | json_sub, | |
13032 | "txAdvertisedAndReceived"); | |
13033 | else if ( | |
13034 | CHECK_FLAG( | |
13035 | p->af_cap | |
13036 | [afi] | |
13037 | [safi], | |
13038 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13039 | json_object_boolean_true_add( | |
13040 | json_sub, | |
13041 | "txAdvertised"); | |
13042 | else if ( | |
13043 | CHECK_FLAG( | |
13044 | p->af_cap | |
13045 | [afi] | |
13046 | [safi], | |
13047 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13048 | json_object_boolean_true_add( | |
13049 | json_sub, | |
13050 | "txReceived"); | |
13051 | } | |
d62a17ae | 13052 | |
05c7a1cc QY |
13053 | if (CHECK_FLAG( |
13054 | p->af_cap[afi] | |
13055 | [safi], | |
13056 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13057 | || CHECK_FLAG( | |
13058 | p->af_cap[afi] | |
13059 | [safi], | |
13060 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 13061 | if (CHECK_FLAG( |
13062 | p->af_cap | |
13063 | [afi] | |
13064 | [safi], | |
13065 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 13066 | && CHECK_FLAG( |
d62a17ae | 13067 | p->af_cap |
13068 | [afi] | |
13069 | [safi], | |
13070 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
13071 | json_object_boolean_true_add( |
13072 | json_sub, | |
13073 | "rxAdvertisedAndReceived"); | |
13074 | else if ( | |
13075 | CHECK_FLAG( | |
13076 | p->af_cap | |
13077 | [afi] | |
13078 | [safi], | |
13079 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13080 | json_object_boolean_true_add( | |
13081 | json_sub, | |
13082 | "rxAdvertised"); | |
13083 | else if ( | |
13084 | CHECK_FLAG( | |
13085 | p->af_cap | |
13086 | [afi] | |
13087 | [safi], | |
13088 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13089 | json_object_boolean_true_add( | |
13090 | json_sub, | |
13091 | "rxReceived"); | |
d62a17ae | 13092 | } |
13093 | ||
05c7a1cc QY |
13094 | if (CHECK_FLAG( |
13095 | p->af_cap[afi] | |
13096 | [safi], | |
13097 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13098 | || CHECK_FLAG( | |
13099 | p->af_cap[afi] | |
13100 | [safi], | |
13101 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
13102 | || CHECK_FLAG( | |
13103 | p->af_cap[afi] | |
13104 | [safi], | |
13105 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13106 | || CHECK_FLAG( | |
13107 | p->af_cap[afi] | |
13108 | [safi], | |
13109 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13110 | json_object_object_add( | |
13111 | json_add, | |
13112 | print_store, | |
13113 | json_sub); | |
13114 | else | |
13115 | json_object_free( | |
13116 | json_sub); | |
13117 | } | |
13118 | ||
d62a17ae | 13119 | json_object_object_add( |
13120 | json_cap, "addPath", json_add); | |
13121 | } | |
13122 | ||
13123 | /* Dynamic */ | |
13124 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13125 | || CHECK_FLAG(p->cap, | |
13126 | PEER_CAP_DYNAMIC_ADV)) { | |
13127 | if (CHECK_FLAG(p->cap, | |
13128 | PEER_CAP_DYNAMIC_ADV) | |
13129 | && CHECK_FLAG(p->cap, | |
13130 | PEER_CAP_DYNAMIC_RCV)) | |
13131 | json_object_string_add( | |
13132 | json_cap, "dynamic", | |
13133 | "advertisedAndReceived"); | |
13134 | else if (CHECK_FLAG( | |
13135 | p->cap, | |
13136 | PEER_CAP_DYNAMIC_ADV)) | |
13137 | json_object_string_add( | |
13138 | json_cap, "dynamic", | |
13139 | "advertised"); | |
13140 | else if (CHECK_FLAG( | |
13141 | p->cap, | |
13142 | PEER_CAP_DYNAMIC_RCV)) | |
13143 | json_object_string_add( | |
13144 | json_cap, "dynamic", | |
13145 | "received"); | |
13146 | } | |
13147 | ||
13148 | /* Extended nexthop */ | |
13149 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13150 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13151 | json_object *json_nxt = NULL; | |
13152 | const char *print_store; | |
13153 | ||
13154 | ||
13155 | if (CHECK_FLAG(p->cap, | |
13156 | PEER_CAP_ENHE_ADV) | |
13157 | && CHECK_FLAG(p->cap, | |
13158 | PEER_CAP_ENHE_RCV)) | |
13159 | json_object_string_add( | |
13160 | json_cap, | |
13161 | "extendedNexthop", | |
13162 | "advertisedAndReceived"); | |
13163 | else if (CHECK_FLAG(p->cap, | |
13164 | PEER_CAP_ENHE_ADV)) | |
13165 | json_object_string_add( | |
13166 | json_cap, | |
13167 | "extendedNexthop", | |
13168 | "advertised"); | |
13169 | else if (CHECK_FLAG(p->cap, | |
13170 | PEER_CAP_ENHE_RCV)) | |
13171 | json_object_string_add( | |
13172 | json_cap, | |
13173 | "extendedNexthop", | |
13174 | "received"); | |
13175 | ||
13176 | if (CHECK_FLAG(p->cap, | |
13177 | PEER_CAP_ENHE_RCV)) { | |
13178 | json_nxt = | |
13179 | json_object_new_object(); | |
13180 | ||
13181 | for (safi = SAFI_UNICAST; | |
13182 | safi < SAFI_MAX; safi++) { | |
13183 | if (CHECK_FLAG( | |
13184 | p->af_cap | |
13185 | [AFI_IP] | |
13186 | [safi], | |
13187 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 13188 | print_store = get_afi_safi_str( |
d62a17ae | 13189 | AFI_IP, |
5cb5f4d0 | 13190 | safi, true); |
d62a17ae | 13191 | json_object_string_add( |
13192 | json_nxt, | |
13193 | print_store, | |
54f29523 | 13194 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 13195 | } |
13196 | } | |
13197 | json_object_object_add( | |
13198 | json_cap, | |
13199 | "extendedNexthopFamililesByPeer", | |
13200 | json_nxt); | |
13201 | } | |
13202 | } | |
13203 | ||
13204 | /* Route Refresh */ | |
13205 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13206 | || CHECK_FLAG(p->cap, | |
13207 | PEER_CAP_REFRESH_NEW_RCV) | |
13208 | || CHECK_FLAG(p->cap, | |
13209 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13210 | if (CHECK_FLAG(p->cap, | |
13211 | PEER_CAP_REFRESH_ADV) | |
13212 | && (CHECK_FLAG( | |
13213 | p->cap, | |
13214 | PEER_CAP_REFRESH_NEW_RCV) | |
13215 | || CHECK_FLAG( | |
13216 | p->cap, | |
13217 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13218 | if (CHECK_FLAG( | |
13219 | p->cap, | |
13220 | PEER_CAP_REFRESH_OLD_RCV) | |
13221 | && CHECK_FLAG( | |
13222 | p->cap, | |
13223 | PEER_CAP_REFRESH_NEW_RCV)) | |
13224 | json_object_string_add( | |
13225 | json_cap, | |
13226 | "routeRefresh", | |
13227 | "advertisedAndReceivedOldNew"); | |
13228 | else { | |
13229 | if (CHECK_FLAG( | |
13230 | p->cap, | |
13231 | PEER_CAP_REFRESH_OLD_RCV)) | |
13232 | json_object_string_add( | |
13233 | json_cap, | |
13234 | "routeRefresh", | |
13235 | "advertisedAndReceivedOld"); | |
13236 | else | |
13237 | json_object_string_add( | |
13238 | json_cap, | |
13239 | "routeRefresh", | |
13240 | "advertisedAndReceivedNew"); | |
13241 | } | |
13242 | } else if ( | |
13243 | CHECK_FLAG( | |
13244 | p->cap, | |
13245 | PEER_CAP_REFRESH_ADV)) | |
13246 | json_object_string_add( | |
13247 | json_cap, | |
13248 | "routeRefresh", | |
13249 | "advertised"); | |
13250 | else if ( | |
13251 | CHECK_FLAG( | |
13252 | p->cap, | |
13253 | PEER_CAP_REFRESH_NEW_RCV) | |
13254 | || CHECK_FLAG( | |
13255 | p->cap, | |
13256 | PEER_CAP_REFRESH_OLD_RCV)) | |
13257 | json_object_string_add( | |
13258 | json_cap, | |
13259 | "routeRefresh", | |
13260 | "received"); | |
13261 | } | |
13262 | ||
9af52ccf DA |
13263 | /* Enhanced Route Refresh */ |
13264 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
13265 | || CHECK_FLAG(p->cap, | |
13266 | PEER_CAP_ENHANCED_RR_RCV)) { | |
13267 | if (CHECK_FLAG(p->cap, | |
13268 | PEER_CAP_ENHANCED_RR_ADV) | |
13269 | && CHECK_FLAG( | |
13270 | p->cap, | |
13271 | PEER_CAP_ENHANCED_RR_RCV)) | |
13272 | json_object_string_add( | |
13273 | json_cap, | |
13274 | "enhancedRouteRefresh", | |
13275 | "advertisedAndReceived"); | |
13276 | else if ( | |
13277 | CHECK_FLAG( | |
13278 | p->cap, | |
13279 | PEER_CAP_ENHANCED_RR_ADV)) | |
13280 | json_object_string_add( | |
13281 | json_cap, | |
13282 | "enhancedRouteRefresh", | |
13283 | "advertised"); | |
13284 | else if ( | |
13285 | CHECK_FLAG( | |
13286 | p->cap, | |
13287 | PEER_CAP_ENHANCED_RR_RCV)) | |
13288 | json_object_string_add( | |
13289 | json_cap, | |
13290 | "enhancedRouteRefresh", | |
13291 | "received"); | |
13292 | } | |
13293 | ||
d62a17ae | 13294 | /* Multiprotocol Extensions */ |
13295 | json_object *json_multi = NULL; | |
13296 | json_multi = json_object_new_object(); | |
13297 | ||
05c7a1cc QY |
13298 | FOREACH_AFI_SAFI (afi, safi) { |
13299 | if (p->afc_adv[afi][safi] | |
13300 | || p->afc_recv[afi][safi]) { | |
13301 | json_object *json_exten = NULL; | |
13302 | json_exten = | |
13303 | json_object_new_object(); | |
13304 | ||
d62a17ae | 13305 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
13306 | && p->afc_recv[afi][safi]) |
13307 | json_object_boolean_true_add( | |
13308 | json_exten, | |
13309 | "advertisedAndReceived"); | |
13310 | else if (p->afc_adv[afi][safi]) | |
13311 | json_object_boolean_true_add( | |
13312 | json_exten, | |
13313 | "advertised"); | |
13314 | else if (p->afc_recv[afi][safi]) | |
13315 | json_object_boolean_true_add( | |
13316 | json_exten, | |
13317 | "received"); | |
d62a17ae | 13318 | |
05c7a1cc QY |
13319 | json_object_object_add( |
13320 | json_multi, | |
5cb5f4d0 DD |
13321 | get_afi_safi_str(afi, |
13322 | safi, | |
13323 | true), | |
05c7a1cc | 13324 | json_exten); |
d62a17ae | 13325 | } |
13326 | } | |
13327 | json_object_object_add( | |
13328 | json_cap, "multiprotocolExtensions", | |
13329 | json_multi); | |
13330 | ||
d77114b7 | 13331 | /* Hostname capabilities */ |
60466a63 | 13332 | json_object *json_hname = NULL; |
d77114b7 MK |
13333 | |
13334 | json_hname = json_object_new_object(); | |
13335 | ||
13336 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13337 | json_object_string_add( | |
60466a63 QY |
13338 | json_hname, "advHostName", |
13339 | bgp->peer_self->hostname | |
13340 | ? bgp->peer_self | |
13341 | ->hostname | |
d77114b7 MK |
13342 | : "n/a"); |
13343 | json_object_string_add( | |
60466a63 QY |
13344 | json_hname, "advDomainName", |
13345 | bgp->peer_self->domainname | |
13346 | ? bgp->peer_self | |
13347 | ->domainname | |
d77114b7 MK |
13348 | : "n/a"); |
13349 | } | |
13350 | ||
13351 | ||
13352 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13353 | json_object_string_add( | |
60466a63 QY |
13354 | json_hname, "rcvHostName", |
13355 | p->hostname ? p->hostname | |
13356 | : "n/a"); | |
d77114b7 | 13357 | json_object_string_add( |
60466a63 QY |
13358 | json_hname, "rcvDomainName", |
13359 | p->domainname ? p->domainname | |
13360 | : "n/a"); | |
d77114b7 MK |
13361 | } |
13362 | ||
60466a63 | 13363 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13364 | json_hname); |
13365 | ||
d62a17ae | 13366 | /* Gracefull Restart */ |
13367 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13368 | || CHECK_FLAG(p->cap, | |
13369 | PEER_CAP_RESTART_ADV)) { | |
13370 | if (CHECK_FLAG(p->cap, | |
13371 | PEER_CAP_RESTART_ADV) | |
13372 | && CHECK_FLAG(p->cap, | |
13373 | PEER_CAP_RESTART_RCV)) | |
13374 | json_object_string_add( | |
13375 | json_cap, | |
13376 | "gracefulRestart", | |
13377 | "advertisedAndReceived"); | |
13378 | else if (CHECK_FLAG( | |
13379 | p->cap, | |
13380 | PEER_CAP_RESTART_ADV)) | |
13381 | json_object_string_add( | |
13382 | json_cap, | |
13383 | "gracefulRestartCapability", | |
13384 | "advertised"); | |
13385 | else if (CHECK_FLAG( | |
13386 | p->cap, | |
13387 | PEER_CAP_RESTART_RCV)) | |
13388 | json_object_string_add( | |
13389 | json_cap, | |
13390 | "gracefulRestartCapability", | |
13391 | "received"); | |
13392 | ||
13393 | if (CHECK_FLAG(p->cap, | |
13394 | PEER_CAP_RESTART_RCV)) { | |
13395 | int restart_af_count = 0; | |
13396 | json_object *json_restart = | |
13397 | NULL; | |
13398 | json_restart = | |
13399 | json_object_new_object(); | |
13400 | ||
13401 | json_object_int_add( | |
13402 | json_cap, | |
13403 | "gracefulRestartRemoteTimerMsecs", | |
13404 | p->v_gr_restart * 1000); | |
13405 | ||
05c7a1cc QY |
13406 | FOREACH_AFI_SAFI (afi, safi) { |
13407 | if (CHECK_FLAG( | |
13408 | p->af_cap | |
13409 | [afi] | |
13410 | [safi], | |
13411 | PEER_CAP_RESTART_AF_RCV)) { | |
13412 | json_object * | |
13413 | json_sub = | |
13414 | NULL; | |
13415 | json_sub = | |
13416 | json_object_new_object(); | |
13417 | ||
d62a17ae | 13418 | if (CHECK_FLAG( |
13419 | p->af_cap | |
13420 | [afi] | |
13421 | [safi], | |
05c7a1cc QY |
13422 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13423 | json_object_boolean_true_add( | |
13424 | json_sub, | |
13425 | "preserved"); | |
13426 | restart_af_count++; | |
13427 | json_object_object_add( | |
13428 | json_restart, | |
5cb5f4d0 | 13429 | get_afi_safi_str( |
05c7a1cc | 13430 | afi, |
5cb5f4d0 DD |
13431 | safi, |
13432 | true), | |
05c7a1cc | 13433 | json_sub); |
d62a17ae | 13434 | } |
13435 | } | |
13436 | if (!restart_af_count) { | |
13437 | json_object_string_add( | |
13438 | json_cap, | |
13439 | "addressFamiliesByPeer", | |
13440 | "none"); | |
13441 | json_object_free( | |
13442 | json_restart); | |
13443 | } else | |
13444 | json_object_object_add( | |
13445 | json_cap, | |
13446 | "addressFamiliesByPeer", | |
13447 | json_restart); | |
13448 | } | |
13449 | } | |
13450 | json_object_object_add(json_neigh, | |
13451 | "neighborCapabilities", | |
13452 | json_cap); | |
13453 | } else { | |
13454 | vty_out(vty, " Neighbor capabilities:\n"); | |
13455 | ||
13456 | /* AS4 */ | |
13457 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13458 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13459 | vty_out(vty, " 4 Byte AS:"); | |
13460 | if (CHECK_FLAG(p->cap, | |
13461 | PEER_CAP_AS4_ADV)) | |
13462 | vty_out(vty, " advertised"); | |
13463 | if (CHECK_FLAG(p->cap, | |
13464 | PEER_CAP_AS4_RCV)) | |
13465 | vty_out(vty, " %sreceived", | |
13466 | CHECK_FLAG( | |
13467 | p->cap, | |
13468 | PEER_CAP_AS4_ADV) | |
13469 | ? "and " | |
13470 | : ""); | |
13471 | vty_out(vty, "\n"); | |
13472 | } | |
13473 | ||
ef56aee4 DA |
13474 | /* Extended Message Support */ |
13475 | if (CHECK_FLAG(p->cap, | |
13476 | PEER_CAP_EXTENDED_MESSAGE_RCV) | |
13477 | || CHECK_FLAG( | |
13478 | p->cap, | |
13479 | PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13480 | vty_out(vty, " Extended Message:"); | |
13481 | if (CHECK_FLAG( | |
13482 | p->cap, | |
13483 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13484 | vty_out(vty, " advertised"); | |
13485 | if (CHECK_FLAG( | |
13486 | p->cap, | |
13487 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13488 | vty_out(vty, " %sreceived", | |
13489 | CHECK_FLAG( | |
13490 | p->cap, | |
13491 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13492 | ? "and " | |
13493 | : ""); | |
13494 | vty_out(vty, "\n"); | |
13495 | } | |
13496 | ||
d62a17ae | 13497 | /* AddPath */ |
13498 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13499 | || CHECK_FLAG(p->cap, | |
13500 | PEER_CAP_ADDPATH_ADV)) { | |
13501 | vty_out(vty, " AddPath:\n"); | |
13502 | ||
05c7a1cc QY |
13503 | FOREACH_AFI_SAFI (afi, safi) { |
13504 | if (CHECK_FLAG( | |
13505 | p->af_cap[afi] | |
13506 | [safi], | |
13507 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13508 | || CHECK_FLAG( | |
13509 | p->af_cap[afi] | |
13510 | [safi], | |
13511 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13512 | vty_out(vty, | |
13513 | " %s: TX ", | |
5cb5f4d0 | 13514 | get_afi_safi_str( |
05c7a1cc | 13515 | afi, |
5cb5f4d0 DD |
13516 | safi, |
13517 | false)); | |
05c7a1cc | 13518 | |
d62a17ae | 13519 | if (CHECK_FLAG( |
13520 | p->af_cap | |
13521 | [afi] | |
13522 | [safi], | |
05c7a1cc | 13523 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13524 | vty_out(vty, |
05c7a1cc | 13525 | "advertised %s", |
5cb5f4d0 | 13526 | get_afi_safi_str( |
d62a17ae | 13527 | afi, |
5cb5f4d0 DD |
13528 | safi, |
13529 | false)); | |
d62a17ae | 13530 | |
05c7a1cc QY |
13531 | if (CHECK_FLAG( |
13532 | p->af_cap | |
13533 | [afi] | |
13534 | [safi], | |
13535 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13536 | vty_out(vty, | |
13537 | "%sreceived", | |
13538 | CHECK_FLAG( | |
13539 | p->af_cap | |
13540 | [afi] | |
13541 | [safi], | |
13542 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13543 | ? " and " | |
13544 | : ""); | |
d62a17ae | 13545 | |
05c7a1cc QY |
13546 | vty_out(vty, "\n"); |
13547 | } | |
d62a17ae | 13548 | |
05c7a1cc QY |
13549 | if (CHECK_FLAG( |
13550 | p->af_cap[afi] | |
13551 | [safi], | |
13552 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13553 | || CHECK_FLAG( | |
13554 | p->af_cap[afi] | |
13555 | [safi], | |
13556 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13557 | vty_out(vty, | |
13558 | " %s: RX ", | |
5cb5f4d0 | 13559 | get_afi_safi_str( |
05c7a1cc | 13560 | afi, |
5cb5f4d0 DD |
13561 | safi, |
13562 | false)); | |
d62a17ae | 13563 | |
13564 | if (CHECK_FLAG( | |
13565 | p->af_cap | |
13566 | [afi] | |
13567 | [safi], | |
05c7a1cc | 13568 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13569 | vty_out(vty, |
05c7a1cc | 13570 | "advertised %s", |
5cb5f4d0 | 13571 | get_afi_safi_str( |
d62a17ae | 13572 | afi, |
5cb5f4d0 DD |
13573 | safi, |
13574 | false)); | |
d62a17ae | 13575 | |
05c7a1cc QY |
13576 | if (CHECK_FLAG( |
13577 | p->af_cap | |
13578 | [afi] | |
13579 | [safi], | |
13580 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13581 | vty_out(vty, |
05c7a1cc QY |
13582 | "%sreceived", |
13583 | CHECK_FLAG( | |
13584 | p->af_cap | |
13585 | [afi] | |
13586 | [safi], | |
13587 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13588 | ? " and " | |
13589 | : ""); | |
13590 | ||
13591 | vty_out(vty, "\n"); | |
d62a17ae | 13592 | } |
05c7a1cc | 13593 | } |
d62a17ae | 13594 | } |
13595 | ||
13596 | /* Dynamic */ | |
13597 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13598 | || CHECK_FLAG(p->cap, | |
13599 | PEER_CAP_DYNAMIC_ADV)) { | |
13600 | vty_out(vty, " Dynamic:"); | |
13601 | if (CHECK_FLAG(p->cap, | |
13602 | PEER_CAP_DYNAMIC_ADV)) | |
13603 | vty_out(vty, " advertised"); | |
13604 | if (CHECK_FLAG(p->cap, | |
13605 | PEER_CAP_DYNAMIC_RCV)) | |
13606 | vty_out(vty, " %sreceived", | |
13607 | CHECK_FLAG( | |
13608 | p->cap, | |
13609 | PEER_CAP_DYNAMIC_ADV) | |
13610 | ? "and " | |
13611 | : ""); | |
13612 | vty_out(vty, "\n"); | |
13613 | } | |
13614 | ||
13615 | /* Extended nexthop */ | |
13616 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13617 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13618 | vty_out(vty, " Extended nexthop:"); | |
13619 | if (CHECK_FLAG(p->cap, | |
13620 | PEER_CAP_ENHE_ADV)) | |
13621 | vty_out(vty, " advertised"); | |
13622 | if (CHECK_FLAG(p->cap, | |
13623 | PEER_CAP_ENHE_RCV)) | |
13624 | vty_out(vty, " %sreceived", | |
13625 | CHECK_FLAG( | |
13626 | p->cap, | |
13627 | PEER_CAP_ENHE_ADV) | |
13628 | ? "and " | |
13629 | : ""); | |
13630 | vty_out(vty, "\n"); | |
13631 | ||
13632 | if (CHECK_FLAG(p->cap, | |
13633 | PEER_CAP_ENHE_RCV)) { | |
13634 | vty_out(vty, | |
13635 | " Address families by peer:\n "); | |
13636 | for (safi = SAFI_UNICAST; | |
13637 | safi < SAFI_MAX; safi++) | |
13638 | if (CHECK_FLAG( | |
13639 | p->af_cap | |
13640 | [AFI_IP] | |
13641 | [safi], | |
13642 | PEER_CAP_ENHE_AF_RCV)) | |
13643 | vty_out(vty, | |
13644 | " %s\n", | |
5cb5f4d0 | 13645 | get_afi_safi_str( |
d62a17ae | 13646 | AFI_IP, |
5cb5f4d0 DD |
13647 | safi, |
13648 | false)); | |
d62a17ae | 13649 | } |
13650 | } | |
13651 | ||
13652 | /* Route Refresh */ | |
13653 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13654 | || CHECK_FLAG(p->cap, | |
13655 | PEER_CAP_REFRESH_NEW_RCV) | |
13656 | || CHECK_FLAG(p->cap, | |
13657 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13658 | vty_out(vty, " Route refresh:"); | |
13659 | if (CHECK_FLAG(p->cap, | |
13660 | PEER_CAP_REFRESH_ADV)) | |
13661 | vty_out(vty, " advertised"); | |
13662 | if (CHECK_FLAG(p->cap, | |
13663 | PEER_CAP_REFRESH_NEW_RCV) | |
13664 | || CHECK_FLAG( | |
13665 | p->cap, | |
13666 | PEER_CAP_REFRESH_OLD_RCV)) | |
13667 | vty_out(vty, " %sreceived(%s)", | |
13668 | CHECK_FLAG( | |
13669 | p->cap, | |
13670 | PEER_CAP_REFRESH_ADV) | |
13671 | ? "and " | |
13672 | : "", | |
13673 | (CHECK_FLAG( | |
13674 | p->cap, | |
13675 | PEER_CAP_REFRESH_OLD_RCV) | |
13676 | && CHECK_FLAG( | |
13677 | p->cap, | |
13678 | PEER_CAP_REFRESH_NEW_RCV)) | |
13679 | ? "old & new" | |
13680 | : CHECK_FLAG( | |
13681 | p->cap, | |
13682 | PEER_CAP_REFRESH_OLD_RCV) | |
13683 | ? "old" | |
13684 | : "new"); | |
13685 | ||
13686 | vty_out(vty, "\n"); | |
13687 | } | |
13688 | ||
9af52ccf DA |
13689 | /* Enhanced Route Refresh */ |
13690 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
13691 | || CHECK_FLAG(p->cap, | |
13692 | PEER_CAP_ENHANCED_RR_RCV)) { | |
13693 | vty_out(vty, | |
13694 | " Enhanced Route Refresh:"); | |
13695 | if (CHECK_FLAG( | |
13696 | p->cap, | |
13697 | PEER_CAP_ENHANCED_RR_ADV)) | |
13698 | vty_out(vty, " advertised"); | |
13699 | if (CHECK_FLAG( | |
13700 | p->cap, | |
13701 | PEER_CAP_ENHANCED_RR_RCV)) | |
13702 | vty_out(vty, " %sreceived", | |
13703 | CHECK_FLAG( | |
13704 | p->cap, | |
13705 | PEER_CAP_REFRESH_ADV) | |
13706 | ? "and " | |
13707 | : ""); | |
13708 | vty_out(vty, "\n"); | |
13709 | } | |
13710 | ||
d62a17ae | 13711 | /* Multiprotocol Extensions */ |
05c7a1cc QY |
13712 | FOREACH_AFI_SAFI (afi, safi) |
13713 | if (p->afc_adv[afi][safi] | |
13714 | || p->afc_recv[afi][safi]) { | |
13715 | vty_out(vty, | |
13716 | " Address Family %s:", | |
5cb5f4d0 DD |
13717 | get_afi_safi_str( |
13718 | afi, | |
13719 | safi, | |
13720 | false)); | |
05c7a1cc | 13721 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13722 | vty_out(vty, |
05c7a1cc QY |
13723 | " advertised"); |
13724 | if (p->afc_recv[afi][safi]) | |
13725 | vty_out(vty, | |
13726 | " %sreceived", | |
13727 | p->afc_adv[afi] | |
13728 | [safi] | |
13729 | ? "and " | |
13730 | : ""); | |
13731 | vty_out(vty, "\n"); | |
13732 | } | |
d62a17ae | 13733 | |
13734 | /* Hostname capability */ | |
60466a63 | 13735 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13736 | |
13737 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13738 | vty_out(vty, |
13739 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13740 | bgp->peer_self->hostname |
13741 | ? bgp->peer_self | |
13742 | ->hostname | |
d77114b7 | 13743 | : "n/a", |
60466a63 QY |
13744 | bgp->peer_self->domainname |
13745 | ? bgp->peer_self | |
13746 | ->domainname | |
d77114b7 MK |
13747 | : "n/a"); |
13748 | } else { | |
13749 | vty_out(vty, " not advertised"); | |
d62a17ae | 13750 | } |
13751 | ||
d77114b7 | 13752 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13753 | vty_out(vty, |
13754 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13755 | p->hostname ? p->hostname |
13756 | : "n/a", | |
13757 | p->domainname ? p->domainname | |
13758 | : "n/a"); | |
d77114b7 MK |
13759 | } else { |
13760 | vty_out(vty, " not received"); | |
13761 | } | |
13762 | ||
13763 | vty_out(vty, "\n"); | |
13764 | ||
61bfbd51 | 13765 | /* Graceful Restart */ |
d62a17ae | 13766 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13767 | || CHECK_FLAG(p->cap, | |
13768 | PEER_CAP_RESTART_ADV)) { | |
13769 | vty_out(vty, | |
61bfbd51 | 13770 | " Graceful Restart Capability:"); |
d62a17ae | 13771 | if (CHECK_FLAG(p->cap, |
13772 | PEER_CAP_RESTART_ADV)) | |
13773 | vty_out(vty, " advertised"); | |
13774 | if (CHECK_FLAG(p->cap, | |
13775 | PEER_CAP_RESTART_RCV)) | |
13776 | vty_out(vty, " %sreceived", | |
13777 | CHECK_FLAG( | |
13778 | p->cap, | |
13779 | PEER_CAP_RESTART_ADV) | |
13780 | ? "and " | |
13781 | : ""); | |
13782 | vty_out(vty, "\n"); | |
13783 | ||
13784 | if (CHECK_FLAG(p->cap, | |
13785 | PEER_CAP_RESTART_RCV)) { | |
13786 | int restart_af_count = 0; | |
13787 | ||
13788 | vty_out(vty, | |
13789 | " Remote Restart timer is %d seconds\n", | |
13790 | p->v_gr_restart); | |
13791 | vty_out(vty, | |
13792 | " Address families by peer:\n "); | |
13793 | ||
05c7a1cc QY |
13794 | FOREACH_AFI_SAFI (afi, safi) |
13795 | if (CHECK_FLAG( | |
13796 | p->af_cap | |
13797 | [afi] | |
13798 | [safi], | |
13799 | PEER_CAP_RESTART_AF_RCV)) { | |
13800 | vty_out(vty, | |
13801 | "%s%s(%s)", | |
13802 | restart_af_count | |
13803 | ? ", " | |
13804 | : "", | |
5cb5f4d0 | 13805 | get_afi_safi_str( |
05c7a1cc | 13806 | afi, |
5cb5f4d0 DD |
13807 | safi, |
13808 | false), | |
05c7a1cc QY |
13809 | CHECK_FLAG( |
13810 | p->af_cap | |
13811 | [afi] | |
13812 | [safi], | |
13813 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13814 | ? "preserved" | |
13815 | : "not preserved"); | |
13816 | restart_af_count++; | |
13817 | } | |
d62a17ae | 13818 | if (!restart_af_count) |
13819 | vty_out(vty, "none"); | |
13820 | vty_out(vty, "\n"); | |
13821 | } | |
2986cac2 | 13822 | } /* Gracefull Restart */ |
d62a17ae | 13823 | } |
13824 | } | |
13825 | } | |
13826 | ||
13827 | /* graceful restart information */ | |
d62a17ae | 13828 | json_object *json_grace = NULL; |
13829 | json_object *json_grace_send = NULL; | |
13830 | json_object *json_grace_recv = NULL; | |
13831 | int eor_send_af_count = 0; | |
13832 | int eor_receive_af_count = 0; | |
13833 | ||
13834 | if (use_json) { | |
13835 | json_grace = json_object_new_object(); | |
13836 | json_grace_send = json_object_new_object(); | |
13837 | json_grace_recv = json_object_new_object(); | |
13838 | ||
36235319 QY |
13839 | if ((p->status == Established) |
13840 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
13841 | FOREACH_AFI_SAFI (afi, safi) { |
13842 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13843 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13844 | json_object_boolean_true_add( |
13845 | json_grace_send, | |
5cb5f4d0 DD |
13846 | get_afi_safi_str(afi, |
13847 | safi, | |
13848 | true)); | |
05c7a1cc | 13849 | eor_send_af_count++; |
d62a17ae | 13850 | } |
13851 | } | |
05c7a1cc QY |
13852 | FOREACH_AFI_SAFI (afi, safi) { |
13853 | if (CHECK_FLAG( | |
36235319 QY |
13854 | p->af_sflags[afi][safi], |
13855 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13856 | json_object_boolean_true_add( |
13857 | json_grace_recv, | |
5cb5f4d0 DD |
13858 | get_afi_safi_str(afi, |
13859 | safi, | |
13860 | true)); | |
05c7a1cc | 13861 | eor_receive_af_count++; |
d62a17ae | 13862 | } |
13863 | } | |
13864 | } | |
36235319 QY |
13865 | json_object_object_add(json_grace, "endOfRibSend", |
13866 | json_grace_send); | |
13867 | json_object_object_add(json_grace, "endOfRibRecv", | |
13868 | json_grace_recv); | |
d62a17ae | 13869 | |
d62a17ae | 13870 | |
13871 | if (p->t_gr_restart) | |
13872 | json_object_int_add(json_grace, | |
13873 | "gracefulRestartTimerMsecs", | |
13874 | thread_timer_remain_second( | |
13875 | p->t_gr_restart) | |
13876 | * 1000); | |
13877 | ||
13878 | if (p->t_gr_stale) | |
13879 | json_object_int_add( | |
13880 | json_grace, | |
13881 | "gracefulStalepathTimerMsecs", | |
13882 | thread_timer_remain_second( | |
13883 | p->t_gr_stale) | |
13884 | * 1000); | |
2986cac2 | 13885 | /* more gr info in new format */ |
13886 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13887 | json_grace); |
d62a17ae | 13888 | json_object_object_add( |
13889 | json_neigh, "gracefulRestartInfo", json_grace); | |
13890 | } else { | |
2089dd80 | 13891 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
13892 | if ((p->status == Established) |
13893 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 13894 | |
d62a17ae | 13895 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13896 | FOREACH_AFI_SAFI (afi, safi) { |
13897 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13898 | PEER_STATUS_EOR_SEND)) { | |
13899 | vty_out(vty, "%s%s", | |
13900 | eor_send_af_count ? ", " | |
13901 | : "", | |
36235319 QY |
13902 | get_afi_safi_str( |
13903 | afi, safi, | |
13904 | false)); | |
05c7a1cc | 13905 | eor_send_af_count++; |
d62a17ae | 13906 | } |
13907 | } | |
13908 | vty_out(vty, "\n"); | |
13909 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13910 | FOREACH_AFI_SAFI (afi, safi) { |
13911 | if (CHECK_FLAG( | |
13912 | p->af_sflags[afi][safi], | |
13913 | PEER_STATUS_EOR_RECEIVED)) { | |
13914 | vty_out(vty, "%s%s", | |
13915 | eor_receive_af_count | |
13916 | ? ", " | |
13917 | : "", | |
5cb5f4d0 DD |
13918 | get_afi_safi_str(afi, |
13919 | safi, | |
13920 | false)); | |
05c7a1cc | 13921 | eor_receive_af_count++; |
d62a17ae | 13922 | } |
13923 | } | |
13924 | vty_out(vty, "\n"); | |
13925 | } | |
13926 | ||
13927 | if (p->t_gr_restart) | |
13928 | vty_out(vty, | |
13929 | " The remaining time of restart timer is %ld\n", | |
13930 | thread_timer_remain_second( | |
13931 | p->t_gr_restart)); | |
13932 | ||
13933 | if (p->t_gr_stale) | |
13934 | vty_out(vty, | |
13935 | " The remaining time of stalepath timer is %ld\n", | |
13936 | thread_timer_remain_second( | |
13937 | p->t_gr_stale)); | |
2986cac2 | 13938 | |
13939 | /* more gr info in new format */ | |
13940 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13941 | } |
2986cac2 | 13942 | |
d62a17ae | 13943 | if (use_json) { |
13944 | json_object *json_stat = NULL; | |
13945 | json_stat = json_object_new_object(); | |
13946 | /* Packet counts. */ | |
43aa5965 QY |
13947 | |
13948 | atomic_size_t outq_count, inq_count; | |
13949 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13950 | memory_order_relaxed); | |
13951 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13952 | memory_order_relaxed); | |
13953 | ||
13954 | json_object_int_add(json_stat, "depthInq", | |
13955 | (unsigned long)inq_count); | |
d62a17ae | 13956 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13957 | (unsigned long)outq_count); |
0112e9e0 QY |
13958 | json_object_int_add(json_stat, "opensSent", |
13959 | atomic_load_explicit(&p->open_out, | |
13960 | memory_order_relaxed)); | |
13961 | json_object_int_add(json_stat, "opensRecv", | |
13962 | atomic_load_explicit(&p->open_in, | |
13963 | memory_order_relaxed)); | |
d62a17ae | 13964 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13965 | atomic_load_explicit(&p->notify_out, |
13966 | memory_order_relaxed)); | |
d62a17ae | 13967 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13968 | atomic_load_explicit(&p->notify_in, |
13969 | memory_order_relaxed)); | |
13970 | json_object_int_add(json_stat, "updatesSent", | |
13971 | atomic_load_explicit(&p->update_out, | |
13972 | memory_order_relaxed)); | |
13973 | json_object_int_add(json_stat, "updatesRecv", | |
13974 | atomic_load_explicit(&p->update_in, | |
13975 | memory_order_relaxed)); | |
d62a17ae | 13976 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13977 | atomic_load_explicit(&p->keepalive_out, |
13978 | memory_order_relaxed)); | |
d62a17ae | 13979 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13980 | atomic_load_explicit(&p->keepalive_in, |
13981 | memory_order_relaxed)); | |
d62a17ae | 13982 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13983 | atomic_load_explicit(&p->refresh_out, |
13984 | memory_order_relaxed)); | |
d62a17ae | 13985 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13986 | atomic_load_explicit(&p->refresh_in, |
13987 | memory_order_relaxed)); | |
d62a17ae | 13988 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13989 | atomic_load_explicit(&p->dynamic_cap_out, |
13990 | memory_order_relaxed)); | |
d62a17ae | 13991 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13992 | atomic_load_explicit(&p->dynamic_cap_in, |
13993 | memory_order_relaxed)); | |
13994 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13995 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13996 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13997 | } else { | |
43aa5965 QY |
13998 | atomic_size_t outq_count, inq_count; |
13999 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14000 | memory_order_relaxed); | |
14001 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14002 | memory_order_relaxed); | |
14003 | ||
d62a17ae | 14004 | /* Packet counts. */ |
14005 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
14006 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
14007 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 14008 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
14009 | vty_out(vty, " Opens: %10d %10d\n", |
14010 | atomic_load_explicit(&p->open_out, | |
14011 | memory_order_relaxed), | |
14012 | atomic_load_explicit(&p->open_in, | |
14013 | memory_order_relaxed)); | |
14014 | vty_out(vty, " Notifications: %10d %10d\n", | |
14015 | atomic_load_explicit(&p->notify_out, | |
14016 | memory_order_relaxed), | |
14017 | atomic_load_explicit(&p->notify_in, | |
14018 | memory_order_relaxed)); | |
14019 | vty_out(vty, " Updates: %10d %10d\n", | |
14020 | atomic_load_explicit(&p->update_out, | |
14021 | memory_order_relaxed), | |
14022 | atomic_load_explicit(&p->update_in, | |
14023 | memory_order_relaxed)); | |
14024 | vty_out(vty, " Keepalives: %10d %10d\n", | |
14025 | atomic_load_explicit(&p->keepalive_out, | |
14026 | memory_order_relaxed), | |
14027 | atomic_load_explicit(&p->keepalive_in, | |
14028 | memory_order_relaxed)); | |
14029 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
14030 | atomic_load_explicit(&p->refresh_out, | |
14031 | memory_order_relaxed), | |
14032 | atomic_load_explicit(&p->refresh_in, | |
14033 | memory_order_relaxed)); | |
d62a17ae | 14034 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
14035 | atomic_load_explicit(&p->dynamic_cap_out, |
14036 | memory_order_relaxed), | |
14037 | atomic_load_explicit(&p->dynamic_cap_in, | |
14038 | memory_order_relaxed)); | |
14039 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
14040 | PEER_TOTAL_RX(p)); | |
d62a17ae | 14041 | } |
14042 | ||
14043 | if (use_json) { | |
14044 | /* advertisement-interval */ | |
14045 | json_object_int_add(json_neigh, | |
14046 | "minBtwnAdvertisementRunsTimerMsecs", | |
14047 | p->v_routeadv * 1000); | |
14048 | ||
14049 | /* Update-source. */ | |
14050 | if (p->update_if || p->update_source) { | |
14051 | if (p->update_if) | |
14052 | json_object_string_add(json_neigh, | |
14053 | "updateSource", | |
14054 | p->update_if); | |
14055 | else if (p->update_source) | |
14056 | json_object_string_add( | |
14057 | json_neigh, "updateSource", | |
14058 | sockunion2str(p->update_source, buf1, | |
14059 | SU_ADDRSTRLEN)); | |
14060 | } | |
14061 | } else { | |
14062 | /* advertisement-interval */ | |
14063 | vty_out(vty, | |
14064 | " Minimum time between advertisement runs is %d seconds\n", | |
14065 | p->v_routeadv); | |
14066 | ||
14067 | /* Update-source. */ | |
14068 | if (p->update_if || p->update_source) { | |
14069 | vty_out(vty, " Update source is "); | |
14070 | if (p->update_if) | |
14071 | vty_out(vty, "%s", p->update_if); | |
14072 | else if (p->update_source) | |
14073 | vty_out(vty, "%s", | |
14074 | sockunion2str(p->update_source, buf1, | |
14075 | SU_ADDRSTRLEN)); | |
14076 | vty_out(vty, "\n"); | |
14077 | } | |
14078 | ||
14079 | vty_out(vty, "\n"); | |
14080 | } | |
14081 | ||
14082 | /* Address Family Information */ | |
14083 | json_object *json_hold = NULL; | |
14084 | ||
14085 | if (use_json) | |
14086 | json_hold = json_object_new_object(); | |
14087 | ||
05c7a1cc QY |
14088 | FOREACH_AFI_SAFI (afi, safi) |
14089 | if (p->afc[afi][safi]) | |
14090 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
14091 | json_hold); | |
d62a17ae | 14092 | |
14093 | if (use_json) { | |
14094 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
14095 | json_hold); | |
14096 | json_object_int_add(json_neigh, "connectionsEstablished", | |
14097 | p->established); | |
14098 | json_object_int_add(json_neigh, "connectionsDropped", | |
14099 | p->dropped); | |
14100 | } else | |
14101 | vty_out(vty, " Connections established %d; dropped %d\n", | |
14102 | p->established, p->dropped); | |
14103 | ||
14104 | if (!p->last_reset) { | |
14105 | if (use_json) | |
14106 | json_object_string_add(json_neigh, "lastReset", | |
14107 | "never"); | |
14108 | else | |
14109 | vty_out(vty, " Last reset never\n"); | |
14110 | } else { | |
14111 | if (use_json) { | |
14112 | time_t uptime; | |
a2700b50 | 14113 | struct tm tm; |
d62a17ae | 14114 | |
14115 | uptime = bgp_clock(); | |
14116 | uptime -= p->resettime; | |
a2700b50 MS |
14117 | gmtime_r(&uptime, &tm); |
14118 | ||
d62a17ae | 14119 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
14120 | (tm.tm_sec * 1000) |
14121 | + (tm.tm_min * 60000) | |
14122 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 14123 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 14124 | } else { |
14125 | vty_out(vty, " Last reset %s, ", | |
14126 | peer_uptime(p->resettime, timebuf, | |
14127 | BGP_UPTIME_LEN, 0, NULL)); | |
14128 | ||
3577f1c5 | 14129 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 14130 | if (p->last_reset_cause_size) { |
14131 | msg = p->last_reset_cause; | |
14132 | vty_out(vty, | |
14133 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
14134 | for (i = 1; i <= p->last_reset_cause_size; | |
14135 | i++) { | |
14136 | vty_out(vty, "%02X", *msg++); | |
14137 | ||
14138 | if (i != p->last_reset_cause_size) { | |
14139 | if (i % 16 == 0) { | |
14140 | vty_out(vty, "\n "); | |
14141 | } else if (i % 4 == 0) { | |
14142 | vty_out(vty, " "); | |
14143 | } | |
14144 | } | |
14145 | } | |
14146 | vty_out(vty, "\n"); | |
14147 | } | |
14148 | } | |
14149 | } | |
14150 | ||
14151 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
14152 | if (use_json) | |
14153 | json_object_boolean_true_add(json_neigh, | |
14154 | "prefixesConfigExceedMax"); | |
14155 | else | |
14156 | vty_out(vty, | |
14157 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
14158 | ||
14159 | if (p->t_pmax_restart) { | |
14160 | if (use_json) { | |
14161 | json_object_boolean_true_add( | |
14162 | json_neigh, "reducePrefixNumFrom"); | |
14163 | json_object_int_add(json_neigh, | |
14164 | "restartInTimerMsec", | |
14165 | thread_timer_remain_second( | |
14166 | p->t_pmax_restart) | |
14167 | * 1000); | |
14168 | } else | |
14169 | vty_out(vty, | |
14170 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
14171 | p->host, thread_timer_remain_second( |
14172 | p->t_pmax_restart)); | |
d62a17ae | 14173 | } else { |
14174 | if (use_json) | |
14175 | json_object_boolean_true_add( | |
14176 | json_neigh, | |
14177 | "reducePrefixNumAndClearIpBgp"); | |
14178 | else | |
14179 | vty_out(vty, | |
14180 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
14181 | p->host); | |
14182 | } | |
14183 | } | |
14184 | ||
14185 | /* EBGP Multihop and GTSM */ | |
14186 | if (p->sort != BGP_PEER_IBGP) { | |
14187 | if (use_json) { | |
e2521429 | 14188 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14189 | json_object_int_add(json_neigh, |
14190 | "externalBgpNbrMaxHopsAway", | |
14191 | p->gtsm_hops); | |
c8d6f0d6 | 14192 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 14193 | json_object_int_add(json_neigh, |
14194 | "externalBgpNbrMaxHopsAway", | |
14195 | p->ttl); | |
14196 | } else { | |
e2521429 | 14197 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14198 | vty_out(vty, |
14199 | " External BGP neighbor may be up to %d hops away.\n", | |
14200 | p->gtsm_hops); | |
c8d6f0d6 | 14201 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 14202 | vty_out(vty, |
14203 | " External BGP neighbor may be up to %d hops away.\n", | |
14204 | p->ttl); | |
14205 | } | |
14206 | } else { | |
e2521429 | 14207 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 14208 | if (use_json) |
14209 | json_object_int_add(json_neigh, | |
14210 | "internalBgpNbrMaxHopsAway", | |
14211 | p->gtsm_hops); | |
14212 | else | |
14213 | vty_out(vty, | |
14214 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14215 | p->gtsm_hops); | |
14216 | } | |
14217 | } | |
14218 | ||
14219 | /* Local address. */ | |
14220 | if (p->su_local) { | |
14221 | if (use_json) { | |
14222 | json_object_string_add(json_neigh, "hostLocal", | |
14223 | sockunion2str(p->su_local, buf1, | |
14224 | SU_ADDRSTRLEN)); | |
14225 | json_object_int_add(json_neigh, "portLocal", | |
14226 | ntohs(p->su_local->sin.sin_port)); | |
14227 | } else | |
14228 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
14229 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
14230 | ntohs(p->su_local->sin.sin_port)); | |
14231 | } | |
14232 | ||
14233 | /* Remote address. */ | |
14234 | if (p->su_remote) { | |
14235 | if (use_json) { | |
14236 | json_object_string_add(json_neigh, "hostForeign", | |
14237 | sockunion2str(p->su_remote, buf1, | |
14238 | SU_ADDRSTRLEN)); | |
14239 | json_object_int_add(json_neigh, "portForeign", | |
14240 | ntohs(p->su_remote->sin.sin_port)); | |
14241 | } else | |
14242 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
14243 | sockunion2str(p->su_remote, buf1, | |
14244 | SU_ADDRSTRLEN), | |
14245 | ntohs(p->su_remote->sin.sin_port)); | |
14246 | } | |
14247 | ||
14248 | /* Nexthop display. */ | |
14249 | if (p->su_local) { | |
14250 | if (use_json) { | |
14251 | json_object_string_add(json_neigh, "nexthop", | |
14252 | inet_ntop(AF_INET, | |
14253 | &p->nexthop.v4, buf1, | |
14254 | sizeof(buf1))); | |
14255 | json_object_string_add(json_neigh, "nexthopGlobal", | |
14256 | inet_ntop(AF_INET6, | |
14257 | &p->nexthop.v6_global, | |
14258 | buf1, sizeof(buf1))); | |
14259 | json_object_string_add(json_neigh, "nexthopLocal", | |
14260 | inet_ntop(AF_INET6, | |
14261 | &p->nexthop.v6_local, | |
14262 | buf1, sizeof(buf1))); | |
14263 | if (p->shared_network) | |
14264 | json_object_string_add(json_neigh, | |
14265 | "bgpConnection", | |
14266 | "sharedNetwork"); | |
14267 | else | |
14268 | json_object_string_add(json_neigh, | |
14269 | "bgpConnection", | |
14270 | "nonSharedNetwork"); | |
14271 | } else { | |
14272 | vty_out(vty, "Nexthop: %s\n", | |
14273 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
14274 | sizeof(buf1))); | |
14275 | vty_out(vty, "Nexthop global: %s\n", | |
14276 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
14277 | sizeof(buf1))); | |
14278 | vty_out(vty, "Nexthop local: %s\n", | |
14279 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
14280 | sizeof(buf1))); | |
14281 | vty_out(vty, "BGP connection: %s\n", | |
14282 | p->shared_network ? "shared network" | |
14283 | : "non shared network"); | |
14284 | } | |
14285 | } | |
14286 | ||
14287 | /* Timer information. */ | |
14288 | if (use_json) { | |
14289 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14290 | p->v_connect); | |
14291 | if (p->status == Established && p->rtt) | |
14292 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
14293 | p->rtt); | |
14294 | if (p->t_start) | |
14295 | json_object_int_add( | |
14296 | json_neigh, "nextStartTimerDueInMsecs", | |
14297 | thread_timer_remain_second(p->t_start) * 1000); | |
14298 | if (p->t_connect) | |
14299 | json_object_int_add( | |
14300 | json_neigh, "nextConnectTimerDueInMsecs", | |
14301 | thread_timer_remain_second(p->t_connect) | |
14302 | * 1000); | |
14303 | if (p->t_routeadv) { | |
14304 | json_object_int_add(json_neigh, "mraiInterval", | |
14305 | p->v_routeadv); | |
14306 | json_object_int_add( | |
14307 | json_neigh, "mraiTimerExpireInMsecs", | |
14308 | thread_timer_remain_second(p->t_routeadv) | |
14309 | * 1000); | |
14310 | } | |
14311 | if (p->password) | |
14312 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14313 | 1); | |
14314 | ||
14315 | if (p->t_read) | |
14316 | json_object_string_add(json_neigh, "readThread", "on"); | |
14317 | else | |
14318 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14319 | |
14320 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14321 | json_object_string_add(json_neigh, "writeThread", "on"); |
14322 | else | |
14323 | json_object_string_add(json_neigh, "writeThread", | |
14324 | "off"); | |
14325 | } else { | |
14326 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14327 | p->v_connect); | |
14328 | if (p->status == Established && p->rtt) | |
14329 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
14330 | p->rtt); | |
14331 | if (p->t_start) | |
14332 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14333 | thread_timer_remain_second(p->t_start)); | |
14334 | if (p->t_connect) | |
14335 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14336 | thread_timer_remain_second(p->t_connect)); | |
14337 | if (p->t_routeadv) | |
14338 | vty_out(vty, | |
14339 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14340 | p->v_routeadv, | |
14341 | thread_timer_remain_second(p->t_routeadv)); | |
14342 | if (p->password) | |
14343 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14344 | ||
cac9e917 | 14345 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14346 | p->t_read ? "on" : "off", |
14347 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14348 | ? "on" | |
cac9e917 | 14349 | : "off", p->fd); |
d62a17ae | 14350 | } |
14351 | ||
14352 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14353 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14354 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14355 | ||
14356 | if (!use_json) | |
14357 | vty_out(vty, "\n"); | |
14358 | ||
14359 | /* BFD information. */ | |
14360 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
14361 | ||
14362 | if (use_json) { | |
14363 | if (p->conf_if) /* Configured interface name. */ | |
14364 | json_object_object_add(json, p->conf_if, json_neigh); | |
14365 | else /* Configured IP address. */ | |
14366 | json_object_object_add(json, p->host, json_neigh); | |
14367 | } | |
14368 | } | |
14369 | ||
36235319 QY |
14370 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14371 | enum show_type type, | |
14372 | union sockunion *su, | |
14373 | const char *conf_if, afi_t afi, | |
74a630b6 | 14374 | bool use_json) |
2986cac2 | 14375 | { |
14376 | struct listnode *node, *nnode; | |
14377 | struct peer *peer; | |
14378 | int find = 0; | |
14379 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14380 | json_object *json = NULL; |
2986cac2 | 14381 | json_object *json_neighbor = NULL; |
14382 | ||
74a630b6 NT |
14383 | if (use_json) { |
14384 | json = json_object_new_object(); | |
14385 | json_neighbor = json_object_new_object(); | |
14386 | } | |
14387 | ||
2986cac2 | 14388 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14389 | ||
14390 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14391 | continue; | |
14392 | ||
14393 | if ((peer->afc[afi][safi]) == 0) | |
14394 | continue; | |
14395 | ||
2ba1fe69 | 14396 | if (type == show_all) { |
2986cac2 | 14397 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14398 | json_neighbor); |
2986cac2 | 14399 | |
74a630b6 | 14400 | if (use_json) { |
13909c4f DS |
14401 | json_object_object_add(json, peer->host, |
14402 | json_neighbor); | |
74a630b6 NT |
14403 | json_neighbor = NULL; |
14404 | } | |
2986cac2 | 14405 | |
2ba1fe69 | 14406 | } else if (type == show_peer) { |
2986cac2 | 14407 | if (conf_if) { |
14408 | if ((peer->conf_if | |
13909c4f DS |
14409 | && !strcmp(peer->conf_if, conf_if)) |
14410 | || (peer->hostname | |
2986cac2 | 14411 | && !strcmp(peer->hostname, conf_if))) { |
14412 | find = 1; | |
13909c4f DS |
14413 | bgp_show_peer_gr_status(vty, peer, |
14414 | use_json, | |
14415 | json_neighbor); | |
2986cac2 | 14416 | } |
14417 | } else { | |
14418 | if (sockunion_same(&peer->su, su)) { | |
14419 | find = 1; | |
13909c4f DS |
14420 | bgp_show_peer_gr_status(vty, peer, |
14421 | use_json, | |
14422 | json_neighbor); | |
2986cac2 | 14423 | } |
14424 | } | |
13909c4f DS |
14425 | if (use_json && find) |
14426 | json_object_object_add(json, peer->host, | |
14427 | json_neighbor); | |
2986cac2 | 14428 | } |
14429 | ||
74a630b6 NT |
14430 | if (find) { |
14431 | json_neighbor = NULL; | |
2986cac2 | 14432 | break; |
74a630b6 | 14433 | } |
2986cac2 | 14434 | } |
14435 | ||
14436 | if (type == show_peer && !find) { | |
14437 | if (use_json) | |
13909c4f | 14438 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14439 | else |
14440 | vty_out(vty, "%% No such neighbor\n"); | |
14441 | } | |
14442 | if (use_json) { | |
13909c4f DS |
14443 | vty_out(vty, "%s\n", |
14444 | json_object_to_json_string_ext( | |
14445 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14446 | |
14447 | if (json_neighbor) | |
14448 | json_object_free(json_neighbor); | |
14449 | json_object_free(json); | |
2986cac2 | 14450 | } else { |
14451 | vty_out(vty, "\n"); | |
14452 | } | |
14453 | ||
14454 | return CMD_SUCCESS; | |
14455 | } | |
14456 | ||
d62a17ae | 14457 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14458 | enum show_type type, union sockunion *su, | |
9f049418 | 14459 | const char *conf_if, bool use_json, |
d62a17ae | 14460 | json_object *json) |
14461 | { | |
14462 | struct listnode *node, *nnode; | |
14463 | struct peer *peer; | |
14464 | int find = 0; | |
9f049418 | 14465 | bool nbr_output = false; |
d1927ebe AS |
14466 | afi_t afi = AFI_MAX; |
14467 | safi_t safi = SAFI_MAX; | |
14468 | ||
14469 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14470 | afi = AFI_IP; | |
14471 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14472 | afi = AFI_IP6; | |
14473 | } | |
d62a17ae | 14474 | |
14475 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14476 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14477 | continue; | |
14478 | ||
14479 | switch (type) { | |
14480 | case show_all: | |
14481 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14482 | nbr_output = true; |
d62a17ae | 14483 | break; |
14484 | case show_peer: | |
14485 | if (conf_if) { | |
14486 | if ((peer->conf_if | |
14487 | && !strcmp(peer->conf_if, conf_if)) | |
14488 | || (peer->hostname | |
14489 | && !strcmp(peer->hostname, conf_if))) { | |
14490 | find = 1; | |
14491 | bgp_show_peer(vty, peer, use_json, | |
14492 | json); | |
14493 | } | |
14494 | } else { | |
14495 | if (sockunion_same(&peer->su, su)) { | |
14496 | find = 1; | |
14497 | bgp_show_peer(vty, peer, use_json, | |
14498 | json); | |
14499 | } | |
14500 | } | |
14501 | break; | |
d1927ebe AS |
14502 | case show_ipv4_peer: |
14503 | case show_ipv6_peer: | |
14504 | FOREACH_SAFI (safi) { | |
14505 | if (peer->afc[afi][safi]) { | |
14506 | if (conf_if) { | |
14507 | if ((peer->conf_if | |
14508 | && !strcmp(peer->conf_if, conf_if)) | |
14509 | || (peer->hostname | |
14510 | && !strcmp(peer->hostname, conf_if))) { | |
14511 | find = 1; | |
14512 | bgp_show_peer(vty, peer, use_json, | |
14513 | json); | |
14514 | break; | |
14515 | } | |
14516 | } else { | |
14517 | if (sockunion_same(&peer->su, su)) { | |
14518 | find = 1; | |
14519 | bgp_show_peer(vty, peer, use_json, | |
14520 | json); | |
14521 | break; | |
14522 | } | |
14523 | } | |
14524 | } | |
14525 | } | |
14526 | break; | |
14527 | case show_ipv4_all: | |
14528 | case show_ipv6_all: | |
14529 | FOREACH_SAFI (safi) { | |
14530 | if (peer->afc[afi][safi]) { | |
14531 | bgp_show_peer(vty, peer, use_json, json); | |
14532 | nbr_output = true; | |
14533 | break; | |
14534 | } | |
14535 | } | |
14536 | break; | |
d62a17ae | 14537 | } |
14538 | } | |
14539 | ||
d1927ebe AS |
14540 | if ((type == show_peer || type == show_ipv4_peer || |
14541 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14542 | if (use_json) |
14543 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14544 | else | |
88b7d255 | 14545 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14546 | } |
14547 | ||
d1927ebe AS |
14548 | if (type != show_peer && type != show_ipv4_peer && |
14549 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14550 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14551 | |
d62a17ae | 14552 | if (use_json) { |
996c9314 LB |
14553 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14554 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14555 | } else { |
14556 | vty_out(vty, "\n"); | |
14557 | } | |
14558 | ||
14559 | return CMD_SUCCESS; | |
14560 | } | |
14561 | ||
36235319 QY |
14562 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14563 | enum show_type type, | |
14564 | const char *ip_str, | |
14565 | afi_t afi, bool use_json) | |
2986cac2 | 14566 | { |
14567 | ||
14568 | int ret; | |
14569 | struct bgp *bgp; | |
14570 | union sockunion su; | |
2986cac2 | 14571 | |
14572 | bgp = bgp_get_default(); | |
14573 | ||
13909c4f DS |
14574 | if (!bgp) |
14575 | return; | |
2986cac2 | 14576 | |
13909c4f DS |
14577 | if (!use_json) |
14578 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14579 | NULL); | |
2986cac2 | 14580 | |
13909c4f DS |
14581 | if (ip_str) { |
14582 | ret = str2sockunion(ip_str, &su); | |
14583 | if (ret < 0) | |
13909c4f | 14584 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14585 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14586 | else | |
14587 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14588 | NULL, afi, use_json); | |
13909c4f DS |
14589 | } else |
14590 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14591 | afi, use_json); |
2986cac2 | 14592 | } |
14593 | ||
d62a17ae | 14594 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14595 | enum show_type type, |
14596 | const char *ip_str, | |
9f049418 | 14597 | bool use_json) |
d62a17ae | 14598 | { |
0291c246 MK |
14599 | struct listnode *node, *nnode; |
14600 | struct bgp *bgp; | |
71aedaa3 | 14601 | union sockunion su; |
0291c246 | 14602 | json_object *json = NULL; |
71aedaa3 | 14603 | int ret, is_first = 1; |
9f049418 | 14604 | bool nbr_output = false; |
d62a17ae | 14605 | |
14606 | if (use_json) | |
14607 | vty_out(vty, "{\n"); | |
14608 | ||
14609 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14610 | nbr_output = true; |
d62a17ae | 14611 | if (use_json) { |
14612 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14613 | flog_err( |
e50f7cfd | 14614 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14615 | "Unable to allocate memory for JSON object"); |
14616 | vty_out(vty, | |
14617 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14618 | return; | |
14619 | } | |
14620 | ||
14621 | json_object_int_add(json, "vrfId", | |
14622 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14623 | ? -1 |
14624 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14625 | json_object_string_add( |
14626 | json, "vrfName", | |
14627 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14628 | ? VRF_DEFAULT_NAME |
d62a17ae | 14629 | : bgp->name); |
14630 | ||
14631 | if (!is_first) | |
14632 | vty_out(vty, ",\n"); | |
14633 | else | |
14634 | is_first = 0; | |
14635 | ||
14636 | vty_out(vty, "\"%s\":", | |
14637 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14638 | ? VRF_DEFAULT_NAME |
d62a17ae | 14639 | : bgp->name); |
14640 | } else { | |
14641 | vty_out(vty, "\nInstance %s:\n", | |
14642 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14643 | ? VRF_DEFAULT_NAME |
d62a17ae | 14644 | : bgp->name); |
14645 | } | |
71aedaa3 | 14646 | |
d1927ebe AS |
14647 | if (type == show_peer || type == show_ipv4_peer || |
14648 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14649 | ret = str2sockunion(ip_str, &su); |
14650 | if (ret < 0) | |
14651 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14652 | use_json, json); | |
14653 | else | |
14654 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14655 | use_json, json); | |
14656 | } else { | |
d1927ebe | 14657 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14658 | use_json, json); |
14659 | } | |
b77004d6 | 14660 | json_object_free(json); |
121067e9 | 14661 | json = NULL; |
d62a17ae | 14662 | } |
14663 | ||
3e78a6ce | 14664 | if (use_json) |
d62a17ae | 14665 | vty_out(vty, "}\n"); |
9f049418 DS |
14666 | else if (!nbr_output) |
14667 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14668 | } |
14669 | ||
14670 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14671 | enum show_type type, const char *ip_str, | |
9f049418 | 14672 | bool use_json) |
d62a17ae | 14673 | { |
14674 | int ret; | |
14675 | struct bgp *bgp; | |
14676 | union sockunion su; | |
14677 | json_object *json = NULL; | |
14678 | ||
14679 | if (name) { | |
14680 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14681 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14682 | use_json); | |
d62a17ae | 14683 | return CMD_SUCCESS; |
14684 | } else { | |
14685 | bgp = bgp_lookup_by_name(name); | |
14686 | if (!bgp) { | |
14687 | if (use_json) { | |
14688 | json = json_object_new_object(); | |
d62a17ae | 14689 | vty_out(vty, "%s\n", |
14690 | json_object_to_json_string_ext( | |
14691 | json, | |
14692 | JSON_C_TO_STRING_PRETTY)); | |
14693 | json_object_free(json); | |
14694 | } else | |
14695 | vty_out(vty, | |
9f049418 | 14696 | "%% BGP instance not found\n"); |
d62a17ae | 14697 | |
14698 | return CMD_WARNING; | |
14699 | } | |
14700 | } | |
14701 | } else { | |
14702 | bgp = bgp_get_default(); | |
14703 | } | |
14704 | ||
14705 | if (bgp) { | |
14706 | json = json_object_new_object(); | |
14707 | if (ip_str) { | |
14708 | ret = str2sockunion(ip_str, &su); | |
14709 | if (ret < 0) | |
14710 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14711 | use_json, json); | |
14712 | else | |
14713 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14714 | use_json, json); | |
14715 | } else { | |
14716 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14717 | json); | |
14718 | } | |
14719 | json_object_free(json); | |
ca61fd25 DS |
14720 | } else { |
14721 | if (use_json) | |
14722 | vty_out(vty, "{}\n"); | |
14723 | else | |
14724 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14725 | } |
14726 | ||
14727 | return CMD_SUCCESS; | |
4fb25c53 DW |
14728 | } |
14729 | ||
2986cac2 | 14730 | |
14731 | ||
14732 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14733 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14734 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14735 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14736 | SHOW_STR | |
14737 | BGP_STR | |
14738 | IP_STR | |
14739 | IPV6_STR | |
14740 | NEIGHBOR_STR | |
14741 | "Neighbor to display information about\n" | |
14742 | "Neighbor to display information about\n" | |
14743 | "Neighbor on BGP configured interface\n" | |
14744 | GR_SHOW | |
14745 | JSON_STR) | |
14746 | { | |
14747 | char *sh_arg = NULL; | |
14748 | enum show_type sh_type; | |
14749 | int idx = 0; | |
14750 | afi_t afi = AFI_MAX; | |
2986cac2 | 14751 | bool uj = use_json(argc, argv); |
14752 | ||
36235319 | 14753 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14754 | afi = AFI_MAX; |
14755 | ||
14756 | idx++; | |
14757 | ||
14758 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14759 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14760 | || argv_find(argv, argc, "WORD", &idx)) { | |
14761 | sh_type = show_peer; | |
14762 | sh_arg = argv[idx]->arg; | |
14763 | } else | |
14764 | sh_type = show_all; | |
14765 | ||
14766 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14767 | return CMD_SUCCESS; | |
14768 | ||
14769 | ||
36235319 QY |
14770 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14771 | afi, uj); | |
2986cac2 | 14772 | } |
14773 | ||
716b2d8a | 14774 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14775 | DEFUN (show_ip_bgp_neighbors, |
14776 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14777 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14778 | SHOW_STR |
14779 | IP_STR | |
14780 | BGP_STR | |
f2a8972b | 14781 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14782 | "Address Family\n" |
14783 | "Address Family\n" | |
718e3744 | 14784 | "Detailed information on TCP and BGP neighbor connections\n" |
14785 | "Neighbor to display information about\n" | |
a80beece | 14786 | "Neighbor to display information about\n" |
91d37724 | 14787 | "Neighbor on BGP configured interface\n" |
9973d184 | 14788 | JSON_STR) |
718e3744 | 14789 | { |
d62a17ae | 14790 | char *vrf = NULL; |
14791 | char *sh_arg = NULL; | |
14792 | enum show_type sh_type; | |
d1927ebe | 14793 | afi_t afi = AFI_MAX; |
718e3744 | 14794 | |
9f049418 | 14795 | bool uj = use_json(argc, argv); |
718e3744 | 14796 | |
d62a17ae | 14797 | int idx = 0; |
718e3744 | 14798 | |
9a8bdf1c PG |
14799 | /* [<vrf> VIEWVRFNAME] */ |
14800 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14801 | vrf = argv[idx + 1]->arg; | |
14802 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14803 | vrf = NULL; | |
14804 | } else if (argv_find(argv, argc, "view", &idx)) | |
14805 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14806 | vrf = argv[idx + 1]->arg; |
718e3744 | 14807 | |
d62a17ae | 14808 | idx++; |
d1927ebe AS |
14809 | |
14810 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14811 | sh_type = show_ipv4_all; | |
14812 | afi = AFI_IP; | |
14813 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14814 | sh_type = show_ipv6_all; | |
14815 | afi = AFI_IP6; | |
14816 | } else { | |
14817 | sh_type = show_all; | |
14818 | } | |
14819 | ||
d62a17ae | 14820 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14821 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14822 | || argv_find(argv, argc, "WORD", &idx)) { | |
14823 | sh_type = show_peer; | |
14824 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14825 | } |
14826 | ||
14827 | if (sh_type == show_peer && afi == AFI_IP) { | |
14828 | sh_type = show_ipv4_peer; | |
14829 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14830 | sh_type = show_ipv6_peer; | |
14831 | } | |
856ca177 | 14832 | |
d62a17ae | 14833 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14834 | } |
14835 | ||
716b2d8a | 14836 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14837 | paths' and `show ip mbgp paths'. Those functions results are the |
14838 | same.*/ | |
f412b39a | 14839 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14840 | show_ip_bgp_paths_cmd, |
46f296b4 | 14841 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14842 | SHOW_STR |
14843 | IP_STR | |
14844 | BGP_STR | |
46f296b4 | 14845 | BGP_SAFI_HELP_STR |
718e3744 | 14846 | "Path information\n") |
14847 | { | |
d62a17ae | 14848 | vty_out(vty, "Address Refcnt Path\n"); |
14849 | aspath_print_all_vty(vty); | |
14850 | return CMD_SUCCESS; | |
718e3744 | 14851 | } |
14852 | ||
718e3744 | 14853 | #include "hash.h" |
14854 | ||
e3b78da8 | 14855 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14856 | struct vty *vty) |
718e3744 | 14857 | { |
d62a17ae | 14858 | struct community *com; |
718e3744 | 14859 | |
e3b78da8 | 14860 | com = (struct community *)bucket->data; |
3f65c5b1 | 14861 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14862 | community_str(com, false)); |
718e3744 | 14863 | } |
14864 | ||
14865 | /* Show BGP's community internal data. */ | |
f412b39a | 14866 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14867 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14868 | "show [ip] bgp community-info", |
718e3744 | 14869 | SHOW_STR |
14870 | IP_STR | |
14871 | BGP_STR | |
14872 | "List all bgp community information\n") | |
14873 | { | |
d62a17ae | 14874 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14875 | |
d62a17ae | 14876 | hash_iterate(community_hash(), |
e3b78da8 | 14877 | (void (*)(struct hash_bucket *, |
d62a17ae | 14878 | void *))community_show_all_iterator, |
14879 | vty); | |
718e3744 | 14880 | |
d62a17ae | 14881 | return CMD_SUCCESS; |
718e3744 | 14882 | } |
14883 | ||
e3b78da8 | 14884 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14885 | struct vty *vty) |
57d187bc | 14886 | { |
d62a17ae | 14887 | struct lcommunity *lcom; |
57d187bc | 14888 | |
e3b78da8 | 14889 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14890 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14891 | lcommunity_str(lcom, false)); |
57d187bc JS |
14892 | } |
14893 | ||
14894 | /* Show BGP's community internal data. */ | |
14895 | DEFUN (show_ip_bgp_lcommunity_info, | |
14896 | show_ip_bgp_lcommunity_info_cmd, | |
14897 | "show ip bgp large-community-info", | |
14898 | SHOW_STR | |
14899 | IP_STR | |
14900 | BGP_STR | |
14901 | "List all bgp large-community information\n") | |
14902 | { | |
d62a17ae | 14903 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14904 | |
d62a17ae | 14905 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14906 | (void (*)(struct hash_bucket *, |
d62a17ae | 14907 | void *))lcommunity_show_all_iterator, |
14908 | vty); | |
57d187bc | 14909 | |
d62a17ae | 14910 | return CMD_SUCCESS; |
57d187bc | 14911 | } |
2986cac2 | 14912 | /* Graceful Restart */ |
14913 | ||
14914 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14915 | struct bgp *bgp, |
14916 | bool use_json, | |
14917 | json_object *json) | |
2986cac2 | 14918 | { |
57d187bc JS |
14919 | |
14920 | ||
2986cac2 | 14921 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14922 | ||
7318ae88 | 14923 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14924 | |
14925 | switch (bgp_global_gr_mode) { | |
14926 | ||
14927 | case GLOBAL_HELPER: | |
13909c4f | 14928 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14929 | break; |
14930 | ||
14931 | case GLOBAL_GR: | |
13909c4f | 14932 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14933 | break; |
14934 | ||
14935 | case GLOBAL_DISABLE: | |
13909c4f | 14936 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14937 | break; |
14938 | ||
14939 | case GLOBAL_INVALID: | |
2986cac2 | 14940 | vty_out(vty, |
2ba1fe69 | 14941 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14942 | break; |
14943 | } | |
14944 | vty_out(vty, "\n"); | |
14945 | } | |
14946 | ||
36235319 QY |
14947 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14948 | enum show_type type, | |
14949 | const char *ip_str, | |
14950 | afi_t afi, bool use_json) | |
2986cac2 | 14951 | { |
14952 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14953 | afi = AFI_IP; | |
14954 | ||
14955 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14956 | ||
36235319 QY |
14957 | bgp_show_neighbor_graceful_restart_vty( |
14958 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14959 | afi++; |
14960 | } | |
14961 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14962 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14963 | use_json); | |
2986cac2 | 14964 | } else { |
14965 | return CMD_ERR_INCOMPLETE; | |
14966 | } | |
14967 | ||
14968 | return CMD_SUCCESS; | |
14969 | } | |
14970 | /* Graceful Restart */ | |
14971 | ||
f412b39a | 14972 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14973 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14974 | "show [ip] bgp attribute-info", |
718e3744 | 14975 | SHOW_STR |
14976 | IP_STR | |
14977 | BGP_STR | |
14978 | "List all bgp attribute information\n") | |
14979 | { | |
d62a17ae | 14980 | attr_show_all(vty); |
14981 | return CMD_SUCCESS; | |
718e3744 | 14982 | } |
6b0655a2 | 14983 | |
03915806 CS |
14984 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14985 | afi_t afi, safi_t safi, | |
14986 | bool use_json, json_object *json) | |
53089bec | 14987 | { |
14988 | struct bgp *bgp; | |
14989 | struct listnode *node; | |
14990 | char *vname; | |
14991 | char buf1[INET6_ADDRSTRLEN]; | |
14992 | char *ecom_str; | |
14993 | vpn_policy_direction_t dir; | |
14994 | ||
03915806 | 14995 | if (json) { |
b46dfd20 DS |
14996 | json_object *json_import_vrfs = NULL; |
14997 | json_object *json_export_vrfs = NULL; | |
14998 | ||
b46dfd20 DS |
14999 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15000 | ||
53089bec | 15001 | if (!bgp) { |
b46dfd20 DS |
15002 | vty_out(vty, "%s\n", |
15003 | json_object_to_json_string_ext( | |
15004 | json, | |
15005 | JSON_C_TO_STRING_PRETTY)); | |
15006 | json_object_free(json); | |
15007 | ||
53089bec | 15008 | return CMD_WARNING; |
15009 | } | |
b46dfd20 | 15010 | |
94d4c685 DS |
15011 | /* Provide context for the block */ |
15012 | json_object_string_add(json, "vrf", name ? name : "default"); | |
15013 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 15014 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 15015 | |
b46dfd20 DS |
15016 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15017 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15018 | json_object_string_add(json, "importFromVrfs", "none"); | |
15019 | json_object_string_add(json, "importRts", "none"); | |
15020 | } else { | |
6ce24e52 DS |
15021 | json_import_vrfs = json_object_new_array(); |
15022 | ||
b46dfd20 DS |
15023 | for (ALL_LIST_ELEMENTS_RO( |
15024 | bgp->vpn_policy[afi].import_vrf, | |
15025 | node, vname)) | |
15026 | json_object_array_add(json_import_vrfs, | |
15027 | json_object_new_string(vname)); | |
15028 | ||
b20875ea CS |
15029 | json_object_object_add(json, "importFromVrfs", |
15030 | json_import_vrfs); | |
b46dfd20 | 15031 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
15032 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15033 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15034 | bgp->vpn_policy[afi].rtlist[dir], |
15035 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15036 | json_object_string_add(json, "importRts", |
15037 | ecom_str); | |
15038 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15039 | } else | |
15040 | json_object_string_add(json, "importRts", | |
15041 | "none"); | |
b46dfd20 DS |
15042 | } |
15043 | ||
15044 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
15045 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
15046 | json_object_string_add(json, "exportToVrfs", "none"); | |
15047 | json_object_string_add(json, "routeDistinguisher", | |
15048 | "none"); | |
15049 | json_object_string_add(json, "exportRts", "none"); | |
15050 | } else { | |
6ce24e52 DS |
15051 | json_export_vrfs = json_object_new_array(); |
15052 | ||
b46dfd20 DS |
15053 | for (ALL_LIST_ELEMENTS_RO( |
15054 | bgp->vpn_policy[afi].export_vrf, | |
15055 | node, vname)) | |
15056 | json_object_array_add(json_export_vrfs, | |
15057 | json_object_new_string(vname)); | |
15058 | json_object_object_add(json, "exportToVrfs", | |
15059 | json_export_vrfs); | |
15060 | json_object_string_add(json, "routeDistinguisher", | |
15061 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
15062 | buf1, RD_ADDRSTRLEN)); | |
15063 | ||
15064 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15065 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15066 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15067 | bgp->vpn_policy[afi].rtlist[dir], |
15068 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15069 | json_object_string_add(json, "exportRts", |
15070 | ecom_str); | |
15071 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15072 | } else | |
15073 | json_object_string_add(json, "exportRts", | |
15074 | "none"); | |
b46dfd20 DS |
15075 | } |
15076 | ||
03915806 CS |
15077 | if (use_json) { |
15078 | vty_out(vty, "%s\n", | |
15079 | json_object_to_json_string_ext(json, | |
b46dfd20 | 15080 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
15081 | json_object_free(json); |
15082 | } | |
53089bec | 15083 | } else { |
b46dfd20 DS |
15084 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15085 | ||
53089bec | 15086 | if (!bgp) { |
b46dfd20 | 15087 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 15088 | return CMD_WARNING; |
15089 | } | |
53089bec | 15090 | |
b46dfd20 DS |
15091 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15092 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
15093 | vty_out(vty, | |
15094 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 15095 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15096 | else { |
15097 | vty_out(vty, | |
15098 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 15099 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15100 | |
15101 | for (ALL_LIST_ELEMENTS_RO( | |
15102 | bgp->vpn_policy[afi].import_vrf, | |
15103 | node, vname)) | |
15104 | vty_out(vty, " %s\n", vname); | |
15105 | ||
15106 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
15107 | ecom_str = NULL; |
15108 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
15109 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15110 | bgp->vpn_policy[afi].rtlist[dir], |
15111 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 15112 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 15113 | |
b20875ea CS |
15114 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
15115 | } else | |
15116 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15117 | } |
53089bec | 15118 | |
b46dfd20 DS |
15119 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15120 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15121 | vty_out(vty, | |
15122 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 15123 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15124 | else { |
15125 | vty_out(vty, | |
04c9077f | 15126 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 15127 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15128 | |
15129 | for (ALL_LIST_ELEMENTS_RO( | |
15130 | bgp->vpn_policy[afi].export_vrf, | |
15131 | node, vname)) | |
15132 | vty_out(vty, " %s\n", vname); | |
15133 | ||
15134 | vty_out(vty, "RD: %s\n", | |
15135 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
15136 | buf1, RD_ADDRSTRLEN)); | |
15137 | ||
15138 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15139 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15140 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15141 | bgp->vpn_policy[afi].rtlist[dir], |
15142 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15143 | vty_out(vty, "Export RT: %s\n", ecom_str); |
15144 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15145 | } else | |
15146 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15147 | } |
53089bec | 15148 | } |
15149 | ||
15150 | return CMD_SUCCESS; | |
15151 | } | |
15152 | ||
03915806 CS |
15153 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
15154 | safi_t safi, bool use_json) | |
15155 | { | |
15156 | struct listnode *node, *nnode; | |
15157 | struct bgp *bgp; | |
15158 | char *vrf_name = NULL; | |
15159 | json_object *json = NULL; | |
15160 | json_object *json_vrf = NULL; | |
15161 | json_object *json_vrfs = NULL; | |
15162 | ||
15163 | if (use_json) { | |
15164 | json = json_object_new_object(); | |
15165 | json_vrfs = json_object_new_object(); | |
15166 | } | |
15167 | ||
15168 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
15169 | ||
15170 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
15171 | vrf_name = bgp->name; | |
15172 | ||
15173 | if (use_json) { | |
15174 | json_vrf = json_object_new_object(); | |
15175 | } else { | |
15176 | vty_out(vty, "\nInstance %s:\n", | |
15177 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15178 | ? VRF_DEFAULT_NAME : bgp->name); | |
15179 | } | |
15180 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
15181 | if (use_json) { | |
15182 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15183 | json_object_object_add(json_vrfs, | |
15184 | VRF_DEFAULT_NAME, json_vrf); | |
15185 | else | |
15186 | json_object_object_add(json_vrfs, vrf_name, | |
15187 | json_vrf); | |
15188 | } | |
15189 | } | |
15190 | ||
15191 | if (use_json) { | |
15192 | json_object_object_add(json, "vrfs", json_vrfs); | |
15193 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
15194 | JSON_C_TO_STRING_PRETTY)); | |
15195 | json_object_free(json); | |
15196 | } | |
15197 | ||
15198 | return CMD_SUCCESS; | |
15199 | } | |
15200 | ||
53089bec | 15201 | /* "show [ip] bgp route-leak" command. */ |
15202 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
15203 | show_ip_bgp_route_leak_cmd, |
15204 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
15205 | SHOW_STR |
15206 | IP_STR | |
15207 | BGP_STR | |
15208 | BGP_INSTANCE_HELP_STR | |
15209 | BGP_AFI_HELP_STR | |
15210 | BGP_SAFI_HELP_STR | |
15211 | "Route leaking information\n" | |
15212 | JSON_STR) | |
53089bec | 15213 | { |
15214 | char *vrf = NULL; | |
15215 | afi_t afi = AFI_MAX; | |
15216 | safi_t safi = SAFI_MAX; | |
15217 | ||
9f049418 | 15218 | bool uj = use_json(argc, argv); |
53089bec | 15219 | int idx = 0; |
03915806 | 15220 | json_object *json = NULL; |
53089bec | 15221 | |
15222 | /* show [ip] bgp */ | |
15223 | if (argv_find(argv, argc, "ip", &idx)) { | |
15224 | afi = AFI_IP; | |
15225 | safi = SAFI_UNICAST; | |
15226 | } | |
15227 | /* [vrf VIEWVRFNAME] */ | |
15228 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
15229 | vty_out(vty, |
15230 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 15231 | return CMD_WARNING; |
15232 | } | |
15233 | ||
9a8bdf1c PG |
15234 | if (argv_find(argv, argc, "vrf", &idx)) { |
15235 | vrf = argv[idx + 1]->arg; | |
15236 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15237 | vrf = NULL; | |
15238 | } | |
53089bec | 15239 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15240 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15241 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15242 | } | |
15243 | ||
15244 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
15245 | vty_out(vty, |
15246 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 15247 | return CMD_WARNING; |
15248 | } | |
15249 | ||
03915806 CS |
15250 | if (vrf && strmatch(vrf, "all")) |
15251 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
15252 | ||
15253 | if (uj) | |
15254 | json = json_object_new_object(); | |
15255 | ||
15256 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15257 | } |
15258 | ||
d62a17ae | 15259 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
15260 | safi_t safi) | |
f186de26 | 15261 | { |
d62a17ae | 15262 | struct listnode *node, *nnode; |
15263 | struct bgp *bgp; | |
f186de26 | 15264 | |
d62a17ae | 15265 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
15266 | vty_out(vty, "\nInstance %s:\n", | |
15267 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15268 | ? VRF_DEFAULT_NAME |
d62a17ae | 15269 | : bgp->name); |
15270 | update_group_show(bgp, afi, safi, vty, 0); | |
15271 | } | |
f186de26 | 15272 | } |
15273 | ||
d62a17ae | 15274 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
15275 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 15276 | { |
d62a17ae | 15277 | struct bgp *bgp; |
4fb25c53 | 15278 | |
d62a17ae | 15279 | if (name) { |
15280 | if (strmatch(name, "all")) { | |
15281 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
15282 | return CMD_SUCCESS; | |
15283 | } else { | |
15284 | bgp = bgp_lookup_by_name(name); | |
15285 | } | |
15286 | } else { | |
15287 | bgp = bgp_get_default(); | |
15288 | } | |
4fb25c53 | 15289 | |
d62a17ae | 15290 | if (bgp) |
15291 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
15292 | return CMD_SUCCESS; | |
4fb25c53 DW |
15293 | } |
15294 | ||
8fe8a7f6 DS |
15295 | DEFUN (show_ip_bgp_updgrps, |
15296 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 15297 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 15298 | SHOW_STR |
15299 | IP_STR | |
15300 | BGP_STR | |
15301 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15302 | BGP_AFI_HELP_STR |
9bedbb1e | 15303 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
15304 | "Detailed info about dynamic update groups\n" |
15305 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 15306 | { |
d62a17ae | 15307 | char *vrf = NULL; |
15308 | afi_t afi = AFI_IP6; | |
15309 | safi_t safi = SAFI_UNICAST; | |
15310 | uint64_t subgrp_id = 0; | |
15311 | ||
15312 | int idx = 0; | |
15313 | ||
15314 | /* show [ip] bgp */ | |
15315 | if (argv_find(argv, argc, "ip", &idx)) | |
15316 | afi = AFI_IP; | |
9a8bdf1c PG |
15317 | /* [<vrf> VIEWVRFNAME] */ |
15318 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15319 | vrf = argv[idx + 1]->arg; | |
15320 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15321 | vrf = NULL; | |
15322 | } else if (argv_find(argv, argc, "view", &idx)) | |
15323 | /* [<view> VIEWVRFNAME] */ | |
15324 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15325 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15326 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15327 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15328 | } | |
5bf15956 | 15329 | |
d62a17ae | 15330 | /* get subgroup id, if provided */ |
15331 | idx = argc - 1; | |
15332 | if (argv[idx]->type == VARIABLE_TKN) | |
15333 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15334 | |
d62a17ae | 15335 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
15336 | } |
15337 | ||
f186de26 | 15338 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15339 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 15340 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 15341 | SHOW_STR |
716b2d8a | 15342 | IP_STR |
f186de26 | 15343 | BGP_STR |
15344 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15345 | "Detailed info about dynamic update groups\n") |
f186de26 | 15346 | { |
d62a17ae | 15347 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15348 | return CMD_SUCCESS; | |
f186de26 | 15349 | } |
15350 | ||
43d3f4fc DS |
15351 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15352 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15353 | "show [ip] bgp l2vpn evpn update-groups", | |
15354 | SHOW_STR | |
15355 | IP_STR | |
15356 | BGP_STR | |
15357 | "l2vpn address family\n" | |
15358 | "evpn sub-address family\n" | |
15359 | "Detailed info about dynamic update groups\n") | |
15360 | { | |
15361 | char *vrf = NULL; | |
15362 | uint64_t subgrp_id = 0; | |
15363 | ||
15364 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15365 | return CMD_SUCCESS; | |
15366 | } | |
15367 | ||
5bf15956 DW |
15368 | DEFUN (show_bgp_updgrps_stats, |
15369 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15370 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15371 | SHOW_STR |
716b2d8a | 15372 | IP_STR |
3f9c7369 | 15373 | BGP_STR |
0c7b1b01 | 15374 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15375 | "Statistics\n") |
15376 | { | |
d62a17ae | 15377 | struct bgp *bgp; |
3f9c7369 | 15378 | |
d62a17ae | 15379 | bgp = bgp_get_default(); |
15380 | if (bgp) | |
15381 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15382 | |
d62a17ae | 15383 | return CMD_SUCCESS; |
3f9c7369 DS |
15384 | } |
15385 | ||
8386ac43 | 15386 | DEFUN (show_bgp_instance_updgrps_stats, |
15387 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15388 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15389 | SHOW_STR |
716b2d8a | 15390 | IP_STR |
8386ac43 | 15391 | BGP_STR |
15392 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15393 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15394 | "Statistics\n") |
15395 | { | |
d62a17ae | 15396 | int idx_word = 3; |
15397 | struct bgp *bgp; | |
8386ac43 | 15398 | |
d62a17ae | 15399 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15400 | if (bgp) | |
15401 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15402 | |
d62a17ae | 15403 | return CMD_SUCCESS; |
8386ac43 | 15404 | } |
15405 | ||
d62a17ae | 15406 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15407 | afi_t afi, safi_t safi, | |
15408 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15409 | { |
d62a17ae | 15410 | struct bgp *bgp; |
8386ac43 | 15411 | |
d62a17ae | 15412 | if (name) |
15413 | bgp = bgp_lookup_by_name(name); | |
15414 | else | |
15415 | bgp = bgp_get_default(); | |
8386ac43 | 15416 | |
d62a17ae | 15417 | if (bgp) { |
15418 | if (!strcmp(what, "advertise-queue")) | |
15419 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15420 | subgrp_id); | |
15421 | else if (!strcmp(what, "advertised-routes")) | |
15422 | update_group_show_advertised(bgp, afi, safi, vty, | |
15423 | subgrp_id); | |
15424 | else if (!strcmp(what, "packet-queue")) | |
15425 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15426 | subgrp_id); | |
15427 | } | |
3f9c7369 DS |
15428 | } |
15429 | ||
dc64bdec QY |
15430 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15431 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15432 | "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", | |
15433 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15434 | BGP_SAFI_HELP_STR | |
15435 | "Detailed info about dynamic update groups\n" | |
15436 | "Specific subgroup to display info for\n" | |
15437 | "Advertisement queue\n" | |
15438 | "Announced routes\n" | |
15439 | "Packet queue\n") | |
3f9c7369 | 15440 | { |
dc64bdec QY |
15441 | uint64_t subgrp_id = 0; |
15442 | afi_t afiz; | |
15443 | safi_t safiz; | |
15444 | if (sgid) | |
15445 | subgrp_id = strtoull(sgid, NULL, 10); | |
15446 | ||
15447 | if (!ip && !afi) | |
15448 | afiz = AFI_IP6; | |
15449 | if (!ip && afi) | |
15450 | afiz = bgp_vty_afi_from_str(afi); | |
15451 | if (ip && !afi) | |
15452 | afiz = AFI_IP; | |
15453 | if (ip && afi) { | |
15454 | afiz = bgp_vty_afi_from_str(afi); | |
15455 | if (afiz != AFI_IP) | |
15456 | vty_out(vty, | |
15457 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15458 | return CMD_WARNING; | |
15459 | } | |
d62a17ae | 15460 | |
dc64bdec | 15461 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15462 | |
dc64bdec | 15463 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15464 | return CMD_SUCCESS; |
15465 | } | |
15466 | ||
d62a17ae | 15467 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
15468 | { | |
15469 | struct listnode *node, *nnode; | |
15470 | struct prefix *range; | |
15471 | struct peer *conf; | |
15472 | struct peer *peer; | |
d62a17ae | 15473 | afi_t afi; |
15474 | safi_t safi; | |
15475 | const char *peer_status; | |
15476 | const char *af_str; | |
15477 | int lr_count; | |
15478 | int dynamic; | |
15479 | int af_cfgd; | |
15480 | ||
15481 | conf = group->conf; | |
15482 | ||
15483 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 15484 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15485 | group->name, conf->as); |
d62a17ae | 15486 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 15487 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 15488 | group->name, group->bgp->as); |
d62a17ae | 15489 | } else { |
15490 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
15491 | } | |
f14e6fdb | 15492 | |
d62a17ae | 15493 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
15494 | vty_out(vty, " Peer-group type is internal\n"); | |
15495 | else | |
15496 | vty_out(vty, " Peer-group type is external\n"); | |
15497 | ||
15498 | /* Display AFs configured. */ | |
15499 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
15500 | FOREACH_AFI_SAFI (afi, safi) { |
15501 | if (conf->afc[afi][safi]) { | |
15502 | af_cfgd = 1; | |
5cb5f4d0 | 15503 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 15504 | } |
05c7a1cc | 15505 | } |
d62a17ae | 15506 | if (!af_cfgd) |
15507 | vty_out(vty, " none\n"); | |
15508 | else | |
15509 | vty_out(vty, "\n"); | |
15510 | ||
15511 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15512 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
15513 | if (afi == AFI_IP) | |
15514 | af_str = "IPv4"; | |
15515 | else if (afi == AFI_IP6) | |
15516 | af_str = "IPv6"; | |
15517 | else | |
15518 | af_str = "???"; | |
15519 | lr_count = listcount(group->listen_range[afi]); | |
15520 | if (lr_count) { | |
15521 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
15522 | af_str); | |
15523 | ||
15524 | ||
15525 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
2dbe669b DA |
15526 | nnode, range)) |
15527 | vty_out(vty, " %pFX\n", range); | |
d62a17ae | 15528 | } |
15529 | } | |
f14e6fdb | 15530 | |
d62a17ae | 15531 | /* Display group members and their status */ |
15532 | if (listcount(group->peer)) { | |
15533 | vty_out(vty, " Peer-group members:\n"); | |
15534 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
15535 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15536 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15537 | peer_status = "Idle (Admin)"; |
15538 | else if (CHECK_FLAG(peer->sflags, | |
15539 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15540 | peer_status = "Idle (PfxCt)"; | |
15541 | else | |
15542 | peer_status = lookup_msg(bgp_status_msg, | |
15543 | peer->status, NULL); | |
15544 | ||
15545 | dynamic = peer_dynamic_neighbor(peer); | |
15546 | vty_out(vty, " %s %s %s \n", peer->host, | |
15547 | dynamic ? "(dynamic)" : "", peer_status); | |
15548 | } | |
15549 | } | |
f14e6fdb | 15550 | |
d62a17ae | 15551 | return CMD_SUCCESS; |
15552 | } | |
15553 | ||
ff9959b0 QY |
15554 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
15555 | const char *group_name) | |
d62a17ae | 15556 | { |
ff9959b0 | 15557 | struct bgp *bgp; |
d62a17ae | 15558 | struct listnode *node, *nnode; |
15559 | struct peer_group *group; | |
ff9959b0 QY |
15560 | bool found = false; |
15561 | ||
15562 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15563 | ||
15564 | if (!bgp) { | |
9f049418 | 15565 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
15566 | return CMD_WARNING; |
15567 | } | |
d62a17ae | 15568 | |
15569 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15570 | if (group_name) { |
15571 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 15572 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
15573 | found = true; |
15574 | break; | |
d62a17ae | 15575 | } |
ff9959b0 QY |
15576 | } else { |
15577 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 15578 | } |
f14e6fdb | 15579 | } |
f14e6fdb | 15580 | |
ff9959b0 | 15581 | if (group_name && !found) |
d62a17ae | 15582 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15583 | |
d62a17ae | 15584 | return CMD_SUCCESS; |
f14e6fdb DS |
15585 | } |
15586 | ||
f14e6fdb DS |
15587 | DEFUN (show_ip_bgp_peer_groups, |
15588 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 15589 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
15590 | SHOW_STR |
15591 | IP_STR | |
15592 | BGP_STR | |
8386ac43 | 15593 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
15594 | "Detailed information on BGP peer groups\n" |
15595 | "Peer group name\n") | |
f14e6fdb | 15596 | { |
d62a17ae | 15597 | char *vrf, *pg; |
d62a17ae | 15598 | int idx = 0; |
f14e6fdb | 15599 | |
a4d82a8a PZ |
15600 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15601 | : NULL; | |
d62a17ae | 15602 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15603 | |
ff9959b0 | 15604 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 15605 | } |
3f9c7369 | 15606 | |
d6e3c605 | 15607 | |
718e3744 | 15608 | /* Redistribute VTY commands. */ |
15609 | ||
37a87b8f CS |
15610 | DEFUN_YANG (bgp_redistribute_ipv4, |
15611 | bgp_redistribute_ipv4_cmd, | |
15612 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15613 | "Redistribute information from another routing protocol\n" | |
15614 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15615 | { |
d62a17ae | 15616 | int idx_protocol = 1; |
37a87b8f | 15617 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 15618 | |
37a87b8f CS |
15619 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15620 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15621 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15622 | argv[idx_protocol]->text, "0"); | |
15623 | ||
15624 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
7f323236 | 15625 | |
37a87b8f | 15626 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 15627 | } |
15628 | ||
d62a17ae | 15629 | ALIAS_HIDDEN( |
15630 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15631 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15632 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15633 | |
37a87b8f CS |
15634 | DEFUN_YANG (bgp_redistribute_ipv4_rmap, |
15635 | bgp_redistribute_ipv4_rmap_cmd, | |
15636 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15637 | "Redistribute information from another routing protocol\n" | |
15638 | FRR_IP_REDIST_HELP_STR_BGPD | |
15639 | "Route map reference\n" | |
15640 | "Pointer to route-map entries\n") | |
718e3744 | 15641 | { |
d62a17ae | 15642 | int idx_protocol = 1; |
15643 | int idx_word = 3; | |
37a87b8f CS |
15644 | char base_xpath[XPATH_MAXLEN]; |
15645 | ||
15646 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15647 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15648 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15649 | argv[idx_protocol]->text, "0"); | |
718e3744 | 15650 | |
37a87b8f CS |
15651 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15652 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15653 | argv[idx_word]->arg); | |
15654 | ||
15655 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 15656 | } |
15657 | ||
d62a17ae | 15658 | ALIAS_HIDDEN( |
15659 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15660 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15661 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15662 | "Route map reference\n" | |
15663 | "Pointer to route-map entries\n") | |
596c17ba | 15664 | |
37a87b8f CS |
15665 | DEFUN_YANG (bgp_redistribute_ipv4_metric, |
15666 | bgp_redistribute_ipv4_metric_cmd, | |
15667 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15668 | "Redistribute information from another routing protocol\n" | |
15669 | FRR_IP_REDIST_HELP_STR_BGPD | |
15670 | "Metric for redistributed routes\n" | |
15671 | "Default metric\n") | |
718e3744 | 15672 | { |
d62a17ae | 15673 | int idx_protocol = 1; |
15674 | int idx_number = 3; | |
37a87b8f CS |
15675 | char base_xpath[XPATH_MAXLEN]; |
15676 | ||
15677 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15678 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15679 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15680 | argv[idx_protocol]->text, "0"); | |
d62a17ae | 15681 | |
37a87b8f CS |
15682 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
15683 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15684 | argv[idx_number]->arg); | |
15685 | ||
15686 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 15687 | } |
15688 | ||
15689 | ALIAS_HIDDEN( | |
15690 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15691 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15692 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15693 | "Metric for redistributed routes\n" | |
15694 | "Default metric\n") | |
596c17ba | 15695 | |
37a87b8f CS |
15696 | DEFUN_YANG( |
15697 | bgp_redistribute_ipv4_rmap_metric, | |
15698 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15699 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15700 | " route-map WORD metric (0-4294967295)", | |
15701 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15702 | "Route map reference\n" | |
15703 | "Pointer to route-map entries\n" | |
15704 | "Metric for redistributed routes\n" | |
15705 | "Default metric\n") | |
718e3744 | 15706 | { |
d62a17ae | 15707 | int idx_protocol = 1; |
15708 | int idx_word = 3; | |
15709 | int idx_number = 5; | |
37a87b8f CS |
15710 | char base_xpath[XPATH_MAXLEN]; |
15711 | ||
15712 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15713 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15714 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15715 | argv[idx_protocol]->text, "0"); | |
15716 | ||
15717 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15718 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15719 | argv[idx_word]->arg); | |
15720 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15721 | argv[idx_number]->arg); | |
d62a17ae | 15722 | |
37a87b8f | 15723 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15724 | } |
15725 | ||
15726 | ALIAS_HIDDEN( | |
15727 | bgp_redistribute_ipv4_rmap_metric, | |
15728 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15729 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15730 | " route-map WORD metric (0-4294967295)", | |
15731 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15732 | "Route map reference\n" | |
15733 | "Pointer to route-map entries\n" | |
15734 | "Metric for redistributed routes\n" | |
15735 | "Default metric\n") | |
596c17ba | 15736 | |
37a87b8f CS |
15737 | DEFUN_YANG( |
15738 | bgp_redistribute_ipv4_metric_rmap, | |
15739 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15740 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15741 | " metric (0-4294967295) route-map WORD", | |
15742 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15743 | "Metric for redistributed routes\n" | |
15744 | "Default metric\n" | |
15745 | "Route map reference\n" | |
15746 | "Pointer to route-map entries\n") | |
718e3744 | 15747 | { |
d62a17ae | 15748 | int idx_protocol = 1; |
d62a17ae | 15749 | int idx_word = 5; |
37a87b8f CS |
15750 | int idx_number = 3; |
15751 | char base_xpath[XPATH_MAXLEN]; | |
15752 | ||
15753 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15754 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15755 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15756 | argv[idx_protocol]->text, "0"); | |
15757 | ||
15758 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15759 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15760 | argv[idx_number]->arg); | |
15761 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15762 | argv[idx_word]->arg); | |
d62a17ae | 15763 | |
37a87b8f | 15764 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15765 | } |
15766 | ||
15767 | ALIAS_HIDDEN( | |
15768 | bgp_redistribute_ipv4_metric_rmap, | |
15769 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15770 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15771 | " metric (0-4294967295) route-map WORD", | |
15772 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15773 | "Metric for redistributed routes\n" | |
15774 | "Default metric\n" | |
15775 | "Route map reference\n" | |
15776 | "Pointer to route-map entries\n") | |
596c17ba | 15777 | |
37a87b8f CS |
15778 | DEFUN_YANG (bgp_redistribute_ipv4_ospf, |
15779 | bgp_redistribute_ipv4_ospf_cmd, | |
15780 | "redistribute <ospf|table> (1-65535)", | |
15781 | "Redistribute information from another routing protocol\n" | |
15782 | "Open Shortest Path First (OSPFv2)\n" | |
15783 | "Non-main Kernel Routing Table\n" | |
15784 | "Instance ID/Table ID\n") | |
7c8ff89e | 15785 | { |
37a87b8f | 15786 | int idx_protocol = 1; |
d62a17ae | 15787 | int idx_number = 2; |
37a87b8f | 15788 | char base_xpath[XPATH_MAXLEN]; |
7c8ff89e | 15789 | |
37a87b8f CS |
15790 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15791 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15792 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15793 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
7a4bb9c5 | 15794 | |
37a87b8f | 15795 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
7a4bb9c5 | 15796 | |
37a87b8f | 15797 | return nb_cli_apply_changes(vty, base_xpath); |
7c8ff89e DS |
15798 | } |
15799 | ||
d62a17ae | 15800 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15801 | "redistribute <ospf|table> (1-65535)", | |
15802 | "Redistribute information from another routing protocol\n" | |
15803 | "Open Shortest Path First (OSPFv2)\n" | |
15804 | "Non-main Kernel Routing Table\n" | |
15805 | "Instance ID/Table ID\n") | |
596c17ba | 15806 | |
37a87b8f CS |
15807 | DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap, |
15808 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15809 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15810 | "Redistribute information from another routing protocol\n" | |
15811 | "Open Shortest Path First (OSPFv2)\n" | |
15812 | "Non-main Kernel Routing Table\n" | |
15813 | "Instance ID/Table ID\n" | |
15814 | "Route map reference\n" | |
15815 | "Pointer to route-map entries\n") | |
7c8ff89e | 15816 | { |
37a87b8f | 15817 | int idx_protocol = 1; |
d62a17ae | 15818 | int idx_number = 2; |
15819 | int idx_word = 4; | |
37a87b8f CS |
15820 | char base_xpath[XPATH_MAXLEN]; |
15821 | ||
15822 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15823 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15824 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15825 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15826 | ||
15827 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
15828 | ||
15829 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15830 | argv[idx_word]->arg); | |
d62a17ae | 15831 | |
37a87b8f | 15832 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15833 | } |
15834 | ||
15835 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15836 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15837 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15838 | "Redistribute information from another routing protocol\n" | |
15839 | "Open Shortest Path First (OSPFv2)\n" | |
15840 | "Non-main Kernel Routing Table\n" | |
15841 | "Instance ID/Table ID\n" | |
15842 | "Route map reference\n" | |
15843 | "Pointer to route-map entries\n") | |
596c17ba | 15844 | |
37a87b8f CS |
15845 | DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric, |
15846 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15847 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15848 | "Redistribute information from another routing protocol\n" | |
15849 | "Open Shortest Path First (OSPFv2)\n" | |
15850 | "Non-main Kernel Routing Table\n" | |
15851 | "Instance ID/Table ID\n" | |
15852 | "Metric for redistributed routes\n" | |
15853 | "Default metric\n") | |
7c8ff89e | 15854 | { |
37a87b8f | 15855 | int idx_protocol = 1; |
d62a17ae | 15856 | int idx_number = 2; |
15857 | int idx_number_2 = 4; | |
37a87b8f CS |
15858 | char base_xpath[XPATH_MAXLEN]; |
15859 | ||
15860 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15861 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15862 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15863 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15864 | ||
15865 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15866 | |
37a87b8f CS |
15867 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15868 | argv[idx_number_2]->arg); | |
d62a17ae | 15869 | |
37a87b8f | 15870 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15871 | } |
15872 | ||
15873 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15874 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15875 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15876 | "Redistribute information from another routing protocol\n" | |
15877 | "Open Shortest Path First (OSPFv2)\n" | |
15878 | "Non-main Kernel Routing Table\n" | |
15879 | "Instance ID/Table ID\n" | |
15880 | "Metric for redistributed routes\n" | |
15881 | "Default metric\n") | |
596c17ba | 15882 | |
37a87b8f CS |
15883 | DEFUN_YANG( |
15884 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15885 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15886 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15887 | "Redistribute information from another routing protocol\n" | |
15888 | "Open Shortest Path First (OSPFv2)\n" | |
15889 | "Non-main Kernel Routing Table\n" | |
15890 | "Instance ID/Table ID\n" | |
15891 | "Route map reference\n" | |
15892 | "Pointer to route-map entries\n" | |
15893 | "Metric for redistributed routes\n" | |
15894 | "Default metric\n") | |
7c8ff89e | 15895 | { |
37a87b8f | 15896 | int idx_protocol = 1; |
d62a17ae | 15897 | int idx_number = 2; |
15898 | int idx_word = 4; | |
15899 | int idx_number_2 = 6; | |
37a87b8f CS |
15900 | char base_xpath[XPATH_MAXLEN]; |
15901 | ||
15902 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15903 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15904 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15905 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15906 | ||
15907 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15908 | |
37a87b8f CS |
15909 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, |
15910 | argv[idx_word]->arg); | |
15911 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
15912 | argv[idx_number_2]->arg); | |
d62a17ae | 15913 | |
37a87b8f | 15914 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15915 | } |
15916 | ||
15917 | ALIAS_HIDDEN( | |
15918 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15919 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15920 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15921 | "Redistribute information from another routing protocol\n" | |
15922 | "Open Shortest Path First (OSPFv2)\n" | |
15923 | "Non-main Kernel Routing Table\n" | |
15924 | "Instance ID/Table ID\n" | |
15925 | "Route map reference\n" | |
15926 | "Pointer to route-map entries\n" | |
15927 | "Metric for redistributed routes\n" | |
15928 | "Default metric\n") | |
596c17ba | 15929 | |
37a87b8f CS |
15930 | DEFUN_YANG( |
15931 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15932 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15933 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15934 | "Redistribute information from another routing protocol\n" | |
15935 | "Open Shortest Path First (OSPFv2)\n" | |
15936 | "Non-main Kernel Routing Table\n" | |
15937 | "Instance ID/Table ID\n" | |
15938 | "Metric for redistributed routes\n" | |
15939 | "Default metric\n" | |
15940 | "Route map reference\n" | |
15941 | "Pointer to route-map entries\n") | |
7c8ff89e | 15942 | { |
37a87b8f | 15943 | int idx_protocol = 1; |
d62a17ae | 15944 | int idx_number = 2; |
15945 | int idx_number_2 = 4; | |
15946 | int idx_word = 6; | |
37a87b8f CS |
15947 | char base_xpath[XPATH_MAXLEN]; |
15948 | ||
15949 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
15950 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15951 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15952 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15953 | ||
15954 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 15955 | |
37a87b8f CS |
15956 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
15957 | argv[idx_number_2]->arg); | |
15958 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
15959 | argv[idx_word]->arg); | |
d62a17ae | 15960 | |
37a87b8f | 15961 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 15962 | } |
15963 | ||
15964 | ALIAS_HIDDEN( | |
15965 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15966 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15967 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15968 | "Redistribute information from another routing protocol\n" | |
15969 | "Open Shortest Path First (OSPFv2)\n" | |
15970 | "Non-main Kernel Routing Table\n" | |
15971 | "Instance ID/Table ID\n" | |
15972 | "Metric for redistributed routes\n" | |
15973 | "Default metric\n" | |
15974 | "Route map reference\n" | |
15975 | "Pointer to route-map entries\n") | |
596c17ba | 15976 | |
37a87b8f CS |
15977 | DEFUN_YANG (no_bgp_redistribute_ipv4_ospf, |
15978 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15979 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15980 | NO_STR | |
15981 | "Redistribute information from another routing protocol\n" | |
15982 | "Open Shortest Path First (OSPFv2)\n" | |
15983 | "Non-main Kernel Routing Table\n" | |
15984 | "Instance ID/Table ID\n" | |
15985 | "Metric for redistributed routes\n" | |
15986 | "Default metric\n" | |
15987 | "Route map reference\n" | |
15988 | "Pointer to route-map entries\n") | |
7c8ff89e | 15989 | { |
37a87b8f | 15990 | int idx_protocol = 2; |
d62a17ae | 15991 | int idx_number = 3; |
37a87b8f | 15992 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 15993 | |
37a87b8f CS |
15994 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
15995 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
15996 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
15997 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
15998 | ||
15999 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
d62a17ae | 16000 | |
37a87b8f | 16001 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16002 | } |
16003 | ||
16004 | ALIAS_HIDDEN( | |
16005 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 16006 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 16007 | NO_STR |
16008 | "Redistribute information from another routing protocol\n" | |
16009 | "Open Shortest Path First (OSPFv2)\n" | |
16010 | "Non-main Kernel Routing Table\n" | |
16011 | "Instance ID/Table ID\n" | |
16012 | "Metric for redistributed routes\n" | |
16013 | "Default metric\n" | |
16014 | "Route map reference\n" | |
16015 | "Pointer to route-map entries\n") | |
596c17ba | 16016 | |
37a87b8f CS |
16017 | DEFUN_YANG (no_bgp_redistribute_ipv4, |
16018 | no_bgp_redistribute_ipv4_cmd, | |
16019 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
16020 | NO_STR | |
16021 | "Redistribute information from another routing protocol\n" | |
16022 | FRR_IP_REDIST_HELP_STR_BGPD | |
16023 | "Metric for redistributed routes\n" | |
16024 | "Default metric\n" | |
16025 | "Route map reference\n" | |
16026 | "Pointer to route-map entries\n") | |
718e3744 | 16027 | { |
d62a17ae | 16028 | int idx_protocol = 2; |
37a87b8f | 16029 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 16030 | |
37a87b8f CS |
16031 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16032 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16033 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16034 | argv[idx_protocol]->text, "0"); | |
16035 | ||
16036 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
16037 | ||
16038 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 16039 | } |
16040 | ||
16041 | ALIAS_HIDDEN( | |
16042 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
16043 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 16044 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 16045 | NO_STR |
16046 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16047 | "Metric for redistributed routes\n" | |
16048 | "Default metric\n" | |
16049 | "Route map reference\n" | |
16050 | "Pointer to route-map entries\n") | |
596c17ba | 16051 | |
37a87b8f CS |
16052 | DEFUN_YANG (bgp_redistribute_ipv6, |
16053 | bgp_redistribute_ipv6_cmd, | |
16054 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
16055 | "Redistribute information from another routing protocol\n" | |
16056 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 16057 | { |
d62a17ae | 16058 | int idx_protocol = 1; |
37a87b8f | 16059 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 16060 | |
37a87b8f CS |
16061 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16062 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16063 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16064 | argv[idx_protocol]->text, "0"); | |
16065 | ||
16066 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
718e3744 | 16067 | |
37a87b8f | 16068 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 16069 | } |
16070 | ||
37a87b8f CS |
16071 | DEFUN_YANG (bgp_redistribute_ipv6_rmap, |
16072 | bgp_redistribute_ipv6_rmap_cmd, | |
16073 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
16074 | "Redistribute information from another routing protocol\n" | |
16075 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16076 | "Route map reference\n" | |
16077 | "Pointer to route-map entries\n") | |
718e3744 | 16078 | { |
d62a17ae | 16079 | int idx_protocol = 1; |
16080 | int idx_word = 3; | |
37a87b8f CS |
16081 | char base_xpath[XPATH_MAXLEN]; |
16082 | ||
16083 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16084 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16085 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16086 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16087 | |
37a87b8f CS |
16088 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16089 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16090 | argv[idx_word]->arg); | |
16091 | ||
16092 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16093 | } |
16094 | ||
37a87b8f | 16095 | DEFUN_YANG (bgp_redistribute_ipv6_metric, |
718e3744 | 16096 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16097 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16098 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16099 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16100 | "Metric for redistributed routes\n" |
16101 | "Default metric\n") | |
16102 | { | |
d62a17ae | 16103 | int idx_protocol = 1; |
16104 | int idx_number = 3; | |
37a87b8f CS |
16105 | char base_xpath[XPATH_MAXLEN]; |
16106 | ||
16107 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16108 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16109 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16110 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16111 | |
37a87b8f CS |
16112 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16113 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16114 | argv[idx_number]->arg); | |
16115 | ||
16116 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16117 | } |
16118 | ||
37a87b8f CS |
16119 | DEFUN_YANG( |
16120 | bgp_redistribute_ipv6_rmap_metric, | |
16121 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
16122 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
16123 | " route-map WORD metric (0-4294967295)", | |
16124 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
16125 | "Route map reference\n" | |
16126 | "Pointer to route-map entries\n" | |
16127 | "Metric for redistributed routes\n" | |
16128 | "Default metric\n") | |
718e3744 | 16129 | { |
d62a17ae | 16130 | int idx_protocol = 1; |
16131 | int idx_word = 3; | |
16132 | int idx_number = 5; | |
37a87b8f CS |
16133 | char base_xpath[XPATH_MAXLEN]; |
16134 | ||
16135 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16136 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16137 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16138 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16139 | |
37a87b8f CS |
16140 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16141 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16142 | argv[idx_word]->arg); | |
16143 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16144 | argv[idx_number]->arg); | |
16145 | ||
16146 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16147 | } |
16148 | ||
37a87b8f CS |
16149 | DEFUN_YANG( |
16150 | bgp_redistribute_ipv6_metric_rmap, | |
16151 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
16152 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
16153 | " metric (0-4294967295) route-map WORD", | |
16154 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
16155 | "Metric for redistributed routes\n" | |
16156 | "Default metric\n" | |
16157 | "Route map reference\n" | |
16158 | "Pointer to route-map entries\n") | |
718e3744 | 16159 | { |
d62a17ae | 16160 | int idx_protocol = 1; |
d62a17ae | 16161 | int idx_word = 5; |
37a87b8f CS |
16162 | int idx_number = 3; |
16163 | char base_xpath[XPATH_MAXLEN]; | |
16164 | ||
16165 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16166 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16167 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16168 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16169 | |
37a87b8f CS |
16170 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16171 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16172 | argv[idx_number]->arg); | |
16173 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16174 | argv[idx_word]->arg); | |
16175 | ||
16176 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16177 | } |
16178 | ||
37a87b8f CS |
16179 | DEFUN_YANG( |
16180 | no_bgp_redistribute_ipv6, | |
16181 | no_bgp_redistribute_ipv6_cmd, | |
16182 | "no redistribute " FRR_IP6_REDIST_STR_BGPD | |
16183 | " [{metric (0-4294967295)|route-map WORD}]", | |
16184 | NO_STR | |
16185 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
16186 | "Metric for redistributed routes\n" | |
16187 | "Default metric\n" | |
16188 | "Route map reference\n" | |
16189 | "Pointer to route-map entries\n") | |
718e3744 | 16190 | { |
d62a17ae | 16191 | int idx_protocol = 2; |
37a87b8f | 16192 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 16193 | |
37a87b8f CS |
16194 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16195 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16196 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16197 | argv[idx_protocol]->text, "0"); | |
16198 | ||
16199 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
16200 | ||
16201 | return nb_cli_apply_changes(vty, base_xpath); | |
16202 | } | |
718e3744 | 16203 | |
37a87b8f CS |
16204 | void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list( |
16205 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
16206 | { | |
16207 | uint32_t instance = 0; | |
16208 | ||
16209 | vty_out(vty, " redistribute %s", | |
16210 | yang_dnode_get_string(dnode, "./route-type")); | |
16211 | if ((instance = yang_dnode_get_uint16(dnode, "./route-instance"))) | |
16212 | vty_out(vty, " %d", instance); | |
16213 | if (yang_dnode_exists(dnode, "./metric")) | |
16214 | vty_out(vty, " metric %u", | |
16215 | yang_dnode_get_uint32(dnode, "./metric")); | |
16216 | if (yang_dnode_exists(dnode, "./rmap-policy-import")) | |
16217 | vty_out(vty, " route-map %s", | |
16218 | yang_dnode_get_string(dnode, "./rmap-policy-import")); | |
16219 | vty_out(vty, "\n"); | |
d62a17ae | 16220 | } |
16221 | ||
dd65f45e DL |
16222 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16223 | afi_t afi, safi_t safi) | |
d62a17ae | 16224 | { |
16225 | int i; | |
16226 | ||
16227 | /* Unicast redistribution only. */ | |
16228 | if (safi != SAFI_UNICAST) | |
2b791107 | 16229 | return; |
d62a17ae | 16230 | |
16231 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16232 | /* Redistribute BGP does not make sense. */ | |
16233 | if (i != ZEBRA_ROUTE_BGP) { | |
16234 | struct list *red_list; | |
16235 | struct listnode *node; | |
16236 | struct bgp_redist *red; | |
16237 | ||
16238 | red_list = bgp->redist[afi][i]; | |
16239 | if (!red_list) | |
16240 | continue; | |
16241 | ||
16242 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16243 | /* "redistribute" configuration. */ |
16244 | vty_out(vty, " redistribute %s", | |
16245 | zebra_route_string(i)); | |
16246 | if (red->instance) | |
16247 | vty_out(vty, " %d", red->instance); | |
16248 | if (red->redist_metric_flag) | |
16249 | vty_out(vty, " metric %u", | |
16250 | red->redist_metric); | |
16251 | if (red->rmap.name) | |
16252 | vty_out(vty, " route-map %s", | |
16253 | red->rmap.name); | |
16254 | vty_out(vty, "\n"); | |
16255 | } | |
16256 | } | |
16257 | } | |
718e3744 | 16258 | } |
6b0655a2 | 16259 | |
dd65f45e DL |
16260 | /* peer-group helpers for config-write */ |
16261 | ||
16262 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16263 | { | |
16264 | if (!peer_group_active(peer)) { | |
16265 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16266 | return !CHECK_FLAG(peer->flags, flag); | |
16267 | else | |
16268 | return !!CHECK_FLAG(peer->flags, flag); | |
16269 | } | |
16270 | ||
16271 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16272 | } | |
16273 | ||
16274 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16275 | uint32_t flag) | |
16276 | { | |
16277 | if (!peer_group_active(peer)) { | |
16278 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16279 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16280 | else | |
16281 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16282 | } | |
16283 | ||
16284 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16285 | } | |
16286 | ||
16287 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16288 | uint8_t type, int direct) | |
16289 | { | |
16290 | struct bgp_filter *filter; | |
16291 | ||
16292 | if (peer_group_active(peer)) | |
16293 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16294 | type); | |
16295 | ||
16296 | filter = &peer->filter[afi][safi]; | |
16297 | switch (type) { | |
16298 | case PEER_FT_DISTRIBUTE_LIST: | |
16299 | return !!(filter->dlist[direct].name); | |
16300 | case PEER_FT_FILTER_LIST: | |
16301 | return !!(filter->aslist[direct].name); | |
16302 | case PEER_FT_PREFIX_LIST: | |
16303 | return !!(filter->plist[direct].name); | |
16304 | case PEER_FT_ROUTE_MAP: | |
16305 | return !!(filter->map[direct].name); | |
16306 | case PEER_FT_UNSUPPRESS_MAP: | |
16307 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16308 | case PEER_FT_ADVERTISE_MAP: |
16309 | return !!(filter->advmap.aname | |
16310 | && ((filter->advmap.condition == direct) | |
16311 | && filter->advmap.cname)); | |
dd65f45e DL |
16312 | default: |
16313 | return false; | |
16314 | } | |
16315 | } | |
16316 | ||
16317 | /* Return true if the addpath type is set for peer and different from | |
16318 | * peer-group. | |
16319 | */ | |
3dc339cd DA |
16320 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16321 | safi_t safi) | |
dd65f45e DL |
16322 | { |
16323 | enum bgp_addpath_strat type, g_type; | |
16324 | ||
16325 | type = peer->addpath_type[afi][safi]; | |
16326 | ||
16327 | if (type != BGP_ADDPATH_NONE) { | |
16328 | if (peer_group_active(peer)) { | |
16329 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16330 | ||
16331 | if (type != g_type) | |
3dc339cd | 16332 | return true; |
dd65f45e | 16333 | else |
3dc339cd | 16334 | return false; |
dd65f45e DL |
16335 | } |
16336 | ||
3dc339cd | 16337 | return true; |
dd65f45e DL |
16338 | } |
16339 | ||
3dc339cd | 16340 | return false; |
dd65f45e DL |
16341 | } |
16342 | ||
b9c7bc5a | 16343 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16344 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16345 | afi_t afi) |
16346 | { | |
b9c7bc5a | 16347 | int indent = 2; |
ddb5b488 | 16348 | |
8a066a70 | 16349 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16350 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16351 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16352 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16353 | bgp->vpn_policy[afi] | |
bb4f6190 | 16354 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16355 | else |
16356 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16357 | bgp->vpn_policy[afi] | |
16358 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16359 | } | |
12a844a5 DS |
16360 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16361 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16362 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16363 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16364 | return; | |
16365 | ||
e70e9f8e PZ |
16366 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16367 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16368 | ||
16369 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16370 | ||
16371 | } else { | |
16372 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16373 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16374 | bgp->vpn_policy[afi].tovpn_label); | |
16375 | } | |
ddb5b488 PZ |
16376 | } |
16377 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16378 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16379 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16380 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16381 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16382 | sizeof(buf))); | |
16383 | } | |
16384 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16385 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16386 | ||
16387 | char buf[PREFIX_STRLEN]; | |
16388 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16389 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16390 | sizeof(buf))) { | |
16391 | ||
b9c7bc5a PZ |
16392 | vty_out(vty, "%*snexthop vpn export %s\n", |
16393 | indent, "", buf); | |
ddb5b488 PZ |
16394 | } |
16395 | } | |
16396 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16397 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16398 | && ecommunity_cmp( | |
16399 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16400 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16401 | ||
16402 | char *b = ecommunity_ecom2str( | |
16403 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16404 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16405 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16406 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16407 | } else { | |
16408 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16409 | char *b = ecommunity_ecom2str( | |
16410 | bgp->vpn_policy[afi] | |
16411 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16412 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16413 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16414 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16415 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16416 | } | |
16417 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16418 | char *b = ecommunity_ecom2str( | |
16419 | bgp->vpn_policy[afi] | |
16420 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16421 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16422 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16423 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16424 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16425 | } | |
16426 | } | |
bb4f6190 DS |
16427 | |
16428 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16429 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16430 | bgp->vpn_policy[afi] |
16431 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16432 | |
301ad80a PG |
16433 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16434 | char *b = ecommunity_ecom2str( | |
16435 | bgp->vpn_policy[afi] | |
16436 | .import_redirect_rtlist, | |
16437 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16438 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16439 | |
9a659715 PG |
16440 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16441 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16442 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16443 | indent, "", b); |
16444 | else | |
16445 | vty_out(vty, "%*srt redirect import %s\n", | |
16446 | indent, "", b); | |
301ad80a PG |
16447 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16448 | } | |
ddb5b488 PZ |
16449 | } |
16450 | ||
dd65f45e DL |
16451 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16452 | afi_t afi, safi_t safi) | |
16453 | { | |
16454 | struct bgp_filter *filter; | |
16455 | char *addr; | |
16456 | ||
16457 | addr = peer->host; | |
16458 | filter = &peer->filter[afi][safi]; | |
16459 | ||
16460 | /* distribute-list. */ | |
16461 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16462 | FILTER_IN)) | |
16463 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16464 | filter->dlist[FILTER_IN].name); | |
16465 | ||
16466 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16467 | FILTER_OUT)) | |
16468 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16469 | filter->dlist[FILTER_OUT].name); | |
16470 | ||
16471 | /* prefix-list. */ | |
16472 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16473 | FILTER_IN)) | |
16474 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16475 | filter->plist[FILTER_IN].name); | |
16476 | ||
16477 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16478 | FILTER_OUT)) | |
16479 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16480 | filter->plist[FILTER_OUT].name); | |
16481 | ||
16482 | /* route-map. */ | |
16483 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16484 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16485 | filter->map[RMAP_IN].name); | |
16486 | ||
16487 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16488 | RMAP_OUT)) | |
16489 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16490 | filter->map[RMAP_OUT].name); | |
16491 | ||
16492 | /* unsuppress-map */ | |
16493 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16494 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16495 | filter->usmap.name); | |
16496 | ||
7f7940e6 MK |
16497 | /* advertise-map : always applied in OUT direction*/ |
16498 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16499 | CONDITION_NON_EXIST)) | |
16500 | vty_out(vty, | |
16501 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16502 | addr, filter->advmap.aname, filter->advmap.cname); | |
16503 | ||
16504 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16505 | CONDITION_EXIST)) | |
16506 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16507 | addr, filter->advmap.aname, filter->advmap.cname); | |
16508 | ||
dd65f45e DL |
16509 | /* filter-list. */ |
16510 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16511 | FILTER_IN)) | |
16512 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16513 | filter->aslist[FILTER_IN].name); | |
16514 | ||
16515 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16516 | FILTER_OUT)) | |
16517 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16518 | filter->aslist[FILTER_OUT].name); | |
16519 | } | |
16520 | ||
16521 | /* BGP peer configuration display function. */ | |
16522 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16523 | struct peer *peer) | |
16524 | { | |
16525 | struct peer *g_peer = NULL; | |
16526 | char buf[SU_ADDRSTRLEN]; | |
16527 | char *addr; | |
16528 | int if_pg_printed = false; | |
16529 | int if_ras_printed = false; | |
16530 | ||
16531 | /* Skip dynamic neighbors. */ | |
16532 | if (peer_dynamic_neighbor(peer)) | |
16533 | return; | |
16534 | ||
16535 | if (peer->conf_if) | |
16536 | addr = peer->conf_if; | |
16537 | else | |
16538 | addr = peer->host; | |
16539 | ||
16540 | /************************************ | |
16541 | ****** Global to the neighbor ****** | |
16542 | ************************************/ | |
16543 | if (peer->conf_if) { | |
16544 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16545 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16546 | else | |
16547 | vty_out(vty, " neighbor %s interface", addr); | |
16548 | ||
16549 | if (peer_group_active(peer)) { | |
16550 | vty_out(vty, " peer-group %s", peer->group->name); | |
16551 | if_pg_printed = true; | |
16552 | } else if (peer->as_type == AS_SPECIFIED) { | |
16553 | vty_out(vty, " remote-as %u", peer->as); | |
16554 | if_ras_printed = true; | |
16555 | } else if (peer->as_type == AS_INTERNAL) { | |
16556 | vty_out(vty, " remote-as internal"); | |
16557 | if_ras_printed = true; | |
16558 | } else if (peer->as_type == AS_EXTERNAL) { | |
16559 | vty_out(vty, " remote-as external"); | |
16560 | if_ras_printed = true; | |
16561 | } | |
16562 | ||
16563 | vty_out(vty, "\n"); | |
16564 | } | |
16565 | ||
16566 | /* remote-as and peer-group */ | |
16567 | /* peer is a member of a peer-group */ | |
16568 | if (peer_group_active(peer)) { | |
16569 | g_peer = peer->group->conf; | |
16570 | ||
16571 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16572 | if (peer->as_type == AS_SPECIFIED) { | |
16573 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16574 | addr, peer->as); | |
16575 | } else if (peer->as_type == AS_INTERNAL) { | |
16576 | vty_out(vty, | |
16577 | " neighbor %s remote-as internal\n", | |
16578 | addr); | |
16579 | } else if (peer->as_type == AS_EXTERNAL) { | |
16580 | vty_out(vty, | |
16581 | " neighbor %s remote-as external\n", | |
16582 | addr); | |
16583 | } | |
16584 | } | |
16585 | ||
16586 | /* For swpX peers we displayed the peer-group | |
16587 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16588 | if (!if_pg_printed) | |
16589 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16590 | peer->group->name); | |
16591 | } | |
16592 | ||
16593 | /* peer is NOT a member of a peer-group */ | |
16594 | else { | |
16595 | /* peer is a peer-group, declare the peer-group */ | |
16596 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16597 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16598 | } | |
16599 | ||
16600 | if (!if_ras_printed) { | |
16601 | if (peer->as_type == AS_SPECIFIED) { | |
16602 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16603 | addr, peer->as); | |
16604 | } else if (peer->as_type == AS_INTERNAL) { | |
16605 | vty_out(vty, | |
16606 | " neighbor %s remote-as internal\n", | |
16607 | addr); | |
16608 | } else if (peer->as_type == AS_EXTERNAL) { | |
16609 | vty_out(vty, | |
16610 | " neighbor %s remote-as external\n", | |
16611 | addr); | |
16612 | } | |
16613 | } | |
16614 | } | |
16615 | ||
16616 | /* local-as */ | |
16617 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16618 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16619 | peer->change_local_as); | |
16620 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16621 | vty_out(vty, " no-prepend"); | |
16622 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16623 | vty_out(vty, " replace-as"); | |
16624 | vty_out(vty, "\n"); | |
16625 | } | |
16626 | ||
16627 | /* description */ | |
16628 | if (peer->desc) { | |
16629 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16630 | } | |
16631 | ||
16632 | /* shutdown */ | |
16633 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16634 | if (peer->tx_shutdown_message) | |
16635 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16636 | peer->tx_shutdown_message); | |
16637 | else | |
16638 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16639 | } | |
16640 | ||
8336c896 DA |
16641 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16642 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16643 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16644 | ||
dd65f45e DL |
16645 | /* bfd */ |
16646 | if (peer->bfd_info) { | |
16647 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
16648 | bgp_bfd_peer_config_write(vty, peer, addr); | |
16649 | } | |
16650 | } | |
16651 | ||
16652 | /* password */ | |
16653 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16654 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16655 | peer->password); | |
16656 | ||
16657 | /* neighbor solo */ | |
16658 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16659 | if (!peer_group_active(peer)) { | |
16660 | vty_out(vty, " neighbor %s solo\n", addr); | |
16661 | } | |
16662 | } | |
16663 | ||
16664 | /* BGP port */ | |
16665 | if (peer->port != BGP_PORT_DEFAULT) { | |
16666 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16667 | } | |
16668 | ||
16669 | /* Local interface name */ | |
16670 | if (peer->ifname) { | |
16671 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16672 | } | |
16673 | ||
16674 | /* passive */ | |
16675 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16676 | vty_out(vty, " neighbor %s passive\n", addr); | |
16677 | ||
16678 | /* ebgp-multihop */ | |
16679 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16680 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16681 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16682 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16683 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16684 | peer->ttl); | |
16685 | } | |
16686 | } | |
16687 | ||
16688 | /* ttl-security hops */ | |
e2521429 | 16689 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16690 | if (!peer_group_active(peer) |
16691 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16692 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16693 | addr, peer->gtsm_hops); | |
16694 | } | |
16695 | } | |
16696 | ||
16697 | /* disable-connected-check */ | |
16698 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16699 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16700 | ||
16701 | /* enforce-first-as */ | |
16702 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16703 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16704 | ||
16705 | /* update-source */ | |
16706 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16707 | if (peer->update_source) | |
16708 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16709 | sockunion2str(peer->update_source, buf, | |
16710 | SU_ADDRSTRLEN)); | |
16711 | else if (peer->update_if) | |
16712 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16713 | peer->update_if); | |
16714 | } | |
16715 | ||
16716 | /* advertisement-interval */ | |
16717 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16718 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16719 | peer->routeadv); | |
16720 | ||
16721 | /* timers */ | |
16722 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16723 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16724 | peer->keepalive, peer->holdtime); | |
16725 | ||
16726 | /* timers connect */ | |
16727 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16728 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16729 | peer->connect); | |
5d5393b9 DL |
16730 | /* need special-case handling for changed default values due to |
16731 | * config profile / version (because there is no "timers bgp connect" | |
16732 | * command, we need to save this per-peer :/) | |
16733 | */ | |
16734 | else if (!peer_group_active(peer) && !peer->connect && | |
16735 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16736 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16737 | peer->bgp->default_connect_retry); | |
dd65f45e | 16738 | |
d43114f3 DS |
16739 | /* timers delayopen */ |
16740 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16741 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16742 | peer->delayopen); | |
16743 | /* Save config even though flag is not set if default values have been | |
16744 | * changed | |
16745 | */ | |
16746 | else if (!peer_group_active(peer) && !peer->delayopen | |
16747 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16748 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16749 | peer->bgp->default_delayopen); | |
16750 | ||
dd65f45e DL |
16751 | /* capability dynamic */ |
16752 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16753 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16754 | ||
16755 | /* capability extended-nexthop */ | |
16756 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16757 | if (!peer->conf_if) { | |
16758 | if (CHECK_FLAG(peer->flags_invert, | |
16759 | PEER_FLAG_CAPABILITY_ENHE)) | |
16760 | vty_out(vty, | |
16761 | " no neighbor %s capability extended-nexthop\n", | |
16762 | addr); | |
16763 | else | |
16764 | vty_out(vty, | |
16765 | " neighbor %s capability extended-nexthop\n", | |
16766 | addr); | |
16767 | } | |
16768 | } | |
16769 | ||
16770 | /* dont-capability-negotiation */ | |
16771 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16772 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16773 | ||
16774 | /* override-capability */ | |
16775 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16776 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16777 | ||
16778 | /* strict-capability-match */ | |
16779 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16780 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16781 | ||
16782 | /* Sender side AS path loop detection. */ | |
16783 | if (peer->as_path_loop_detection) | |
16784 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16785 | addr); | |
cfd47646 | 16786 | |
16787 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16788 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16789 | |
16790 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16791 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16792 | vty_out(vty, |
16793 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16794 | } else if (CHECK_FLAG( |
16795 | peer->peer_gr_new_status_flag, | |
16796 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16797 | vty_out(vty, |
16798 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16799 | } else if ( |
16800 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16801 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16802 | && !(CHECK_FLAG( | |
16803 | peer->peer_gr_new_status_flag, | |
16804 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16805 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16806 | addr); | |
cfd47646 | 16807 | } |
16808 | } | |
dd65f45e DL |
16809 | } |
16810 | ||
16811 | /* BGP peer configuration display function. */ | |
16812 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16813 | struct peer *peer, afi_t afi, safi_t safi) | |
16814 | { | |
16815 | struct peer *g_peer = NULL; | |
16816 | char *addr; | |
16817 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16818 | ||
16819 | /* Skip dynamic neighbors. */ | |
16820 | if (peer_dynamic_neighbor(peer)) | |
16821 | return; | |
16822 | ||
16823 | if (peer->conf_if) | |
16824 | addr = peer->conf_if; | |
16825 | else | |
16826 | addr = peer->host; | |
16827 | ||
16828 | /************************************ | |
16829 | ****** Per AF to the neighbor ****** | |
16830 | ************************************/ | |
16831 | if (peer_group_active(peer)) { | |
16832 | g_peer = peer->group->conf; | |
16833 | ||
16834 | /* If the peer-group is active but peer is not, print a 'no | |
16835 | * activate' */ | |
16836 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16837 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16838 | } | |
16839 | ||
16840 | /* If the peer-group is not active but peer is, print an | |
16841 | 'activate' */ | |
16842 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16843 | vty_out(vty, " neighbor %s activate\n", addr); | |
16844 | } | |
16845 | } else { | |
16846 | if (peer->afc[afi][safi]) { | |
16847 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16848 | if (CHECK_FLAG(bgp->flags, |
16849 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16850 | vty_out(vty, " neighbor %s activate\n", |
16851 | addr); | |
16852 | } | |
16853 | } else | |
16854 | vty_out(vty, " neighbor %s activate\n", addr); | |
16855 | } else { | |
16856 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
16857 | if (!CHECK_FLAG(bgp->flags, |
16858 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
16859 | vty_out(vty, |
16860 | " no neighbor %s activate\n", | |
16861 | addr); | |
16862 | } | |
16863 | } | |
16864 | } | |
16865 | } | |
16866 | ||
16867 | /* addpath TX knobs */ | |
16868 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16869 | switch (peer->addpath_type[afi][safi]) { | |
16870 | case BGP_ADDPATH_ALL: | |
16871 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16872 | addr); | |
16873 | break; | |
16874 | case BGP_ADDPATH_BEST_PER_AS: | |
16875 | vty_out(vty, | |
16876 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16877 | addr); | |
16878 | break; | |
16879 | case BGP_ADDPATH_MAX: | |
16880 | case BGP_ADDPATH_NONE: | |
16881 | break; | |
16882 | } | |
16883 | } | |
16884 | ||
16885 | /* ORF capability. */ | |
16886 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16887 | || peergroup_af_flag_check(peer, afi, safi, | |
16888 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16889 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16890 | ||
16891 | if (peergroup_af_flag_check(peer, afi, safi, | |
16892 | PEER_FLAG_ORF_PREFIX_SM) | |
16893 | && peergroup_af_flag_check(peer, afi, safi, | |
16894 | PEER_FLAG_ORF_PREFIX_RM)) | |
16895 | vty_out(vty, " both"); | |
16896 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16897 | PEER_FLAG_ORF_PREFIX_SM)) | |
16898 | vty_out(vty, " send"); | |
16899 | else | |
16900 | vty_out(vty, " receive"); | |
16901 | vty_out(vty, "\n"); | |
16902 | } | |
16903 | ||
dd65f45e DL |
16904 | /* Route reflector client. */ |
16905 | if (peergroup_af_flag_check(peer, afi, safi, | |
16906 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16907 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16908 | } | |
16909 | ||
16910 | /* next-hop-self force */ | |
16911 | if (peergroup_af_flag_check(peer, afi, safi, | |
16912 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16913 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16914 | } | |
16915 | ||
16916 | /* next-hop-self */ | |
16917 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16918 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16919 | } | |
16920 | ||
16921 | /* remove-private-AS */ | |
16922 | if (peergroup_af_flag_check(peer, afi, safi, | |
16923 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16924 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16925 | addr); | |
16926 | } | |
16927 | ||
16928 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16929 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16930 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16931 | addr); | |
16932 | } | |
16933 | ||
16934 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16935 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16936 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16937 | } | |
16938 | ||
16939 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16940 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16941 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16942 | } | |
16943 | ||
16944 | /* as-override */ | |
16945 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16946 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16947 | } | |
16948 | ||
16949 | /* send-community print. */ | |
16950 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16951 | PEER_FLAG_SEND_COMMUNITY); | |
16952 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16953 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16954 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16955 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16956 | ||
16957 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16958 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16959 | } else { | |
16960 | if (flag_scomm) | |
16961 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16962 | if (flag_secomm) | |
16963 | vty_out(vty, | |
16964 | " no neighbor %s send-community extended\n", | |
16965 | addr); | |
16966 | ||
16967 | if (flag_slcomm) | |
16968 | vty_out(vty, " no neighbor %s send-community large\n", | |
16969 | addr); | |
16970 | } | |
16971 | ||
16972 | /* Default information */ | |
16973 | if (peergroup_af_flag_check(peer, afi, safi, | |
16974 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16975 | vty_out(vty, " neighbor %s default-originate", addr); | |
16976 | ||
16977 | if (peer->default_rmap[afi][safi].name) | |
16978 | vty_out(vty, " route-map %s", | |
16979 | peer->default_rmap[afi][safi].name); | |
16980 | ||
16981 | vty_out(vty, "\n"); | |
16982 | } | |
16983 | ||
16984 | /* Soft reconfiguration inbound. */ | |
16985 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16986 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16987 | addr); | |
16988 | } | |
16989 | ||
16990 | /* maximum-prefix. */ | |
16991 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16992 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16993 | peer->pmax[afi][safi]); |
16994 | ||
16995 | if (peer->pmax_threshold[afi][safi] | |
16996 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16997 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16998 | if (peer_af_flag_check(peer, afi, safi, | |
16999 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
17000 | vty_out(vty, " warning-only"); | |
17001 | if (peer->pmax_restart[afi][safi]) | |
17002 | vty_out(vty, " restart %u", | |
17003 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
17004 | if (peer_af_flag_check(peer, afi, safi, |
17005 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
17006 | vty_out(vty, " force"); | |
dd65f45e DL |
17007 | |
17008 | vty_out(vty, "\n"); | |
17009 | } | |
17010 | ||
fde246e8 DA |
17011 | /* maximum-prefix-out */ |
17012 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 17013 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
17014 | addr, peer->pmax_out[afi][safi]); |
17015 | ||
dd65f45e DL |
17016 | /* Route server client. */ |
17017 | if (peergroup_af_flag_check(peer, afi, safi, | |
17018 | PEER_FLAG_RSERVER_CLIENT)) { | |
17019 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
17020 | } | |
17021 | ||
17022 | /* Nexthop-local unchanged. */ | |
17023 | if (peergroup_af_flag_check(peer, afi, safi, | |
17024 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
17025 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17026 | } | |
17027 | ||
17028 | /* allowas-in <1-10> */ | |
17029 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17030 | if (peer_af_flag_check(peer, afi, safi, | |
17031 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17032 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17033 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17034 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17035 | } else { | |
17036 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17037 | peer->allowas_in[afi][safi]); | |
17038 | } | |
17039 | } | |
17040 | ||
17041 | /* weight */ | |
17042 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17043 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17044 | peer->weight[afi][safi]); | |
17045 | ||
17046 | /* Filter. */ | |
17047 | bgp_config_write_filter(vty, peer, afi, safi); | |
17048 | ||
17049 | /* atribute-unchanged. */ | |
17050 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17051 | || (safi != SAFI_EVPN | |
17052 | && peer_af_flag_check(peer, afi, safi, | |
17053 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17054 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17055 | ||
17056 | if (!peer_group_active(peer) | |
17057 | || peergroup_af_flag_check(peer, afi, safi, | |
17058 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17059 | || peergroup_af_flag_check(peer, afi, safi, | |
17060 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17061 | || peergroup_af_flag_check(peer, afi, safi, | |
17062 | PEER_FLAG_MED_UNCHANGED)) { | |
17063 | ||
17064 | vty_out(vty, | |
17065 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17066 | addr, | |
17067 | peer_af_flag_check(peer, afi, safi, | |
17068 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17069 | ? " as-path" | |
17070 | : "", | |
17071 | peer_af_flag_check(peer, afi, safi, | |
17072 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17073 | ? " next-hop" | |
17074 | : "", | |
17075 | peer_af_flag_check(peer, afi, safi, | |
17076 | PEER_FLAG_MED_UNCHANGED) | |
17077 | ? " med" | |
17078 | : ""); | |
17079 | } | |
17080 | } | |
17081 | } | |
17082 | ||
17083 | /* Address family based peer configuration display. */ | |
17084 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17085 | safi_t safi) | |
17086 | { | |
17087 | struct peer *peer; | |
17088 | struct peer_group *group; | |
17089 | struct listnode *node, *nnode; | |
17090 | ||
17091 | ||
17092 | vty_frame(vty, " !\n address-family "); | |
17093 | if (afi == AFI_IP) { | |
17094 | if (safi == SAFI_UNICAST) | |
17095 | vty_frame(vty, "ipv4 unicast"); | |
17096 | else if (safi == SAFI_LABELED_UNICAST) | |
17097 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17098 | else if (safi == SAFI_MULTICAST) | |
17099 | vty_frame(vty, "ipv4 multicast"); | |
17100 | else if (safi == SAFI_MPLS_VPN) | |
17101 | vty_frame(vty, "ipv4 vpn"); | |
17102 | else if (safi == SAFI_ENCAP) | |
17103 | vty_frame(vty, "ipv4 encap"); | |
17104 | else if (safi == SAFI_FLOWSPEC) | |
17105 | vty_frame(vty, "ipv4 flowspec"); | |
17106 | } else if (afi == AFI_IP6) { | |
17107 | if (safi == SAFI_UNICAST) | |
17108 | vty_frame(vty, "ipv6 unicast"); | |
17109 | else if (safi == SAFI_LABELED_UNICAST) | |
17110 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17111 | else if (safi == SAFI_MULTICAST) | |
17112 | vty_frame(vty, "ipv6 multicast"); | |
17113 | else if (safi == SAFI_MPLS_VPN) | |
17114 | vty_frame(vty, "ipv6 vpn"); | |
17115 | else if (safi == SAFI_ENCAP) | |
17116 | vty_frame(vty, "ipv6 encap"); | |
17117 | else if (safi == SAFI_FLOWSPEC) | |
17118 | vty_frame(vty, "ipv6 flowspec"); | |
17119 | } else if (afi == AFI_L2VPN) { | |
17120 | if (safi == SAFI_EVPN) | |
17121 | vty_frame(vty, "l2vpn evpn"); | |
17122 | } | |
17123 | vty_frame(vty, "\n"); | |
17124 | ||
17125 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17126 | ||
17127 | bgp_config_write_network(vty, bgp, afi, safi); | |
17128 | ||
17129 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17130 | ||
8a4e7fe6 DA |
17131 | /* BGP flag dampening. */ |
17132 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
0221327c DS |
17133 | bgp_config_write_damp(vty, bgp, afi, safi); |
17134 | for (ALL_LIST_ELEMENTS_RO(bgp->group, node, group)) | |
17135 | if (peer_af_flag_check(group->conf, afi, safi, | |
17136 | PEER_FLAG_CONFIG_DAMPENING)) | |
17137 | bgp_config_write_peer_damp(vty, group->conf, afi, safi); | |
17138 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) | |
17139 | if (peer_af_flag_check(peer, afi, safi, | |
17140 | PEER_FLAG_CONFIG_DAMPENING)) | |
17141 | bgp_config_write_peer_damp(vty, peer, afi, safi); | |
8a4e7fe6 | 17142 | |
dd65f45e DL |
17143 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17144 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17145 | ||
17146 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17147 | /* Skip dynamic neighbors. */ | |
17148 | if (peer_dynamic_neighbor(peer)) | |
17149 | continue; | |
17150 | ||
17151 | /* Do not display doppelganger peers */ | |
17152 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17153 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17154 | } | |
17155 | ||
17156 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17157 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17158 | ||
17159 | if (safi == SAFI_EVPN) | |
17160 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17161 | ||
17162 | if (safi == SAFI_FLOWSPEC) | |
17163 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17164 | ||
17165 | if (safi == SAFI_UNICAST) { | |
17166 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17167 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17168 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17169 | ||
17170 | vty_out(vty, " export vpn\n"); | |
17171 | } | |
17172 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17173 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17174 | ||
17175 | vty_out(vty, " import vpn\n"); | |
17176 | } | |
17177 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17178 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17179 | char *name; | |
17180 | ||
17181 | for (ALL_LIST_ELEMENTS_RO( | |
17182 | bgp->vpn_policy[afi].import_vrf, node, | |
17183 | name)) | |
17184 | vty_out(vty, " import vrf %s\n", name); | |
17185 | } | |
17186 | } | |
17187 | ||
17188 | vty_endframe(vty, " exit-address-family\n"); | |
17189 | } | |
17190 | ||
17191 | int bgp_config_write(struct vty *vty) | |
17192 | { | |
17193 | struct bgp *bgp; | |
17194 | struct peer_group *group; | |
17195 | struct peer *peer; | |
17196 | struct listnode *node, *nnode; | |
17197 | struct listnode *mnode, *mnnode; | |
17198 | ||
17199 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17200 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17201 | bm->rmap_update_timer); | |
17202 | ||
d70583f7 D |
17203 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17204 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17205 | if (bm->v_update_delay != bm->v_establish_wait) | |
17206 | vty_out(vty, " %d", bm->v_establish_wait); | |
17207 | vty_out(vty, "\n"); | |
17208 | } | |
17209 | ||
9acb67cb DS |
17210 | if (bm->wait_for_fib) |
17211 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17212 | ||
05bd726c | 17213 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17214 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17215 | ||
c163f297 DS |
17216 | /* No-RIB (Zebra) option flag configuration */ |
17217 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17218 | vty_out(vty, "bgp no-rib\n"); | |
17219 | ||
ec0acb80 | 17220 | if (!CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
e46723a5 DS |
17221 | vty_out(vty, "no bgp send-extra-data zebra\n"); |
17222 | ||
dd65f45e DL |
17223 | /* BGP configuration. */ |
17224 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17225 | ||
17226 | /* skip all auto created vrf as they dont have user config */ | |
17227 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17228 | continue; | |
17229 | ||
17230 | /* Router bgp ASN */ | |
17231 | vty_out(vty, "router bgp %u", bgp->as); | |
17232 | ||
17233 | if (bgp->name) | |
17234 | vty_out(vty, " %s %s", | |
17235 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17236 | ? "view" : "vrf", bgp->name); | |
17237 | vty_out(vty, "\n"); | |
17238 | ||
17239 | /* BGP fast-external-failover. */ | |
17240 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17241 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17242 | ||
17243 | /* BGP router ID. */ | |
3a6290bd | 17244 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17245 | vty_out(vty, " bgp router-id %pI4\n", |
17246 | &bgp->router_id_static); | |
dd65f45e | 17247 | |
c208c586 S |
17248 | /* Suppress fib pending */ |
17249 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17250 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17251 | ||
dd65f45e | 17252 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17253 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17254 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17255 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17256 | CHECK_FLAG(bgp->flags, |
17257 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17258 | ? "" |
17259 | : "no "); | |
17260 | ||
17261 | /* BGP configuration. */ | |
892fedb6 | 17262 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17263 | vty_out(vty, " bgp always-compare-med\n"); |
17264 | ||
17265 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17266 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17267 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17268 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17269 | CHECK_FLAG(bgp->flags, | |
17270 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17271 | ? "" | |
17272 | : "no "); | |
dd65f45e DL |
17273 | |
17274 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17275 | if (bgp->reject_as_sets) |
dd65f45e DL |
17276 | vty_out(vty, " bgp reject-as-sets\n"); |
17277 | ||
2adac256 DA |
17278 | /* Suppress duplicate updates if the route actually not changed |
17279 | */ | |
17280 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17281 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17282 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17283 | CHECK_FLAG(bgp->flags, | |
17284 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17285 | ? "" | |
17286 | : "no "); | |
17287 | ||
dd65f45e | 17288 | /* BGP default ipv4-unicast. */ |
892fedb6 | 17289 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
17290 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
17291 | ||
17292 | /* BGP default local-preference. */ | |
17293 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17294 | vty_out(vty, " bgp default local-preference %u\n", | |
17295 | bgp->default_local_pref); | |
17296 | ||
17297 | /* BGP default show-hostname */ | |
892fedb6 | 17298 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17299 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17300 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17301 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17302 | ? "" |
17303 | : "no "); | |
17304 | ||
aef999a2 DA |
17305 | /* BGP default show-nexthop-hostname */ |
17306 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17307 | != SAVE_BGP_SHOW_HOSTNAME) | |
17308 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17309 | CHECK_FLAG(bgp->flags, | |
17310 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17311 | ? "" | |
17312 | : "no "); | |
17313 | ||
dd65f45e DL |
17314 | /* BGP default subgroup-pkt-queue-max. */ |
17315 | if (bgp->default_subgroup_pkt_queue_max | |
17316 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17317 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17318 | bgp->default_subgroup_pkt_queue_max); | |
17319 | ||
17320 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17321 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17322 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17323 | ||
17324 | /* BGP cluster ID. */ | |
17325 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17326 | vty_out(vty, " bgp cluster-id %pI4\n", |
17327 | &bgp->cluster_id); | |
dd65f45e DL |
17328 | |
17329 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17330 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17331 | vty_out(vty, |
17332 | " bgp disable-ebgp-connected-route-check\n"); | |
17333 | ||
17334 | /* Confederation identifier*/ | |
17335 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17336 | vty_out(vty, " bgp confederation identifier %u\n", | |
17337 | bgp->confed_id); | |
17338 | ||
17339 | /* Confederation peer */ | |
17340 | if (bgp->confed_peers_cnt > 0) { | |
17341 | int i; | |
17342 | ||
17343 | vty_out(vty, " bgp confederation peers"); | |
17344 | ||
17345 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17346 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17347 | ||
17348 | vty_out(vty, "\n"); | |
17349 | } | |
17350 | ||
17351 | /* BGP deterministic-med. */ | |
892fedb6 | 17352 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17353 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17354 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17355 | CHECK_FLAG(bgp->flags, |
17356 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17357 | ? "" |
17358 | : "no "); | |
17359 | ||
17360 | /* BGP update-delay. */ | |
17361 | bgp_config_write_update_delay(vty, bgp); | |
17362 | ||
17363 | if (bgp->v_maxmed_onstartup | |
17364 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17365 | vty_out(vty, " bgp max-med on-startup %u", | |
17366 | bgp->v_maxmed_onstartup); | |
17367 | if (bgp->maxmed_onstartup_value | |
17368 | != BGP_MAXMED_VALUE_DEFAULT) | |
17369 | vty_out(vty, " %u", | |
17370 | bgp->maxmed_onstartup_value); | |
17371 | vty_out(vty, "\n"); | |
17372 | } | |
17373 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17374 | vty_out(vty, " bgp max-med administrative"); | |
17375 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17376 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17377 | vty_out(vty, "\n"); | |
17378 | } | |
17379 | ||
17380 | /* write quanta */ | |
17381 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17382 | /* read quanta */ | |
17383 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17384 | ||
17385 | /* coalesce time */ | |
17386 | bgp_config_write_coalesce_time(vty, bgp); | |
17387 | ||
05bd726c | 17388 | /* BGP per-instance graceful-shutdown */ |
17389 | /* BGP-wide settings and per-instance settings are mutually | |
17390 | * exclusive. | |
17391 | */ | |
17392 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17393 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17394 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17395 | ||
dd65f45e DL |
17396 | /* BGP graceful-restart. */ |
17397 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17398 | vty_out(vty, | |
17399 | " bgp graceful-restart stalepath-time %u\n", | |
17400 | bgp->stalepath_time); | |
cfd47646 | 17401 | |
dd65f45e DL |
17402 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17403 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17404 | bgp->restart_time); | |
cfd47646 | 17405 | |
17406 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17407 | vty_out(vty, | |
17408 | " bgp graceful-restart select-defer-time %u\n", | |
17409 | bgp->select_defer_time); | |
17410 | ||
17411 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17412 | vty_out(vty, " bgp graceful-restart\n"); |
17413 | ||
cfd47646 | 17414 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17415 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17416 | ||
dd65f45e | 17417 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17418 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17419 | vty_out(vty, |
17420 | " bgp graceful-restart preserve-fw-state\n"); | |
17421 | ||
dc95985f | 17422 | /* Stale timer for RIB */ |
17423 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17424 | vty_out(vty, | |
17425 | " bgp graceful-restart rib-stale-time %u\n", | |
17426 | bgp->rib_stale_time); | |
17427 | ||
dd65f45e | 17428 | /* BGP bestpath method. */ |
892fedb6 | 17429 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17430 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17431 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17432 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17433 | ||
892fedb6 DA |
17434 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17435 | if (CHECK_FLAG(bgp->flags, | |
17436 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17437 | vty_out(vty, |
17438 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17439 | } else { | |
17440 | vty_out(vty, | |
17441 | " bgp bestpath as-path multipath-relax\n"); | |
17442 | } | |
17443 | } | |
17444 | ||
892fedb6 | 17445 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17446 | vty_out(vty, |
17447 | " bgp route-reflector allow-outbound-policy\n"); | |
17448 | } | |
892fedb6 | 17449 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17450 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17451 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17452 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17453 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17454 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17455 | vty_out(vty, " confed"); |
892fedb6 DA |
17456 | if (CHECK_FLAG(bgp->flags, |
17457 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17458 | vty_out(vty, " missing-as-worst"); |
17459 | vty_out(vty, "\n"); | |
17460 | } | |
17461 | ||
f7e1c681 | 17462 | /* Link bandwidth handling. */ |
17463 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17464 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17465 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17466 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17467 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17468 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17469 | ||
dd65f45e | 17470 | /* BGP network import check. */ |
892fedb6 | 17471 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17472 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17473 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17474 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17475 | ? "" |
17476 | : "no "); | |
17477 | ||
17478 | /* BGP timers configuration. */ | |
5d5393b9 DL |
17479 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
17480 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
17481 | vty_out(vty, " timers bgp %u %u\n", |
17482 | bgp->default_keepalive, bgp->default_holdtime); | |
17483 | ||
17484 | /* peer-group */ | |
17485 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17486 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17487 | } | |
17488 | ||
17489 | /* Normal neighbor configuration. */ | |
17490 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17491 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17492 | bgp_config_write_peer_global(vty, bgp, peer); | |
17493 | } | |
17494 | ||
17495 | /* listen range and limit for dynamic BGP neighbors */ | |
17496 | bgp_config_write_listen(vty, bgp); | |
17497 | ||
17498 | /* | |
17499 | * BGP default autoshutdown neighbors | |
17500 | * | |
17501 | * This must be placed after any peer and peer-group | |
17502 | * configuration, to avoid setting all peers to shutdown after | |
17503 | * a daemon restart, which is undesired behavior. (see #2286) | |
17504 | */ | |
17505 | if (bgp->autoshutdown) | |
17506 | vty_out(vty, " bgp default shutdown\n"); | |
17507 | ||
9cf59432 DS |
17508 | /* BGP instance administrative shutdown */ |
17509 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17510 | vty_out(vty, " bgp shutdown\n"); | |
17511 | ||
dd65f45e DL |
17512 | /* IPv4 unicast configuration. */ |
17513 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17514 | ||
17515 | /* IPv4 multicast configuration. */ | |
17516 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17517 | ||
17518 | /* IPv4 labeled-unicast configuration. */ | |
17519 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17520 | ||
17521 | /* IPv4 VPN configuration. */ | |
17522 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17523 | ||
17524 | /* ENCAPv4 configuration. */ | |
17525 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17526 | ||
17527 | /* FLOWSPEC v4 configuration. */ | |
17528 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17529 | ||
17530 | /* IPv6 unicast configuration. */ | |
17531 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17532 | ||
17533 | /* IPv6 multicast configuration. */ | |
17534 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17535 | ||
17536 | /* IPv6 labeled-unicast configuration. */ | |
17537 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17538 | SAFI_LABELED_UNICAST); | |
17539 | ||
17540 | /* IPv6 VPN configuration. */ | |
17541 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17542 | ||
17543 | /* ENCAPv6 configuration. */ | |
17544 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17545 | ||
17546 | /* FLOWSPEC v6 configuration. */ | |
17547 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17548 | ||
17549 | /* EVPN configuration. */ | |
17550 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17551 | ||
17552 | hook_call(bgp_inst_config_write, bgp, vty); | |
17553 | ||
49e5a4a0 | 17554 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17555 | bgp_rfapi_cfg_write(vty, bgp); |
17556 | #endif | |
17557 | ||
17558 | vty_out(vty, "!\n"); | |
17559 | } | |
17560 | return 0; | |
17561 | } | |
17562 | ||
ddb5b488 | 17563 | |
718e3744 | 17564 | /* BGP node structure. */ |
d62a17ae | 17565 | static struct cmd_node bgp_node = { |
f4b8291f | 17566 | .name = "bgp", |
62b346ee | 17567 | .node = BGP_NODE, |
24389580 | 17568 | .parent_node = CONFIG_NODE, |
62b346ee | 17569 | .prompt = "%s(config-router)# ", |
612c2c15 | 17570 | .config_write = bgp_config_write, |
718e3744 | 17571 | }; |
17572 | ||
d62a17ae | 17573 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17574 | .name = "bgp ipv4 unicast", |
62b346ee | 17575 | .node = BGP_IPV4_NODE, |
24389580 | 17576 | .parent_node = BGP_NODE, |
62b346ee | 17577 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17578 | }; |
17579 | ||
d62a17ae | 17580 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17581 | .name = "bgp ipv4 multicast", |
62b346ee | 17582 | .node = BGP_IPV4M_NODE, |
24389580 | 17583 | .parent_node = BGP_NODE, |
62b346ee | 17584 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17585 | }; |
17586 | ||
d62a17ae | 17587 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17588 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17589 | .node = BGP_IPV4L_NODE, |
24389580 | 17590 | .parent_node = BGP_NODE, |
62b346ee | 17591 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17592 | }; |
17593 | ||
d62a17ae | 17594 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 17595 | .name = "bgp ipv6", |
62b346ee | 17596 | .node = BGP_IPV6_NODE, |
24389580 | 17597 | .parent_node = BGP_NODE, |
62b346ee | 17598 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17599 | }; |
17600 | ||
d62a17ae | 17601 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17602 | .name = "bgp ipv6 multicast", |
62b346ee | 17603 | .node = BGP_IPV6M_NODE, |
24389580 | 17604 | .parent_node = BGP_NODE, |
62b346ee | 17605 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 17606 | }; |
17607 | ||
d62a17ae | 17608 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17609 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17610 | .node = BGP_IPV6L_NODE, |
24389580 | 17611 | .parent_node = BGP_NODE, |
62b346ee | 17612 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17613 | }; |
17614 | ||
62b346ee | 17615 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17616 | .name = "bgp vpnv4", |
62b346ee | 17617 | .node = BGP_VPNV4_NODE, |
24389580 | 17618 | .parent_node = BGP_NODE, |
62b346ee | 17619 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17620 | }; |
6b0655a2 | 17621 | |
62b346ee | 17622 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17623 | .name = "bgp vpnv6", |
62b346ee | 17624 | .node = BGP_VPNV6_NODE, |
24389580 | 17625 | .parent_node = BGP_NODE, |
62b346ee | 17626 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17627 | }; |
8ecd3266 | 17628 | |
62b346ee | 17629 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17630 | .name = "bgp evpn", |
62b346ee | 17631 | .node = BGP_EVPN_NODE, |
24389580 | 17632 | .parent_node = BGP_NODE, |
62b346ee | 17633 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 17634 | }; |
4e0b7b6d | 17635 | |
62b346ee | 17636 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17637 | .name = "bgp evpn vni", |
62b346ee | 17638 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17639 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17640 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17641 | }; |
90e60aa7 | 17642 | |
62b346ee | 17643 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17644 | .name = "bgp ipv4 flowspec", |
62b346ee | 17645 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17646 | .parent_node = BGP_NODE, |
62b346ee | 17647 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17648 | }; |
7c40bf39 | 17649 | |
62b346ee | 17650 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17651 | .name = "bgp ipv6 flowspec", |
62b346ee | 17652 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17653 | .parent_node = BGP_NODE, |
62b346ee | 17654 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17655 | }; |
7c40bf39 | 17656 | |
d62a17ae | 17657 | static void community_list_vty(void); |
1f8ae70b | 17658 | |
d62a17ae | 17659 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17660 | { |
d62a17ae | 17661 | struct bgp *bgp; |
17662 | struct peer *peer; | |
d62a17ae | 17663 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17664 | |
d62a17ae | 17665 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17666 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17667 | /* only provide suggestions on the appropriate input | |
17668 | * token type, | |
17669 | * they'll otherwise show up multiple times */ | |
17670 | enum cmd_token_type match_type; | |
17671 | char *name = peer->host; | |
d48ed3e0 | 17672 | |
d62a17ae | 17673 | if (peer->conf_if) { |
17674 | match_type = VARIABLE_TKN; | |
17675 | name = peer->conf_if; | |
17676 | } else if (strchr(peer->host, ':')) | |
17677 | match_type = IPV6_TKN; | |
17678 | else | |
17679 | match_type = IPV4_TKN; | |
d48ed3e0 | 17680 | |
d62a17ae | 17681 | if (token->type != match_type) |
17682 | continue; | |
d48ed3e0 | 17683 | |
d62a17ae | 17684 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17685 | } | |
d62a17ae | 17686 | } |
b8a815e5 DL |
17687 | } |
17688 | ||
17689 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17690 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17691 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17692 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17693 | {.completions = NULL}}; |
17694 | ||
47a306a0 DS |
17695 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17696 | { | |
17697 | struct bgp *bgp; | |
17698 | struct peer_group *group; | |
17699 | struct listnode *lnbgp, *lnpeer; | |
17700 | ||
17701 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17702 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17703 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17704 | group->name)); | |
17705 | } | |
17706 | } | |
17707 | ||
17708 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17709 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17710 | {.completions = NULL} }; | |
17711 | ||
d62a17ae | 17712 | void bgp_vty_init(void) |
17713 | { | |
17714 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17715 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17716 | |
17717 | /* Install bgp top node. */ | |
612c2c15 DL |
17718 | install_node(&bgp_node); |
17719 | install_node(&bgp_ipv4_unicast_node); | |
17720 | install_node(&bgp_ipv4_multicast_node); | |
17721 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17722 | install_node(&bgp_ipv6_unicast_node); | |
17723 | install_node(&bgp_ipv6_multicast_node); | |
17724 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17725 | install_node(&bgp_vpnv4_node); | |
17726 | install_node(&bgp_vpnv6_node); | |
17727 | install_node(&bgp_evpn_node); | |
17728 | install_node(&bgp_evpn_vni_node); | |
17729 | install_node(&bgp_flowspecv4_node); | |
17730 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 17731 | |
17732 | /* Install default VTY commands to new nodes. */ | |
17733 | install_default(BGP_NODE); | |
17734 | install_default(BGP_IPV4_NODE); | |
17735 | install_default(BGP_IPV4M_NODE); | |
17736 | install_default(BGP_IPV4L_NODE); | |
17737 | install_default(BGP_IPV6_NODE); | |
17738 | install_default(BGP_IPV6M_NODE); | |
17739 | install_default(BGP_IPV6L_NODE); | |
17740 | install_default(BGP_VPNV4_NODE); | |
17741 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17742 | install_default(BGP_FLOWSPECV4_NODE); |
17743 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17744 | install_default(BGP_EVPN_NODE); |
17745 | install_default(BGP_EVPN_VNI_NODE); | |
17746 | ||
8029b216 AK |
17747 | /* "bgp local-mac" hidden commands. */ |
17748 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17749 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17750 | ||
9acb67cb DS |
17751 | /* "bgp suppress-fib-pending" global */ |
17752 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17753 | ||
d62a17ae | 17754 | /* bgp route-map delay-timer commands. */ |
17755 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17756 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17757 | ||
d70583f7 D |
17758 | /* global bgp update-delay command */ |
17759 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17760 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17761 | ||
05bd726c | 17762 | /* global bgp graceful-shutdown command */ |
17763 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17764 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17765 | ||
d62a17ae | 17766 | /* Dummy commands (Currently not supported) */ |
17767 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17768 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17769 | ||
17770 | /* "router bgp" commands. */ | |
17771 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17772 | ||
17773 | /* "no router bgp" commands. */ | |
17774 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17775 | ||
17776 | /* "bgp router-id" commands. */ | |
17777 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17778 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17779 | ||
c208c586 S |
17780 | /* "bgp suppress-fib-pending" command */ |
17781 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17782 | ||
d62a17ae | 17783 | /* "bgp cluster-id" commands. */ |
17784 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17785 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17786 | ||
c163f297 DS |
17787 | /* "bgp no-rib" commands. */ |
17788 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17789 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17790 | ||
e46723a5 DS |
17791 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
17792 | ||
d62a17ae | 17793 | /* "bgp confederation" commands. */ |
17794 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17795 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17796 | ||
17797 | /* "bgp confederation peers" commands. */ | |
17798 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17799 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17800 | ||
17801 | /* bgp max-med command */ | |
17802 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17803 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17804 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17805 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17806 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17807 | ||
17808 | /* bgp disable-ebgp-connected-nh-check */ | |
17809 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17810 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17811 | ||
17812 | /* bgp update-delay command */ | |
17813 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17814 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17815 | |
17816 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17817 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17818 | |
17819 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17820 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17821 | ||
17822 | /* "maximum-paths" commands. */ | |
17823 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17824 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17825 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17826 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17827 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17828 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17829 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17830 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17831 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17832 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17833 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17834 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17835 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17836 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17837 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17838 | ||
39edabac PG |
17839 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17840 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17841 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17842 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17843 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17844 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17845 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17846 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17847 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17848 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17849 | ||
17850 | /* "timers bgp" commands. */ | |
17851 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17852 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17853 | ||
17854 | /* route-map delay-timer commands - per instance for backwards compat. | |
17855 | */ | |
17856 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17857 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17858 | ||
17859 | /* "bgp client-to-client reflection" commands */ | |
17860 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17861 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17862 | ||
17863 | /* "bgp always-compare-med" commands */ | |
17864 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17865 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17866 | ||
9dac9fc8 DA |
17867 | /* bgp ebgp-requires-policy */ |
17868 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17869 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17870 | ||
2adac256 DA |
17871 | /* bgp suppress-duplicates */ |
17872 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17873 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
17874 | ||
fb29348a DA |
17875 | /* bgp reject-as-sets */ |
17876 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17877 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17878 | ||
d62a17ae | 17879 | /* "bgp deterministic-med" commands */ |
17880 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17881 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17882 | ||
055679e9 | 17883 | /* "bgp graceful-restart" command */ |
36235319 QY |
17884 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17885 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17886 | |
17887 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17888 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17889 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17890 | |
17891 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17892 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17893 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17894 | |
17895 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17896 | install_element(BGP_NODE, | |
17897 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17898 | install_element(BGP_NODE, | |
17899 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17900 | ||
17901 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17902 | install_element(BGP_NODE, | |
17903 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17904 | install_element(BGP_NODE, | |
17905 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17906 | ||
d62a17ae | 17907 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17908 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17909 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17910 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17911 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17912 | install_element(BGP_NODE, |
17913 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17914 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17915 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17916 | ||
d6e3c15b | 17917 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17918 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17919 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17920 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17921 | |
7f323236 DW |
17922 | /* "bgp graceful-shutdown" commands */ |
17923 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17924 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17925 | ||
d62a17ae | 17926 | /* "bgp fast-external-failover" commands */ |
17927 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17928 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17929 | ||
d62a17ae | 17930 | /* "bgp bestpath compare-routerid" commands */ |
17931 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17932 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17933 | ||
17934 | /* "bgp bestpath as-path ignore" commands */ | |
17935 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17936 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17937 | ||
17938 | /* "bgp bestpath as-path confed" commands */ | |
17939 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17940 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17941 | ||
17942 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17943 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17944 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17945 | ||
17946 | /* "bgp log-neighbor-changes" commands */ | |
17947 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17948 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17949 | ||
17950 | /* "bgp bestpath med" commands */ | |
17951 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17952 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17953 | ||
f7e1c681 | 17954 | /* "bgp bestpath bandwidth" commands */ |
17955 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17956 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17957 | |
d62a17ae | 17958 | /* "no bgp default ipv4-unicast" commands. */ |
17959 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
17960 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
17961 | ||
17962 | /* "bgp network import-check" commands. */ | |
17963 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17964 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17965 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17966 | ||
17967 | /* "bgp default local-preference" commands. */ | |
17968 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17969 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17970 | ||
17971 | /* bgp default show-hostname */ | |
17972 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17973 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17974 | ||
aef999a2 DA |
17975 | /* bgp default show-nexthop-hostname */ |
17976 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17977 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17978 | ||
d62a17ae | 17979 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17980 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17981 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17982 | ||
17983 | /* bgp ibgp-allow-policy-mods command */ | |
17984 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17985 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17986 | ||
17987 | /* "bgp listen limit" commands. */ | |
17988 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17989 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17990 | ||
17991 | /* "bgp listen range" commands. */ | |
17992 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17993 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17994 | ||
8175f54a | 17995 | /* "bgp default shutdown" command */ |
f26845f9 | 17996 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17997 | |
17998 | /* "bgp shutdown" commands */ | |
17999 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 18000 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 18001 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 18002 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 18003 | |
d62a17ae | 18004 | /* "neighbor remote-as" commands. */ |
18005 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
18006 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
18007 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
18008 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
18009 | install_element(BGP_NODE, | |
18010 | &neighbor_interface_v6only_config_remote_as_cmd); | |
18011 | install_element(BGP_NODE, &no_neighbor_cmd); | |
18012 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
18013 | ||
18014 | /* "neighbor peer-group" commands. */ | |
18015 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
18016 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
18017 | install_element(BGP_NODE, | |
18018 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
18019 | ||
18020 | /* "neighbor local-as" commands. */ | |
18021 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
18022 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
18023 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
18024 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
18025 | ||
18026 | /* "neighbor solo" commands. */ | |
18027 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
18028 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
18029 | ||
18030 | /* "neighbor password" commands. */ | |
18031 | install_element(BGP_NODE, &neighbor_password_cmd); | |
18032 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
18033 | ||
18034 | /* "neighbor activate" commands. */ | |
18035 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
18036 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
18037 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
18038 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
18039 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
18040 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
18041 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
18042 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
18043 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 18044 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
18045 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 18046 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
18047 | ||
18048 | /* "no neighbor activate" commands. */ | |
18049 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
18050 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
18051 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
18052 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
18053 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
18054 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
18055 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
18056 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
18057 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 18058 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
18059 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 18060 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
18061 | ||
18062 | /* "neighbor peer-group" set commands. */ | |
18063 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
18064 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18065 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18066 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18067 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18068 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18069 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18070 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18071 | install_element(BGP_FLOWSPECV4_NODE, |
18072 | &neighbor_set_peer_group_hidden_cmd); | |
18073 | install_element(BGP_FLOWSPECV6_NODE, | |
18074 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18075 | |
18076 | /* "no neighbor peer-group unset" commands. */ | |
18077 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
18078 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18079 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18080 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18081 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18082 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18083 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18084 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18085 | install_element(BGP_FLOWSPECV4_NODE, |
18086 | &no_neighbor_set_peer_group_hidden_cmd); | |
18087 | install_element(BGP_FLOWSPECV6_NODE, | |
18088 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18089 | |
18090 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18091 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18092 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18093 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18094 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18095 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18096 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18097 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18098 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18099 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18100 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18101 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18102 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18103 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18104 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18105 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18106 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18107 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18108 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 18109 | install_element(BGP_FLOWSPECV4_NODE, |
18110 | &neighbor_soft_reconfiguration_cmd); | |
18111 | install_element(BGP_FLOWSPECV4_NODE, | |
18112 | &no_neighbor_soft_reconfiguration_cmd); | |
18113 | install_element(BGP_FLOWSPECV6_NODE, | |
18114 | &neighbor_soft_reconfiguration_cmd); | |
18115 | install_element(BGP_FLOWSPECV6_NODE, | |
18116 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
18117 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
18118 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 18119 | |
18120 | /* "neighbor attribute-unchanged" commands. */ | |
18121 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18122 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18123 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18124 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18125 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18126 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18127 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18128 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18129 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18130 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18131 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18132 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18133 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18134 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18135 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18136 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18137 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18138 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18139 | ||
18140 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18141 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18142 | ||
b8ad84d2 PG |
18143 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
18144 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18145 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18146 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18147 | ||
d62a17ae | 18148 | /* "nexthop-local unchanged" commands */ |
18149 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18150 | install_element(BGP_IPV6_NODE, | |
18151 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18152 | ||
18153 | /* "neighbor next-hop-self" commands. */ | |
18154 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18155 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18156 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18157 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18158 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18159 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18160 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18161 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18162 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18163 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18164 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18165 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18166 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18167 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18168 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18169 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18170 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18171 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
18172 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
18173 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 18174 | |
18175 | /* "neighbor next-hop-self force" commands. */ | |
18176 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18177 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
18178 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18179 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18180 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
18181 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18182 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18183 | install_element(BGP_IPV4_NODE, | |
18184 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18185 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18186 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18187 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18188 | install_element(BGP_IPV4M_NODE, | |
18189 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18190 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18191 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18192 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18193 | install_element(BGP_IPV4L_NODE, | |
18194 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18195 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18196 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18197 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18198 | install_element(BGP_IPV6_NODE, | |
18199 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18200 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18201 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18202 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18203 | install_element(BGP_IPV6M_NODE, | |
18204 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18205 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18206 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18207 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18208 | install_element(BGP_IPV6L_NODE, | |
18209 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18210 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18211 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18212 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18213 | install_element(BGP_VPNV4_NODE, | |
18214 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18215 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18216 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18217 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18218 | install_element(BGP_VPNV6_NODE, | |
18219 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18220 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18221 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18222 | |
18223 | /* "neighbor as-override" commands. */ | |
18224 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18225 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18226 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18227 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18228 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18229 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18230 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18231 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18232 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18233 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18234 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18235 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18236 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18237 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18238 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18239 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18240 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18241 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18242 | ||
18243 | /* "neighbor remove-private-AS" commands. */ | |
18244 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18245 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18246 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18247 | install_element(BGP_NODE, | |
18248 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18249 | install_element(BGP_NODE, | |
18250 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18251 | install_element(BGP_NODE, | |
18252 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18253 | install_element(BGP_NODE, | |
18254 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18255 | install_element( | |
18256 | BGP_NODE, | |
18257 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18258 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18259 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18260 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18261 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18262 | install_element(BGP_IPV4_NODE, | |
18263 | &neighbor_remove_private_as_replace_as_cmd); | |
18264 | install_element(BGP_IPV4_NODE, | |
18265 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18266 | install_element(BGP_IPV4_NODE, | |
18267 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18268 | install_element(BGP_IPV4_NODE, | |
18269 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18270 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18271 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18272 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18273 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18274 | install_element(BGP_IPV4M_NODE, | |
18275 | &neighbor_remove_private_as_replace_as_cmd); | |
18276 | install_element(BGP_IPV4M_NODE, | |
18277 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18278 | install_element(BGP_IPV4M_NODE, | |
18279 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18280 | install_element(BGP_IPV4M_NODE, | |
18281 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18282 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18283 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18284 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18285 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18286 | install_element(BGP_IPV4L_NODE, | |
18287 | &neighbor_remove_private_as_replace_as_cmd); | |
18288 | install_element(BGP_IPV4L_NODE, | |
18289 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18290 | install_element(BGP_IPV4L_NODE, | |
18291 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18292 | install_element(BGP_IPV4L_NODE, | |
18293 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18294 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18295 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18296 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18297 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18298 | install_element(BGP_IPV6_NODE, | |
18299 | &neighbor_remove_private_as_replace_as_cmd); | |
18300 | install_element(BGP_IPV6_NODE, | |
18301 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18302 | install_element(BGP_IPV6_NODE, | |
18303 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18304 | install_element(BGP_IPV6_NODE, | |
18305 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18306 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18307 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18308 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18309 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18310 | install_element(BGP_IPV6M_NODE, | |
18311 | &neighbor_remove_private_as_replace_as_cmd); | |
18312 | install_element(BGP_IPV6M_NODE, | |
18313 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18314 | install_element(BGP_IPV6M_NODE, | |
18315 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18316 | install_element(BGP_IPV6M_NODE, | |
18317 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18318 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18319 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18320 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18321 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18322 | install_element(BGP_IPV6L_NODE, | |
18323 | &neighbor_remove_private_as_replace_as_cmd); | |
18324 | install_element(BGP_IPV6L_NODE, | |
18325 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18326 | install_element(BGP_IPV6L_NODE, | |
18327 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18328 | install_element(BGP_IPV6L_NODE, | |
18329 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18330 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18331 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18332 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18333 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18334 | install_element(BGP_VPNV4_NODE, | |
18335 | &neighbor_remove_private_as_replace_as_cmd); | |
18336 | install_element(BGP_VPNV4_NODE, | |
18337 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18338 | install_element(BGP_VPNV4_NODE, | |
18339 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18340 | install_element(BGP_VPNV4_NODE, | |
18341 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18342 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18343 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18344 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18345 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18346 | install_element(BGP_VPNV6_NODE, | |
18347 | &neighbor_remove_private_as_replace_as_cmd); | |
18348 | install_element(BGP_VPNV6_NODE, | |
18349 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18350 | install_element(BGP_VPNV6_NODE, | |
18351 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18352 | install_element(BGP_VPNV6_NODE, | |
18353 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18354 | ||
18355 | /* "neighbor send-community" commands.*/ | |
18356 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18357 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18358 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18359 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18360 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18361 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18362 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18363 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18364 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18365 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18366 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18367 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18368 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18369 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18370 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18371 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18372 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18373 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18374 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18375 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18376 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18377 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18378 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18379 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18380 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18381 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18382 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18383 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18384 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18385 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18386 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18387 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18388 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18389 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18390 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18391 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18392 | ||
18393 | /* "neighbor route-reflector" commands.*/ | |
18394 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18395 | install_element(BGP_NODE, | |
18396 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18397 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18398 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18399 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18400 | install_element(BGP_IPV4M_NODE, | |
18401 | &no_neighbor_route_reflector_client_cmd); | |
18402 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18403 | install_element(BGP_IPV4L_NODE, | |
18404 | &no_neighbor_route_reflector_client_cmd); | |
18405 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18406 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18407 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18408 | install_element(BGP_IPV6M_NODE, | |
18409 | &no_neighbor_route_reflector_client_cmd); | |
18410 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18411 | install_element(BGP_IPV6L_NODE, | |
18412 | &no_neighbor_route_reflector_client_cmd); | |
18413 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18414 | install_element(BGP_VPNV4_NODE, | |
18415 | &no_neighbor_route_reflector_client_cmd); | |
18416 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18417 | install_element(BGP_VPNV6_NODE, | |
18418 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18419 | install_element(BGP_FLOWSPECV4_NODE, |
18420 | &neighbor_route_reflector_client_cmd); | |
18421 | install_element(BGP_FLOWSPECV4_NODE, | |
18422 | &no_neighbor_route_reflector_client_cmd); | |
18423 | install_element(BGP_FLOWSPECV6_NODE, | |
18424 | &neighbor_route_reflector_client_cmd); | |
18425 | install_element(BGP_FLOWSPECV6_NODE, | |
18426 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18427 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18428 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18429 | ||
18430 | /* "neighbor route-server" commands.*/ | |
18431 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18432 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18433 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18434 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18435 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18436 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18437 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18438 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18439 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18440 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18441 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18442 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18443 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18444 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18445 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18446 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18447 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18448 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18449 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18450 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18451 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18452 | install_element(BGP_FLOWSPECV4_NODE, | |
18453 | &no_neighbor_route_server_client_cmd); | |
18454 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18455 | install_element(BGP_FLOWSPECV6_NODE, | |
18456 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18457 | |
18458 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
18459 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18460 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18461 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18462 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18463 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18464 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18465 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18466 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18467 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18468 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18469 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18470 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18471 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18472 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18473 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18474 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18475 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18476 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18477 | ||
18478 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18479 | install_element(BGP_NODE, | |
18480 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18481 | install_element(BGP_NODE, | |
18482 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18483 | install_element(BGP_IPV4_NODE, | |
18484 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18485 | install_element(BGP_IPV4_NODE, | |
18486 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18487 | install_element(BGP_IPV4M_NODE, | |
18488 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18489 | install_element(BGP_IPV4M_NODE, | |
18490 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18491 | install_element(BGP_IPV4L_NODE, | |
18492 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18493 | install_element(BGP_IPV4L_NODE, | |
18494 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18495 | install_element(BGP_IPV6_NODE, | |
18496 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18497 | install_element(BGP_IPV6_NODE, | |
18498 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18499 | install_element(BGP_IPV6M_NODE, | |
18500 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18501 | install_element(BGP_IPV6M_NODE, | |
18502 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18503 | install_element(BGP_IPV6L_NODE, | |
18504 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18505 | install_element(BGP_IPV6L_NODE, | |
18506 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18507 | install_element(BGP_VPNV4_NODE, | |
18508 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18509 | install_element(BGP_VPNV4_NODE, | |
18510 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18511 | install_element(BGP_VPNV6_NODE, | |
18512 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18513 | install_element(BGP_VPNV6_NODE, | |
18514 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18515 | ||
2b31007c RZ |
18516 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18517 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18518 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18519 | ||
d62a17ae | 18520 | /* "neighbor passive" commands. */ |
18521 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18522 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18523 | ||
18524 | ||
18525 | /* "neighbor shutdown" commands. */ | |
18526 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18527 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18528 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18529 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18530 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18531 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18532 | |
18533 | /* "neighbor capability extended-nexthop" commands.*/ | |
18534 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18535 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18536 | ||
18537 | /* "neighbor capability orf prefix-list" commands.*/ | |
18538 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18539 | install_element(BGP_NODE, | |
18540 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18541 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18542 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18543 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18544 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18545 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18546 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18547 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18548 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18549 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18550 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18551 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18552 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18553 | ||
18554 | /* "neighbor capability dynamic" commands.*/ | |
18555 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18556 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18557 | ||
18558 | /* "neighbor dont-capability-negotiate" commands. */ | |
18559 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18560 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18561 | ||
18562 | /* "neighbor ebgp-multihop" commands. */ | |
18563 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18564 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18565 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18566 | ||
18567 | /* "neighbor disable-connected-check" commands. */ | |
18568 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18569 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18570 | ||
47cbc09b PM |
18571 | /* "neighbor enforce-first-as" commands. */ |
18572 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18573 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18574 | ||
d62a17ae | 18575 | /* "neighbor description" commands. */ |
18576 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18577 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18578 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18579 | |
18580 | /* "neighbor update-source" commands. "*/ | |
18581 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18582 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18583 | ||
18584 | /* "neighbor default-originate" commands. */ | |
18585 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18586 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18587 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18588 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18589 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18590 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18591 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18592 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18593 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18594 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18595 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18596 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18597 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18598 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18599 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18600 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18601 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18602 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18603 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18604 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18605 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18606 | ||
18607 | /* "neighbor port" commands. */ | |
18608 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18609 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18610 | ||
18611 | /* "neighbor weight" commands. */ | |
18612 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18613 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18614 | ||
18615 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18616 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18617 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18618 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18619 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18620 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18621 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18622 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18623 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18624 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18625 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18626 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18627 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18628 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18629 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18630 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18631 | ||
18632 | /* "neighbor override-capability" commands. */ | |
18633 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18634 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18635 | ||
18636 | /* "neighbor strict-capability-match" commands. */ | |
18637 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18638 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18639 | ||
18640 | /* "neighbor timers" commands. */ | |
18641 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18642 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18643 | ||
18644 | /* "neighbor timers connect" commands. */ | |
18645 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18646 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18647 | ||
d43114f3 DS |
18648 | /* "neighbor timers delayopen" commands. */ |
18649 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18650 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18651 | ||
d62a17ae | 18652 | /* "neighbor advertisement-interval" commands. */ |
18653 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18654 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18655 | ||
18656 | /* "neighbor interface" commands. */ | |
18657 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18658 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18659 | ||
18660 | /* "neighbor distribute" commands. */ | |
18661 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18662 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18663 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18664 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18665 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18666 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18667 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18668 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18669 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18670 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18671 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18672 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18673 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18674 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18675 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18676 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18677 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18678 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18679 | ||
18680 | /* "neighbor prefix-list" commands. */ | |
18681 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
d62a17ae | 18682 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18683 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18684 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18685 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18686 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18687 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18688 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18689 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
7c40bf39 | 18690 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
7c40bf39 | 18691 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 18692 | |
18693 | /* "neighbor filter-list" commands. */ | |
18694 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18695 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18696 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18697 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18698 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18699 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18700 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18701 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18702 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18703 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18704 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18705 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18706 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18707 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18708 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18709 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18710 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18711 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18712 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18713 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18714 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18715 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18716 | |
18717 | /* "neighbor route-map" commands. */ | |
d62a17ae | 18718 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18719 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18720 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18721 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18722 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18723 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18724 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18725 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
7c40bf39 | 18726 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
7c40bf39 | 18727 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
d37ba549 | 18728 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
d62a17ae | 18729 | |
18730 | /* "neighbor unsuppress-map" commands. */ | |
18731 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18732 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18733 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18734 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18735 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18736 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18737 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18738 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18739 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18740 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18741 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18742 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18743 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18744 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18745 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18746 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18747 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18748 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18749 | ||
7f7940e6 MK |
18750 | /* "neighbor advertise-map" commands. */ |
18751 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
7f7940e6 | 18752 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18753 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18754 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18755 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18756 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18757 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18758 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18759 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18760 | |
fde246e8 DA |
18761 | /* neighbor maximum-prefix-out commands. */ |
18762 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18763 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18764 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18765 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18766 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18767 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18768 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18769 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18770 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18771 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18772 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18773 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18774 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18775 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18776 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18777 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18778 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18779 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18780 | ||
d62a17ae | 18781 | /* "neighbor maximum-prefix" commands. */ |
18782 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18783 | install_element(BGP_NODE, | |
18784 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18785 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18786 | install_element(BGP_NODE, | |
18787 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18788 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18789 | install_element(BGP_NODE, | |
18790 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18791 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18792 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18793 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18794 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18795 | install_element(BGP_IPV4_NODE, | |
18796 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18797 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18798 | install_element(BGP_IPV4_NODE, | |
18799 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18800 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18801 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18802 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18803 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18804 | install_element(BGP_IPV4M_NODE, | |
18805 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18806 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18807 | install_element(BGP_IPV4M_NODE, | |
18808 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18809 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18810 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18811 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18812 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18813 | install_element(BGP_IPV4L_NODE, | |
18814 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18815 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18816 | install_element(BGP_IPV4L_NODE, | |
18817 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18818 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18819 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18820 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18821 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18822 | install_element(BGP_IPV6_NODE, | |
18823 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18824 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18825 | install_element(BGP_IPV6_NODE, | |
18826 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18827 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18828 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18829 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18830 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18831 | install_element(BGP_IPV6M_NODE, | |
18832 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18833 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18834 | install_element(BGP_IPV6M_NODE, | |
18835 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18836 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18837 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18838 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18839 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18840 | install_element(BGP_IPV6L_NODE, | |
18841 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18842 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18843 | install_element(BGP_IPV6L_NODE, | |
18844 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18845 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18846 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18847 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18848 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18849 | install_element(BGP_VPNV4_NODE, | |
18850 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18851 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18852 | install_element(BGP_VPNV4_NODE, | |
18853 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18854 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18855 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18856 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18857 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18858 | install_element(BGP_VPNV6_NODE, | |
18859 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18860 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18861 | install_element(BGP_VPNV6_NODE, | |
18862 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18863 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18864 | ||
18865 | /* "neighbor allowas-in" */ | |
18866 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18867 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18868 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18869 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18870 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18871 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18872 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18873 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18874 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18875 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18876 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18877 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18878 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18879 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18880 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18881 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18882 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18883 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18884 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18885 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18886 | ||
0221327c DS |
18887 | /* "neighbor dampening" commands. */ |
18888 | install_element(BGP_NODE, &neighbor_damp_cmd); | |
18889 | install_element(BGP_NODE, &no_neighbor_damp_cmd); | |
18890 | install_element(BGP_IPV4_NODE, &neighbor_damp_cmd); | |
18891 | install_element(BGP_IPV4_NODE, &no_neighbor_damp_cmd); | |
18892 | install_element(BGP_IPV4M_NODE, &neighbor_damp_cmd); | |
18893 | install_element(BGP_IPV4M_NODE, &no_neighbor_damp_cmd); | |
18894 | install_element(BGP_IPV4L_NODE, &neighbor_damp_cmd); | |
18895 | install_element(BGP_IPV4L_NODE, &no_neighbor_damp_cmd); | |
18896 | install_element(BGP_IPV6_NODE, &neighbor_damp_cmd); | |
18897 | install_element(BGP_IPV6_NODE, &no_neighbor_damp_cmd); | |
18898 | install_element(BGP_IPV6M_NODE, &neighbor_damp_cmd); | |
18899 | install_element(BGP_IPV6M_NODE, &no_neighbor_damp_cmd); | |
18900 | install_element(BGP_IPV6L_NODE, &neighbor_damp_cmd); | |
18901 | install_element(BGP_IPV6L_NODE, &no_neighbor_damp_cmd); | |
18902 | install_element(VIEW_NODE, &show_ip_bgp_neighbor_damp_param_cmd); | |
18903 | ||
d62a17ae | 18904 | /* address-family commands. */ |
18905 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18906 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18907 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18908 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18909 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18910 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18911 | |
d62a17ae | 18912 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18913 | ||
18914 | /* "exit-address-family" command. */ | |
18915 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18916 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18917 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18918 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18919 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18920 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18921 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18922 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18923 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18924 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18925 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18926 | ||
18927 | /* "clear ip bgp commands" */ | |
18928 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18929 | ||
18930 | /* clear ip bgp prefix */ | |
18931 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18932 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18933 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18934 | ||
18935 | /* "show [ip] bgp summary" commands. */ | |
18936 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18937 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18938 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18939 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18940 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18941 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18942 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18943 | ||
18944 | /* "show [ip] bgp neighbors" commands. */ | |
18945 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18946 | ||
36235319 | 18947 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18948 | |
d62a17ae | 18949 | /* "show [ip] bgp peer-group" commands. */ |
18950 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18951 | ||
18952 | /* "show [ip] bgp paths" commands. */ | |
18953 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18954 | ||
18955 | /* "show [ip] bgp community" commands. */ | |
18956 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18957 | ||
18958 | /* "show ip bgp large-community" commands. */ | |
18959 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18960 | /* "show [ip] bgp attribute-info" commands. */ | |
18961 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18962 | /* "show [ip] bgp route-leak" command */ |
18963 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18964 | |
18965 | /* "redistribute" commands. */ | |
18966 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18967 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18968 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18969 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18970 | install_element(BGP_NODE, | |
18971 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18972 | install_element(BGP_NODE, | |
18973 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18974 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18975 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18976 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18977 | install_element(BGP_NODE, | |
18978 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18979 | install_element(BGP_NODE, | |
18980 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18981 | install_element(BGP_NODE, | |
18982 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18983 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18984 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18985 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18986 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18987 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18988 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18989 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18990 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18991 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18992 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18993 | install_element(BGP_IPV4_NODE, | |
18994 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18995 | install_element(BGP_IPV4_NODE, | |
18996 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18997 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18998 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18999 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
19000 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
19001 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
19002 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
19003 | ||
b9c7bc5a PZ |
19004 | /* import|export vpn [route-map WORD] */ |
19005 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
19006 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 19007 | |
12a844a5 DS |
19008 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
19009 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
19010 | ||
d62a17ae | 19011 | /* ttl_security commands */ |
19012 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
19013 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
19014 | ||
19015 | /* "show [ip] bgp memory" commands. */ | |
19016 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
19017 | ||
acf71666 MK |
19018 | /* "show bgp martian next-hop" */ |
19019 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
19020 | ||
48ecf8f5 DS |
19021 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
19022 | ||
d62a17ae | 19023 | /* "show [ip] bgp views" commands. */ |
19024 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
19025 | ||
19026 | /* "show [ip] bgp vrfs" commands. */ | |
19027 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
19028 | ||
19029 | /* Community-list. */ | |
19030 | community_list_vty(); | |
ddb5b488 PZ |
19031 | |
19032 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
19033 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
19034 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
19035 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
19036 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
19037 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
19038 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
19039 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
19040 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
19041 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
19042 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19043 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
19044 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 19045 | |
301ad80a PG |
19046 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
19047 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
19048 | ||
b9c7bc5a PZ |
19049 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
19050 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
19051 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
19052 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
19053 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
19054 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
19055 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
19056 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19057 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
19058 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 19059 | } |
6b0655a2 | 19060 | |
718e3744 | 19061 | #include "memory.h" |
19062 | #include "bgp_regex.h" | |
19063 | #include "bgp_clist.h" | |
19064 | #include "bgp_ecommunity.h" | |
19065 | ||
19066 | /* VTY functions. */ | |
19067 | ||
19068 | /* Direction value to string conversion. */ | |
d62a17ae | 19069 | static const char *community_direct_str(int direct) |
19070 | { | |
19071 | switch (direct) { | |
19072 | case COMMUNITY_DENY: | |
19073 | return "deny"; | |
19074 | case COMMUNITY_PERMIT: | |
19075 | return "permit"; | |
19076 | default: | |
19077 | return "unknown"; | |
19078 | } | |
718e3744 | 19079 | } |
19080 | ||
19081 | /* Display error string. */ | |
d62a17ae | 19082 | static void community_list_perror(struct vty *vty, int ret) |
19083 | { | |
19084 | switch (ret) { | |
19085 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19086 | vty_out(vty, "%% Can't find community-list\n"); | |
19087 | break; | |
19088 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19089 | vty_out(vty, "%% Malformed community-list value\n"); | |
19090 | break; | |
19091 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19092 | vty_out(vty, | |
19093 | "%% Community name conflict, previously defined as standard community\n"); | |
19094 | break; | |
19095 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19096 | vty_out(vty, | |
19097 | "%% Community name conflict, previously defined as expanded community\n"); | |
19098 | break; | |
19099 | } | |
718e3744 | 19100 | } |
19101 | ||
5bf15956 DW |
19102 | /* "community-list" keyword help string. */ |
19103 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19104 | ||
7336e101 SP |
19105 | /*community-list standard */ |
19106 | DEFUN (community_list_standard, | |
19107 | bgp_community_list_standard_cmd, | |
a08032fe | 19108 | "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19109 | BGP_STR |
718e3744 | 19110 | COMMUNITY_LIST_STR |
19111 | "Community list number (standard)\n" | |
5bf15956 | 19112 | "Add an standard community-list entry\n" |
718e3744 | 19113 | "Community list name\n" |
2f8cc0e5 DA |
19114 | "Sequence number of an entry\n" |
19115 | "Sequence number\n" | |
718e3744 | 19116 | "Specify community to reject\n" |
19117 | "Specify community to accept\n" | |
19118 | COMMUNITY_VAL_STR) | |
19119 | { | |
d62a17ae | 19120 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19121 | char *seq = NULL; |
d62a17ae | 19122 | int direct = 0; |
19123 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 19124 | int idx = 0; |
7336e101 | 19125 | |
a08032fe | 19126 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19127 | if (idx) |
19128 | seq = argv[idx]->arg; | |
19129 | ||
19130 | idx = 0; | |
d62a17ae | 19131 | argv_find(argv, argc, "(1-99)", &idx); |
19132 | argv_find(argv, argc, "WORD", &idx); | |
19133 | cl_name_or_number = argv[idx]->arg; | |
19134 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19135 | : COMMUNITY_DENY; | |
19136 | argv_find(argv, argc, "AA:NN", &idx); | |
19137 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19138 | |
2f8cc0e5 DA |
19139 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19140 | direct, style); | |
42f914d4 | 19141 | |
d62a17ae | 19142 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19143 | |
d62a17ae | 19144 | if (ret < 0) { |
19145 | /* Display error string. */ | |
19146 | community_list_perror(vty, ret); | |
19147 | return CMD_WARNING_CONFIG_FAILED; | |
19148 | } | |
42f914d4 | 19149 | |
d62a17ae | 19150 | return CMD_SUCCESS; |
718e3744 | 19151 | } |
19152 | ||
7336e101 SP |
19153 | DEFUN (no_community_list_standard_all, |
19154 | no_bgp_community_list_standard_all_cmd, | |
a08032fe | 19155 | "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19156 | NO_STR |
19157 | BGP_STR | |
19158 | COMMUNITY_LIST_STR | |
19159 | "Community list number (standard)\n" | |
19160 | "Add an standard community-list entry\n" | |
19161 | "Community list name\n" | |
2f8cc0e5 DA |
19162 | "Sequence number of an entry\n" |
19163 | "Sequence number\n" | |
7336e101 SP |
19164 | "Specify community to reject\n" |
19165 | "Specify community to accept\n" | |
19166 | COMMUNITY_VAL_STR) | |
718e3744 | 19167 | { |
d62a17ae | 19168 | char *cl_name_or_number = NULL; |
174b5cb9 | 19169 | char *str = NULL; |
d62a17ae | 19170 | int direct = 0; |
19171 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19172 | char *seq = NULL; |
d62a17ae | 19173 | int idx = 0; |
7336e101 | 19174 | |
a08032fe | 19175 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19176 | if (idx) |
19177 | seq = argv[idx]->arg; | |
19178 | ||
19179 | idx = 0; | |
174b5cb9 DA |
19180 | argv_find(argv, argc, "permit", &idx); |
19181 | argv_find(argv, argc, "deny", &idx); | |
19182 | ||
19183 | if (idx) { | |
19184 | direct = argv_find(argv, argc, "permit", &idx) | |
19185 | ? COMMUNITY_PERMIT | |
19186 | : COMMUNITY_DENY; | |
19187 | ||
19188 | idx = 0; | |
19189 | argv_find(argv, argc, "AA:NN", &idx); | |
19190 | str = argv_concat(argv, argc, idx); | |
19191 | } | |
19192 | ||
19193 | idx = 0; | |
d62a17ae | 19194 | argv_find(argv, argc, "(1-99)", &idx); |
19195 | argv_find(argv, argc, "WORD", &idx); | |
19196 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19197 | |
2f8cc0e5 | 19198 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19199 | direct, style); |
42f914d4 | 19200 | |
d62a17ae | 19201 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19202 | |
d62a17ae | 19203 | if (ret < 0) { |
19204 | community_list_perror(vty, ret); | |
19205 | return CMD_WARNING_CONFIG_FAILED; | |
19206 | } | |
42f914d4 | 19207 | |
d62a17ae | 19208 | return CMD_SUCCESS; |
718e3744 | 19209 | } |
7336e101 | 19210 | |
174b5cb9 DA |
19211 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
19212 | "no bgp community-list <(1-99)|standard WORD>", | |
19213 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
19214 | "Community list number (standard)\n" | |
19215 | "Add an standard community-list entry\n" | |
19216 | "Community list name\n") | |
19217 | ||
7336e101 SP |
19218 | /*community-list expanded */ |
19219 | DEFUN (community_list_expanded_all, | |
19220 | bgp_community_list_expanded_all_cmd, | |
a08032fe | 19221 | "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19222 | BGP_STR |
19223 | COMMUNITY_LIST_STR | |
718e3744 | 19224 | "Community list number (expanded)\n" |
5bf15956 | 19225 | "Add an expanded community-list entry\n" |
718e3744 | 19226 | "Community list name\n" |
2f8cc0e5 DA |
19227 | "Sequence number of an entry\n" |
19228 | "Sequence number\n" | |
718e3744 | 19229 | "Specify community to reject\n" |
19230 | "Specify community to accept\n" | |
19231 | COMMUNITY_VAL_STR) | |
19232 | { | |
d62a17ae | 19233 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19234 | char *seq = NULL; |
d62a17ae | 19235 | int direct = 0; |
19236 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19237 | int idx = 0; |
7b9a4750 | 19238 | |
a08032fe | 19239 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19240 | if (idx) |
19241 | seq = argv[idx]->arg; | |
19242 | ||
19243 | idx = 0; | |
19244 | ||
d62a17ae | 19245 | argv_find(argv, argc, "(100-500)", &idx); |
19246 | argv_find(argv, argc, "WORD", &idx); | |
19247 | cl_name_or_number = argv[idx]->arg; | |
19248 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19249 | : COMMUNITY_DENY; | |
19250 | argv_find(argv, argc, "AA:NN", &idx); | |
19251 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19252 | |
2f8cc0e5 DA |
19253 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19254 | direct, style); | |
42f914d4 | 19255 | |
d62a17ae | 19256 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19257 | |
d62a17ae | 19258 | if (ret < 0) { |
19259 | /* Display error string. */ | |
19260 | community_list_perror(vty, ret); | |
19261 | return CMD_WARNING_CONFIG_FAILED; | |
19262 | } | |
42f914d4 | 19263 | |
d62a17ae | 19264 | return CMD_SUCCESS; |
718e3744 | 19265 | } |
19266 | ||
7336e101 SP |
19267 | DEFUN (no_community_list_expanded_all, |
19268 | no_bgp_community_list_expanded_all_cmd, | |
a08032fe | 19269 | "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19270 | NO_STR |
19271 | BGP_STR | |
19272 | COMMUNITY_LIST_STR | |
19273 | "Community list number (expanded)\n" | |
19274 | "Add an expanded community-list entry\n" | |
19275 | "Community list name\n" | |
2f8cc0e5 DA |
19276 | "Sequence number of an entry\n" |
19277 | "Sequence number\n" | |
7336e101 SP |
19278 | "Specify community to reject\n" |
19279 | "Specify community to accept\n" | |
19280 | COMMUNITY_VAL_STR) | |
718e3744 | 19281 | { |
d62a17ae | 19282 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19283 | char *seq = NULL; |
174b5cb9 | 19284 | char *str = NULL; |
d62a17ae | 19285 | int direct = 0; |
19286 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19287 | int idx = 0; |
174b5cb9 | 19288 | |
a08032fe | 19289 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19290 | if (idx) |
19291 | seq = argv[idx]->arg; | |
19292 | ||
19293 | idx = 0; | |
174b5cb9 DA |
19294 | argv_find(argv, argc, "permit", &idx); |
19295 | argv_find(argv, argc, "deny", &idx); | |
19296 | ||
19297 | if (idx) { | |
19298 | direct = argv_find(argv, argc, "permit", &idx) | |
19299 | ? COMMUNITY_PERMIT | |
19300 | : COMMUNITY_DENY; | |
19301 | ||
19302 | idx = 0; | |
19303 | argv_find(argv, argc, "AA:NN", &idx); | |
19304 | str = argv_concat(argv, argc, idx); | |
7336e101 | 19305 | } |
174b5cb9 DA |
19306 | |
19307 | idx = 0; | |
d62a17ae | 19308 | argv_find(argv, argc, "(100-500)", &idx); |
19309 | argv_find(argv, argc, "WORD", &idx); | |
19310 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19311 | |
2f8cc0e5 | 19312 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19313 | direct, style); |
42f914d4 | 19314 | |
d62a17ae | 19315 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19316 | |
d62a17ae | 19317 | if (ret < 0) { |
19318 | community_list_perror(vty, ret); | |
19319 | return CMD_WARNING_CONFIG_FAILED; | |
19320 | } | |
42f914d4 | 19321 | |
d62a17ae | 19322 | return CMD_SUCCESS; |
718e3744 | 19323 | } |
19324 | ||
36d4bb44 EB |
19325 | ALIAS(no_community_list_expanded_all, |
19326 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 19327 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 19328 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
19329 | "Community list number (expanded)\n" |
19330 | "Add an expanded community-list entry\n" | |
19331 | "Community list name\n") | |
19332 | ||
8d9b8ed9 PM |
19333 | /* Return configuration string of community-list entry. */ |
19334 | static const char *community_list_config_str(struct community_entry *entry) | |
19335 | { | |
19336 | const char *str; | |
19337 | ||
19338 | if (entry->any) | |
19339 | str = ""; | |
19340 | else { | |
19341 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
19342 | str = community_str(entry->u.com, false); | |
19343 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
19344 | str = lcommunity_str(entry->u.lcom, false); | |
19345 | else | |
19346 | str = entry->config; | |
19347 | } | |
19348 | return str; | |
19349 | } | |
19350 | ||
d62a17ae | 19351 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19352 | { |
d62a17ae | 19353 | struct community_entry *entry; |
718e3744 | 19354 | |
d62a17ae | 19355 | for (entry = list->head; entry; entry = entry->next) { |
19356 | if (entry == list->head) { | |
19357 | if (all_digit(list->name)) | |
19358 | vty_out(vty, "Community %s list %s\n", | |
19359 | entry->style == COMMUNITY_LIST_STANDARD | |
19360 | ? "standard" | |
19361 | : "(expanded) access", | |
19362 | list->name); | |
19363 | else | |
19364 | vty_out(vty, "Named Community %s list %s\n", | |
19365 | entry->style == COMMUNITY_LIST_STANDARD | |
19366 | ? "standard" | |
19367 | : "expanded", | |
19368 | list->name); | |
19369 | } | |
19370 | if (entry->any) | |
19371 | vty_out(vty, " %s\n", | |
19372 | community_direct_str(entry->direct)); | |
19373 | else | |
19374 | vty_out(vty, " %s %s\n", | |
19375 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19376 | community_list_config_str(entry)); |
d62a17ae | 19377 | } |
718e3744 | 19378 | } |
19379 | ||
7336e101 SP |
19380 | DEFUN (show_community_list, |
19381 | show_bgp_community_list_cmd, | |
19382 | "show bgp community-list", | |
718e3744 | 19383 | SHOW_STR |
7336e101 | 19384 | BGP_STR |
718e3744 | 19385 | "List community-list\n") |
19386 | { | |
d62a17ae | 19387 | struct community_list *list; |
19388 | struct community_list_master *cm; | |
718e3744 | 19389 | |
d62a17ae | 19390 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19391 | if (!cm) | |
19392 | return CMD_SUCCESS; | |
718e3744 | 19393 | |
d62a17ae | 19394 | for (list = cm->num.head; list; list = list->next) |
19395 | community_list_show(vty, list); | |
718e3744 | 19396 | |
d62a17ae | 19397 | for (list = cm->str.head; list; list = list->next) |
19398 | community_list_show(vty, list); | |
718e3744 | 19399 | |
d62a17ae | 19400 | return CMD_SUCCESS; |
718e3744 | 19401 | } |
19402 | ||
7336e101 SP |
19403 | DEFUN (show_community_list_arg, |
19404 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 19405 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
19406 | SHOW_STR |
19407 | BGP_STR | |
718e3744 | 19408 | "List community-list\n" |
19409 | "Community-list number\n" | |
960b69b9 | 19410 | "Community-list name\n" |
19411 | "Detailed information on community-list\n") | |
718e3744 | 19412 | { |
d62a17ae | 19413 | int idx_comm_list = 3; |
19414 | struct community_list *list; | |
718e3744 | 19415 | |
e237b0d2 | 19416 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19417 | COMMUNITY_LIST_MASTER); |
19418 | if (!list) { | |
19419 | vty_out(vty, "%% Can't find community-list\n"); | |
19420 | return CMD_WARNING; | |
19421 | } | |
718e3744 | 19422 | |
d62a17ae | 19423 | community_list_show(vty, list); |
718e3744 | 19424 | |
d62a17ae | 19425 | return CMD_SUCCESS; |
718e3744 | 19426 | } |
6b0655a2 | 19427 | |
57d187bc JS |
19428 | /* |
19429 | * Large Community code. | |
19430 | */ | |
d62a17ae | 19431 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19432 | struct cmd_token **argv, int style, | |
19433 | int reject_all_digit_name) | |
19434 | { | |
19435 | int ret; | |
19436 | int direct; | |
19437 | char *str; | |
19438 | int idx = 0; | |
19439 | char *cl_name; | |
2f8cc0e5 DA |
19440 | char *seq = NULL; |
19441 | ||
a08032fe | 19442 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19443 | seq = argv[idx]->arg; |
d62a17ae | 19444 | |
2f8cc0e5 | 19445 | idx = 0; |
d62a17ae | 19446 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19447 | : COMMUNITY_DENY; | |
19448 | ||
19449 | /* All digit name check. */ | |
19450 | idx = 0; | |
19451 | argv_find(argv, argc, "WORD", &idx); | |
19452 | argv_find(argv, argc, "(1-99)", &idx); | |
19453 | argv_find(argv, argc, "(100-500)", &idx); | |
19454 | cl_name = argv[idx]->arg; | |
19455 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19456 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19457 | return CMD_WARNING_CONFIG_FAILED; | |
19458 | } | |
19459 | ||
19460 | idx = 0; | |
19461 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19462 | argv_find(argv, argc, "LINE", &idx); | |
19463 | /* Concat community string argument. */ | |
19464 | if (idx) | |
19465 | str = argv_concat(argv, argc, idx); | |
19466 | else | |
19467 | str = NULL; | |
19468 | ||
2f8cc0e5 | 19469 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19470 | |
19471 | /* Free temporary community list string allocated by | |
19472 | argv_concat(). */ | |
0a22ddfb | 19473 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19474 | |
19475 | if (ret < 0) { | |
19476 | community_list_perror(vty, ret); | |
19477 | return CMD_WARNING_CONFIG_FAILED; | |
19478 | } | |
19479 | return CMD_SUCCESS; | |
19480 | } | |
19481 | ||
19482 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19483 | struct cmd_token **argv, int style) | |
19484 | { | |
19485 | int ret; | |
19486 | int direct = 0; | |
19487 | char *str = NULL; | |
19488 | int idx = 0; | |
2f8cc0e5 | 19489 | char *seq = NULL; |
d62a17ae | 19490 | |
a08032fe | 19491 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19492 | seq = argv[idx]->arg; |
d62a17ae | 19493 | |
2f8cc0e5 | 19494 | idx = 0; |
d62a17ae | 19495 | argv_find(argv, argc, "permit", &idx); |
19496 | argv_find(argv, argc, "deny", &idx); | |
19497 | ||
19498 | if (idx) { | |
19499 | /* Check the list direct. */ | |
19500 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19501 | direct = COMMUNITY_PERMIT; | |
19502 | else | |
19503 | direct = COMMUNITY_DENY; | |
19504 | ||
19505 | idx = 0; | |
19506 | argv_find(argv, argc, "LINE", &idx); | |
19507 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19508 | /* Concat community string argument. */ | |
19509 | str = argv_concat(argv, argc, idx); | |
19510 | } | |
19511 | ||
19512 | idx = 0; | |
19513 | argv_find(argv, argc, "(1-99)", &idx); | |
19514 | argv_find(argv, argc, "(100-500)", &idx); | |
19515 | argv_find(argv, argc, "WORD", &idx); | |
19516 | ||
19517 | /* Unset community list. */ | |
2f8cc0e5 | 19518 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19519 | style); |
19520 | ||
19521 | /* Free temporary community list string allocated by | |
19522 | argv_concat(). */ | |
0a22ddfb | 19523 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19524 | |
19525 | if (ret < 0) { | |
19526 | community_list_perror(vty, ret); | |
19527 | return CMD_WARNING_CONFIG_FAILED; | |
19528 | } | |
19529 | ||
19530 | return CMD_SUCCESS; | |
57d187bc JS |
19531 | } |
19532 | ||
19533 | /* "large-community-list" keyword help string. */ | |
19534 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19535 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19536 | ||
7336e101 SP |
19537 | DEFUN (lcommunity_list_standard, |
19538 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19539 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19540 | BGP_STR |
19541 | LCOMMUNITY_LIST_STR | |
19542 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19543 | "Sequence number of an entry\n" |
19544 | "Sequence number\n" | |
7336e101 SP |
19545 | "Specify large community to reject\n" |
19546 | "Specify large community to accept\n" | |
19547 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19548 | { |
d62a17ae | 19549 | return lcommunity_list_set_vty(vty, argc, argv, |
19550 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19551 | } |
19552 | ||
7336e101 SP |
19553 | DEFUN (lcommunity_list_expanded, |
19554 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19555 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19556 | BGP_STR |
19557 | LCOMMUNITY_LIST_STR | |
19558 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19559 | "Sequence number of an entry\n" |
19560 | "Sequence number\n" | |
7336e101 SP |
19561 | "Specify large community to reject\n" |
19562 | "Specify large community to accept\n" | |
19563 | "An ordered list as a regular-expression\n") | |
57d187bc | 19564 | { |
d62a17ae | 19565 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19566 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19567 | } |
19568 | ||
7336e101 SP |
19569 | DEFUN (lcommunity_list_name_standard, |
19570 | bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 19571 | "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19572 | BGP_STR |
19573 | LCOMMUNITY_LIST_STR | |
19574 | "Specify standard large-community-list\n" | |
19575 | "Large Community list name\n" | |
2f8cc0e5 DA |
19576 | "Sequence number of an entry\n" |
19577 | "Sequence number\n" | |
7336e101 SP |
19578 | "Specify large community to reject\n" |
19579 | "Specify large community to accept\n" | |
19580 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19581 | { |
d62a17ae | 19582 | return lcommunity_list_set_vty(vty, argc, argv, |
19583 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19584 | } |
19585 | ||
7336e101 SP |
19586 | DEFUN (lcommunity_list_name_expanded, |
19587 | bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 19588 | "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19589 | BGP_STR |
19590 | LCOMMUNITY_LIST_STR | |
19591 | "Specify expanded large-community-list\n" | |
19592 | "Large Community list name\n" | |
2f8cc0e5 DA |
19593 | "Sequence number of an entry\n" |
19594 | "Sequence number\n" | |
7336e101 SP |
19595 | "Specify large community to reject\n" |
19596 | "Specify large community to accept\n" | |
19597 | "An ordered list as a regular-expression\n") | |
57d187bc | 19598 | { |
d62a17ae | 19599 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19600 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19601 | } |
19602 | ||
4378f57c DA |
19603 | DEFUN (no_lcommunity_list_all, |
19604 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
19605 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
19606 | NO_STR | |
19607 | BGP_STR | |
19608 | LCOMMUNITY_LIST_STR | |
19609 | "Large Community list number (standard)\n" | |
19610 | "Large Community list number (expanded)\n" | |
19611 | "Large Community list name\n") | |
57d187bc | 19612 | { |
7336e101 SP |
19613 | return lcommunity_list_unset_vty(vty, argc, argv, |
19614 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19615 | } |
19616 | ||
4378f57c DA |
19617 | DEFUN (no_lcommunity_list_name_standard_all, |
19618 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19619 | "no bgp large-community-list standard WORD", | |
19620 | NO_STR | |
19621 | BGP_STR | |
19622 | LCOMMUNITY_LIST_STR | |
19623 | "Specify standard large-community-list\n" | |
19624 | "Large Community list name\n") | |
19625 | { | |
19626 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19627 | LARGE_COMMUNITY_LIST_STANDARD); | |
19628 | } | |
19629 | ||
7336e101 SP |
19630 | DEFUN (no_lcommunity_list_name_expanded_all, |
19631 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19632 | "no bgp large-community-list expanded WORD", | |
19633 | NO_STR | |
19634 | BGP_STR | |
19635 | LCOMMUNITY_LIST_STR | |
19636 | "Specify expanded large-community-list\n" | |
19637 | "Large Community list name\n") | |
57d187bc | 19638 | { |
d62a17ae | 19639 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19640 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19641 | } |
19642 | ||
7336e101 SP |
19643 | DEFUN (no_lcommunity_list_standard, |
19644 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19645 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19646 | NO_STR |
19647 | BGP_STR | |
19648 | LCOMMUNITY_LIST_STR | |
19649 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19650 | "Sequence number of an entry\n" |
19651 | "Sequence number\n" | |
7336e101 SP |
19652 | "Specify large community to reject\n" |
19653 | "Specify large community to accept\n" | |
19654 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19655 | { |
d62a17ae | 19656 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19657 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19658 | } |
19659 | ||
7336e101 SP |
19660 | DEFUN (no_lcommunity_list_expanded, |
19661 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19662 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19663 | NO_STR |
19664 | BGP_STR | |
19665 | LCOMMUNITY_LIST_STR | |
19666 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19667 | "Sequence number of an entry\n" |
19668 | "Sequence number\n" | |
7336e101 SP |
19669 | "Specify large community to reject\n" |
19670 | "Specify large community to accept\n" | |
19671 | "An ordered list as a regular-expression\n") | |
57d187bc | 19672 | { |
d62a17ae | 19673 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19674 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19675 | } |
19676 | ||
7336e101 SP |
19677 | DEFUN (no_lcommunity_list_name_standard, |
19678 | no_bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 19679 | "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19680 | NO_STR |
19681 | BGP_STR | |
19682 | LCOMMUNITY_LIST_STR | |
19683 | "Specify standard large-community-list\n" | |
19684 | "Large Community list name\n" | |
2f8cc0e5 DA |
19685 | "Sequence number of an entry\n" |
19686 | "Sequence number\n" | |
7336e101 SP |
19687 | "Specify large community to reject\n" |
19688 | "Specify large community to accept\n" | |
19689 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19690 | { |
d62a17ae | 19691 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19692 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19693 | } |
19694 | ||
7336e101 SP |
19695 | DEFUN (no_lcommunity_list_name_expanded, |
19696 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 19697 | "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19698 | NO_STR |
19699 | BGP_STR | |
19700 | LCOMMUNITY_LIST_STR | |
19701 | "Specify expanded large-community-list\n" | |
19702 | "Large community list name\n" | |
2f8cc0e5 DA |
19703 | "Sequence number of an entry\n" |
19704 | "Sequence number\n" | |
7336e101 SP |
19705 | "Specify large community to reject\n" |
19706 | "Specify large community to accept\n" | |
19707 | "An ordered list as a regular-expression\n") | |
57d187bc | 19708 | { |
d62a17ae | 19709 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19710 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19711 | } |
19712 | ||
d62a17ae | 19713 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19714 | { | |
19715 | struct community_entry *entry; | |
19716 | ||
19717 | for (entry = list->head; entry; entry = entry->next) { | |
19718 | if (entry == list->head) { | |
19719 | if (all_digit(list->name)) | |
19720 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19721 | entry->style == |
19722 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19723 | ? "standard" |
19724 | : "(expanded) access", | |
19725 | list->name); | |
19726 | else | |
19727 | vty_out(vty, | |
19728 | "Named large community %s list %s\n", | |
169b72c8 | 19729 | entry->style == |
19730 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19731 | ? "standard" |
19732 | : "expanded", | |
19733 | list->name); | |
19734 | } | |
19735 | if (entry->any) | |
19736 | vty_out(vty, " %s\n", | |
19737 | community_direct_str(entry->direct)); | |
19738 | else | |
19739 | vty_out(vty, " %s %s\n", | |
19740 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19741 | community_list_config_str(entry)); |
d62a17ae | 19742 | } |
57d187bc JS |
19743 | } |
19744 | ||
7336e101 SP |
19745 | DEFUN (show_lcommunity_list, |
19746 | show_bgp_lcommunity_list_cmd, | |
19747 | "show bgp large-community-list", | |
57d187bc | 19748 | SHOW_STR |
7336e101 | 19749 | BGP_STR |
57d187bc JS |
19750 | "List large-community list\n") |
19751 | { | |
d62a17ae | 19752 | struct community_list *list; |
19753 | struct community_list_master *cm; | |
57d187bc | 19754 | |
d62a17ae | 19755 | cm = community_list_master_lookup(bgp_clist, |
19756 | LARGE_COMMUNITY_LIST_MASTER); | |
19757 | if (!cm) | |
19758 | return CMD_SUCCESS; | |
57d187bc | 19759 | |
d62a17ae | 19760 | for (list = cm->num.head; list; list = list->next) |
19761 | lcommunity_list_show(vty, list); | |
57d187bc | 19762 | |
d62a17ae | 19763 | for (list = cm->str.head; list; list = list->next) |
19764 | lcommunity_list_show(vty, list); | |
57d187bc | 19765 | |
d62a17ae | 19766 | return CMD_SUCCESS; |
57d187bc JS |
19767 | } |
19768 | ||
7336e101 SP |
19769 | DEFUN (show_lcommunity_list_arg, |
19770 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 19771 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
19772 | SHOW_STR |
19773 | BGP_STR | |
57d187bc | 19774 | "List large-community list\n" |
960b69b9 | 19775 | "Large-community-list number\n" |
19776 | "Large-community-list name\n" | |
19777 | "Detailed information on large-community-list\n") | |
57d187bc | 19778 | { |
d62a17ae | 19779 | struct community_list *list; |
57d187bc | 19780 | |
e237b0d2 | 19781 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19782 | LARGE_COMMUNITY_LIST_MASTER); |
19783 | if (!list) { | |
960b69b9 | 19784 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19785 | return CMD_WARNING; |
19786 | } | |
57d187bc | 19787 | |
d62a17ae | 19788 | lcommunity_list_show(vty, list); |
57d187bc | 19789 | |
d62a17ae | 19790 | return CMD_SUCCESS; |
57d187bc JS |
19791 | } |
19792 | ||
718e3744 | 19793 | /* "extcommunity-list" keyword help string. */ |
19794 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19795 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19796 | ||
7336e101 SP |
19797 | DEFUN (extcommunity_list_standard, |
19798 | bgp_extcommunity_list_standard_cmd, | |
a08032fe | 19799 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19800 | BGP_STR |
718e3744 | 19801 | EXTCOMMUNITY_LIST_STR |
19802 | "Extended Community list number (standard)\n" | |
718e3744 | 19803 | "Specify standard extcommunity-list\n" |
5bf15956 | 19804 | "Community list name\n" |
2f8cc0e5 DA |
19805 | "Sequence number of an entry\n" |
19806 | "Sequence number\n" | |
718e3744 | 19807 | "Specify community to reject\n" |
19808 | "Specify community to accept\n" | |
19809 | EXTCOMMUNITY_VAL_STR) | |
19810 | { | |
d62a17ae | 19811 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19812 | int direct = 0; | |
19813 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19814 | char *seq = NULL; |
42f914d4 | 19815 | |
d62a17ae | 19816 | int idx = 0; |
7b9a4750 | 19817 | |
d62a17ae | 19818 | argv_find(argv, argc, "(1-99)", &idx); |
19819 | argv_find(argv, argc, "WORD", &idx); | |
19820 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19821 | |
a08032fe | 19822 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19823 | seq = argv[idx]->arg; |
19824 | ||
d62a17ae | 19825 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19826 | : COMMUNITY_DENY; | |
19827 | argv_find(argv, argc, "AA:NN", &idx); | |
19828 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19829 | |
2f8cc0e5 | 19830 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19831 | direct, style); |
42f914d4 | 19832 | |
d62a17ae | 19833 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19834 | |
d62a17ae | 19835 | if (ret < 0) { |
19836 | community_list_perror(vty, ret); | |
19837 | return CMD_WARNING_CONFIG_FAILED; | |
19838 | } | |
42f914d4 | 19839 | |
d62a17ae | 19840 | return CMD_SUCCESS; |
718e3744 | 19841 | } |
19842 | ||
7336e101 SP |
19843 | DEFUN (extcommunity_list_name_expanded, |
19844 | bgp_extcommunity_list_name_expanded_cmd, | |
a08032fe | 19845 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19846 | BGP_STR |
19847 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19848 | "Extended Community list number (expanded)\n" |
718e3744 | 19849 | "Specify expanded extcommunity-list\n" |
19850 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19851 | "Sequence number of an entry\n" |
19852 | "Sequence number\n" | |
718e3744 | 19853 | "Specify community to reject\n" |
19854 | "Specify community to accept\n" | |
19855 | "An ordered list as a regular-expression\n") | |
19856 | { | |
d62a17ae | 19857 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19858 | int direct = 0; | |
19859 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19860 | char *seq = NULL; |
d62a17ae | 19861 | int idx = 0; |
7336e101 | 19862 | |
d62a17ae | 19863 | argv_find(argv, argc, "(100-500)", &idx); |
19864 | argv_find(argv, argc, "WORD", &idx); | |
19865 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19866 | |
a08032fe | 19867 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19868 | seq = argv[idx]->arg; |
19869 | ||
d62a17ae | 19870 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19871 | : COMMUNITY_DENY; | |
19872 | argv_find(argv, argc, "LINE", &idx); | |
19873 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19874 | |
2f8cc0e5 | 19875 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19876 | direct, style); |
42f914d4 | 19877 | |
d62a17ae | 19878 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19879 | |
d62a17ae | 19880 | if (ret < 0) { |
19881 | community_list_perror(vty, ret); | |
19882 | return CMD_WARNING_CONFIG_FAILED; | |
19883 | } | |
42f914d4 | 19884 | |
d62a17ae | 19885 | return CMD_SUCCESS; |
718e3744 | 19886 | } |
19887 | ||
7336e101 SP |
19888 | DEFUN (no_extcommunity_list_standard_all, |
19889 | no_bgp_extcommunity_list_standard_all_cmd, | |
a08032fe | 19890 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19891 | NO_STR |
19892 | BGP_STR | |
19893 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19894 | "Extended Community list number (standard)\n" |
718e3744 | 19895 | "Specify standard extcommunity-list\n" |
5bf15956 | 19896 | "Community list name\n" |
2f8cc0e5 DA |
19897 | "Sequence number of an entry\n" |
19898 | "Sequence number\n" | |
718e3744 | 19899 | "Specify community to reject\n" |
19900 | "Specify community to accept\n" | |
19901 | EXTCOMMUNITY_VAL_STR) | |
19902 | { | |
d62a17ae | 19903 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19904 | int direct = 0; | |
19905 | char *cl_number_or_name = NULL; | |
d4455c89 | 19906 | char *str = NULL; |
2f8cc0e5 | 19907 | char *seq = NULL; |
d62a17ae | 19908 | int idx = 0; |
d4455c89 | 19909 | |
a08032fe | 19910 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19911 | seq = argv[idx]->arg; |
19912 | ||
19913 | idx = 0; | |
d4455c89 DA |
19914 | argv_find(argv, argc, "permit", &idx); |
19915 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19916 | if (idx) { |
19917 | direct = argv_find(argv, argc, "permit", &idx) | |
19918 | ? COMMUNITY_PERMIT | |
19919 | : COMMUNITY_DENY; | |
19920 | ||
19921 | idx = 0; | |
19922 | argv_find(argv, argc, "AA:NN", &idx); | |
19923 | str = argv_concat(argv, argc, idx); | |
19924 | } | |
19925 | ||
19926 | idx = 0; | |
d62a17ae | 19927 | argv_find(argv, argc, "(1-99)", &idx); |
19928 | argv_find(argv, argc, "WORD", &idx); | |
19929 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19930 | |
d62a17ae | 19931 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19932 | seq, direct, style); |
42f914d4 | 19933 | |
d62a17ae | 19934 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19935 | |
d62a17ae | 19936 | if (ret < 0) { |
19937 | community_list_perror(vty, ret); | |
19938 | return CMD_WARNING_CONFIG_FAILED; | |
19939 | } | |
42f914d4 | 19940 | |
d62a17ae | 19941 | return CMD_SUCCESS; |
718e3744 | 19942 | } |
19943 | ||
d4455c89 DA |
19944 | ALIAS(no_extcommunity_list_standard_all, |
19945 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19946 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 19947 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19948 | "Extended Community list number (standard)\n" |
19949 | "Specify standard extcommunity-list\n" | |
19950 | "Community list name\n") | |
19951 | ||
7336e101 SP |
19952 | DEFUN (no_extcommunity_list_expanded_all, |
19953 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a08032fe | 19954 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19955 | NO_STR |
19956 | BGP_STR | |
19957 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19958 | "Extended Community list number (expanded)\n" |
718e3744 | 19959 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19960 | "Extended Community list name\n" |
2f8cc0e5 DA |
19961 | "Sequence number of an entry\n" |
19962 | "Sequence number\n" | |
718e3744 | 19963 | "Specify community to reject\n" |
19964 | "Specify community to accept\n" | |
19965 | "An ordered list as a regular-expression\n") | |
19966 | { | |
d62a17ae | 19967 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19968 | int direct = 0; | |
19969 | char *cl_number_or_name = NULL; | |
d4455c89 | 19970 | char *str = NULL; |
2f8cc0e5 | 19971 | char *seq = NULL; |
d62a17ae | 19972 | int idx = 0; |
d4455c89 | 19973 | |
a08032fe | 19974 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19975 | seq = argv[idx]->arg; |
19976 | ||
19977 | idx = 0; | |
d4455c89 DA |
19978 | argv_find(argv, argc, "permit", &idx); |
19979 | argv_find(argv, argc, "deny", &idx); | |
19980 | ||
19981 | if (idx) { | |
19982 | direct = argv_find(argv, argc, "permit", &idx) | |
19983 | ? COMMUNITY_PERMIT | |
19984 | : COMMUNITY_DENY; | |
19985 | ||
19986 | idx = 0; | |
19987 | argv_find(argv, argc, "LINE", &idx); | |
19988 | str = argv_concat(argv, argc, idx); | |
19989 | } | |
19990 | ||
19991 | idx = 0; | |
d62a17ae | 19992 | argv_find(argv, argc, "(100-500)", &idx); |
19993 | argv_find(argv, argc, "WORD", &idx); | |
19994 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19995 | |
d62a17ae | 19996 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19997 | seq, direct, style); |
42f914d4 | 19998 | |
d62a17ae | 19999 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20000 | |
d62a17ae | 20001 | if (ret < 0) { |
20002 | community_list_perror(vty, ret); | |
20003 | return CMD_WARNING_CONFIG_FAILED; | |
20004 | } | |
42f914d4 | 20005 | |
d62a17ae | 20006 | return CMD_SUCCESS; |
718e3744 | 20007 | } |
20008 | ||
d4455c89 DA |
20009 | ALIAS(no_extcommunity_list_expanded_all, |
20010 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
20011 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 20012 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20013 | "Extended Community list number (expanded)\n" |
20014 | "Specify expanded extcommunity-list\n" | |
20015 | "Extended Community list name\n") | |
20016 | ||
d62a17ae | 20017 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20018 | { |
d62a17ae | 20019 | struct community_entry *entry; |
718e3744 | 20020 | |
d62a17ae | 20021 | for (entry = list->head; entry; entry = entry->next) { |
20022 | if (entry == list->head) { | |
20023 | if (all_digit(list->name)) | |
20024 | vty_out(vty, "Extended community %s list %s\n", | |
20025 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20026 | ? "standard" | |
20027 | : "(expanded) access", | |
20028 | list->name); | |
20029 | else | |
20030 | vty_out(vty, | |
20031 | "Named extended community %s list %s\n", | |
20032 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20033 | ? "standard" | |
20034 | : "expanded", | |
20035 | list->name); | |
20036 | } | |
20037 | if (entry->any) | |
20038 | vty_out(vty, " %s\n", | |
20039 | community_direct_str(entry->direct)); | |
20040 | else | |
20041 | vty_out(vty, " %s %s\n", | |
20042 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20043 | community_list_config_str(entry)); |
d62a17ae | 20044 | } |
718e3744 | 20045 | } |
20046 | ||
7336e101 SP |
20047 | DEFUN (show_extcommunity_list, |
20048 | show_bgp_extcommunity_list_cmd, | |
20049 | "show bgp extcommunity-list", | |
718e3744 | 20050 | SHOW_STR |
7336e101 | 20051 | BGP_STR |
718e3744 | 20052 | "List extended-community list\n") |
20053 | { | |
d62a17ae | 20054 | struct community_list *list; |
20055 | struct community_list_master *cm; | |
718e3744 | 20056 | |
d62a17ae | 20057 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
20058 | if (!cm) | |
20059 | return CMD_SUCCESS; | |
718e3744 | 20060 | |
d62a17ae | 20061 | for (list = cm->num.head; list; list = list->next) |
20062 | extcommunity_list_show(vty, list); | |
718e3744 | 20063 | |
d62a17ae | 20064 | for (list = cm->str.head; list; list = list->next) |
20065 | extcommunity_list_show(vty, list); | |
718e3744 | 20066 | |
d62a17ae | 20067 | return CMD_SUCCESS; |
718e3744 | 20068 | } |
20069 | ||
7336e101 SP |
20070 | DEFUN (show_extcommunity_list_arg, |
20071 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 20072 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
20073 | SHOW_STR |
20074 | BGP_STR | |
718e3744 | 20075 | "List extended-community list\n" |
20076 | "Extcommunity-list number\n" | |
960b69b9 | 20077 | "Extcommunity-list name\n" |
20078 | "Detailed information on extcommunity-list\n") | |
718e3744 | 20079 | { |
d62a17ae | 20080 | int idx_comm_list = 3; |
20081 | struct community_list *list; | |
718e3744 | 20082 | |
e237b0d2 | 20083 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20084 | EXTCOMMUNITY_LIST_MASTER); |
20085 | if (!list) { | |
20086 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20087 | return CMD_WARNING; | |
20088 | } | |
718e3744 | 20089 | |
d62a17ae | 20090 | extcommunity_list_show(vty, list); |
718e3744 | 20091 | |
d62a17ae | 20092 | return CMD_SUCCESS; |
718e3744 | 20093 | } |
6b0655a2 | 20094 | |
718e3744 | 20095 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 20096 | static int community_list_config_write(struct vty *vty) |
20097 | { | |
20098 | struct community_list *list; | |
20099 | struct community_entry *entry; | |
20100 | struct community_list_master *cm; | |
20101 | int write = 0; | |
20102 | ||
20103 | /* Community-list. */ | |
20104 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20105 | ||
20106 | for (list = cm->num.head; list; list = list->next) | |
20107 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20108 | vty_out(vty, |
20109 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20110 | list->name, entry->seq, | |
d62a17ae | 20111 | community_direct_str(entry->direct), |
20112 | community_list_config_str(entry)); | |
20113 | write++; | |
20114 | } | |
20115 | for (list = cm->str.head; list; list = list->next) | |
20116 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20117 | vty_out(vty, |
20118 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 20119 | entry->style == COMMUNITY_LIST_STANDARD |
20120 | ? "standard" | |
20121 | : "expanded", | |
2f8cc0e5 DA |
20122 | list->name, entry->seq, |
20123 | community_direct_str(entry->direct), | |
d62a17ae | 20124 | community_list_config_str(entry)); |
20125 | write++; | |
20126 | } | |
20127 | ||
20128 | /* Extcommunity-list. */ | |
20129 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20130 | ||
20131 | for (list = cm->num.head; list; list = list->next) | |
20132 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20133 | vty_out(vty, |
20134 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20135 | list->name, entry->seq, | |
20136 | community_direct_str(entry->direct), | |
d62a17ae | 20137 | community_list_config_str(entry)); |
20138 | write++; | |
20139 | } | |
20140 | for (list = cm->str.head; list; list = list->next) | |
20141 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20142 | vty_out(vty, |
6cde4b45 | 20143 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20144 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20145 | ? "standard" | |
20146 | : "expanded", | |
2f8cc0e5 DA |
20147 | list->name, entry->seq, |
20148 | community_direct_str(entry->direct), | |
d62a17ae | 20149 | community_list_config_str(entry)); |
20150 | write++; | |
20151 | } | |
20152 | ||
20153 | ||
20154 | /* lcommunity-list. */ | |
20155 | cm = community_list_master_lookup(bgp_clist, | |
20156 | LARGE_COMMUNITY_LIST_MASTER); | |
20157 | ||
20158 | for (list = cm->num.head; list; list = list->next) | |
20159 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20160 | vty_out(vty, |
6cde4b45 | 20161 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20162 | list->name, entry->seq, |
20163 | community_direct_str(entry->direct), | |
d62a17ae | 20164 | community_list_config_str(entry)); |
20165 | write++; | |
20166 | } | |
20167 | for (list = cm->str.head; list; list = list->next) | |
20168 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20169 | vty_out(vty, |
6cde4b45 | 20170 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20171 | |
d62a17ae | 20172 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20173 | ? "standard" | |
20174 | : "expanded", | |
2f8cc0e5 | 20175 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20176 | community_list_config_str(entry)); |
20177 | write++; | |
20178 | } | |
20179 | ||
20180 | return write; | |
20181 | } | |
20182 | ||
612c2c15 | 20183 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20184 | static struct cmd_node community_list_node = { |
f4b8291f | 20185 | .name = "community list", |
62b346ee DL |
20186 | .node = COMMUNITY_LIST_NODE, |
20187 | .prompt = "", | |
612c2c15 | 20188 | .config_write = community_list_config_write, |
718e3744 | 20189 | }; |
20190 | ||
d62a17ae | 20191 | static void community_list_vty(void) |
20192 | { | |
612c2c15 | 20193 | install_node(&community_list_node); |
d62a17ae | 20194 | |
20195 | /* Community-list. */ | |
7336e101 SP |
20196 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20197 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20198 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20199 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20200 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20201 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20202 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20203 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20204 | |
20205 | /* Extcommunity-list. */ | |
7336e101 SP |
20206 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20207 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20208 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20209 | install_element(CONFIG_NODE, |
20210 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20211 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20212 | install_element(CONFIG_NODE, |
20213 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20214 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20215 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20216 | |
20217 | /* Large Community List */ | |
7336e101 | 20218 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20219 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20220 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20221 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20222 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20223 | install_element(CONFIG_NODE, | |
20224 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20225 | install_element(CONFIG_NODE, |
20226 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20227 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20228 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20229 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20230 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20231 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20232 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 20233 | } |