]>
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" |
4ab46701 | 25 | #include "lib/sockopt.h" |
5cb5f4d0 | 26 | #include "lib_errors.h" |
ec0ab544 | 27 | #include "lib/zclient.h" |
6f4eacf3 | 28 | #include "lib/printfrr.h" |
718e3744 | 29 | #include "prefix.h" |
30 | #include "plist.h" | |
31 | #include "buffer.h" | |
32 | #include "linklist.h" | |
33 | #include "stream.h" | |
34 | #include "thread.h" | |
35 | #include "log.h" | |
3b8b1855 | 36 | #include "memory.h" |
1c0d8808 | 37 | #include "lib_vty.h" |
4bf6a362 | 38 | #include "hash.h" |
3f9c7369 | 39 | #include "queue.h" |
039f3a34 | 40 | #include "filter.h" |
5d5ba018 | 41 | #include "frrstr.h" |
718e3744 | 42 | |
43 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 44 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 45 | #include "bgpd/bgp_advertise.h" |
718e3744 | 46 | #include "bgpd/bgp_attr.h" |
47 | #include "bgpd/bgp_aspath.h" | |
48 | #include "bgpd/bgp_community.h" | |
ed0e57e3 | 49 | #include "bgpd/bgp_community_alias.h" |
4bf6a362 | 50 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 51 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 52 | #include "bgpd/bgp_damp.h" |
718e3744 | 53 | #include "bgpd/bgp_debug.h" |
14454c9f | 54 | #include "bgpd/bgp_errors.h" |
e0701b79 | 55 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 56 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 57 | #include "bgpd/bgp_open.h" |
4bf6a362 | 58 | #include "bgpd/bgp_regex.h" |
718e3744 | 59 | #include "bgpd/bgp_route.h" |
c016b6c7 | 60 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 61 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 62 | #include "bgpd/bgp_table.h" |
94f2b392 | 63 | #include "bgpd/bgp_vty.h" |
165b5fff | 64 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 65 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 66 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 67 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 68 | #include "bgpd/bgp_io.h" |
94c2f693 | 69 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 70 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 71 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 72 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 73 | #include "bgpd/bgp_mac.h" |
dd65f45e | 74 | #include "bgpd/bgp_flowspec.h" |
389e4f92 | 75 | #include "bgpd/bgp_conditional_adv.h" |
49e5a4a0 | 76 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
77 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
78 | #endif | |
79 | ||
ff8a8a7a CS |
80 | #include "northbound.h" |
81 | #include "northbound_cli.h" | |
82 | #include "bgpd/bgp_nb.h" | |
83 | ||
84 | ||
5d5393b9 | 85 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
86 | { |
87 | .val_bool = false, | |
88 | .match_profile = "traditional", | |
89 | .match_version = "< 7.4", | |
90 | }, | |
91 | { .val_bool = true }, | |
67b0f40c | 92 | ); |
5d5393b9 | 93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
94 | { .val_bool = true, .match_profile = "datacenter", }, |
95 | { .val_bool = false }, | |
67b0f40c | 96 | ); |
aef999a2 DA |
97 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
98 | { .val_bool = true, .match_profile = "datacenter", }, | |
99 | { .val_bool = false }, | |
67b0f40c | 100 | ); |
5d5393b9 | 101 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
102 | { .val_bool = true, .match_profile = "datacenter", }, |
103 | { .val_bool = false }, | |
67b0f40c | 104 | ); |
5d5393b9 | 105 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
106 | { .val_bool = true, .match_profile = "datacenter", }, |
107 | { .val_bool = false }, | |
67b0f40c | 108 | ); |
5d5393b9 DL |
109 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
110 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 120 }, | |
67b0f40c | 112 | ); |
5d5393b9 DL |
113 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
114 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 180 }, | |
67b0f40c | 116 | ); |
5d5393b9 DL |
117 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
118 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
119 | { .val_ulong = 60 }, | |
67b0f40c | 120 | ); |
1d3fdccf DA |
121 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
122 | { .val_bool = false, .match_profile = "datacenter", }, | |
123 | { .val_bool = false, .match_version = "< 7.4", }, | |
124 | { .val_bool = true }, | |
67b0f40c | 125 | ); |
2adac256 DA |
126 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
127 | { .val_bool = false, .match_version = "< 7.6", }, | |
128 | { .val_bool = true }, | |
67b0f40c | 129 | ); |
5d5393b9 | 130 | |
dd65f45e DL |
131 | DEFINE_HOOK(bgp_inst_config_write, |
132 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
133 | (bgp, vty)); |
134 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
718e3744 | 135 | |
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 | ||
b16bcbba TA |
474 | /* |
475 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
476 | * | |
477 | * afi | |
478 | * address-family identifier | |
479 | * | |
480 | * safi | |
481 | * subsequent address-family identifier | |
482 | * | |
483 | * Returns: | |
484 | * default_af string corresponding to the supplied afi/safi pair. | |
485 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
486 | * return -1. | |
487 | */ | |
488 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
489 | { | |
490 | switch (afi) { | |
491 | case AFI_IP: | |
492 | switch (safi) { | |
493 | case SAFI_UNICAST: | |
494 | return "ipv4-unicast"; | |
495 | case SAFI_MULTICAST: | |
496 | return "ipv4-multicast"; | |
497 | case SAFI_MPLS_VPN: | |
498 | return "ipv4-vpn"; | |
499 | case SAFI_ENCAP: | |
500 | return "ipv4-encap"; | |
501 | case SAFI_LABELED_UNICAST: | |
502 | return "ipv4-labeled-unicast"; | |
503 | case SAFI_FLOWSPEC: | |
504 | return "ipv4-flowspec"; | |
505 | default: | |
506 | return "unknown-afi/safi"; | |
507 | } | |
508 | break; | |
509 | case AFI_IP6: | |
510 | switch (safi) { | |
511 | case SAFI_UNICAST: | |
512 | return "ipv6-unicast"; | |
513 | case SAFI_MULTICAST: | |
514 | return "ipv6-multicast"; | |
515 | case SAFI_MPLS_VPN: | |
516 | return "ipv6-vpn"; | |
517 | case SAFI_ENCAP: | |
518 | return "ipv6-encap"; | |
519 | case SAFI_LABELED_UNICAST: | |
520 | return "ipv6-labeled-unicast"; | |
521 | case SAFI_FLOWSPEC: | |
522 | return "ipv6-flowspec"; | |
523 | default: | |
524 | return "unknown-afi/safi"; | |
525 | } | |
526 | break; | |
527 | case AFI_L2VPN: | |
528 | switch (safi) { | |
529 | case SAFI_EVPN: | |
530 | return "l2vpn-evpn"; | |
531 | default: | |
532 | return "unknown-afi/safi"; | |
533 | } | |
534 | case AFI_UNSPEC: | |
535 | case AFI_MAX: | |
536 | return "unknown-afi/safi"; | |
537 | } | |
538 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
539 | return "unknown-afi/safi"; | |
540 | } | |
541 | ||
5d5393b9 DL |
542 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
543 | enum bgp_instance_type inst_type) | |
544 | { | |
545 | int ret = bgp_get(bgp, as, name, inst_type); | |
546 | ||
547 | if (ret == BGP_CREATED) { | |
548 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 549 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
550 | |
551 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 552 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 553 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 554 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
555 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
556 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 557 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 558 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 559 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 560 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
561 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
562 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
563 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
564 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
5d5393b9 DL |
565 | |
566 | ret = BGP_SUCCESS; | |
567 | } | |
568 | return ret; | |
569 | } | |
570 | ||
7eeee51e | 571 | /* |
f212a857 | 572 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 573 | * |
f212a857 DS |
574 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
575 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
576 | * to appropriate values for the calling function. This is to allow the |
577 | * calling function to make decisions appropriate for the show command | |
578 | * that is being parsed. | |
579 | * | |
580 | * The show commands are generally of the form: | |
d62a17ae | 581 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
582 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
583 | * |
584 | * Since we use argv_find if the show command in particular doesn't have: | |
585 | * [ip] | |
18c57037 | 586 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 587 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
588 | * The command parsing should still be ok. |
589 | * | |
590 | * vty -> The vty for the command so we can output some useful data in | |
591 | * the event of a parse error in the vrf. | |
592 | * argv -> The command tokens | |
593 | * argc -> How many command tokens we have | |
d62a17ae | 594 | * idx -> The current place in the command, generally should be 0 for this |
595 | * function | |
7eeee51e DS |
596 | * afi -> The parsed afi if it was included in the show command, returned here |
597 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 598 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 599 | * use_json -> json is configured or not |
7eeee51e DS |
600 | * |
601 | * The function returns the correct location in the parse tree for the | |
602 | * last token found. | |
0e37c258 DS |
603 | * |
604 | * Returns 0 for failure to parse correctly, else the idx position of where | |
605 | * it found the last token. | |
7eeee51e | 606 | */ |
d62a17ae | 607 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
608 | struct cmd_token **argv, int argc, | |
609 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 610 | struct bgp **bgp, bool use_json) |
d62a17ae | 611 | { |
612 | char *vrf_name = NULL; | |
613 | ||
614 | assert(afi); | |
615 | assert(safi); | |
616 | assert(bgp); | |
617 | ||
618 | if (argv_find(argv, argc, "ip", idx)) | |
619 | *afi = AFI_IP; | |
620 | ||
9a8bdf1c | 621 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 622 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
623 | else if (argv_find(argv, argc, "vrf", idx)) { |
624 | vrf_name = argv[*idx + 1]->arg; | |
625 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
626 | vrf_name = NULL; | |
627 | } | |
628 | if (vrf_name) { | |
d62a17ae | 629 | if (strmatch(vrf_name, "all")) |
630 | *bgp = NULL; | |
631 | else { | |
632 | *bgp = bgp_lookup_by_name(vrf_name); | |
633 | if (!*bgp) { | |
52e5b8c4 SP |
634 | if (use_json) { |
635 | json_object *json = NULL; | |
636 | json = json_object_new_object(); | |
637 | json_object_string_add( | |
638 | json, "warning", | |
639 | "View/Vrf is unknown"); | |
640 | vty_out(vty, "%s\n", | |
641 | json_object_to_json_string_ext(json, | |
642 | JSON_C_TO_STRING_PRETTY)); | |
643 | json_object_free(json); | |
644 | } | |
ca61fd25 DS |
645 | else |
646 | vty_out(vty, "View/Vrf %s is unknown\n", | |
647 | vrf_name); | |
d62a17ae | 648 | *idx = 0; |
649 | return 0; | |
650 | } | |
651 | } | |
652 | } else { | |
653 | *bgp = bgp_get_default(); | |
654 | if (!*bgp) { | |
52e5b8c4 SP |
655 | if (use_json) { |
656 | json_object *json = NULL; | |
657 | json = json_object_new_object(); | |
658 | json_object_string_add( | |
659 | json, "warning", | |
660 | "Default BGP instance not found"); | |
661 | vty_out(vty, "%s\n", | |
662 | json_object_to_json_string_ext(json, | |
663 | JSON_C_TO_STRING_PRETTY)); | |
664 | json_object_free(json); | |
665 | } | |
ca61fd25 DS |
666 | else |
667 | vty_out(vty, | |
668 | "Default BGP instance not found\n"); | |
d62a17ae | 669 | *idx = 0; |
670 | return 0; | |
671 | } | |
672 | } | |
673 | ||
674 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
675 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
676 | ||
677 | *idx += 1; | |
678 | return *idx; | |
679 | } | |
680 | ||
f4b8ec07 | 681 | bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 682 | { |
683 | struct interface *ifp = NULL; | |
684 | ||
685 | if (su->sa.sa_family == AF_INET) | |
686 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
687 | else if (su->sa.sa_family == AF_INET6) | |
688 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
689 | su->sin6.sin6_scope_id, | |
690 | bgp->vrf_id); | |
691 | ||
692 | if (ifp) | |
3dc339cd | 693 | return true; |
d62a17ae | 694 | |
3dc339cd | 695 | return false; |
718e3744 | 696 | } |
697 | ||
718e3744 | 698 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
699 | /* This is used only for configuration, so disallow if attempted on |
700 | * a dynamic neighbor. | |
701 | */ | |
d62a17ae | 702 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
703 | { | |
704 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
705 | int ret; | |
706 | union sockunion su; | |
707 | struct peer *peer = NULL; | |
708 | struct peer_group *group = NULL; | |
709 | ||
710 | if (!bgp) { | |
711 | return NULL; | |
712 | } | |
713 | ||
714 | ret = str2sockunion(peer_str, &su); | |
715 | if (ret == 0) { | |
716 | /* IP address, locate peer. */ | |
717 | peer = peer_lookup(bgp, &su); | |
718 | } else { | |
719 | /* Not IP, could match either peer configured on interface or a | |
720 | * group. */ | |
721 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
722 | if (!peer) | |
723 | group = peer_group_lookup(bgp, peer_str); | |
724 | } | |
725 | ||
726 | if (peer) { | |
727 | if (peer_dynamic_neighbor(peer)) { | |
728 | vty_out(vty, | |
729 | "%% Operation not allowed on a dynamic neighbor\n"); | |
730 | return NULL; | |
731 | } | |
732 | ||
733 | return peer; | |
734 | } | |
735 | ||
736 | if (group) | |
737 | return group->conf; | |
738 | ||
739 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
740 | ||
741 | return NULL; | |
742 | } | |
743 | ||
f4b8ec07 CS |
744 | int bgp_nb_errmsg_return(char *errmsg, size_t errmsg_len, int ret) |
745 | { | |
746 | const char *str = NULL; | |
747 | ||
748 | switch (ret) { | |
749 | case BGP_ERR_INVALID_VALUE: | |
750 | str = "Invalid value"; | |
751 | break; | |
752 | case BGP_ERR_INVALID_FLAG: | |
753 | str = "Invalid flag"; | |
754 | break; | |
755 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
756 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
757 | break; | |
758 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
759 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
760 | break; | |
761 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
762 | str = "Specify remote-as or peer-group remote AS first"; | |
763 | break; | |
764 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
765 | str = "Cannot change the peer-group. Deconfigure first"; | |
766 | break; | |
767 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
768 | str = "Peer is not a member of this peer-group"; | |
769 | break; | |
770 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
771 | str = "Prefix/distribute list can not co-exist"; | |
772 | break; | |
773 | case BGP_ERR_NOT_INTERNAL_PEER: | |
774 | str = "Invalid command. Not an internal neighbor"; | |
775 | break; | |
776 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
777 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
778 | break; | |
779 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
780 | str = "Local-AS allowed only for EBGP peers"; | |
781 | break; | |
782 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
783 | str = "Cannot have local-as same as BGP AS number"; | |
784 | break; | |
785 | case BGP_ERR_TCPSIG_FAILED: | |
786 | str = "Error while applying TCP-Sig to session(s)"; | |
787 | break; | |
788 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
789 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
790 | break; | |
791 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
792 | str = "ttl-security only allowed for EBGP peers"; | |
793 | break; | |
794 | case BGP_ERR_AS_OVERRIDE: | |
795 | str = "as-override cannot be configured for IBGP peers"; | |
796 | break; | |
797 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
798 | str = "Invalid limit for number of dynamic neighbors"; | |
799 | break; | |
800 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
801 | str = "Dynamic neighbor listen range already exists"; | |
802 | break; | |
803 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
804 | str = "Operation not allowed on a dynamic neighbor"; | |
805 | break; | |
806 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
807 | str = "Operation not allowed on a directly connected neighbor"; | |
808 | break; | |
809 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 810 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
f4b8ec07 CS |
811 | break; |
812 | case BGP_ERR_GR_INVALID_CMD: | |
813 | str = "The Graceful Restart command used is not valid at this moment."; | |
814 | break; | |
815 | case BGP_ERR_GR_OPERATION_FAILED: | |
816 | str = "The Graceful Restart Operation failed due to an err."; | |
817 | break; | |
f4b8ec07 CS |
818 | case BGP_ERR_PEER_GROUP_MEMBER: |
819 | str = "Peer-group member cannot override remote-as of peer-group"; | |
820 | break; | |
821 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
822 | str = "Peer-group members must be all internal or all external"; | |
823 | break; | |
824 | } | |
825 | if (str) { | |
826 | snprintf(errmsg, errmsg_len, "%s", str); | |
827 | return -1; | |
828 | } | |
829 | ||
830 | return 0; | |
831 | } | |
832 | ||
d62a17ae | 833 | int bgp_vty_return(struct vty *vty, int ret) |
834 | { | |
835 | const char *str = NULL; | |
836 | ||
837 | switch (ret) { | |
838 | case BGP_ERR_INVALID_VALUE: | |
839 | str = "Invalid value"; | |
840 | break; | |
841 | case BGP_ERR_INVALID_FLAG: | |
842 | str = "Invalid flag"; | |
843 | break; | |
844 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
845 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
846 | break; | |
847 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
848 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
849 | break; | |
850 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
851 | str = "Specify remote-as or peer-group remote AS first"; | |
852 | break; | |
853 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
854 | str = "Cannot change the peer-group. Deconfigure first"; | |
855 | break; | |
856 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
857 | str = "Peer is not a member of this peer-group"; | |
858 | break; | |
859 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
860 | str = "Prefix/distribute list can not co-exist"; | |
861 | break; | |
862 | case BGP_ERR_NOT_INTERNAL_PEER: | |
863 | str = "Invalid command. Not an internal neighbor"; | |
864 | break; | |
865 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
866 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
867 | break; | |
868 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
869 | str = "Local-AS allowed only for EBGP peers"; | |
870 | break; | |
871 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
872 | str = "Cannot have local-as same as BGP AS number"; | |
873 | break; | |
874 | case BGP_ERR_TCPSIG_FAILED: | |
875 | str = "Error while applying TCP-Sig to session(s)"; | |
876 | break; | |
877 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
878 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
879 | break; | |
880 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
881 | str = "ttl-security only allowed for EBGP peers"; | |
882 | break; | |
883 | case BGP_ERR_AS_OVERRIDE: | |
884 | str = "as-override cannot be configured for IBGP peers"; | |
885 | break; | |
886 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
887 | str = "Invalid limit for number of dynamic neighbors"; | |
888 | break; | |
889 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
890 | str = "Dynamic neighbor listen range already exists"; | |
891 | break; | |
892 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
893 | str = "Operation not allowed on a dynamic neighbor"; | |
894 | break; | |
895 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
896 | str = "Operation not allowed on a directly connected neighbor"; | |
897 | break; | |
898 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 899 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 900 | break; |
901 | case BGP_ERR_GR_INVALID_CMD: | |
902 | str = "The Graceful Restart command used is not valid at this moment."; | |
903 | break; | |
904 | case BGP_ERR_GR_OPERATION_FAILED: | |
905 | str = "The Graceful Restart Operation failed due to an err."; | |
906 | break; | |
d62a17ae | 907 | } |
908 | if (str) { | |
909 | vty_out(vty, "%% %s\n", str); | |
910 | return CMD_WARNING_CONFIG_FAILED; | |
911 | } | |
912 | return CMD_SUCCESS; | |
718e3744 | 913 | } |
914 | ||
7aafcaca | 915 | /* BGP clear sort. */ |
d62a17ae | 916 | enum clear_sort { |
917 | clear_all, | |
918 | clear_peer, | |
919 | clear_group, | |
920 | clear_external, | |
921 | clear_as | |
7aafcaca DS |
922 | }; |
923 | ||
ff8a8a7a CS |
924 | static void bgp_clear_vty_error(struct peer *peer, afi_t afi, safi_t safi, |
925 | int error, char *errmsg, size_t errmsg_len) | |
d62a17ae | 926 | { |
927 | switch (error) { | |
928 | case BGP_ERR_AF_UNCONFIGURED: | |
ff8a8a7a CS |
929 | snprintf(errmsg, errmsg_len, |
930 | "%%BGP: Enable %s address family for the neighbor %s", | |
931 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 932 | break; |
933 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
ff8a8a7a CS |
934 | snprintf( |
935 | errmsg, errmsg_len, | |
936 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig", | |
d62a17ae | 937 | peer->host); |
938 | break; | |
939 | default: | |
940 | break; | |
941 | } | |
7aafcaca DS |
942 | } |
943 | ||
dc912615 | 944 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 945 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
946 | { |
947 | int ret = 0; | |
2adac256 | 948 | struct peer_af *paf; |
dc912615 DS |
949 | |
950 | /* if afi/.safi not specified, spin thru all of them */ | |
951 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
952 | afi_t tmp_afi; | |
953 | safi_t tmp_safi; | |
954 | ||
955 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
2adac256 DA |
956 | paf = peer_af_find(peer, tmp_afi, tmp_safi); |
957 | if (paf && paf->subgroup) | |
958 | SET_FLAG(paf->subgroup->sflags, | |
959 | SUBGRP_STATUS_FORCE_UPDATES); | |
960 | ||
dc912615 DS |
961 | if (!peer->afc[tmp_afi][tmp_safi]) |
962 | continue; | |
963 | ||
964 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 965 | ret = peer_clear(peer, nnode); |
dc912615 DS |
966 | else |
967 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
968 | stype); | |
969 | } | |
970 | /* if afi specified and safi not, spin thru safis on this afi */ | |
971 | } else if (safi == SAFI_UNSPEC) { | |
972 | safi_t tmp_safi; | |
973 | ||
974 | for (tmp_safi = SAFI_UNICAST; | |
975 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
976 | if (!peer->afc[afi][tmp_safi]) | |
977 | continue; | |
978 | ||
2adac256 DA |
979 | paf = peer_af_find(peer, afi, tmp_safi); |
980 | if (paf && paf->subgroup) | |
981 | SET_FLAG(paf->subgroup->sflags, | |
982 | SUBGRP_STATUS_FORCE_UPDATES); | |
983 | ||
dc912615 | 984 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 985 | ret = peer_clear(peer, nnode); |
dc912615 DS |
986 | else |
987 | ret = peer_clear_soft(peer, afi, | |
988 | tmp_safi, stype); | |
989 | } | |
990 | /* both afi/safi specified, let the caller know if not defined */ | |
991 | } else { | |
992 | if (!peer->afc[afi][safi]) | |
993 | return 1; | |
994 | ||
2adac256 DA |
995 | paf = peer_af_find(peer, afi, safi); |
996 | if (paf && paf->subgroup) | |
997 | SET_FLAG(paf->subgroup->sflags, | |
998 | SUBGRP_STATUS_FORCE_UPDATES); | |
999 | ||
dc912615 | 1000 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1001 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1002 | else |
1003 | ret = peer_clear_soft(peer, afi, safi, stype); | |
1004 | } | |
1005 | ||
1006 | return ret; | |
1007 | } | |
1008 | ||
7aafcaca | 1009 | /* `clear ip bgp' functions. */ |
ff8a8a7a | 1010 | static int bgp_clear(struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 1011 | enum clear_sort sort, enum bgp_clear_type stype, |
ff8a8a7a | 1012 | const char *arg, char *errmsg, size_t errmsg_len) |
d62a17ae | 1013 | { |
dc912615 | 1014 | int ret = 0; |
3ae8bfa5 | 1015 | bool found = false; |
d62a17ae | 1016 | struct peer *peer; |
dc95985f | 1017 | |
1018 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 1019 | |
1020 | /* Clear all neighbors. */ | |
1021 | /* | |
1022 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
1023 | * nodes on the BGP instance as that may get freed if it is a |
1024 | * doppelganger | |
d62a17ae | 1025 | */ |
1026 | if (sort == clear_all) { | |
1027 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 1028 | |
1029 | bgp_peer_gr_flags_update(peer); | |
1030 | ||
36235319 | 1031 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 1032 | gr_router_detected = true; |
1033 | ||
c368171c | 1034 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 1035 | stype); |
d62a17ae | 1036 | |
1037 | if (ret < 0) | |
ff8a8a7a CS |
1038 | bgp_clear_vty_error(peer, afi, safi, ret, |
1039 | errmsg, errmsg_len); | |
dc95985f | 1040 | } |
1041 | ||
36235319 QY |
1042 | if (gr_router_detected |
1043 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1044 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1045 | } else if (!gr_router_detected |
1046 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1047 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1048 | } |
d62a17ae | 1049 | |
1050 | /* This is to apply read-only mode on this clear. */ | |
1051 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1052 | bgp->update_delay_over = 0; | |
1053 | ||
1054 | return CMD_SUCCESS; | |
7aafcaca DS |
1055 | } |
1056 | ||
3ae8bfa5 | 1057 | /* Clear specified neighbor. */ |
d62a17ae | 1058 | if (sort == clear_peer) { |
1059 | union sockunion su; | |
d62a17ae | 1060 | |
1061 | /* Make sockunion for lookup. */ | |
1062 | ret = str2sockunion(arg, &su); | |
1063 | if (ret < 0) { | |
1064 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1065 | if (!peer) { | |
1066 | peer = peer_lookup_by_hostname(bgp, arg); | |
1067 | if (!peer) { | |
ff8a8a7a CS |
1068 | snprintf( |
1069 | errmsg, errmsg_len, | |
1070 | "Malformed address or name: %s", | |
d62a17ae | 1071 | arg); |
1072 | return CMD_WARNING; | |
1073 | } | |
1074 | } | |
1075 | } else { | |
1076 | peer = peer_lookup(bgp, &su); | |
1077 | if (!peer) { | |
ff8a8a7a CS |
1078 | snprintf(errmsg, errmsg_len, |
1079 | "%%BGP: Unknown neighbor - \"%s\"", | |
1080 | arg); | |
d62a17ae | 1081 | return CMD_WARNING; |
1082 | } | |
1083 | } | |
7aafcaca | 1084 | |
dc95985f | 1085 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1086 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1087 | ||
dc912615 DS |
1088 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1089 | ||
1090 | /* if afi/safi not defined for this peer, let caller know */ | |
1091 | if (ret == 1) | |
3ae8bfa5 | 1092 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1093 | |
d62a17ae | 1094 | if (ret < 0) |
ff8a8a7a CS |
1095 | bgp_clear_vty_error(peer, afi, safi, ret, errmsg, |
1096 | errmsg_len); | |
7aafcaca | 1097 | |
d62a17ae | 1098 | return CMD_SUCCESS; |
7aafcaca | 1099 | } |
7aafcaca | 1100 | |
3ae8bfa5 | 1101 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1102 | if (sort == clear_group) { |
1103 | struct peer_group *group; | |
7aafcaca | 1104 | |
d62a17ae | 1105 | group = peer_group_lookup(bgp, arg); |
1106 | if (!group) { | |
ff8a8a7a CS |
1107 | snprintf(errmsg, errmsg_len, |
1108 | "%%BGP: No such peer-group %s", arg); | |
d62a17ae | 1109 | return CMD_WARNING; |
1110 | } | |
1111 | ||
1112 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1113 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1114 | |
d62a17ae | 1115 | if (ret < 0) |
ff8a8a7a CS |
1116 | bgp_clear_vty_error(peer, afi, safi, ret, |
1117 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1118 | else |
1119 | found = true; | |
d62a17ae | 1120 | } |
3ae8bfa5 PM |
1121 | |
1122 | if (!found) | |
ff8a8a7a CS |
1123 | snprintf( |
1124 | errmsg, errmsg_len, | |
1125 | "%%BGP: No %s peer belonging to peer-group %s is configured", | |
5cb5f4d0 | 1126 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1127 | |
d62a17ae | 1128 | return CMD_SUCCESS; |
7aafcaca | 1129 | } |
7aafcaca | 1130 | |
3ae8bfa5 | 1131 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1132 | if (sort == clear_external) { |
1133 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1134 | if (peer->sort == BGP_PEER_IBGP) | |
1135 | continue; | |
7aafcaca | 1136 | |
dc95985f | 1137 | bgp_peer_gr_flags_update(peer); |
1138 | ||
36235319 | 1139 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1140 | gr_router_detected = true; |
dc95985f | 1141 | |
c368171c | 1142 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1143 | |
d62a17ae | 1144 | if (ret < 0) |
ff8a8a7a CS |
1145 | bgp_clear_vty_error(peer, afi, safi, ret, |
1146 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1147 | else |
1148 | found = true; | |
d62a17ae | 1149 | } |
3ae8bfa5 | 1150 | |
36235319 QY |
1151 | if (gr_router_detected |
1152 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1153 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1154 | } else if (!gr_router_detected |
1155 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1156 | bgp_zebra_send_capabilities(bgp, true); |
1157 | } | |
1158 | ||
3ae8bfa5 | 1159 | if (!found) |
ff8a8a7a CS |
1160 | snprintf(errmsg, errmsg_len, |
1161 | "%%BGP: No external %s peer is configured", | |
1162 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 1163 | |
d62a17ae | 1164 | return CMD_SUCCESS; |
1165 | } | |
1166 | ||
3ae8bfa5 | 1167 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1168 | if (sort == clear_as) { |
3ae8bfa5 | 1169 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1170 | |
1171 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1172 | if (peer->as != as) | |
1173 | continue; | |
1174 | ||
dc95985f | 1175 | bgp_peer_gr_flags_update(peer); |
1176 | ||
36235319 | 1177 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1178 | gr_router_detected = true; |
dc95985f | 1179 | |
c368171c | 1180 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1181 | |
1182 | if (ret < 0) | |
ff8a8a7a CS |
1183 | bgp_clear_vty_error(peer, afi, safi, ret, |
1184 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1185 | else |
1186 | found = true; | |
d62a17ae | 1187 | } |
3ae8bfa5 | 1188 | |
36235319 QY |
1189 | if (gr_router_detected |
1190 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1191 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1192 | } else if (!gr_router_detected |
1193 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1194 | bgp_zebra_send_capabilities(bgp, true); |
1195 | } | |
1196 | ||
3ae8bfa5 | 1197 | if (!found) |
ff8a8a7a CS |
1198 | snprintf(errmsg, errmsg_len, |
1199 | "%%BGP: No %s peer is configured with AS %s", | |
1200 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1201 | |
d62a17ae | 1202 | return CMD_SUCCESS; |
1203 | } | |
1204 | ||
1205 | return CMD_SUCCESS; | |
1206 | } | |
1207 | ||
ff8a8a7a CS |
1208 | static int bgp_clear_vty(const char *name, afi_t afi, safi_t safi, |
1209 | enum clear_sort sort, enum bgp_clear_type stype, | |
1210 | const char *arg, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1211 | { |
1212 | struct bgp *bgp; | |
1213 | ||
1214 | /* BGP structure lookup. */ | |
1215 | if (name) { | |
1216 | bgp = bgp_lookup_by_name(name); | |
1217 | if (bgp == NULL) { | |
ff8a8a7a CS |
1218 | snprintf(errmsg, errmsg_len, |
1219 | "Can't find BGP instance %s", name); | |
d62a17ae | 1220 | return CMD_WARNING; |
1221 | } | |
1222 | } else { | |
1223 | bgp = bgp_get_default(); | |
1224 | if (bgp == NULL) { | |
ff8a8a7a CS |
1225 | snprintf(errmsg, errmsg_len, |
1226 | "No BGP process is configured"); | |
d62a17ae | 1227 | return CMD_WARNING; |
1228 | } | |
1229 | } | |
1230 | ||
ff8a8a7a | 1231 | return bgp_clear(bgp, afi, safi, sort, stype, arg, errmsg, errmsg_len); |
7aafcaca DS |
1232 | } |
1233 | ||
1234 | /* clear soft inbound */ | |
ff8a8a7a | 1235 | int bgp_clear_star_soft_in(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1236 | { |
99b3ebd3 NS |
1237 | afi_t afi; |
1238 | safi_t safi; | |
ff8a8a7a CS |
1239 | int ret; |
1240 | ||
1241 | FOREACH_AFI_SAFI (afi, safi) { | |
1242 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1243 | BGP_CLEAR_SOFT_IN, NULL, errmsg, | |
1244 | errmsg_len); | |
1245 | if (ret != CMD_SUCCESS) | |
1246 | return -1; | |
1247 | } | |
99b3ebd3 | 1248 | |
ff8a8a7a | 1249 | return 0; |
7aafcaca DS |
1250 | } |
1251 | ||
1252 | /* clear soft outbound */ | |
ff8a8a7a | 1253 | int bgp_clear_star_soft_out(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1254 | { |
99b3ebd3 NS |
1255 | afi_t afi; |
1256 | safi_t safi; | |
ff8a8a7a | 1257 | int ret; |
99b3ebd3 | 1258 | |
ff8a8a7a CS |
1259 | FOREACH_AFI_SAFI (afi, safi) { |
1260 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1261 | BGP_CLEAR_SOFT_OUT, NULL, errmsg, | |
1262 | errmsg_len); | |
1263 | if (ret != CMD_SUCCESS) | |
1264 | return -1; | |
1265 | } | |
1266 | ||
1267 | return 0; | |
7aafcaca DS |
1268 | } |
1269 | ||
1270 | ||
f787d7a0 | 1271 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1272 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1273 | #endif |
1274 | ||
8029b216 AK |
1275 | DEFUN_HIDDEN (bgp_local_mac, |
1276 | bgp_local_mac_cmd, | |
093e3f23 | 1277 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1278 | BGP_STR |
1279 | "Local MAC config\n" | |
1280 | "VxLAN Network Identifier\n" | |
1281 | "VNI number\n" | |
1282 | "local mac\n" | |
1283 | "mac address\n" | |
1284 | "mac-mobility sequence\n" | |
1285 | "seq number\n") | |
1286 | { | |
1287 | int rv; | |
1288 | vni_t vni; | |
1289 | struct ethaddr mac; | |
1290 | struct ipaddr ip; | |
1291 | uint32_t seq; | |
1292 | struct bgp *bgp; | |
1293 | ||
1294 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1295 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1296 | vty_out(vty, "%% Malformed MAC address\n"); | |
1297 | return CMD_WARNING; | |
1298 | } | |
1299 | memset(&ip, 0, sizeof(ip)); | |
1300 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1301 | ||
1302 | bgp = bgp_get_default(); | |
1303 | if (!bgp) { | |
1304 | vty_out(vty, "Default BGP instance is not there\n"); | |
1305 | return CMD_WARNING; | |
1306 | } | |
1307 | ||
b5e140c8 AK |
1308 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1309 | zero_esi); | |
8029b216 AK |
1310 | if (rv < 0) { |
1311 | vty_out(vty, "Internal error\n"); | |
1312 | return CMD_WARNING; | |
1313 | } | |
1314 | ||
1315 | return CMD_SUCCESS; | |
1316 | } | |
1317 | ||
1318 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1319 | no_bgp_local_mac_cmd, | |
093e3f23 | 1320 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1321 | NO_STR |
1322 | BGP_STR | |
1323 | "Local MAC config\n" | |
1324 | "VxLAN Network Identifier\n" | |
1325 | "VNI number\n" | |
1326 | "local mac\n" | |
1327 | "mac address\n") | |
1328 | { | |
1329 | int rv; | |
1330 | vni_t vni; | |
1331 | struct ethaddr mac; | |
1332 | struct ipaddr ip; | |
1333 | struct bgp *bgp; | |
1334 | ||
1335 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1336 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1337 | vty_out(vty, "%% Malformed MAC address\n"); | |
1338 | return CMD_WARNING; | |
1339 | } | |
1340 | memset(&ip, 0, sizeof(ip)); | |
1341 | ||
1342 | bgp = bgp_get_default(); | |
1343 | if (!bgp) { | |
1344 | vty_out(vty, "Default BGP instance is not there\n"); | |
1345 | return CMD_WARNING; | |
1346 | } | |
1347 | ||
ec0ab544 | 1348 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1349 | if (rv < 0) { |
1350 | vty_out(vty, "Internal error\n"); | |
1351 | return CMD_WARNING; | |
1352 | } | |
1353 | ||
1354 | return CMD_SUCCESS; | |
1355 | } | |
1356 | ||
718e3744 | 1357 | DEFUN (no_synchronization, |
1358 | no_synchronization_cmd, | |
1359 | "no synchronization", | |
1360 | NO_STR | |
1361 | "Perform IGP synchronization\n") | |
1362 | { | |
d62a17ae | 1363 | return CMD_SUCCESS; |
718e3744 | 1364 | } |
1365 | ||
1366 | DEFUN (no_auto_summary, | |
1367 | no_auto_summary_cmd, | |
1368 | "no auto-summary", | |
1369 | NO_STR | |
1370 | "Enable automatic network number summarization\n") | |
1371 | { | |
d62a17ae | 1372 | return CMD_SUCCESS; |
718e3744 | 1373 | } |
3d515fd9 | 1374 | |
718e3744 | 1375 | /* "router bgp" commands. */ |
ff8a8a7a CS |
1376 | DEFUN_YANG_NOSH(router_bgp, |
1377 | router_bgp_cmd, | |
1378 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1379 | ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1380 | { |
d62a17ae | 1381 | int idx_asn = 2; |
1382 | int idx_view_vrf = 3; | |
1383 | int idx_vrf = 4; | |
ff8a8a7a | 1384 | int ret = CMD_SUCCESS; |
d62a17ae | 1385 | as_t as; |
1386 | struct bgp *bgp; | |
1387 | const char *name = NULL; | |
1388 | enum bgp_instance_type inst_type; | |
ff8a8a7a | 1389 | char base_xpath[XPATH_MAXLEN]; |
4062b455 | 1390 | const struct lyd_node *bgp_glb_dnode; |
d62a17ae | 1391 | |
1392 | // "router bgp" without an ASN | |
1393 | if (argc == 2) { | |
1394 | // Pending: Make VRF option available for ASN less config | |
4062b455 IR |
1395 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1396 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); | |
d62a17ae | 1397 | |
4062b455 IR |
1398 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, |
1399 | base_xpath); | |
1400 | if (!bgp_glb_dnode) { | |
d62a17ae | 1401 | vty_out(vty, "%% No BGP process is configured\n"); |
1402 | return CMD_WARNING_CONFIG_FAILED; | |
1403 | } | |
1404 | ||
1405 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1406 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1407 | return CMD_WARNING_CONFIG_FAILED; |
1408 | } | |
ff8a8a7a | 1409 | |
4062b455 | 1410 | as = yang_dnode_get_uint32(bgp_glb_dnode, "./global/local-as"); |
ff8a8a7a | 1411 | |
4062b455 | 1412 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); |
ff8a8a7a | 1413 | |
4062b455 IR |
1414 | /* |
1415 | * For backward compatibility with old commands we still | |
1416 | * need to use the qobj infrastructure. | |
1417 | */ | |
1418 | bgp = bgp_lookup(as, NULL); | |
1419 | if (bgp) | |
ff8a8a7a | 1420 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
4062b455 IR |
1421 | |
1422 | return CMD_SUCCESS; | |
d62a17ae | 1423 | } |
1424 | ||
1425 | // "router bgp X" | |
1426 | else { | |
d62a17ae | 1427 | |
ff8a8a7a | 1428 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
d62a17ae | 1429 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1430 | if (argc > 3) { | |
1431 | name = argv[idx_vrf]->arg; | |
1432 | ||
9a8bdf1c PG |
1433 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1434 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1435 | name = NULL; | |
1436 | else | |
1437 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
ff8a8a7a | 1438 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) { |
d62a17ae | 1439 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
ff8a8a7a | 1440 | } |
d62a17ae | 1441 | } |
ff8a8a7a CS |
1442 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1443 | "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME); | |
1444 | ||
1445 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
87ce2564 | 1446 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
ff8a8a7a CS |
1447 | argv[idx_asn]->arg); |
1448 | if (inst_type == BGP_INSTANCE_TYPE_VIEW) { | |
87ce2564 CS |
1449 | nb_cli_enqueue_change(vty, |
1450 | "./global/instance-type-view", | |
ff8a8a7a | 1451 | NB_OP_MODIFY, "true"); |
d3e36770 IR |
1452 | } else { |
1453 | nb_cli_enqueue_change(vty, | |
1454 | "./global/instance-type-view", | |
1455 | NB_OP_MODIFY, "false"); | |
d62a17ae | 1456 | } |
1457 | ||
fd396924 | 1458 | ret = nb_cli_apply_changes_clear_pending(vty, base_xpath); |
ff8a8a7a CS |
1459 | if (ret == CMD_SUCCESS) { |
1460 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
3bd70bf8 | 1461 | |
ff8a8a7a CS |
1462 | /* |
1463 | * For backward compatibility with old commands we still | |
1464 | * need to use the qobj infrastructure. | |
1465 | */ | |
1466 | bgp = bgp_lookup(as, name); | |
1467 | if (bgp) | |
1468 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1469 | } | |
d62a17ae | 1470 | } |
1471 | ||
ff8a8a7a | 1472 | return ret; |
718e3744 | 1473 | } |
1474 | ||
718e3744 | 1475 | /* "no router bgp" commands. */ |
ff8a8a7a CS |
1476 | DEFUN_YANG(no_router_bgp, |
1477 | no_router_bgp_cmd, | |
1478 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1479 | NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1480 | { |
d62a17ae | 1481 | int idx_vrf = 5; |
d62a17ae | 1482 | const char *name = NULL; |
ff8a8a7a | 1483 | char base_xpath[XPATH_MAXLEN]; |
4b63e358 | 1484 | const struct lyd_node *bgp_glb_dnode; |
718e3744 | 1485 | |
d62a17ae | 1486 | // "no router bgp" without an ASN |
1487 | if (argc == 3) { | |
1488 | // Pending: Make VRF option available for ASN less config | |
4b63e358 CS |
1489 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1490 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); | |
718e3744 | 1491 | |
4b63e358 CS |
1492 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, |
1493 | base_xpath); | |
1494 | if (!bgp_glb_dnode) { | |
d62a17ae | 1495 | vty_out(vty, "%% No BGP process is configured\n"); |
1496 | return CMD_WARNING_CONFIG_FAILED; | |
1497 | } | |
7fb21a9f | 1498 | |
d62a17ae | 1499 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1500 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1501 | return CMD_WARNING_CONFIG_FAILED; |
1502 | } | |
1503 | } else { | |
d62a17ae | 1504 | if (argc > 4) |
1505 | name = argv[idx_vrf]->arg; | |
45d1d7c9 IR |
1506 | else |
1507 | name = VRF_DEFAULT_NAME; | |
7fb21a9f | 1508 | |
45d1d7c9 IR |
1509 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1510 | "frr-bgp:bgp", "bgp", name); | |
d62a17ae | 1511 | } |
718e3744 | 1512 | |
ff8a8a7a | 1513 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); |
718e3744 | 1514 | |
fd396924 CH |
1515 | /* We want to finish any classic config after a no router */ |
1516 | return nb_cli_apply_changes_clear_pending(vty, base_xpath); | |
718e3744 | 1517 | } |
1518 | ||
ff8a8a7a CS |
1519 | void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode, |
1520 | bool show_defaults) | |
1521 | { | |
1522 | const struct lyd_node *vrf_dnode; | |
1523 | const char *vrf_name; | |
1524 | as_t as; | |
6b0655a2 | 1525 | |
ff8a8a7a CS |
1526 | vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol"); |
1527 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
5e42cb2f | 1528 | as = yang_dnode_get_uint32(dnode, "./global/local-as"); |
718e3744 | 1529 | |
ff8a8a7a CS |
1530 | vty_out(vty, "!\n"); |
1531 | vty_out(vty, "router bgp %u", as); | |
1532 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
1533 | vty_out(vty, " vrf %s", vrf_name); | |
1534 | vty_out(vty, "\n"); | |
718e3744 | 1535 | } |
1536 | ||
ff8a8a7a CS |
1537 | /* BGP router-id. */ |
1538 | ||
1539 | DEFPY_YANG(bgp_router_id, bgp_router_id_cmd, "bgp router-id A.B.C.D", | |
1540 | BGP_STR | |
1541 | "Override configured router identifier\n" | |
1542 | "Manually configured router identifier\n") | |
718e3744 | 1543 | { |
87ce2564 CS |
1544 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_MODIFY, |
1545 | router_id_str); | |
718e3744 | 1546 | |
ff8a8a7a CS |
1547 | return nb_cli_apply_changes(vty, NULL); |
1548 | } | |
718e3744 | 1549 | |
ff8a8a7a CS |
1550 | DEFPY_YANG(no_bgp_router_id, no_bgp_router_id_cmd, "no bgp router-id [A.B.C.D]", |
1551 | NO_STR BGP_STR | |
1552 | "Override configured router identifier\n" | |
1553 | "Manually configured router identifier\n") | |
1554 | { | |
87ce2564 | 1555 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_DESTROY, |
ff8a8a7a | 1556 | router_id_str ? router_id_str : NULL); |
718e3744 | 1557 | |
ff8a8a7a | 1558 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1559 | } |
1560 | ||
ff8a8a7a CS |
1561 | void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode, |
1562 | bool show_defaults) | |
1563 | { | |
1564 | vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL)); | |
1565 | } | |
6b0655a2 | 1566 | |
ed0e57e3 DA |
1567 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
1568 | "[no$no] bgp community alias WORD$community WORD$alias", | |
1569 | NO_STR BGP_STR | |
1570 | "Add community specific parameters\n" | |
1571 | "Create an alias for a community\n" | |
1572 | "Community (AA:BB or AA:BB:CC)\n" | |
1573 | "Alias name\n") | |
1574 | { | |
1575 | struct community_alias ca1; | |
1576 | struct community_alias ca2; | |
1577 | struct community_alias *lookup_community; | |
1578 | struct community_alias *lookup_alias; | |
1579 | ||
1580 | if (!community_str2com(community) && !lcommunity_str2com(community)) { | |
1581 | vty_out(vty, "Invalid community format\n"); | |
1582 | return CMD_WARNING; | |
1583 | } | |
1584 | ||
1585 | memset(&ca1, 0, sizeof(ca1)); | |
1586 | memset(&ca2, 0, sizeof(ca2)); | |
1587 | strlcpy(ca1.community, community, sizeof(ca1.community)); | |
1588 | strlcpy(ca1.alias, alias, sizeof(ca1.alias)); | |
1589 | ||
1590 | lookup_community = bgp_ca_community_lookup(&ca1); | |
1591 | lookup_alias = bgp_ca_alias_lookup(&ca1); | |
1592 | ||
1593 | if (no) { | |
1594 | bgp_ca_alias_delete(&ca1); | |
1595 | bgp_ca_community_delete(&ca1); | |
1596 | } else { | |
1597 | if (lookup_alias) { | |
1598 | /* Lookup if community hash table has an item | |
1599 | * with the same alias name. | |
1600 | */ | |
1601 | strlcpy(ca2.community, lookup_alias->community, | |
1602 | sizeof(ca2.community)); | |
1603 | if (bgp_ca_community_lookup(&ca2)) { | |
1604 | vty_out(vty, | |
1605 | "community (%s) already has this alias (%s)\n", | |
1606 | lookup_alias->community, | |
1607 | lookup_alias->alias); | |
1608 | return CMD_WARNING; | |
1609 | } | |
1610 | bgp_ca_alias_delete(&ca1); | |
1611 | } | |
1612 | ||
1613 | if (lookup_community) | |
1614 | bgp_ca_community_delete(&ca1); | |
1615 | ||
1616 | bgp_ca_alias_insert(&ca1); | |
1617 | bgp_ca_community_insert(&ca1); | |
1618 | } | |
1619 | ||
1620 | return CMD_SUCCESS; | |
1621 | } | |
1622 | ||
9acb67cb DS |
1623 | DEFPY (bgp_global_suppress_fib_pending, |
1624 | bgp_global_suppress_fib_pending_cmd, | |
1625 | "[no] bgp suppress-fib-pending", | |
1626 | NO_STR | |
1627 | BGP_STR | |
1628 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1629 | { | |
1630 | bm_wait_for_fib_set(!no); | |
1631 | ||
1632 | return CMD_SUCCESS; | |
1633 | } | |
1634 | ||
c208c586 S |
1635 | DEFPY (bgp_suppress_fib_pending, |
1636 | bgp_suppress_fib_pending_cmd, | |
1637 | "[no] bgp suppress-fib-pending", | |
1638 | NO_STR | |
1639 | BGP_STR | |
1640 | "Advertise only routes that are programmed in kernel to peers\n") | |
1641 | { | |
1642 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1643 | ||
1644 | bgp_suppress_fib_pending_set(bgp, !no); | |
1645 | return CMD_SUCCESS; | |
1646 | } | |
1647 | ||
1648 | ||
718e3744 | 1649 | /* BGP Cluster ID. */ |
ff8a8a7a CS |
1650 | DEFUN_YANG(bgp_cluster_id, |
1651 | bgp_cluster_id_cmd, | |
1652 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1653 | BGP_STR | |
1654 | "Configure Route-Reflector Cluster-id\n" | |
1655 | "Route-Reflector Cluster-id in IP address format\n" | |
1656 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1657 | { |
d62a17ae | 1658 | int idx_ipv4 = 2; |
718e3744 | 1659 | |
87ce2564 CS |
1660 | nb_cli_enqueue_change( |
1661 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1662 | NB_OP_MODIFY, argv[idx_ipv4]->arg); | |
718e3744 | 1663 | |
ff8a8a7a | 1664 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1665 | } |
1666 | ||
ff8a8a7a CS |
1667 | DEFUN_YANG(no_bgp_cluster_id, |
1668 | no_bgp_cluster_id_cmd, | |
1669 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1670 | NO_STR BGP_STR | |
1671 | "Configure Route-Reflector Cluster-id\n" | |
1672 | "Route-Reflector Cluster-id in IP address format\n" | |
1673 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1674 | { |
87ce2564 CS |
1675 | nb_cli_enqueue_change( |
1676 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1677 | NB_OP_DESTROY, NULL); | |
718e3744 | 1678 | |
ff8a8a7a | 1679 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1680 | } |
1681 | ||
c163f297 DS |
1682 | DEFPY (bgp_norib, |
1683 | bgp_norib_cmd, | |
1684 | "bgp no-rib", | |
1685 | BGP_STR | |
1686 | "Disable BGP route installation to RIB (Zebra)\n") | |
1687 | { | |
1688 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1689 | vty_out(vty, | |
1690 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1691 | return CMD_SUCCESS; | |
1692 | } | |
1693 | ||
1694 | bgp_option_norib_set_runtime(); | |
1695 | ||
1696 | return CMD_SUCCESS; | |
1697 | } | |
1698 | ||
1699 | DEFPY (no_bgp_norib, | |
1700 | no_bgp_norib_cmd, | |
1701 | "no bgp no-rib", | |
1702 | NO_STR | |
1703 | BGP_STR | |
1704 | "Disable BGP route installation to RIB (Zebra)\n") | |
1705 | { | |
1706 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1707 | vty_out(vty, | |
1708 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1709 | return CMD_SUCCESS; | |
1710 | } | |
1711 | ||
1712 | bgp_option_norib_unset_runtime(); | |
1713 | ||
1714 | return CMD_SUCCESS; | |
1715 | } | |
1716 | ||
e46723a5 DS |
1717 | DEFPY (no_bgp_send_extra_data, |
1718 | no_bgp_send_extra_data_cmd, | |
1719 | "[no] bgp send-extra-data zebra", | |
1720 | NO_STR | |
1721 | BGP_STR | |
1722 | "Extra data to Zebra for display/use\n" | |
1723 | "To zebra\n") | |
1724 | { | |
ec0acb80 DA |
1725 | if (no) |
1726 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1727 | else | |
1728 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1729 | |
1730 | return CMD_SUCCESS; | |
1731 | } | |
1732 | ||
ff8a8a7a CS |
1733 | DEFUN_YANG(bgp_confederation_identifier, |
1734 | bgp_confederation_identifier_cmd, | |
1735 | "bgp confederation identifier (1-4294967295)", | |
1736 | "BGP specific commands\n" | |
1737 | "AS confederation parameters\n" | |
1738 | "AS number\n" | |
1739 | "Set routing domain confederation AS\n") | |
718e3744 | 1740 | { |
d62a17ae | 1741 | int idx_number = 3; |
718e3744 | 1742 | |
87ce2564 CS |
1743 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1744 | NB_OP_MODIFY, argv[idx_number]->arg); | |
718e3744 | 1745 | |
ff8a8a7a | 1746 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1747 | } |
1748 | ||
ff8a8a7a CS |
1749 | DEFUN_YANG(no_bgp_confederation_identifier, |
1750 | no_bgp_confederation_identifier_cmd, | |
1751 | "no bgp confederation identifier [(1-4294967295)]", | |
1752 | NO_STR | |
1753 | "BGP specific commands\n" | |
1754 | "AS confederation parameters\n" | |
1755 | "AS number\n" | |
1756 | "Set routing domain confederation AS\n") | |
718e3744 | 1757 | { |
87ce2564 CS |
1758 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1759 | NB_OP_DESTROY, NULL); | |
718e3744 | 1760 | |
ff8a8a7a | 1761 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1762 | } |
1763 | ||
ff8a8a7a CS |
1764 | void cli_show_router_bgp_confederation_identifier(struct vty *vty, |
1765 | struct lyd_node *dnode, | |
1766 | bool show_defaults) | |
1767 | { | |
1768 | vty_out(vty, " bgp confederation identifier %u\n", | |
1769 | yang_dnode_get_uint32(dnode, NULL)); | |
1770 | } | |
1771 | ||
1772 | DEFUN_YANG(bgp_confederation_peers, | |
1773 | bgp_confederation_peers_cmd, | |
1774 | "bgp confederation peers (1-4294967295)...", | |
1775 | "BGP specific commands\n" | |
1776 | "AS confederation parameters\n" | |
1777 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1778 | { |
d62a17ae | 1779 | int idx_asn = 3; |
d62a17ae | 1780 | int i; |
718e3744 | 1781 | |
ff8a8a7a | 1782 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1783 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1784 | NB_OP_CREATE, argv[i]->arg); |
718e3744 | 1785 | |
ff8a8a7a | 1786 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1787 | } |
1788 | ||
ff8a8a7a CS |
1789 | DEFUN_YANG(no_bgp_confederation_peers, |
1790 | no_bgp_confederation_peers_cmd, | |
1791 | "no bgp confederation peers (1-4294967295)...", | |
1792 | NO_STR | |
1793 | "BGP specific commands\n" | |
1794 | "AS confederation parameters\n" | |
1795 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1796 | { |
d62a17ae | 1797 | int idx_asn = 4; |
d62a17ae | 1798 | int i; |
718e3744 | 1799 | |
ff8a8a7a | 1800 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1801 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1802 | NB_OP_DESTROY, argv[i]->arg); |
0b2aa3a0 | 1803 | |
ff8a8a7a CS |
1804 | return nb_cli_apply_changes(vty, NULL); |
1805 | } | |
1806 | ||
1807 | void cli_show_router_bgp_confederation_member_as(struct vty *vty, | |
1808 | struct lyd_node *dnode, | |
1809 | bool show_defaults) | |
1810 | { | |
1811 | vty_out(vty, " bgp confederation peers %u \n", | |
1812 | yang_dnode_get_uint32(dnode, NULL)); | |
718e3744 | 1813 | } |
6b0655a2 | 1814 | |
5e242b0d DS |
1815 | /** |
1816 | * Central routine for maximum-paths configuration. | |
1817 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1818 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1819 | */ | |
37a87b8f CS |
1820 | int bgp_maxpaths_config_vty(struct bgp *bgp, afi_t afi, safi_t safi, |
1821 | int peer_type, uint16_t maxpaths, uint16_t options, | |
1822 | int set, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1823 | { |
d62a17ae | 1824 | int ret; |
d62a17ae | 1825 | |
1826 | if (set) { | |
d62a17ae | 1827 | if (maxpaths > multipath_num) { |
37a87b8f CS |
1828 | snprintf( |
1829 | errmsg, errmsg_len, | |
d62a17ae | 1830 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1831 | maxpaths, multipath_num); | |
1832 | return CMD_WARNING_CONFIG_FAILED; | |
1833 | } | |
1834 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1835 | options); | |
1836 | } else | |
1837 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1838 | ||
1839 | if (ret < 0) { | |
37a87b8f CS |
1840 | snprintf( |
1841 | errmsg, errmsg_len, | |
d62a17ae | 1842 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1843 | (set == 1) ? "" : "un", | |
1844 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1845 | maxpaths, afi, safi); | |
1846 | return CMD_WARNING_CONFIG_FAILED; | |
1847 | } | |
1848 | ||
1849 | bgp_recalculate_all_bestpaths(bgp); | |
1850 | ||
1851 | return CMD_SUCCESS; | |
165b5fff JB |
1852 | } |
1853 | ||
ff8a8a7a CS |
1854 | void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode, |
1855 | bool show_defaults) | |
abc920f8 | 1856 | { |
ff8a8a7a CS |
1857 | if (yang_dnode_get_bool(dnode, "./enable-med-admin")) { |
1858 | uint32_t med_admin_val; | |
abc920f8 | 1859 | |
ff8a8a7a | 1860 | vty_out(vty, " bgp max-med administrative"); |
4953391b DA |
1861 | med_admin_val = yang_dnode_get_uint32(dnode, "./max-med-admin"); |
1862 | if (med_admin_val != BGP_MAXMED_VALUE_DEFAULT) | |
ff8a8a7a CS |
1863 | vty_out(vty, " %u", med_admin_val); |
1864 | vty_out(vty, "\n"); | |
1865 | } | |
abc920f8 | 1866 | |
ff8a8a7a CS |
1867 | if (yang_dnode_exists(dnode, "./max-med-onstart-up-time")) { |
1868 | uint32_t onstartup_val; | |
abc920f8 | 1869 | |
ff8a8a7a CS |
1870 | vty_out(vty, " bgp max-med on-startup %u", |
1871 | yang_dnode_get_uint32(dnode, | |
1872 | "./max-med-onstart-up-time")); | |
1873 | onstartup_val = yang_dnode_get_uint32( | |
1874 | dnode, "./max-med-onstart-up-value"); | |
1875 | if (onstartup_val != BGP_MAXMED_VALUE_DEFAULT) | |
1876 | vty_out(vty, " %u", onstartup_val); | |
1877 | ||
1878 | vty_out(vty, "\n"); | |
1879 | } | |
abc920f8 DS |
1880 | } |
1881 | ||
ff8a8a7a CS |
1882 | DEFUN_YANG(bgp_maxmed_admin, |
1883 | bgp_maxmed_admin_cmd, | |
1884 | "bgp max-med administrative ", | |
1885 | BGP_STR | |
1886 | "Advertise routes with max-med\n" | |
1887 | "Administratively applied, for an indefinite period\n") | |
1888 | { | |
87ce2564 | 1889 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a CS |
1890 | NB_OP_MODIFY, "true"); |
1891 | ||
1892 | return nb_cli_apply_changes(vty, NULL); | |
1893 | } | |
1894 | ||
1895 | DEFUN_YANG(bgp_maxmed_admin_medv, | |
1896 | bgp_maxmed_admin_medv_cmd, | |
1897 | "bgp max-med administrative (0-4294967295)", | |
1898 | BGP_STR | |
1899 | "Advertise routes with max-med\n" | |
1900 | "Administratively applied, for an indefinite period\n" | |
1901 | "Max MED value to be used\n") | |
abc920f8 | 1902 | { |
d62a17ae | 1903 | int idx_number = 3; |
abc920f8 | 1904 | |
87ce2564 | 1905 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1906 | NB_OP_MODIFY, "true"); |
abc920f8 | 1907 | |
87ce2564 CS |
1908 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1909 | NB_OP_MODIFY, argv[idx_number]->arg); | |
abc920f8 | 1910 | |
ff8a8a7a | 1911 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1912 | } |
1913 | ||
ff8a8a7a CS |
1914 | DEFUN_YANG(no_bgp_maxmed_admin, |
1915 | no_bgp_maxmed_admin_cmd, | |
1916 | "no bgp max-med administrative [(0-4294967295)]", | |
1917 | NO_STR BGP_STR | |
1918 | "Advertise routes with max-med\n" | |
1919 | "Administratively applied, for an indefinite period\n" | |
1920 | "Max MED value to be used\n") | |
abc920f8 | 1921 | { |
87ce2564 | 1922 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1923 | NB_OP_MODIFY, "false"); |
abc920f8 | 1924 | |
87ce2564 CS |
1925 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1926 | NB_OP_MODIFY, NULL); | |
ff8a8a7a CS |
1927 | |
1928 | return nb_cli_apply_changes(vty, NULL); | |
abc920f8 DS |
1929 | } |
1930 | ||
37a87b8f CS |
1931 | DEFUN_YANG (bgp_maxmed_onstartup, |
1932 | bgp_maxmed_onstartup_cmd, | |
1933 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1934 | BGP_STR | |
1935 | "Advertise routes with max-med\n" | |
1936 | "Effective on a startup\n" | |
1937 | "Time (seconds) period for max-med\n" | |
1938 | "Max MED value to be used\n") | |
abc920f8 | 1939 | { |
d62a17ae | 1940 | int idx = 0; |
4668a151 | 1941 | |
d62a17ae | 1942 | argv_find(argv, argc, "(5-86400)", &idx); |
87ce2564 CS |
1943 | nb_cli_enqueue_change(vty, |
1944 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a CS |
1945 | NB_OP_MODIFY, argv[idx]->arg); |
1946 | ||
d62a17ae | 1947 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
87ce2564 CS |
1948 | nb_cli_enqueue_change( |
1949 | vty, "./global/med-config/max-med-onstart-up-value", | |
1950 | NB_OP_MODIFY, argv[idx]->arg); | |
d62a17ae | 1951 | else |
87ce2564 CS |
1952 | nb_cli_enqueue_change( |
1953 | vty, "./global/med-config/max-med-onstart-up-value", | |
1954 | NB_OP_MODIFY, NULL); | |
abc920f8 | 1955 | |
ff8a8a7a | 1956 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1957 | } |
1958 | ||
37a87b8f CS |
1959 | DEFUN_YANG (no_bgp_maxmed_onstartup, |
1960 | no_bgp_maxmed_onstartup_cmd, | |
1961 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1962 | NO_STR BGP_STR | |
1963 | "Advertise routes with max-med\n" | |
1964 | "Effective on a startup\n" | |
1965 | "Time (seconds) period for max-med\n" | |
1966 | "Max MED value to be used\n") | |
abc920f8 | 1967 | { |
87ce2564 CS |
1968 | nb_cli_enqueue_change(vty, |
1969 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a | 1970 | NB_OP_DESTROY, NULL); |
abc920f8 | 1971 | |
87ce2564 CS |
1972 | nb_cli_enqueue_change(vty, |
1973 | "./global/med-config/max-med-onstart-up-value", | |
ff8a8a7a | 1974 | NB_OP_MODIFY, NULL); |
abc920f8 | 1975 | |
ff8a8a7a | 1976 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1977 | } |
1978 | ||
d70583f7 D |
1979 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1980 | uint16_t update_delay, | |
1981 | uint16_t establish_wait) | |
1982 | { | |
1983 | struct listnode *node, *nnode; | |
1984 | struct bgp *bgp; | |
1985 | bool vrf_cfg = false; | |
1986 | ||
1987 | /* | |
1988 | * See if update-delay is set per-vrf and warn user to delete it | |
1989 | * Note that we only need to check this if this is the first time | |
1990 | * setting the global config. | |
1991 | */ | |
1992 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1993 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1994 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1995 | vty_out(vty, | |
1996 | "%% update-delay configuration found in vrf %s\n", | |
1997 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1998 | ? VRF_DEFAULT_NAME | |
1999 | : bgp->name); | |
2000 | vrf_cfg = true; | |
2001 | } | |
2002 | } | |
2003 | } | |
2004 | ||
2005 | if (vrf_cfg) { | |
2006 | vty_out(vty, | |
2007 | "%%Failed: global update-delay config not permitted\n"); | |
2008 | return CMD_WARNING; | |
2009 | } | |
2010 | ||
2011 | if (!establish_wait) { /* update-delay <delay> */ | |
2012 | bm->v_update_delay = update_delay; | |
2013 | bm->v_establish_wait = bm->v_update_delay; | |
2014 | } else { | |
2015 | /* update-delay <delay> <establish-wait> */ | |
2016 | if (update_delay < establish_wait) { | |
2017 | vty_out(vty, | |
2018 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2019 | return CMD_WARNING_CONFIG_FAILED; | |
2020 | } | |
2021 | ||
2022 | bm->v_update_delay = update_delay; | |
2023 | bm->v_establish_wait = establish_wait; | |
2024 | } | |
2025 | ||
2026 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2027 | bgp->v_update_delay = bm->v_update_delay; | |
2028 | bgp->v_establish_wait = bm->v_establish_wait; | |
2029 | } | |
2030 | ||
2031 | return CMD_SUCCESS; | |
2032 | } | |
2033 | ||
2034 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2035 | { | |
2036 | struct listnode *node, *nnode; | |
2037 | struct bgp *bgp; | |
2038 | ||
2039 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2040 | bm->v_establish_wait = bm->v_update_delay; | |
2041 | ||
2042 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2043 | bgp->v_update_delay = bm->v_update_delay; | |
2044 | bgp->v_establish_wait = bm->v_establish_wait; | |
2045 | } | |
2046 | ||
2047 | return CMD_SUCCESS; | |
2048 | } | |
2049 | ||
2050 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2051 | uint16_t establish_wait) | |
f188f2c4 | 2052 | { |
d62a17ae | 2053 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2054 | |
d70583f7 D |
2055 | /* if configured globally, per-instance config is not allowed */ |
2056 | if (bm->v_update_delay) { | |
2057 | vty_out(vty, | |
2058 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2059 | return CMD_WARNING_CONFIG_FAILED; | |
2060 | } | |
2061 | ||
f188f2c4 | 2062 | |
d70583f7 | 2063 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2064 | { |
2065 | bgp->v_update_delay = update_delay; | |
2066 | bgp->v_establish_wait = bgp->v_update_delay; | |
2067 | return CMD_SUCCESS; | |
2068 | } | |
f188f2c4 | 2069 | |
d62a17ae | 2070 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2071 | if (update_delay < establish_wait) { |
2072 | vty_out(vty, | |
2073 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2074 | return CMD_WARNING_CONFIG_FAILED; | |
2075 | } | |
f188f2c4 | 2076 | |
d62a17ae | 2077 | bgp->v_update_delay = update_delay; |
2078 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2079 | |
d62a17ae | 2080 | return CMD_SUCCESS; |
f188f2c4 DS |
2081 | } |
2082 | ||
d62a17ae | 2083 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2084 | { |
d62a17ae | 2085 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2086 | |
d70583f7 D |
2087 | /* If configured globally, cannot remove from one bgp instance */ |
2088 | if (bm->v_update_delay) { | |
2089 | vty_out(vty, | |
2090 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2091 | return CMD_WARNING_CONFIG_FAILED; | |
2092 | } | |
d62a17ae | 2093 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2094 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2095 | |
d62a17ae | 2096 | return CMD_SUCCESS; |
f188f2c4 DS |
2097 | } |
2098 | ||
2b791107 | 2099 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2100 | { |
d70583f7 D |
2101 | /* If configured globally, no need to display per-instance value */ |
2102 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2103 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2104 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2105 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2106 | vty_out(vty, "\n"); | |
2107 | } | |
f188f2c4 DS |
2108 | } |
2109 | ||
d70583f7 D |
2110 | /* Global update-delay configuration */ |
2111 | DEFPY (bgp_global_update_delay, | |
2112 | bgp_global_update_delay_cmd, | |
2113 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2114 | BGP_STR | |
2115 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2116 | "Max delay in seconds\n" | |
2117 | "Establish wait in seconds\n") | |
2118 | { | |
2119 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2120 | } | |
f188f2c4 | 2121 | |
d70583f7 D |
2122 | /* Global update-delay deconfiguration */ |
2123 | DEFPY (no_bgp_global_update_delay, | |
2124 | no_bgp_global_update_delay_cmd, | |
2125 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2126 | NO_STR | |
2127 | BGP_STR | |
f188f2c4 | 2128 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2129 | "Max delay in seconds\n" |
2130 | "Establish wait in seconds\n") | |
f188f2c4 | 2131 | { |
d70583f7 | 2132 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2133 | } |
2134 | ||
d70583f7 D |
2135 | /* Update-delay configuration */ |
2136 | ||
2137 | DEFPY (bgp_update_delay, | |
2138 | bgp_update_delay_cmd, | |
2139 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2140 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2141 | "Max delay in seconds\n" |
2142 | "Establish wait in seconds\n") | |
f188f2c4 | 2143 | { |
d70583f7 | 2144 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2145 | } |
2146 | ||
2147 | /* Update-delay deconfiguration */ | |
d70583f7 | 2148 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2149 | no_bgp_update_delay_cmd, |
838758ac DW |
2150 | "no update-delay [(0-3600) [(1-3600)]]", |
2151 | NO_STR | |
f188f2c4 | 2152 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2153 | "Max delay in seconds\n" |
2154 | "Establish wait in seconds\n") | |
f188f2c4 | 2155 | { |
d62a17ae | 2156 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2157 | } |
2158 | ||
5e242b0d | 2159 | |
ff8a8a7a | 2160 | int bgp_wpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
cb1faec9 | 2161 | { |
8fa7732f QY |
2162 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2163 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2164 | |
2165 | return CMD_SUCCESS; | |
2166 | } | |
2167 | ||
ff8a8a7a | 2168 | int bgp_rpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
555e09d4 | 2169 | { |
8fa7732f QY |
2170 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2171 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2172 | |
d62a17ae | 2173 | return CMD_SUCCESS; |
cb1faec9 DS |
2174 | } |
2175 | ||
2b791107 | 2176 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2177 | { |
555e09d4 QY |
2178 | uint32_t quanta = |
2179 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2180 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2181 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2182 | } |
2183 | ||
555e09d4 QY |
2184 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2185 | { | |
2186 | uint32_t quanta = | |
2187 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2188 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2189 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2190 | } |
cb1faec9 | 2191 | |
8fa7732f QY |
2192 | /* Packet quanta configuration |
2193 | * | |
2194 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2195 | * thread. When changing these limits be careful to prevent stack overflow. | |
2196 | * | |
2197 | * Furthermore, the maximums used here should correspond to | |
2198 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2199 | */ | |
37a87b8f CS |
2200 | DEFPY_YANG (bgp_wpkt_quanta, |
2201 | bgp_wpkt_quanta_cmd, | |
2202 | "[no] write-quanta (1-64)$quanta", | |
2203 | NO_STR | |
2204 | "How many packets to write to peer socket per run\n" | |
2205 | "Number of packets\n") | |
ff8a8a7a CS |
2206 | { |
2207 | if (!no) | |
2208 | nb_cli_enqueue_change( | |
2209 | vty, | |
87ce2564 | 2210 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
2211 | NB_OP_MODIFY, quanta_str); |
2212 | else | |
2213 | nb_cli_enqueue_change( | |
2214 | vty, | |
87ce2564 | 2215 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
2216 | NB_OP_MODIFY, NULL); |
2217 | ||
2218 | return nb_cli_apply_changes(vty, NULL); | |
2219 | } | |
2220 | ||
37a87b8f CS |
2221 | DEFPY_YANG (bgp_rpkt_quanta, |
2222 | bgp_rpkt_quanta_cmd, | |
2223 | "[no] read-quanta (1-10)$quanta", | |
2224 | NO_STR | |
2225 | "How many packets to read from peer socket per I/O cycle\n" | |
2226 | "Number of packets\n") | |
ff8a8a7a CS |
2227 | { |
2228 | if (!no) | |
2229 | nb_cli_enqueue_change( | |
2230 | vty, | |
87ce2564 | 2231 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a CS |
2232 | NB_OP_MODIFY, quanta_str); |
2233 | else | |
2234 | nb_cli_enqueue_change( | |
2235 | vty, | |
87ce2564 | 2236 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a | 2237 | NB_OP_MODIFY, NULL); |
cb1faec9 | 2238 | |
ff8a8a7a | 2239 | return nb_cli_apply_changes(vty, NULL); |
555e09d4 QY |
2240 | } |
2241 | ||
2b791107 | 2242 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2243 | { |
37a333fe | 2244 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2245 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2246 | } |
2247 | ||
ff8a8a7a CS |
2248 | void cli_show_router_global_update_group_config_coalesce_time( |
2249 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3f9c7369 | 2250 | { |
ff8a8a7a CS |
2251 | vty_out(vty, " coalesce-time %u\n", yang_dnode_get_uint32(dnode, NULL)); |
2252 | } | |
2253 | ||
4668a151 | 2254 | |
37a87b8f CS |
2255 | DEFUN_YANG (bgp_coalesce_time, |
2256 | bgp_coalesce_time_cmd, | |
2257 | "coalesce-time (0-4294967295)", | |
2258 | "Subgroup coalesce timer\n" | |
2259 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2260 | { |
d62a17ae | 2261 | int idx = 0; |
ff8a8a7a | 2262 | |
d62a17ae | 2263 | argv_find(argv, argc, "(0-4294967295)", &idx); |
87ce2564 CS |
2264 | nb_cli_enqueue_change( |
2265 | vty, "./global/global-update-group-config/coalesce-time", | |
2266 | NB_OP_MODIFY, argv[idx]->arg); | |
ff8a8a7a CS |
2267 | |
2268 | return nb_cli_apply_changes(vty, NULL); | |
3f9c7369 DS |
2269 | } |
2270 | ||
ff8a8a7a CS |
2271 | DEFUN_YANG(no_bgp_coalesce_time, |
2272 | no_bgp_coalesce_time_cmd, | |
2273 | "no coalesce-time (0-4294967295)", | |
2274 | NO_STR | |
2275 | "Subgroup coalesce timer\n" | |
2276 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2277 | { |
87ce2564 CS |
2278 | nb_cli_enqueue_change( |
2279 | vty, "./global/global-update-group-config/coalesce-time", | |
2280 | NB_OP_MODIFY, NULL); | |
4668a151 | 2281 | |
ff8a8a7a | 2282 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
2283 | } |
2284 | ||
5e242b0d | 2285 | /* Maximum-paths configuration */ |
37a87b8f CS |
2286 | DEFUN_YANG (bgp_maxpaths, |
2287 | bgp_maxpaths_cmd, | |
2288 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2289 | "Forward packets over multiple paths\n" | |
2290 | "Number of paths\n") | |
5e242b0d | 2291 | { |
d62a17ae | 2292 | int idx_number = 1; |
37a87b8f CS |
2293 | char base_xpath[XPATH_MAXLEN]; |
2294 | afi_t afi; | |
2295 | safi_t safi; | |
2296 | ||
2297 | afi = bgp_node_afi(vty); | |
2298 | safi = bgp_node_safi(vty); | |
2299 | ||
2300 | snprintf( | |
2301 | base_xpath, sizeof(base_xpath), | |
2302 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths", | |
2303 | yang_afi_safi_value2identity(afi, safi), | |
2304 | bgp_afi_safi_get_container_str(afi, safi)); | |
2305 | ||
2306 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2307 | argv[idx_number]->arg); | |
2308 | ||
2309 | return nb_cli_apply_changes(vty, NULL); | |
2310 | } | |
2311 | ||
2312 | void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths( | |
2313 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
2314 | { | |
2315 | vty_out(vty, " maximum-paths %d\n", | |
2316 | yang_dnode_get_uint16(dnode, NULL)); | |
5e242b0d DS |
2317 | } |
2318 | ||
d62a17ae | 2319 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2320 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2321 | "Forward packets over multiple paths\n" | |
2322 | "Number of paths\n") | |
596c17ba | 2323 | |
37a87b8f CS |
2324 | DEFUN_YANG (bgp_maxpaths_ibgp, |
2325 | bgp_maxpaths_ibgp_cmd, | |
2326 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2327 | "Forward packets over multiple paths\n" | |
2328 | "iBGP-multipath\n" | |
2329 | "Number of paths\n") | |
165b5fff | 2330 | { |
d62a17ae | 2331 | int idx_number = 2; |
37a87b8f CS |
2332 | char base_xpath[XPATH_MAXLEN]; |
2333 | afi_t afi; | |
2334 | safi_t safi; | |
2335 | ||
2336 | afi = bgp_node_afi(vty); | |
2337 | safi = bgp_node_safi(vty); | |
2338 | ||
2339 | snprintf( | |
2340 | base_xpath, sizeof(base_xpath), | |
2341 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2342 | yang_afi_safi_value2identity(afi, safi), | |
2343 | bgp_afi_safi_get_container_str(afi, safi)); | |
2344 | ||
2345 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, | |
2346 | argv[idx_number]->arg); | |
2347 | ||
2348 | return nb_cli_apply_changes(vty, NULL); | |
5e242b0d | 2349 | } |
165b5fff | 2350 | |
d62a17ae | 2351 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2352 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2353 | "Forward packets over multiple paths\n" | |
2354 | "iBGP-multipath\n" | |
2355 | "Number of paths\n") | |
596c17ba | 2356 | |
37a87b8f CS |
2357 | DEFUN_YANG (bgp_maxpaths_ibgp_cluster, |
2358 | bgp_maxpaths_ibgp_cluster_cmd, | |
2359 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2360 | "Forward packets over multiple paths\n" | |
2361 | "iBGP-multipath\n" | |
2362 | "Number of paths\n" | |
2363 | "Match the cluster length\n") | |
5e242b0d | 2364 | { |
d62a17ae | 2365 | int idx_number = 2; |
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/ibgp/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, | |
2380 | argv[idx_number]->arg); | |
2381 | ||
2382 | snprintf( | |
2383 | base_xpath, sizeof(base_xpath), | |
2384 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list", | |
2385 | yang_afi_safi_value2identity(afi, safi), | |
2386 | bgp_afi_safi_get_container_str(afi, safi)); | |
2387 | ||
2388 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, "true"); | |
2389 | ||
2390 | return nb_cli_apply_changes(vty, NULL); | |
2391 | } | |
2392 | ||
2393 | void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths( | |
2394 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
2395 | { | |
2396 | vty_out(vty, " maximum-paths ibgp %d", | |
2397 | yang_dnode_get_uint16(dnode, "./maximum-paths")); | |
2398 | if (yang_dnode_get_bool(dnode, "./cluster-length-list")) | |
2399 | vty_out(vty, " equal-cluster-length"); | |
2400 | vty_out(vty, "\n"); | |
165b5fff JB |
2401 | } |
2402 | ||
d62a17ae | 2403 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2404 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2405 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2406 | "Forward packets over multiple paths\n" | |
2407 | "iBGP-multipath\n" | |
2408 | "Number of paths\n" | |
2409 | "Match the cluster length\n") | |
596c17ba | 2410 | |
37a87b8f CS |
2411 | DEFUN_YANG (no_bgp_maxpaths, |
2412 | no_bgp_maxpaths_cmd, | |
2413 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2414 | NO_STR | |
2415 | "Forward packets over multiple paths\n" | |
2416 | "Number of paths\n") | |
165b5fff | 2417 | { |
37a87b8f CS |
2418 | char base_xpath[XPATH_MAXLEN]; |
2419 | afi_t afi; | |
2420 | safi_t safi; | |
2421 | ||
2422 | afi = bgp_node_afi(vty); | |
2423 | safi = bgp_node_safi(vty); | |
2424 | ||
2425 | snprintf( | |
2426 | base_xpath, sizeof(base_xpath), | |
2427 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths", | |
2428 | yang_afi_safi_value2identity(afi, safi), | |
2429 | bgp_afi_safi_get_container_str(afi, safi)); | |
2430 | ||
2431 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, NULL); | |
2432 | ||
2433 | return nb_cli_apply_changes(vty, NULL); | |
165b5fff JB |
2434 | } |
2435 | ||
d62a17ae | 2436 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2437 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2438 | "Forward packets over multiple paths\n" |
2439 | "Number of paths\n") | |
596c17ba | 2440 | |
37a87b8f CS |
2441 | DEFUN_YANG (no_bgp_maxpaths_ibgp, |
2442 | no_bgp_maxpaths_ibgp_cmd, | |
2443 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2444 | NO_STR | |
2445 | "Forward packets over multiple paths\n" | |
2446 | "iBGP-multipath\n" | |
2447 | "Number of paths\n" | |
2448 | "Match the cluster length\n") | |
165b5fff | 2449 | { |
37a87b8f CS |
2450 | char base_xpath[XPATH_MAXLEN]; |
2451 | afi_t afi; | |
2452 | safi_t safi; | |
2453 | ||
2454 | afi = bgp_node_afi(vty); | |
2455 | safi = bgp_node_safi(vty); | |
2456 | ||
2457 | snprintf( | |
2458 | base_xpath, sizeof(base_xpath), | |
2459 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths", | |
2460 | yang_afi_safi_value2identity(afi, safi), | |
2461 | bgp_afi_safi_get_container_str(afi, safi)); | |
2462 | ||
2463 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, NULL); | |
2464 | ||
2465 | snprintf( | |
2466 | base_xpath, sizeof(base_xpath), | |
2467 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list", | |
2468 | yang_afi_safi_value2identity(afi, safi), | |
2469 | bgp_afi_safi_get_container_str(afi, safi)); | |
2470 | ||
2471 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_MODIFY, "false"); | |
2472 | ||
2473 | return nb_cli_apply_changes(vty, NULL); | |
165b5fff JB |
2474 | } |
2475 | ||
d62a17ae | 2476 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2477 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2478 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2479 | NO_STR | |
2480 | "Forward packets over multiple paths\n" | |
2481 | "iBGP-multipath\n" | |
2482 | "Number of paths\n" | |
2483 | "Match the cluster length\n") | |
596c17ba | 2484 | |
dd65f45e DL |
2485 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2486 | afi_t afi, safi_t safi) | |
165b5fff | 2487 | { |
00908b7a | 2488 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2489 | vty_out(vty, " maximum-paths %d\n", |
2490 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2491 | } | |
165b5fff | 2492 | |
00908b7a | 2493 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2494 | vty_out(vty, " maximum-paths ibgp %d", |
2495 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2496 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2497 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2498 | vty_out(vty, " equal-cluster-length"); | |
2499 | vty_out(vty, "\n"); | |
2500 | } | |
165b5fff | 2501 | } |
6b0655a2 | 2502 | |
718e3744 | 2503 | /* BGP timers. */ |
2504 | ||
37a87b8f CS |
2505 | DEFUN_YANG (bgp_timers, |
2506 | bgp_timers_cmd, | |
2507 | "timers bgp (0-65535) (0-65535)", | |
2508 | "Adjust routing timers\n" | |
2509 | "BGP timers\n" | |
2510 | "Keepalive interval\n" | |
2511 | "Holdtime\n") | |
718e3744 | 2512 | { |
d62a17ae | 2513 | int idx_number = 2; |
2514 | int idx_number_2 = 3; | |
718e3744 | 2515 | |
87ce2564 | 2516 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2517 | NB_OP_MODIFY, argv[idx_number]->arg); |
87ce2564 | 2518 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2519 | NB_OP_MODIFY, argv[idx_number_2]->arg); |
718e3744 | 2520 | |
ff8a8a7a CS |
2521 | return nb_cli_apply_changes(vty, NULL); |
2522 | } | |
718e3744 | 2523 | |
37a87b8f CS |
2524 | DEFUN_YANG (no_bgp_timers, |
2525 | no_bgp_timers_cmd, | |
2526 | "no timers bgp [(0-65535) (0-65535)]", | |
2527 | NO_STR | |
2528 | "Adjust routing timers\n" | |
2529 | "BGP timers\n" | |
2530 | "Keepalive interval\n" | |
2531 | "Holdtime\n") | |
ff8a8a7a | 2532 | { |
87ce2564 | 2533 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2534 | NB_OP_DESTROY, NULL); |
87ce2564 | 2535 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2536 | NB_OP_DESTROY, NULL); |
718e3744 | 2537 | |
ff8a8a7a | 2538 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2539 | } |
2540 | ||
ff8a8a7a CS |
2541 | void cli_show_router_bgp_route_reflector(struct vty *vty, |
2542 | struct lyd_node *dnode, | |
2543 | bool show_defaults) | |
718e3744 | 2544 | { |
ff8a8a7a CS |
2545 | if (yang_dnode_get_bool(dnode, "./no-client-reflect")) |
2546 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
718e3744 | 2547 | |
ff8a8a7a CS |
2548 | if (yang_dnode_get_bool(dnode, "./allow-outbound-policy")) |
2549 | vty_out(vty, " bgp route-reflector allow-outbound-policy\n"); | |
2550 | ||
2551 | if (yang_dnode_exists(dnode, "./route-reflector-cluster-id")) | |
2552 | vty_out(vty, " bgp cluster-id %s\n", | |
2553 | yang_dnode_get_string(dnode, | |
2554 | "./route-reflector-cluster-id")); | |
718e3744 | 2555 | } |
2556 | ||
ff8a8a7a CS |
2557 | DEFUN_YANG(bgp_client_to_client_reflection, |
2558 | bgp_client_to_client_reflection_cmd, | |
2559 | "bgp client-to-client reflection", | |
2560 | "BGP specific commands\n" | |
2561 | "Configure client to client route reflection\n" | |
2562 | "reflection of routes allowed\n") | |
2563 | { | |
87ce2564 | 2564 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2565 | NB_OP_MODIFY, "false"); |
6b0655a2 | 2566 | |
ff8a8a7a CS |
2567 | return nb_cli_apply_changes(vty, NULL); |
2568 | } | |
2569 | ||
2570 | DEFUN_YANG(no_bgp_client_to_client_reflection, | |
2571 | no_bgp_client_to_client_reflection_cmd, | |
2572 | "no bgp client-to-client reflection", | |
2573 | NO_STR | |
2574 | "BGP specific commands\n" | |
2575 | "Configure client to client route reflection\n" | |
2576 | "reflection of routes allowed\n") | |
718e3744 | 2577 | { |
87ce2564 | 2578 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2579 | NB_OP_MODIFY, "true"); |
7aafcaca | 2580 | |
ff8a8a7a | 2581 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2582 | } |
2583 | ||
ff8a8a7a CS |
2584 | void cli_show_router_bgp_route_selection(struct vty *vty, |
2585 | struct lyd_node *dnode, | |
2586 | bool show_defaults) | |
718e3744 | 2587 | { |
7aafcaca | 2588 | |
ff8a8a7a CS |
2589 | if (yang_dnode_get_bool(dnode, "./always-compare-med")) |
2590 | vty_out(vty, " bgp always-compare-med\n"); | |
2591 | ||
2592 | if (yang_dnode_get_bool(dnode, "./ignore-as-path-length")) | |
2593 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
2594 | ||
2595 | if (yang_dnode_get_bool(dnode, "./aspath-confed")) | |
2596 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
2597 | ||
2598 | if (yang_dnode_get_bool(dnode, "./external-compare-router-id")) | |
2599 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
2600 | ||
2601 | if (yang_dnode_get_bool(dnode, "./allow-multiple-as")) { | |
2602 | if (yang_dnode_get_bool(dnode, "./multi-path-as-set")) | |
2603 | vty_out(vty, | |
2604 | " bgp bestpath as-path multipath-relax as-set\n"); | |
2605 | else | |
2606 | vty_out(vty, " bgp bestpath as-path multipath-relax\n"); | |
2607 | } | |
2608 | ||
2609 | if (yang_dnode_get_bool(dnode, "./deterministic-med")) | |
2610 | vty_out(vty, " bgp deterministic-med\n"); | |
2611 | ||
2612 | if (yang_dnode_get_bool(dnode, "./confed-med") | |
2613 | || yang_dnode_get_bool(dnode, "./missing-as-worst-med")) { | |
2614 | vty_out(vty, " bgp bestpath med"); | |
2615 | if (yang_dnode_get_bool(dnode, "./confed-med")) | |
2616 | vty_out(vty, " confed"); | |
2617 | if (yang_dnode_get_bool(dnode, "./missing-as-worst-med")) | |
2618 | vty_out(vty, " missing-as-worst"); | |
2619 | vty_out(vty, "\n"); | |
2620 | } | |
718e3744 | 2621 | } |
2622 | ||
2623 | /* "bgp always-compare-med" configuration. */ | |
ff8a8a7a CS |
2624 | DEFUN_YANG(bgp_always_compare_med, |
2625 | bgp_always_compare_med_cmd, | |
2626 | "bgp always-compare-med", | |
2627 | "BGP specific commands\n" | |
2628 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2629 | { |
87ce2564 CS |
2630 | nb_cli_enqueue_change( |
2631 | vty, "./global/route-selection-options/always-compare-med", | |
2632 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2633 | |
ff8a8a7a | 2634 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2635 | } |
2636 | ||
ff8a8a7a CS |
2637 | DEFUN_YANG(no_bgp_always_compare_med, |
2638 | no_bgp_always_compare_med_cmd, | |
2639 | "no bgp always-compare-med", | |
2640 | NO_STR | |
2641 | "BGP specific commands\n" | |
2642 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2643 | { |
87ce2564 CS |
2644 | nb_cli_enqueue_change( |
2645 | vty, "./global/route-selection-options/always-compare-med", | |
2646 | NB_OP_MODIFY, "false"); | |
7aafcaca | 2647 | |
ff8a8a7a | 2648 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2649 | } |
6b0655a2 | 2650 | |
2adac256 DA |
2651 | DEFUN_YANG(bgp_suppress_duplicates, |
2652 | bgp_suppress_duplicates_cmd, | |
2653 | "bgp suppress-duplicates", | |
2654 | "BGP specific commands\n" | |
2655 | "Suppress duplicate updates if the route actually not changed\n") | |
2656 | { | |
2657 | nb_cli_enqueue_change(vty, "./global/suppress-duplicates", | |
2658 | NB_OP_MODIFY, "true"); | |
2659 | return nb_cli_apply_changes(vty, NULL); | |
2660 | } | |
2661 | ||
2662 | DEFUN_YANG(no_bgp_suppress_duplicates, | |
2663 | no_bgp_suppress_duplicates_cmd, | |
2664 | "no bgp suppress-duplicates", | |
2665 | NO_STR | |
2666 | "BGP specific commands\n" | |
2667 | "Suppress duplicate updates if the route actually not changed\n") | |
2668 | { | |
2669 | nb_cli_enqueue_change(vty, "./global/suppress-duplicates", | |
2670 | NB_OP_MODIFY, "false"); | |
2671 | return nb_cli_apply_changes(vty, NULL); | |
2672 | } | |
2673 | ||
2674 | void cli_show_router_bgp_suppress_duplicates(struct vty *vty, | |
2675 | struct lyd_node *dnode, | |
2676 | bool show_defaults) | |
2677 | { | |
2678 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SUPPRESS_DUPLICATES) | |
2679 | vty_out(vty, " bgp suppress-duplicates\n"); | |
2680 | } | |
2681 | ||
ff8a8a7a CS |
2682 | DEFUN_YANG(bgp_ebgp_requires_policy, |
2683 | bgp_ebgp_requires_policy_cmd, | |
2684 | "bgp ebgp-requires-policy", | |
2685 | "BGP specific commands\n" | |
2686 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2687 | { | |
87ce2564 CS |
2688 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2689 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
2690 | return nb_cli_apply_changes(vty, NULL); |
2691 | } | |
9dac9fc8 | 2692 | |
ff8a8a7a CS |
2693 | DEFUN_YANG(no_bgp_ebgp_requires_policy, |
2694 | no_bgp_ebgp_requires_policy_cmd, | |
2695 | "no bgp ebgp-requires-policy", | |
2696 | NO_STR | |
2697 | "BGP specific commands\n" | |
2698 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
9dac9fc8 | 2699 | { |
87ce2564 CS |
2700 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2701 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 2702 | return nb_cli_apply_changes(vty, NULL); |
9dac9fc8 DA |
2703 | } |
2704 | ||
ff8a8a7a CS |
2705 | void cli_show_router_bgp_ebgp_requires_policy(struct vty *vty, |
2706 | struct lyd_node *dnode, | |
2707 | bool show_defaults) | |
9dac9fc8 | 2708 | { |
ff8a8a7a CS |
2709 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_EBGP_REQUIRES_POLICY) |
2710 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
9dac9fc8 DA |
2711 | } |
2712 | ||
fb29348a DA |
2713 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2714 | "bgp reject-as-sets", | |
2715 | "BGP specific commands\n" | |
2716 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2717 | { | |
2718 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2719 | struct listnode *node, *nnode; | |
2720 | struct peer *peer; | |
2721 | ||
7f972cd8 | 2722 | bgp->reject_as_sets = true; |
fb29348a DA |
2723 | |
2724 | /* Reset existing BGP sessions to reject routes | |
2725 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2726 | */ | |
2727 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2728 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2729 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2730 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2731 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2732 | } | |
2733 | } | |
2734 | ||
2735 | return CMD_SUCCESS; | |
2736 | } | |
2737 | ||
2738 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2739 | "no bgp reject-as-sets", | |
2740 | NO_STR | |
2741 | "BGP specific commands\n" | |
2742 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2743 | { | |
2744 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2745 | struct listnode *node, *nnode; | |
2746 | struct peer *peer; | |
2747 | ||
7f972cd8 | 2748 | bgp->reject_as_sets = false; |
fb29348a DA |
2749 | |
2750 | /* Reset existing BGP sessions to reject routes | |
2751 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2752 | */ | |
2753 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2754 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2755 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2756 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2757 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2758 | } | |
2759 | } | |
2760 | ||
2761 | return CMD_SUCCESS; | |
2762 | } | |
9dac9fc8 | 2763 | |
718e3744 | 2764 | /* "bgp deterministic-med" configuration. */ |
ff8a8a7a | 2765 | DEFUN_YANG (bgp_deterministic_med, |
718e3744 | 2766 | bgp_deterministic_med_cmd, |
2767 | "bgp deterministic-med", | |
2768 | "BGP specific commands\n" | |
2769 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2770 | { | |
87ce2564 CS |
2771 | nb_cli_enqueue_change( |
2772 | vty, "./global/route-selection-options/deterministic-med", | |
2773 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2774 | |
ff8a8a7a | 2775 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2776 | } |
2777 | ||
ff8a8a7a | 2778 | DEFUN_YANG (no_bgp_deterministic_med, |
718e3744 | 2779 | no_bgp_deterministic_med_cmd, |
2780 | "no bgp deterministic-med", | |
2781 | NO_STR | |
2782 | "BGP specific commands\n" | |
2783 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2784 | { | |
87ce2564 CS |
2785 | nb_cli_enqueue_change( |
2786 | vty, "./global/route-selection-options/deterministic-med", | |
2787 | NB_OP_MODIFY, "false"); | |
d62a17ae | 2788 | |
ff8a8a7a | 2789 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2790 | } |
538621f2 | 2791 | |
055679e9 | 2792 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2793 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2794 | bgp_graceful_restart_cmd, |
2795 | "bgp graceful-restart", | |
2796 | "BGP specific commands\n" | |
2797 | GR_CMD | |
055679e9 | 2798 | ) |
538621f2 | 2799 | { |
055679e9 | 2800 | int ret = BGP_GR_FAILURE; |
2801 | ||
2802 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2803 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2804 | |
d62a17ae | 2805 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2806 | |
2807 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2808 | ||
36235319 QY |
2809 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2810 | ret); | |
5cce3f05 | 2811 | |
055679e9 | 2812 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2813 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2814 | vty_out(vty, |
2815 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2816 | return bgp_vty_return(vty, ret); |
538621f2 | 2817 | } |
2818 | ||
2819 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2820 | no_bgp_graceful_restart_cmd, |
2821 | "no bgp graceful-restart", | |
2822 | NO_STR | |
2823 | "BGP specific commands\n" | |
2824 | NO_GR_CMD | |
055679e9 | 2825 | ) |
538621f2 | 2826 | { |
d62a17ae | 2827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2828 | |
2829 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2830 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2831 | |
2832 | int ret = BGP_GR_FAILURE; | |
2833 | ||
2834 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2835 | ||
36235319 QY |
2836 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2837 | ret); | |
5cce3f05 | 2838 | |
055679e9 | 2839 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2840 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2841 | vty_out(vty, |
2842 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2843 | |
2844 | return bgp_vty_return(vty, ret); | |
538621f2 | 2845 | } |
2846 | ||
93406d87 | 2847 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2848 | bgp_graceful_restart_stalepath_time_cmd, |
2849 | "bgp graceful-restart stalepath-time (1-4095)", | |
2850 | "BGP specific commands\n" | |
2851 | "Graceful restart capability parameters\n" | |
2852 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2853 | "Delay value (seconds)\n") | |
93406d87 | 2854 | { |
d62a17ae | 2855 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2856 | int idx_number = 3; | |
d7c0a89a | 2857 | uint32_t stalepath; |
93406d87 | 2858 | |
d62a17ae | 2859 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2860 | bgp->stalepath_time = stalepath; | |
2861 | return CMD_SUCCESS; | |
93406d87 | 2862 | } |
2863 | ||
eb6f1b41 | 2864 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2865 | bgp_graceful_restart_restart_time_cmd, |
2866 | "bgp graceful-restart restart-time (1-4095)", | |
2867 | "BGP specific commands\n" | |
2868 | "Graceful restart capability parameters\n" | |
2869 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2870 | "Delay value (seconds)\n") | |
eb6f1b41 | 2871 | { |
d62a17ae | 2872 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2873 | int idx_number = 3; | |
d7c0a89a | 2874 | uint32_t restart; |
eb6f1b41 | 2875 | |
d62a17ae | 2876 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2877 | bgp->restart_time = restart; | |
2878 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2879 | } |
2880 | ||
cfd47646 | 2881 | DEFUN (bgp_graceful_restart_select_defer_time, |
2882 | bgp_graceful_restart_select_defer_time_cmd, | |
2883 | "bgp graceful-restart select-defer-time (0-3600)", | |
2884 | "BGP specific commands\n" | |
2885 | "Graceful restart capability parameters\n" | |
2886 | "Set the time to defer the BGP route selection after restart\n" | |
2887 | "Delay value (seconds, 0 - disable)\n") | |
2888 | { | |
2889 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2890 | int idx_number = 3; | |
2891 | uint32_t defer_time; | |
2892 | ||
2893 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2894 | bgp->select_defer_time = defer_time; | |
2895 | if (defer_time == 0) | |
892fedb6 | 2896 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2897 | else |
892fedb6 | 2898 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2899 | |
2900 | return CMD_SUCCESS; | |
2901 | } | |
2902 | ||
93406d87 | 2903 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2904 | no_bgp_graceful_restart_stalepath_time_cmd, |
2905 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2906 | NO_STR | |
2907 | "BGP specific commands\n" | |
2908 | "Graceful restart capability parameters\n" | |
2909 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2910 | "Delay value (seconds)\n") | |
93406d87 | 2911 | { |
d62a17ae | 2912 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2913 | |
d62a17ae | 2914 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2915 | return CMD_SUCCESS; | |
93406d87 | 2916 | } |
2917 | ||
eb6f1b41 | 2918 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2919 | no_bgp_graceful_restart_restart_time_cmd, |
2920 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2921 | NO_STR | |
2922 | "BGP specific commands\n" | |
2923 | "Graceful restart capability parameters\n" | |
2924 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2925 | "Delay value (seconds)\n") | |
eb6f1b41 | 2926 | { |
d62a17ae | 2927 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2928 | |
d62a17ae | 2929 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2930 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2931 | } |
2932 | ||
cfd47646 | 2933 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2934 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2935 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2936 | NO_STR | |
2937 | "BGP specific commands\n" | |
2938 | "Graceful restart capability parameters\n" | |
2939 | "Set the time to defer the BGP route selection after restart\n" | |
2940 | "Delay value (seconds)\n") | |
2941 | { | |
2942 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2943 | ||
2944 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2945 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2946 | |
2947 | return CMD_SUCCESS; | |
2948 | } | |
2949 | ||
43fc21b3 | 2950 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2951 | bgp_graceful_restart_preserve_fw_cmd, |
2952 | "bgp graceful-restart preserve-fw-state", | |
2953 | "BGP specific commands\n" | |
2954 | "Graceful restart capability parameters\n" | |
2955 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2956 | { |
d62a17ae | 2957 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2958 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2959 | return CMD_SUCCESS; |
43fc21b3 JC |
2960 | } |
2961 | ||
2962 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2963 | no_bgp_graceful_restart_preserve_fw_cmd, |
2964 | "no bgp graceful-restart preserve-fw-state", | |
2965 | NO_STR | |
2966 | "BGP specific commands\n" | |
2967 | "Graceful restart capability parameters\n" | |
2968 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2969 | { |
d62a17ae | 2970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2971 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2972 | return CMD_SUCCESS; |
43fc21b3 JC |
2973 | } |
2974 | ||
055679e9 | 2975 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2976 | bgp_graceful_restart_disable_cmd, |
2977 | "bgp graceful-restart-disable", | |
2978 | "BGP specific commands\n" | |
2979 | GR_DISABLE) | |
055679e9 | 2980 | { |
2981 | int ret = BGP_GR_FAILURE; | |
2982 | ||
2983 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2984 | zlog_debug( | |
2ba1fe69 | 2985 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2986 | |
055679e9 | 2987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2988 | ||
2989 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2990 | ||
dc95985f | 2991 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2992 | bgp->peer, ret); | |
5cce3f05 | 2993 | |
055679e9 | 2994 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2995 | zlog_debug( | |
2ba1fe69 | 2996 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2997 | vty_out(vty, |
2998 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2999 | ||
055679e9 | 3000 | return bgp_vty_return(vty, ret); |
3001 | } | |
3002 | ||
3003 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 3004 | no_bgp_graceful_restart_disable_cmd, |
3005 | "no bgp graceful-restart-disable", | |
3006 | NO_STR | |
3007 | "BGP specific commands\n" | |
3008 | NO_GR_DISABLE | |
055679e9 | 3009 | ) |
3010 | { | |
3011 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3012 | ||
3013 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3014 | zlog_debug( | |
2ba1fe69 | 3015 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 3016 | |
3017 | int ret = BGP_GR_FAILURE; | |
3018 | ||
3019 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
3020 | ||
36235319 QY |
3021 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
3022 | ret); | |
5cce3f05 | 3023 | |
055679e9 | 3024 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3025 | zlog_debug( | |
2ba1fe69 | 3026 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3027 | vty_out(vty, |
3028 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 3029 | |
3030 | return bgp_vty_return(vty, ret); | |
3031 | } | |
3032 | ||
3033 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 3034 | bgp_neighbor_graceful_restart_set_cmd, |
3035 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3036 | NEIGHBOR_STR | |
3037 | NEIGHBOR_ADDR_STR2 | |
3038 | GR_NEIGHBOR_CMD | |
055679e9 | 3039 | ) |
3040 | { | |
3041 | int idx_peer = 1; | |
3042 | struct peer *peer; | |
3043 | int ret = BGP_GR_FAILURE; | |
3044 | ||
dc95985f | 3045 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3046 | ||
055679e9 | 3047 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3048 | zlog_debug( | |
2ba1fe69 | 3049 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 3050 | |
055679e9 | 3051 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3052 | if (!peer) | |
3053 | return CMD_WARNING_CONFIG_FAILED; | |
3054 | ||
3055 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
3056 | ||
dc95985f | 3057 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3058 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3059 | |
3060 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3061 | zlog_debug( | |
2ba1fe69 | 3062 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3063 | vty_out(vty, |
3064 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3065 | |
3066 | return bgp_vty_return(vty, ret); | |
3067 | } | |
3068 | ||
3069 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 3070 | no_bgp_neighbor_graceful_restart_set_cmd, |
3071 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3072 | NO_STR | |
3073 | NEIGHBOR_STR | |
3074 | NEIGHBOR_ADDR_STR2 | |
3075 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 3076 | ) |
3077 | { | |
3078 | int idx_peer = 2; | |
3079 | int ret = BGP_GR_FAILURE; | |
3080 | struct peer *peer; | |
3081 | ||
dc95985f | 3082 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3083 | ||
055679e9 | 3084 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3085 | if (!peer) | |
3086 | return CMD_WARNING_CONFIG_FAILED; | |
3087 | ||
3088 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3089 | zlog_debug( | |
2ba1fe69 | 3090 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 3091 | |
3092 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
3093 | ||
dc95985f | 3094 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3095 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3096 | |
3097 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3098 | zlog_debug( | |
2ba1fe69 | 3099 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3100 | vty_out(vty, |
3101 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3102 | |
3103 | return bgp_vty_return(vty, ret); | |
3104 | } | |
3105 | ||
3106 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 3107 | bgp_neighbor_graceful_restart_helper_set_cmd, |
3108 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3109 | NEIGHBOR_STR | |
3110 | NEIGHBOR_ADDR_STR2 | |
3111 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3112 | ) |
3113 | { | |
3114 | int idx_peer = 1; | |
3115 | struct peer *peer; | |
3116 | int ret = BGP_GR_FAILURE; | |
3117 | ||
dc95985f | 3118 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3119 | ||
055679e9 | 3120 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3121 | zlog_debug( | |
2ba1fe69 | 3122 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 3123 | |
055679e9 | 3124 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3125 | ||
055679e9 | 3126 | if (!peer) |
3127 | return CMD_WARNING_CONFIG_FAILED; | |
3128 | ||
3129 | ||
3130 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 3131 | |
dc95985f | 3132 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3133 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 3134 | |
055679e9 | 3135 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3136 | zlog_debug( | |
2ba1fe69 | 3137 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3138 | vty_out(vty, |
3139 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3140 | |
3141 | return bgp_vty_return(vty, ret); | |
3142 | } | |
3143 | ||
3144 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 3145 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
3146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3147 | NO_STR | |
3148 | NEIGHBOR_STR | |
3149 | NEIGHBOR_ADDR_STR2 | |
3150 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3151 | ) |
3152 | { | |
3153 | int idx_peer = 2; | |
3154 | int ret = BGP_GR_FAILURE; | |
3155 | struct peer *peer; | |
3156 | ||
dc95985f | 3157 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3158 | ||
055679e9 | 3159 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3160 | if (!peer) | |
3161 | return CMD_WARNING_CONFIG_FAILED; | |
3162 | ||
3163 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3164 | zlog_debug( | |
2ba1fe69 | 3165 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3166 | |
36235319 | 3167 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3168 | |
dc95985f | 3169 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3170 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3171 | |
3172 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3173 | zlog_debug( | |
2ba1fe69 | 3174 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3175 | vty_out(vty, |
3176 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3177 | |
3178 | return bgp_vty_return(vty, ret); | |
3179 | } | |
3180 | ||
3181 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3182 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3183 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3184 | NEIGHBOR_STR | |
3185 | NEIGHBOR_ADDR_STR2 | |
3186 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3187 | ) |
3188 | { | |
3189 | int idx_peer = 1; | |
3190 | struct peer *peer; | |
3191 | int ret = BGP_GR_FAILURE; | |
3192 | ||
dc95985f | 3193 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3194 | ||
055679e9 | 3195 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3196 | zlog_debug( | |
2ba1fe69 | 3197 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3198 | |
3199 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3200 | if (!peer) | |
3201 | return CMD_WARNING_CONFIG_FAILED; | |
3202 | ||
36235319 | 3203 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3204 | |
3205 | if (peer->bgp->t_startup) | |
3206 | bgp_peer_gr_flags_update(peer); | |
3207 | ||
dc95985f | 3208 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3209 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3210 | ||
055679e9 | 3211 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3212 | zlog_debug( | |
2ba1fe69 | 3213 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3214 | vty_out(vty, |
3215 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3216 | |
3217 | return bgp_vty_return(vty, ret); | |
3218 | } | |
3219 | ||
3220 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3221 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3222 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3223 | NO_STR | |
3224 | NEIGHBOR_STR | |
3225 | NEIGHBOR_ADDR_STR2 | |
3226 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3227 | ) |
3228 | { | |
3229 | int idx_peer = 2; | |
3230 | int ret = BGP_GR_FAILURE; | |
3231 | struct peer *peer; | |
3232 | ||
dc95985f | 3233 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3234 | ||
055679e9 | 3235 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3236 | if (!peer) | |
3237 | return CMD_WARNING_CONFIG_FAILED; | |
3238 | ||
3239 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3240 | zlog_debug( | |
2ba1fe69 | 3241 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3242 | |
3243 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3244 | ||
dc95985f | 3245 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3246 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3247 | |
3248 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3249 | zlog_debug( | |
2ba1fe69 | 3250 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3251 | vty_out(vty, |
3252 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3253 | |
3254 | return bgp_vty_return(vty, ret); | |
3255 | } | |
3256 | ||
d6e3c15b | 3257 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3258 | bgp_graceful_restart_disable_eor_cmd, | |
3259 | "bgp graceful-restart disable-eor", | |
3260 | "BGP specific commands\n" | |
3261 | "Graceful restart configuration parameters\n" | |
3262 | "Disable EOR Check\n") | |
3263 | { | |
3264 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3265 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3266 | |
d6e3c15b | 3267 | return CMD_SUCCESS; |
3268 | } | |
3269 | ||
3270 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3271 | no_bgp_graceful_restart_disable_eor_cmd, | |
3272 | "no bgp graceful-restart disable-eor", | |
3273 | NO_STR | |
3274 | "BGP specific commands\n" | |
3275 | "Graceful restart configuration parameters\n" | |
3276 | "Disable EOR Check\n") | |
3277 | { | |
3278 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3279 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3280 | |
3281 | return CMD_SUCCESS; | |
3282 | } | |
3283 | ||
3284 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3285 | bgp_graceful_restart_rib_stale_time_cmd, | |
3286 | "bgp graceful-restart rib-stale-time (1-3600)", | |
3287 | "BGP specific commands\n" | |
3288 | "Graceful restart configuration parameters\n" | |
3289 | "Specify the stale route removal timer in rib\n" | |
3290 | "Delay value (seconds)\n") | |
3291 | { | |
3292 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3293 | int idx_number = 3; | |
3294 | uint32_t stale_time; | |
3295 | ||
3296 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3297 | bgp->rib_stale_time = stale_time; | |
3298 | /* Send the stale timer update message to RIB */ | |
3299 | if (bgp_zebra_stale_timer_update(bgp)) | |
3300 | return CMD_WARNING; | |
3301 | ||
3302 | return CMD_SUCCESS; | |
3303 | } | |
3304 | ||
3305 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3306 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3307 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3308 | NO_STR | |
3309 | "BGP specific commands\n" | |
3310 | "Graceful restart configuration parameters\n" | |
3311 | "Specify the stale route removal timer in rib\n" | |
3312 | "Delay value (seconds)\n") | |
3313 | { | |
3314 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3315 | ||
3316 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3317 | /* Send the stale timer update message to RIB */ | |
3318 | if (bgp_zebra_stale_timer_update(bgp)) | |
3319 | return CMD_WARNING; | |
3320 | ||
d6e3c15b | 3321 | return CMD_SUCCESS; |
3322 | } | |
3323 | ||
ff8a8a7a CS |
3324 | static inline int bgp_initiate_graceful_shut_unshut(struct bgp *bgp, |
3325 | char *errmsg, | |
3326 | size_t errmsg_len) | |
05bd726c | 3327 | { |
3328 | bgp_static_redo_import_check(bgp); | |
3329 | bgp_redistribute_redo(bgp); | |
ff8a8a7a CS |
3330 | if (bgp_clear_star_soft_out(bgp->name, errmsg, errmsg_len) < 0) |
3331 | return -1; | |
3332 | if (bgp_clear_star_soft_in(bgp->name, errmsg, errmsg_len) < 0) | |
3333 | return -1; | |
3334 | ||
3335 | return 0; | |
05bd726c | 3336 | } |
3337 | ||
3338 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3339 | { | |
3340 | struct listnode *node, *nnode; | |
3341 | struct bgp *bgp; | |
3342 | bool vrf_cfg = false; | |
ff8a8a7a | 3343 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3344 | |
3345 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3346 | return CMD_SUCCESS; | |
3347 | ||
3348 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3349 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3350 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3351 | vty_out(vty, | |
3352 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3353 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3354 | VRF_DEFAULT_NAME : bgp->name); | |
3355 | vrf_cfg = true; | |
3356 | } | |
3357 | } | |
3358 | ||
3359 | if (vrf_cfg) { | |
3360 | vty_out(vty, | |
3361 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3362 | return CMD_WARNING; | |
3363 | } | |
3364 | ||
3365 | /* Set flag globally */ | |
3366 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3367 | ||
3368 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3369 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3370 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3371 | sizeof(errmsg)) | |
3372 | < 0) | |
3373 | if (strlen(errmsg)) | |
3374 | vty_out(vty, "%s\n", errmsg); | |
3375 | } | |
05bd726c | 3376 | |
3377 | return CMD_SUCCESS; | |
3378 | } | |
3379 | ||
3380 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3381 | { | |
3382 | struct listnode *node, *nnode; | |
3383 | struct bgp *bgp; | |
ff8a8a7a | 3384 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3385 | |
3386 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3387 | return CMD_SUCCESS; | |
3388 | ||
3389 | /* Unset flag globally */ | |
3390 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3391 | ||
3392 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3393 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3394 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3395 | sizeof(errmsg)) | |
3396 | < 0) | |
3397 | if (strlen(errmsg)) | |
3398 | vty_out(vty, "%s\n", errmsg); | |
3399 | } | |
05bd726c | 3400 | |
3401 | return CMD_SUCCESS; | |
3402 | } | |
3403 | ||
7f323236 DW |
3404 | /* "bgp graceful-shutdown" configuration */ |
3405 | DEFUN (bgp_graceful_shutdown, | |
3406 | bgp_graceful_shutdown_cmd, | |
3407 | "bgp graceful-shutdown", | |
3408 | BGP_STR | |
3409 | "Graceful shutdown parameters\n") | |
3410 | { | |
05bd726c | 3411 | if (vty->node == CONFIG_NODE) |
3412 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3413 | ||
87ce2564 CS |
3414 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3415 | NB_OP_MODIFY, "true"); | |
7f323236 | 3416 | |
ff8a8a7a | 3417 | return nb_cli_apply_changes(vty, NULL); |
7f323236 DW |
3418 | } |
3419 | ||
ff8a8a7a | 3420 | DEFUN_YANG (no_bgp_graceful_shutdown, |
7f323236 DW |
3421 | no_bgp_graceful_shutdown_cmd, |
3422 | "no bgp graceful-shutdown", | |
3423 | NO_STR | |
3424 | BGP_STR | |
3425 | "Graceful shutdown parameters\n") | |
3426 | { | |
05bd726c | 3427 | if (vty->node == CONFIG_NODE) |
3428 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3429 | ||
87ce2564 CS |
3430 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3431 | NB_OP_MODIFY, "false"); | |
05bd726c | 3432 | |
ff8a8a7a CS |
3433 | return nb_cli_apply_changes(vty, NULL); |
3434 | } | |
7f323236 | 3435 | |
ff8a8a7a CS |
3436 | void cli_show_router_bgp_graceful_shutdown(struct vty *vty, |
3437 | struct lyd_node *dnode, | |
3438 | bool show_defaults) | |
3439 | { | |
3440 | if (yang_dnode_get_bool(dnode, NULL)) | |
3441 | vty_out(vty, " bgp graceful-shutdown\n"); | |
7f323236 DW |
3442 | } |
3443 | ||
718e3744 | 3444 | /* "bgp fast-external-failover" configuration. */ |
ff8a8a7a | 3445 | DEFUN_YANG (bgp_fast_external_failover, |
718e3744 | 3446 | bgp_fast_external_failover_cmd, |
3447 | "bgp fast-external-failover", | |
3448 | BGP_STR | |
3449 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3450 | { | |
87ce2564 CS |
3451 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3452 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3453 | |
3454 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 3455 | } |
3456 | ||
ff8a8a7a | 3457 | DEFUN_YANG (no_bgp_fast_external_failover, |
718e3744 | 3458 | no_bgp_fast_external_failover_cmd, |
3459 | "no bgp fast-external-failover", | |
3460 | NO_STR | |
3461 | BGP_STR | |
3462 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3463 | { | |
87ce2564 CS |
3464 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3465 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3466 | |
3467 | return nb_cli_apply_changes(vty, NULL); | |
3468 | } | |
3469 | ||
3470 | void cli_show_router_bgp_fast_external_failover(struct vty *vty, | |
3471 | struct lyd_node *dnode, | |
3472 | bool show_defaults) | |
3473 | { | |
3474 | if (!yang_dnode_get_bool(dnode, NULL)) | |
3475 | vty_out(vty, " no bgp fast-external-failover\n"); | |
718e3744 | 3476 | } |
6b0655a2 | 3477 | |
718e3744 | 3478 | /* "bgp bestpath compare-routerid" configuration. */ |
ff8a8a7a CS |
3479 | DEFUN_YANG(bgp_bestpath_compare_router_id, |
3480 | bgp_bestpath_compare_router_id_cmd, | |
3481 | "bgp bestpath compare-routerid", | |
3482 | "BGP specific commands\n" | |
3483 | "Change the default bestpath selection\n" | |
3484 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3485 | { |
ff8a8a7a | 3486 | nb_cli_enqueue_change( |
87ce2564 CS |
3487 | vty, |
3488 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3489 | NB_OP_MODIFY, "true"); |
7aafcaca | 3490 | |
ff8a8a7a | 3491 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3492 | } |
3493 | ||
ff8a8a7a CS |
3494 | DEFUN_YANG(no_bgp_bestpath_compare_router_id, |
3495 | no_bgp_bestpath_compare_router_id_cmd, | |
3496 | "no bgp bestpath compare-routerid", | |
3497 | NO_STR | |
3498 | "BGP specific commands\n" | |
3499 | "Change the default bestpath selection\n" | |
3500 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3501 | { |
ff8a8a7a | 3502 | nb_cli_enqueue_change( |
87ce2564 CS |
3503 | vty, |
3504 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3505 | NB_OP_MODIFY, "false"); |
7aafcaca | 3506 | |
ff8a8a7a | 3507 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3508 | } |
6b0655a2 | 3509 | |
718e3744 | 3510 | /* "bgp bestpath as-path ignore" configuration. */ |
ff8a8a7a CS |
3511 | DEFUN_YANG(bgp_bestpath_aspath_ignore, |
3512 | bgp_bestpath_aspath_ignore_cmd, | |
3513 | "bgp bestpath as-path ignore", | |
3514 | "BGP specific commands\n" | |
3515 | "Change the default bestpath selection\n" | |
3516 | "AS-path attribute\n" | |
3517 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3518 | { |
87ce2564 CS |
3519 | nb_cli_enqueue_change( |
3520 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3521 | NB_OP_MODIFY, "true"); | |
7aafcaca | 3522 | |
ff8a8a7a | 3523 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3524 | } |
3525 | ||
ff8a8a7a CS |
3526 | DEFUN_YANG(no_bgp_bestpath_aspath_ignore, |
3527 | no_bgp_bestpath_aspath_ignore_cmd, | |
3528 | "no bgp bestpath as-path ignore", | |
3529 | NO_STR | |
3530 | "BGP specific commands\n" | |
3531 | "Change the default bestpath selection\n" | |
3532 | "AS-path attribute\n" | |
3533 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3534 | { |
87ce2564 CS |
3535 | nb_cli_enqueue_change( |
3536 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3537 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3538 | |
ff8a8a7a | 3539 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3540 | } |
6b0655a2 | 3541 | |
6811845b | 3542 | /* "bgp bestpath as-path confed" configuration. */ |
ff8a8a7a | 3543 | DEFUN_YANG (bgp_bestpath_aspath_confed, |
6811845b | 3544 | bgp_bestpath_aspath_confed_cmd, |
3545 | "bgp bestpath as-path confed", | |
3546 | "BGP specific commands\n" | |
3547 | "Change the default bestpath selection\n" | |
3548 | "AS-path attribute\n" | |
3549 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3550 | { | |
87ce2564 CS |
3551 | nb_cli_enqueue_change(vty, |
3552 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3553 | NB_OP_MODIFY, "true"); |
7aafcaca | 3554 | |
ff8a8a7a | 3555 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3556 | } |
3557 | ||
ff8a8a7a | 3558 | DEFUN_YANG (no_bgp_bestpath_aspath_confed, |
6811845b | 3559 | no_bgp_bestpath_aspath_confed_cmd, |
3560 | "no bgp bestpath as-path confed", | |
3561 | NO_STR | |
3562 | "BGP specific commands\n" | |
3563 | "Change the default bestpath selection\n" | |
3564 | "AS-path attribute\n" | |
3565 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3566 | { | |
87ce2564 CS |
3567 | nb_cli_enqueue_change(vty, |
3568 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3569 | NB_OP_MODIFY, "false"); |
7aafcaca | 3570 | |
ff8a8a7a | 3571 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3572 | } |
6b0655a2 | 3573 | |
2fdd455c | 3574 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
ff8a8a7a | 3575 | DEFUN_YANG (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3576 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3577 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3578 | "BGP specific commands\n" |
3579 | "Change the default bestpath selection\n" | |
3580 | "AS-path attribute\n" | |
3581 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3582 | "Generate an AS_SET\n" |
16fc1eec DS |
3583 | "Do not generate an AS_SET\n") |
3584 | { | |
d62a17ae | 3585 | int idx = 0; |
219178b6 | 3586 | |
87ce2564 CS |
3587 | nb_cli_enqueue_change( |
3588 | vty, "./global/route-selection-options/allow-multiple-as", | |
3589 | NB_OP_MODIFY, "true"); | |
d62a17ae | 3590 | if (argv_find(argv, argc, "as-set", &idx)) |
ff8a8a7a | 3591 | nb_cli_enqueue_change( |
87ce2564 CS |
3592 | vty, |
3593 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3594 | NB_OP_MODIFY, "true"); |
d62a17ae | 3595 | else |
ff8a8a7a | 3596 | nb_cli_enqueue_change( |
87ce2564 CS |
3597 | vty, |
3598 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3599 | NB_OP_MODIFY, "false"); |
7aafcaca | 3600 | |
ff8a8a7a | 3601 | return nb_cli_apply_changes(vty, NULL); |
16fc1eec DS |
3602 | } |
3603 | ||
ff8a8a7a | 3604 | DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3605 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3606 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3607 | NO_STR |
3608 | "BGP specific commands\n" | |
3609 | "Change the default bestpath selection\n" | |
3610 | "AS-path attribute\n" | |
3611 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3612 | "Generate an AS_SET\n" |
16fc1eec DS |
3613 | "Do not generate an AS_SET\n") |
3614 | { | |
87ce2564 CS |
3615 | nb_cli_enqueue_change( |
3616 | vty, "./global/route-selection-options/allow-multiple-as", | |
3617 | NB_OP_MODIFY, "false"); | |
3618 | nb_cli_enqueue_change( | |
3619 | vty, "./global/route-selection-options/multi-path-as-set", | |
3620 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3621 | |
ff8a8a7a | 3622 | return nb_cli_apply_changes(vty, NULL); |
2fdd455c | 3623 | } |
6b0655a2 | 3624 | |
ee88563a JM |
3625 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3626 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3627 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3628 | "bgp bestpath peer-type multipath-relax", | |
3629 | BGP_STR | |
3630 | "Change the default bestpath selection\n" | |
3631 | "Peer type\n" | |
3632 | "Allow load sharing across routes learned from different peer types\n") | |
3633 | { | |
3634 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3635 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3636 | bgp_recalculate_all_bestpaths(bgp); | |
3637 | ||
3638 | return CMD_SUCCESS; | |
3639 | } | |
3640 | ||
3641 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3642 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3643 | "no bgp bestpath peer-type multipath-relax", | |
3644 | NO_STR BGP_STR | |
3645 | "Change the default bestpath selection\n" | |
3646 | "Peer type\n" | |
3647 | "Allow load sharing across routes learned from different peer types\n") | |
3648 | { | |
3649 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3650 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3651 | bgp_recalculate_all_bestpaths(bgp); | |
3652 | ||
3653 | return CMD_SUCCESS; | |
3654 | } | |
3655 | ||
848973c7 | 3656 | /* "bgp log-neighbor-changes" configuration. */ |
ff8a8a7a CS |
3657 | DEFUN_YANG(bgp_log_neighbor_changes, |
3658 | bgp_log_neighbor_changes_cmd, | |
3659 | "bgp log-neighbor-changes", | |
3660 | "BGP specific commands\n" | |
3661 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3662 | { |
87ce2564 CS |
3663 | nb_cli_enqueue_change( |
3664 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3665 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3666 | |
3667 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3668 | } |
3669 | ||
ff8a8a7a CS |
3670 | DEFUN_YANG(no_bgp_log_neighbor_changes, |
3671 | no_bgp_log_neighbor_changes_cmd, | |
3672 | "no bgp log-neighbor-changes", | |
3673 | NO_STR | |
3674 | "BGP specific commands\n" | |
3675 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3676 | { |
87ce2564 CS |
3677 | nb_cli_enqueue_change( |
3678 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3679 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3680 | |
3681 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3682 | } |
6b0655a2 | 3683 | |
718e3744 | 3684 | /* "bgp bestpath med" configuration. */ |
ff8a8a7a | 3685 | DEFUN_YANG (bgp_bestpath_med, |
718e3744 | 3686 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3687 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3688 | "BGP specific commands\n" |
3689 | "Change the default bestpath selection\n" | |
3690 | "MED attribute\n" | |
3691 | "Compare MED among confederation paths\n" | |
838758ac DW |
3692 | "Treat missing MED as the least preferred one\n" |
3693 | "Treat missing MED as the least preferred one\n" | |
3694 | "Compare MED among confederation paths\n") | |
718e3744 | 3695 | { |
d62a17ae | 3696 | int idx = 0; |
ff8a8a7a CS |
3697 | bool confed = false; |
3698 | bool worst_med = false; | |
3699 | ||
3700 | ||
d62a17ae | 3701 | if (argv_find(argv, argc, "confed", &idx)) |
ff8a8a7a CS |
3702 | confed = true; |
3703 | ||
87ce2564 CS |
3704 | nb_cli_enqueue_change(vty, |
3705 | "./global/route-selection-options/confed-med", | |
ff8a8a7a CS |
3706 | NB_OP_MODIFY, confed ? "true" : "false"); |
3707 | ||
d62a17ae | 3708 | idx = 0; |
3709 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3710 | worst_med = true; |
e52702f2 | 3711 | |
87ce2564 CS |
3712 | nb_cli_enqueue_change( |
3713 | vty, "./global/route-selection-options/missing-as-worst-med", | |
3714 | NB_OP_MODIFY, worst_med ? "true" : "false"); | |
7aafcaca | 3715 | |
ff8a8a7a | 3716 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3717 | } |
3718 | ||
ff8a8a7a | 3719 | DEFUN_YANG (no_bgp_bestpath_med, |
718e3744 | 3720 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3721 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3722 | NO_STR |
3723 | "BGP specific commands\n" | |
3724 | "Change the default bestpath selection\n" | |
3725 | "MED attribute\n" | |
3726 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3727 | "Treat missing MED as the least preferred one\n" |
3728 | "Treat missing MED as the least preferred one\n" | |
3729 | "Compare MED among confederation paths\n") | |
718e3744 | 3730 | { |
d62a17ae | 3731 | int idx = 0; |
ff8a8a7a | 3732 | |
d62a17ae | 3733 | if (argv_find(argv, argc, "confed", &idx)) |
87ce2564 CS |
3734 | nb_cli_enqueue_change( |
3735 | vty, "./global/route-selection-options/confed-med", | |
3736 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 3737 | |
d62a17ae | 3738 | idx = 0; |
3739 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3740 | nb_cli_enqueue_change( |
87ce2564 CS |
3741 | vty, |
3742 | "./global/route-selection-options/missing-as-worst-med", | |
ff8a8a7a | 3743 | NB_OP_MODIFY, "false"); |
718e3744 | 3744 | |
ff8a8a7a | 3745 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3746 | } |
3747 | ||
f7e1c681 | 3748 | /* "bgp bestpath bandwidth" configuration. */ |
3749 | DEFPY (bgp_bestpath_bw, | |
3750 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3751 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 3752 | "BGP specific commands\n" |
3753 | "Change the default bestpath selection\n" | |
3754 | "Link Bandwidth attribute\n" | |
3755 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3756 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3757 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3758 | { | |
3759 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3760 | afi_t afi; | |
3761 | safi_t safi; | |
3762 | ||
ad36d216 DS |
3763 | if (!bw_cfg) { |
3764 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3765 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3766 | } |
ad36d216 DS |
3767 | if (!strcmp(bw_cfg, "ignore")) |
3768 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3769 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3770 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3771 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3772 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3773 | else | |
3774 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3775 | |
3776 | /* This config is used in route install, so redo that. */ | |
3777 | FOREACH_AFI_SAFI (afi, safi) { | |
3778 | if (!bgp_fibupd_safi(safi)) | |
3779 | continue; | |
3780 | bgp_zebra_announce_table(bgp, afi, safi); | |
3781 | } | |
3782 | ||
3783 | return CMD_SUCCESS; | |
3784 | } | |
3785 | ||
ad36d216 DS |
3786 | DEFPY (no_bgp_bestpath_bw, |
3787 | no_bgp_bestpath_bw_cmd, | |
3788 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3789 | NO_STR | |
3790 | "BGP specific commands\n" | |
3791 | "Change the default bestpath selection\n" | |
3792 | "Link Bandwidth attribute\n" | |
3793 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3794 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3795 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3796 | { | |
3797 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3798 | afi_t afi; | |
3799 | safi_t safi; | |
3800 | ||
3801 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3802 | ||
3803 | /* This config is used in route install, so redo that. */ | |
3804 | FOREACH_AFI_SAFI (afi, safi) { | |
3805 | if (!bgp_fibupd_safi(safi)) | |
3806 | continue; | |
3807 | bgp_zebra_announce_table(bgp, afi, safi); | |
3808 | } | |
3809 | return CMD_SUCCESS; | |
3810 | } | |
3811 | ||
b16bcbba | 3812 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3813 | "[no] bgp default <ipv4-unicast|" |
3814 | "ipv4-multicast|" | |
3815 | "ipv4-vpn|" | |
3816 | "ipv4-labeled-unicast|" | |
3817 | "ipv4-flowspec|" | |
3818 | "ipv6-unicast|" | |
3819 | "ipv6-multicast|" | |
3820 | "ipv6-vpn|" | |
3821 | "ipv6-labeled-unicast|" | |
3822 | "ipv6-flowspec|" | |
3823 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3824 | NO_STR |
e84c59af DA |
3825 | "BGP specific commands\n" |
3826 | "Configure BGP defaults\n" | |
b16bcbba | 3827 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3828 | "Activate ipv4-multicast for a peer by default\n" |
3829 | "Activate ipv4-vpn for a peer by default\n" | |
3830 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3831 | "Activate ipv4-flowspec for a peer by default\n" | |
3832 | "Activate ipv6-unicast for a peer by default\n" | |
3833 | "Activate ipv6-multicast for a peer by default\n" | |
3834 | "Activate ipv6-vpn for a peer by default\n" | |
3835 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3836 | "Activate ipv6-flowspec for a peer by default\n" | |
3837 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3838 | { |
3839 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3840 | char afi_safi_str[strlen(afi_safi) + 1]; |
3841 | char *afi_safi_str_tok; | |
e84c59af | 3842 | |
b16bcbba TA |
3843 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3844 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3845 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3846 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3847 | safi_t safi; |
e84c59af | 3848 | |
38d11af5 TA |
3849 | if (strmatch(safi_str, "labeled")) |
3850 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3851 | else | |
3852 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba TA |
3853 | |
3854 | if (no) | |
3855 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3856 | else { |
3857 | if ((safi == SAFI_LABELED_UNICAST | |
3858 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3859 | || (safi == SAFI_UNICAST | |
3860 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3861 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3862 | else | |
3863 | bgp->default_af[afi][safi] = true; | |
3864 | } | |
718e3744 | 3865 | |
d62a17ae | 3866 | return CMD_SUCCESS; |
718e3744 | 3867 | } |
6b0655a2 | 3868 | |
04b6bdc0 | 3869 | /* Display hostname in certain command outputs */ |
ff8a8a7a | 3870 | DEFUN_YANG (bgp_default_show_hostname, |
04b6bdc0 DW |
3871 | bgp_default_show_hostname_cmd, |
3872 | "bgp default show-hostname", | |
3873 | "BGP specific commands\n" | |
3874 | "Configure BGP defaults\n" | |
0437e105 | 3875 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3876 | { |
87ce2564 CS |
3877 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3878 | "true"); | |
ff8a8a7a CS |
3879 | |
3880 | return nb_cli_apply_changes(vty, NULL); | |
04b6bdc0 DW |
3881 | } |
3882 | ||
ff8a8a7a CS |
3883 | DEFUN_YANG(no_bgp_default_show_hostname, |
3884 | no_bgp_default_show_hostname_cmd, | |
3885 | "no bgp default show-hostname", | |
3886 | NO_STR | |
3887 | "BGP specific commands\n" | |
3888 | "Configure BGP defaults\n" | |
3889 | "Show hostname in certain command outputs\n") | |
04b6bdc0 | 3890 | { |
87ce2564 CS |
3891 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3892 | "false"); | |
ff8a8a7a CS |
3893 | |
3894 | return nb_cli_apply_changes(vty, NULL); | |
3895 | } | |
3896 | ||
3897 | void cli_show_router_bgp_show_hostname(struct vty *vty, struct lyd_node *dnode, | |
3898 | bool show_defaults) | |
3899 | { | |
3900 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3901 | vty_out(vty, " bgp default show-hostname\n"); | |
04b6bdc0 DW |
3902 | } |
3903 | ||
aef999a2 | 3904 | /* Display hostname in certain command outputs */ |
232c75cd CS |
3905 | DEFUN_YANG(bgp_default_show_nexthop_hostname, |
3906 | bgp_default_show_nexthop_hostname_cmd, | |
3907 | "bgp default show-nexthop-hostname", | |
3908 | "BGP specific commands\n" | |
3909 | "Configure BGP defaults\n" | |
3910 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3911 | { |
87ce2564 CS |
3912 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3913 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3914 | |
3915 | return nb_cli_apply_changes(vty, NULL); | |
aef999a2 DA |
3916 | } |
3917 | ||
3918 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3919 | no_bgp_default_show_nexthop_hostname_cmd, | |
3920 | "no bgp default show-nexthop-hostname", | |
3921 | NO_STR | |
3922 | "BGP specific commands\n" | |
3923 | "Configure BGP defaults\n" | |
3924 | "Show hostname for nexthop in certain command outputs\n") | |
3925 | { | |
87ce2564 CS |
3926 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3927 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3928 | |
3929 | return nb_cli_apply_changes(vty, NULL); | |
3930 | } | |
3931 | ||
3932 | void cli_show_router_bgp_show_nexthop_hostname(struct vty *vty, | |
3933 | struct lyd_node *dnode, | |
3934 | bool show_defaults) | |
3935 | { | |
3936 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3937 | vty_out(vty, " bgp default show-nexthop-hostname\n"); | |
aef999a2 DA |
3938 | } |
3939 | ||
8233ef81 | 3940 | /* "bgp network import-check" configuration. */ |
ff8a8a7a CS |
3941 | DEFUN_YANG(bgp_network_import_check, |
3942 | bgp_network_import_check_cmd, | |
3943 | "bgp network import-check", | |
3944 | "BGP specific commands\n" | |
3945 | "BGP network command\n" | |
3946 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3947 | { |
87ce2564 CS |
3948 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3949 | "true"); | |
078430f6 | 3950 | |
ff8a8a7a | 3951 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3952 | } |
3953 | ||
d62a17ae | 3954 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3955 | "bgp network import-check exact", | |
3956 | "BGP specific commands\n" | |
3957 | "BGP network command\n" | |
3958 | "Check BGP network route exists in IGP\n" | |
3959 | "Match route precisely\n") | |
8233ef81 | 3960 | |
ff8a8a7a CS |
3961 | DEFUN_YANG(no_bgp_network_import_check, |
3962 | no_bgp_network_import_check_cmd, | |
3963 | "no bgp network import-check", | |
3964 | NO_STR | |
3965 | "BGP specific commands\n" | |
3966 | "BGP network command\n" | |
3967 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3968 | { |
87ce2564 CS |
3969 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3970 | "false"); | |
5623e905 | 3971 | |
ff8a8a7a | 3972 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3973 | } |
6b0655a2 | 3974 | |
ff8a8a7a CS |
3975 | void cli_show_router_bgp_import_check(struct vty *vty, struct lyd_node *dnode, |
3976 | bool show_defaults) | |
718e3744 | 3977 | { |
ff8a8a7a CS |
3978 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_IMPORT_CHECK) |
3979 | vty_out(vty, " bgp network import-check\n"); | |
3980 | } | |
718e3744 | 3981 | |
ff8a8a7a CS |
3982 | DEFUN_YANG(bgp_default_local_preference, |
3983 | bgp_default_local_preference_cmd, | |
3984 | "bgp default local-preference (0-4294967295)", | |
3985 | "BGP specific commands\n" | |
3986 | "Configure BGP defaults\n" | |
3987 | "local preference (higher=more preferred)\n" | |
3988 | "Configure default local preference value\n") | |
3989 | { | |
3990 | int idx_number = 3; | |
718e3744 | 3991 | |
87ce2564 | 3992 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, |
ff8a8a7a | 3993 | argv[idx_number]->arg); |
718e3744 | 3994 | |
ff8a8a7a | 3995 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3996 | } |
3997 | ||
ff8a8a7a CS |
3998 | DEFUN_YANG(no_bgp_default_local_preference, |
3999 | no_bgp_default_local_preference_cmd, | |
4000 | "no bgp default local-preference [(0-4294967295)]", | |
4001 | NO_STR | |
4002 | "BGP specific commands\n" | |
4003 | "Configure BGP defaults\n" | |
4004 | "local preference (higher=more preferred)\n" | |
4005 | "Configure default local preference value\n") | |
718e3744 | 4006 | { |
87ce2564 | 4007 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, NULL); |
7aafcaca | 4008 | |
ff8a8a7a | 4009 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 4010 | } |
4011 | ||
ff8a8a7a CS |
4012 | void cli_show_router_bgp_local_pref(struct vty *vty, struct lyd_node *dnode, |
4013 | bool show_defaults) | |
4014 | { | |
4015 | vty_out(vty, " bgp default local-preference %u\n", | |
4016 | yang_dnode_get_uint32(dnode, NULL)); | |
4017 | } | |
6b0655a2 | 4018 | |
ff8a8a7a CS |
4019 | |
4020 | DEFUN_YANG(bgp_default_subgroup_pkt_queue_max, | |
4021 | bgp_default_subgroup_pkt_queue_max_cmd, | |
4022 | "bgp default subgroup-pkt-queue-max (20-100)", | |
4023 | "BGP specific commands\n" | |
4024 | "Configure BGP defaults\n" | |
4025 | "subgroup-pkt-queue-max\n" | |
4026 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 4027 | { |
d62a17ae | 4028 | int idx_number = 3; |
3f9c7369 | 4029 | |
ff8a8a7a | 4030 | nb_cli_enqueue_change( |
87ce2564 CS |
4031 | vty, |
4032 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a | 4033 | NB_OP_MODIFY, argv[idx_number]->arg); |
3f9c7369 | 4034 | |
ff8a8a7a | 4035 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
4036 | } |
4037 | ||
ff8a8a7a CS |
4038 | DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max, |
4039 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
4040 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
4041 | NO_STR | |
4042 | "BGP specific commands\n" | |
4043 | "Configure BGP defaults\n" | |
4044 | "subgroup-pkt-queue-max\n" | |
4045 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 4046 | { |
ff8a8a7a | 4047 | nb_cli_enqueue_change( |
87ce2564 CS |
4048 | vty, |
4049 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a CS |
4050 | NB_OP_MODIFY, NULL); |
4051 | ||
4052 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
4053 | } |
4054 | ||
ff8a8a7a CS |
4055 | void cli_show_router_global_update_group_config_subgroup_pkt_queue_size( |
4056 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
4057 | { | |
4058 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
4059 | yang_dnode_get_uint32(dnode, NULL)); | |
4060 | } | |
813d4307 | 4061 | |
ff8a8a7a CS |
4062 | DEFUN_YANG(bgp_rr_allow_outbound_policy, |
4063 | bgp_rr_allow_outbound_policy_cmd, | |
4064 | "bgp route-reflector allow-outbound-policy", | |
4065 | "BGP specific commands\n" | |
4066 | "Allow modifications made by out route-map\n" | |
4067 | "on ibgp neighbors\n") | |
8bd9d948 | 4068 | { |
87ce2564 CS |
4069 | nb_cli_enqueue_change(vty, |
4070 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a | 4071 | NB_OP_MODIFY, "true"); |
8bd9d948 | 4072 | |
ff8a8a7a CS |
4073 | return nb_cli_apply_changes(vty, NULL); |
4074 | } | |
8bd9d948 | 4075 | |
ff8a8a7a CS |
4076 | DEFUN_YANG(no_bgp_rr_allow_outbound_policy, |
4077 | no_bgp_rr_allow_outbound_policy_cmd, | |
4078 | "no bgp route-reflector allow-outbound-policy", | |
4079 | NO_STR | |
4080 | "BGP specific commands\n" | |
4081 | "Allow modifications made by out route-map\n" | |
4082 | "on ibgp neighbors\n") | |
4083 | { | |
87ce2564 CS |
4084 | nb_cli_enqueue_change(vty, |
4085 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a CS |
4086 | NB_OP_MODIFY, "false"); |
4087 | ||
4088 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
4089 | } |
4090 | ||
ff8a8a7a CS |
4091 | |
4092 | void cli_show_router_global_neighbor_config(struct vty *vty, | |
4093 | struct lyd_node *dnode, | |
4094 | bool show_defaults) | |
8bd9d948 | 4095 | { |
ff8a8a7a CS |
4096 | uint32_t write_quanta, read_quanta; |
4097 | ||
4098 | if (yang_dnode_get_bool(dnode, "./log-neighbor-changes")) | |
4099 | vty_out(vty, " bgp log-neighbor-changes\n"); | |
8bd9d948 | 4100 | |
ff8a8a7a CS |
4101 | if (yang_dnode_exists(dnode, "./dynamic-neighbors-limit")) { |
4102 | uint32_t listen_limit = yang_dnode_get_uint32( | |
4103 | dnode, "./dynamic-neighbors-limit"); | |
4104 | vty_out(vty, " bgp listen limit %u\n", listen_limit); | |
d62a17ae | 4105 | } |
8bd9d948 | 4106 | |
ff8a8a7a CS |
4107 | write_quanta = yang_dnode_get_uint32( |
4108 | dnode, "./packet-quanta-config/wpkt-quanta"); | |
4109 | if (write_quanta != BGP_WRITE_PACKET_MAX) | |
4110 | vty_out(vty, " write-quanta %d\n", write_quanta); | |
4111 | ||
4112 | read_quanta = yang_dnode_get_uint32( | |
4113 | dnode, "./packet-quanta-config/rpkt-quanta"); | |
4114 | ||
4115 | if (read_quanta != BGP_READ_PACKET_MAX) | |
4116 | vty_out(vty, " read-quanta %d\n", read_quanta); | |
8bd9d948 DS |
4117 | } |
4118 | ||
ff8a8a7a CS |
4119 | DEFUN_YANG(bgp_listen_limit, |
4120 | bgp_listen_limit_cmd, | |
5b1b6b8b | 4121 | "bgp listen limit (1-65535)", |
ff8a8a7a CS |
4122 | "BGP specific commands\n" |
4123 | "BGP Dynamic Neighbors listen commands\n" | |
4124 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4125 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4126 | { |
d62a17ae | 4127 | int idx_number = 3; |
f14e6fdb | 4128 | |
ff8a8a7a | 4129 | nb_cli_enqueue_change( |
87ce2564 | 4130 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a | 4131 | NB_OP_MODIFY, argv[idx_number]->arg); |
f14e6fdb | 4132 | |
ff8a8a7a | 4133 | return nb_cli_apply_changes(vty, NULL); |
f14e6fdb DS |
4134 | } |
4135 | ||
ff8a8a7a CS |
4136 | DEFUN_YANG(no_bgp_listen_limit, |
4137 | no_bgp_listen_limit_cmd, | |
5b1b6b8b | 4138 | "no bgp listen limit [(1-65535)]", |
ff8a8a7a CS |
4139 | NO_STR |
4140 | "BGP specific commands\n" | |
4141 | "BGP Dynamic Neighbors listen commands\n" | |
4142 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4143 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4144 | { |
ff8a8a7a | 4145 | nb_cli_enqueue_change( |
87ce2564 | 4146 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a CS |
4147 | NB_OP_DESTROY, NULL); |
4148 | ||
4149 | return nb_cli_apply_changes(vty, NULL); | |
f14e6fdb DS |
4150 | } |
4151 | ||
4152 | ||
20eb8864 | 4153 | /* |
4154 | * Check if this listen range is already configured. Check for exact | |
4155 | * match or overlap based on input. | |
4156 | */ | |
d62a17ae | 4157 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
4158 | struct prefix *range, int exact) | |
4159 | { | |
4160 | struct listnode *node, *nnode; | |
4161 | struct listnode *node1, *nnode1; | |
4162 | struct peer_group *group; | |
4163 | struct prefix *lr; | |
4164 | afi_t afi; | |
4165 | int match; | |
4166 | ||
4167 | afi = family2afi(range->family); | |
4168 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4169 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4170 | lr)) { | |
4171 | if (exact) | |
4172 | match = prefix_same(range, lr); | |
4173 | else | |
4174 | match = (prefix_match(range, lr) | |
4175 | || prefix_match(lr, range)); | |
4176 | if (match) | |
4177 | return group; | |
4178 | } | |
4179 | } | |
4180 | ||
4181 | return NULL; | |
20eb8864 | 4182 | } |
4183 | ||
f14e6fdb DS |
4184 | DEFUN (bgp_listen_range, |
4185 | bgp_listen_range_cmd, | |
d7b9898c | 4186 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 4187 | "BGP specific commands\n" |
d7fa34c1 QY |
4188 | "Configure BGP dynamic neighbors listen range\n" |
4189 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
4190 | NEIGHBOR_ADDR_STR |
4191 | "Member of the peer-group\n" | |
4192 | "Peer-group name\n") | |
f14e6fdb | 4193 | { |
d62a17ae | 4194 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4195 | struct prefix range; | |
4196 | struct peer_group *group, *existing_group; | |
4197 | afi_t afi; | |
4198 | int ret; | |
4199 | int idx = 0; | |
4200 | ||
4201 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4202 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4203 | char *prefix = argv[idx]->arg; | |
d7b9898c | 4204 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4205 | char *peergroup = argv[idx]->arg; |
4206 | ||
4207 | /* Convert IP prefix string to struct prefix. */ | |
4208 | ret = str2prefix(prefix, &range); | |
4209 | if (!ret) { | |
4210 | vty_out(vty, "%% Malformed listen range\n"); | |
4211 | return CMD_WARNING_CONFIG_FAILED; | |
4212 | } | |
4213 | ||
4214 | afi = family2afi(range.family); | |
4215 | ||
4216 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4217 | vty_out(vty, | |
4218 | "%% Malformed listen range (link-local address)\n"); | |
4219 | return CMD_WARNING_CONFIG_FAILED; | |
4220 | } | |
4221 | ||
4222 | apply_mask(&range); | |
4223 | ||
4224 | /* Check if same listen range is already configured. */ | |
4225 | existing_group = listen_range_exists(bgp, &range, 1); | |
4226 | if (existing_group) { | |
4227 | if (strcmp(existing_group->name, peergroup) == 0) | |
4228 | return CMD_SUCCESS; | |
4229 | else { | |
4230 | vty_out(vty, | |
4231 | "%% Same listen range is attached to peer-group %s\n", | |
4232 | existing_group->name); | |
4233 | return CMD_WARNING_CONFIG_FAILED; | |
4234 | } | |
4235 | } | |
4236 | ||
4237 | /* Check if an overlapping listen range exists. */ | |
4238 | if (listen_range_exists(bgp, &range, 0)) { | |
4239 | vty_out(vty, | |
4240 | "%% Listen range overlaps with existing listen range\n"); | |
4241 | return CMD_WARNING_CONFIG_FAILED; | |
4242 | } | |
4243 | ||
4244 | group = peer_group_lookup(bgp, peergroup); | |
4245 | if (!group) { | |
4246 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4247 | return CMD_WARNING_CONFIG_FAILED; | |
4248 | } | |
4249 | ||
4250 | ret = peer_group_listen_range_add(group, &range); | |
4251 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4252 | } |
4253 | ||
4254 | DEFUN (no_bgp_listen_range, | |
4255 | no_bgp_listen_range_cmd, | |
d7b9898c | 4256 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4257 | NO_STR |
f14e6fdb | 4258 | "BGP specific commands\n" |
d7fa34c1 QY |
4259 | "Unconfigure BGP dynamic neighbors listen range\n" |
4260 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4261 | NEIGHBOR_ADDR_STR | |
4262 | "Member of the peer-group\n" | |
4263 | "Peer-group name\n") | |
f14e6fdb | 4264 | { |
d62a17ae | 4265 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4266 | struct prefix range; | |
4267 | struct peer_group *group; | |
4268 | afi_t afi; | |
4269 | int ret; | |
4270 | int idx = 0; | |
4271 | ||
4272 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4273 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4274 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4275 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4276 | char *peergroup = argv[idx]->arg; |
4277 | ||
4278 | /* Convert IP prefix string to struct prefix. */ | |
4279 | ret = str2prefix(prefix, &range); | |
4280 | if (!ret) { | |
4281 | vty_out(vty, "%% Malformed listen range\n"); | |
4282 | return CMD_WARNING_CONFIG_FAILED; | |
4283 | } | |
4284 | ||
4285 | afi = family2afi(range.family); | |
4286 | ||
4287 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4288 | vty_out(vty, | |
4289 | "%% Malformed listen range (link-local address)\n"); | |
4290 | return CMD_WARNING_CONFIG_FAILED; | |
4291 | } | |
4292 | ||
4293 | apply_mask(&range); | |
4294 | ||
4295 | group = peer_group_lookup(bgp, peergroup); | |
4296 | if (!group) { | |
4297 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4298 | return CMD_WARNING_CONFIG_FAILED; | |
4299 | } | |
4300 | ||
4301 | ret = peer_group_listen_range_del(group, &range); | |
4302 | return bgp_vty_return(vty, ret); | |
4303 | } | |
4304 | ||
2b791107 | 4305 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4306 | { |
4307 | struct peer_group *group; | |
4308 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4309 | struct prefix *range; | |
4310 | afi_t afi; | |
d62a17ae | 4311 | |
4312 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4313 | vty_out(vty, " bgp listen limit %d\n", | |
4314 | bgp->dynamic_neighbors_limit); | |
4315 | ||
4316 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4317 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4318 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4319 | nrnode, range)) { | |
d62a17ae | 4320 | vty_out(vty, |
2dbe669b DA |
4321 | " bgp listen range %pFX peer-group %s\n", |
4322 | range, group->name); | |
d62a17ae | 4323 | } |
4324 | } | |
4325 | } | |
f14e6fdb DS |
4326 | } |
4327 | ||
4328 | ||
ff8a8a7a CS |
4329 | DEFUN_YANG(bgp_disable_connected_route_check, |
4330 | bgp_disable_connected_route_check_cmd, | |
4331 | "bgp disable-ebgp-connected-route-check", | |
4332 | "BGP specific commands\n" | |
4333 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 4334 | { |
87ce2564 CS |
4335 | nb_cli_enqueue_change(vty, |
4336 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 4337 | NB_OP_MODIFY, "true"); |
7aafcaca | 4338 | |
ff8a8a7a | 4339 | return nb_cli_apply_changes(vty, NULL); |
907f92c8 DS |
4340 | } |
4341 | ||
ff8a8a7a CS |
4342 | DEFUN_YANG(no_bgp_disable_connected_route_check, |
4343 | no_bgp_disable_connected_route_check_cmd, | |
4344 | "no bgp disable-ebgp-connected-route-check", | |
4345 | NO_STR | |
4346 | "BGP specific commands\n" | |
4347 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 4348 | { |
87ce2564 CS |
4349 | nb_cli_enqueue_change(vty, |
4350 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 4351 | NB_OP_MODIFY, "false"); |
d62a17ae | 4352 | |
ff8a8a7a | 4353 | return nb_cli_apply_changes(vty, NULL); |
d62a17ae | 4354 | } |
4355 | ||
ff8a8a7a CS |
4356 | void cli_show_router_global_ebgp_multihop_connected_route_check( |
4357 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
4358 | { | |
4359 | if (yang_dnode_get_bool(dnode, NULL)) | |
4360 | vty_out(vty, " bgp disable-ebgp-connected-route-check\n"); | |
4361 | } | |
d62a17ae | 4362 | |
ff8a8a7a CS |
4363 | DEFUN_YANG(bgp_default_shutdown, |
4364 | bgp_default_shutdown_cmd, | |
4365 | "[no] bgp default shutdown", | |
4366 | NO_STR BGP_STR | |
4367 | "Configure BGP defaults\n" | |
4368 | "Apply administrative shutdown to newly configured peers\n") | |
f26845f9 | 4369 | { |
87ce2564 | 4370 | nb_cli_enqueue_change(vty, "./global/default-shutdown", NB_OP_MODIFY, |
ff8a8a7a CS |
4371 | strmatch(argv[0]->text, "no") ? "false" : "true"); |
4372 | ||
4373 | return nb_cli_apply_changes(vty, NULL); | |
4374 | } | |
4375 | ||
4376 | void cli_show_router_bgp_default_shutdown(struct vty *vty, | |
4377 | struct lyd_node *dnode, | |
4378 | bool show_defaults) | |
4379 | { | |
4380 | if (yang_dnode_get_bool(dnode, NULL)) | |
4381 | vty_out(vty, " bgp default shutdown\n"); | |
f26845f9 QY |
4382 | } |
4383 | ||
736b68f3 DS |
4384 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4385 | BGP_STR | |
9ddf4b81 | 4386 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4387 | "Add a shutdown message (RFC 8203)\n" |
4388 | "Shutdown message\n") | |
9cf59432 | 4389 | { |
736b68f3 | 4390 | char *msgstr = NULL; |
8389c83a | 4391 | |
9cf59432 DS |
4392 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4393 | ||
8389c83a | 4394 | if (argc > 3) |
f80e35b6 | 4395 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4396 | |
4397 | bgp_shutdown_enable(bgp, msgstr); | |
4398 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4399 | |
4400 | return CMD_SUCCESS; | |
4401 | } | |
4402 | ||
736b68f3 | 4403 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4404 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4405 | { |
4406 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4407 | ||
4408 | bgp_shutdown_enable(bgp, NULL); | |
4409 | ||
4410 | return CMD_SUCCESS; | |
4411 | } | |
8389c83a | 4412 | |
736b68f3 | 4413 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4414 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4415 | { |
4416 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4417 | ||
4418 | bgp_shutdown_disable(bgp); | |
4419 | ||
4420 | return CMD_SUCCESS; | |
4421 | } | |
4422 | ||
9ddf4b81 | 4423 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4424 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4425 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4426 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4427 | |
f4b8ec07 CS |
4428 | DEFUN_YANG(neighbor_remote_as, |
4429 | neighbor_remote_as_cmd, | |
4430 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4431 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4432 | "Specify a BGP neighbor\n" AS_STR | |
4433 | "Internal BGP peer\n" | |
4434 | "External BGP peer\n") | |
718e3744 | 4435 | { |
d62a17ae | 4436 | int idx_peer = 1; |
4437 | int idx_remote_as = 3; | |
f4b8ec07 CS |
4438 | char base_xpath[XPATH_MAXLEN]; |
4439 | char unnbr_xpath[XPATH_MAXLEN]; | |
4440 | char prgrp_xpath[XPATH_MAXLEN]; | |
4441 | union sockunion su; | |
4442 | const char *as_type_str = "as-specified"; | |
4443 | ||
4444 | if (str2sockunion(argv[idx_peer]->arg, &su) < 0) { | |
4445 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4446 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4447 | ||
4448 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4449 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4450 | ||
3bb513c3 CH |
4451 | if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
4452 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
f4b8ec07 | 4453 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); |
3bb513c3 CH |
4454 | } else if (yang_dnode_existsf(vty->candidate_config->dnode, |
4455 | "%s%s", VTY_CURR_XPATH, | |
4456 | prgrp_xpath + 1)) { | |
f4b8ec07 CS |
4457 | snprintf(base_xpath, sizeof(base_xpath), |
4458 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, | |
4459 | ""); | |
4460 | } else { | |
4461 | vty_out(vty, | |
4462 | "%% Create the peer-group or interface first\n"); | |
4463 | return CMD_WARNING_CONFIG_FAILED; | |
4464 | } | |
4465 | } else { | |
4466 | snprintf(base_xpath, sizeof(base_xpath), | |
4467 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
4468 | } | |
4469 | ||
4470 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4471 | as_type_str = "internal"; | |
4472 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4473 | as_type_str = "external"; | |
4474 | } else { | |
4475 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4476 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4477 | } | |
4478 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4479 | NB_OP_MODIFY, as_type_str); | |
4480 | ||
4481 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 4482 | } |
4483 | ||
e84c59af DA |
4484 | int peer_conf_interface_create(struct bgp *bgp, const char *conf_if, |
4485 | bool v6only, const char *peer_group_name, | |
4486 | int as_type, as_t as, char *errmsg, | |
4487 | size_t errmsg_len) | |
d62a17ae | 4488 | { |
d62a17ae | 4489 | struct peer *peer; |
4490 | struct peer_group *group; | |
4491 | int ret = 0; | |
d62a17ae | 4492 | |
4493 | group = peer_group_lookup(bgp, conf_if); | |
4494 | ||
4495 | if (group) { | |
f4b8ec07 CS |
4496 | snprintf(errmsg, errmsg_len, |
4497 | "Name conflict with peer-group \n"); | |
4498 | return -1; | |
d62a17ae | 4499 | } |
4500 | ||
4501 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4502 | if (peer) { | |
f4b8ec07 | 4503 | if (as_type != AS_UNSPECIFIED) |
e84c59af | 4504 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4505 | } else { |
e84c59af DA |
4506 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4507 | NULL); | |
d62a17ae | 4508 | |
4509 | if (!peer) { | |
f4b8ec07 CS |
4510 | snprintf(errmsg, errmsg_len, |
4511 | "BGP failed to create peer\n"); | |
4512 | return -1; | |
d62a17ae | 4513 | } |
4514 | ||
4515 | if (v6only) | |
527de3dc | 4516 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4517 | |
4518 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4519 | * this | |
4520 | * any unnumbered peer in order to not worry about run-time | |
4521 | * transitions | |
4522 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4523 | * address | |
4524 | * gets deleted later etc.) | |
4525 | */ | |
4526 | if (peer->ifp) | |
4527 | bgp_zebra_initiate_radv(bgp, peer); | |
4528 | } | |
4529 | ||
4530 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4531 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4532 | if (v6only) | |
527de3dc | 4533 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4534 | else |
527de3dc | 4535 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4536 | |
4537 | /* v6only flag changed. Reset bgp seesion */ | |
4538 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4539 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4540 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4541 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4542 | } else | |
4543 | bgp_session_reset(peer); | |
4544 | } | |
4545 | ||
9fb964de PM |
4546 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4547 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4548 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4549 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4550 | } |
d62a17ae | 4551 | |
4552 | if (peer_group_name) { | |
4553 | group = peer_group_lookup(bgp, peer_group_name); | |
4554 | if (!group) { | |
f4b8ec07 CS |
4555 | snprintf(errmsg, errmsg_len, |
4556 | "Configure the peer-group first\n"); | |
4557 | return -1; | |
d62a17ae | 4558 | } |
4559 | ||
8395c1f8 | 4560 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4561 | } |
4562 | ||
f4b8ec07 | 4563 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); |
a80beece DS |
4564 | } |
4565 | ||
232c75cd CS |
4566 | DEFUN_YANG(neighbor_interface_config, |
4567 | neighbor_interface_config_cmd, | |
f4b8ec07 CS |
4568 | "neighbor WORD interface [peer-group PGNAME]", |
4569 | NEIGHBOR_STR | |
4570 | "Interface name or neighbor tag\n" | |
4571 | "Enable BGP on interface\n" | |
4572 | "Member of the peer-group\n" | |
4573 | "Peer-group name\n") | |
4c48cf63 | 4574 | { |
d62a17ae | 4575 | int idx_word = 1; |
4576 | int idx_peer_group_word = 4; | |
f4b8ec07 CS |
4577 | char base_xpath[XPATH_MAXLEN]; |
4578 | ||
4579 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4580 | argv[idx_word]->arg, ""); | |
31500417 | 4581 | |
f4b8ec07 | 4582 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4583 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4584 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4585 | argv[idx_peer_group_word]->arg); | |
4586 | ||
4587 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4588 | } |
4589 | ||
f4b8ec07 CS |
4590 | DEFUN_YANG(neighbor_interface_config_v6only, |
4591 | neighbor_interface_config_v6only_cmd, | |
4592 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4593 | NEIGHBOR_STR | |
4594 | "Interface name or neighbor tag\n" | |
4595 | "Enable BGP on interface\n" | |
4596 | "Enable BGP with v6 link-local only\n" | |
4597 | "Member of the peer-group\n" | |
4598 | "Peer-group name\n") | |
4c48cf63 | 4599 | { |
d62a17ae | 4600 | int idx_word = 1; |
4601 | int idx_peer_group_word = 5; | |
f4b8ec07 CS |
4602 | char base_xpath[XPATH_MAXLEN]; |
4603 | ||
4604 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4605 | argv[idx_word]->arg, ""); | |
31500417 | 4606 | |
f4b8ec07 | 4607 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
d62a17ae | 4608 | if (argc > idx_peer_group_word) |
f4b8ec07 CS |
4609 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_MODIFY, |
4610 | argv[idx_peer_group_word]->arg); | |
31500417 | 4611 | |
f4b8ec07 CS |
4612 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); |
4613 | ||
4614 | return nb_cli_apply_changes(vty, base_xpath); | |
4c48cf63 DW |
4615 | } |
4616 | ||
a80beece | 4617 | |
f4b8ec07 CS |
4618 | DEFUN_YANG( |
4619 | neighbor_interface_config_remote_as, | |
4620 | neighbor_interface_config_remote_as_cmd, | |
4621 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4622 | NEIGHBOR_STR | |
4623 | "Interface name or neighbor tag\n" | |
4624 | "Enable BGP on interface\n" | |
4625 | "Specify a BGP neighbor\n" AS_STR | |
4626 | "Internal BGP peer\n" | |
4627 | "External BGP peer\n") | |
b3a39dc5 | 4628 | { |
d62a17ae | 4629 | int idx_word = 1; |
4630 | int idx_remote_as = 4; | |
f4b8ec07 CS |
4631 | char base_xpath[XPATH_MAXLEN]; |
4632 | const char *as_type_str = "as-specified"; | |
4633 | ||
4634 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4635 | argv[idx_word]->arg, ""); | |
4636 | ||
4637 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4638 | ||
4639 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4640 | as_type_str = "internal"; | |
4641 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4642 | as_type_str = "external"; | |
4643 | } else { | |
4644 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4645 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4646 | } | |
4647 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4648 | NB_OP_MODIFY, as_type_str); | |
4649 | ||
4650 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4651 | } |
4652 | ||
f4b8ec07 CS |
4653 | DEFUN_YANG( |
4654 | neighbor_interface_v6only_config_remote_as, | |
4655 | neighbor_interface_v6only_config_remote_as_cmd, | |
4656 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4657 | NEIGHBOR_STR | |
4658 | "Interface name or neighbor tag\n" | |
4659 | "Enable BGP with v6 link-local only\n" | |
4660 | "Enable BGP on interface\n" | |
4661 | "Specify a BGP neighbor\n" AS_STR | |
4662 | "Internal BGP peer\n" | |
4663 | "External BGP peer\n") | |
b3a39dc5 | 4664 | { |
d62a17ae | 4665 | int idx_word = 1; |
4666 | int idx_remote_as = 5; | |
f4b8ec07 CS |
4667 | char base_xpath[XPATH_MAXLEN]; |
4668 | const char *as_type_str = "as-specified"; | |
4669 | ||
4670 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, | |
4671 | argv[idx_word]->arg, ""); | |
4672 | ||
4673 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
4674 | ||
4675 | nb_cli_enqueue_change(vty, "./v6only", NB_OP_MODIFY, "true"); | |
4676 | ||
4677 | if (argv[idx_remote_as]->arg[0] == 'i') { | |
4678 | as_type_str = "internal"; | |
4679 | } else if (argv[idx_remote_as]->arg[0] == 'e') { | |
4680 | as_type_str = "external"; | |
4681 | } else { | |
4682 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as", | |
4683 | NB_OP_MODIFY, argv[idx_remote_as]->arg); | |
4684 | } | |
4685 | nb_cli_enqueue_change(vty, "./neighbor-remote-as/remote-as-type", | |
4686 | NB_OP_MODIFY, as_type_str); | |
4687 | ||
4688 | return nb_cli_apply_changes(vty, base_xpath); | |
b3a39dc5 DD |
4689 | } |
4690 | ||
f4b8ec07 CS |
4691 | DEFUN_YANG(neighbor_peer_group, neighbor_peer_group_cmd, |
4692 | "neighbor WORD peer-group", | |
4693 | NEIGHBOR_STR | |
4694 | "Interface name or neighbor tag\n" | |
4695 | "Configure peer-group\n") | |
718e3744 | 4696 | { |
f4b8ec07 | 4697 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4698 | int idx_word = 1; |
718e3744 | 4699 | |
f4b8ec07 CS |
4700 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4701 | argv[idx_word]->arg, ""); | |
718e3744 | 4702 | |
f4b8ec07 | 4703 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
718e3744 | 4704 | |
f4b8ec07 | 4705 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 4706 | } |
4707 | ||
232c75cd CS |
4708 | DEFUN_YANG(no_neighbor, |
4709 | no_neighbor_cmd, | |
4710 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4711 | NO_STR NEIGHBOR_STR | |
4712 | NEIGHBOR_ADDR_STR2 | |
4713 | "Specify a BGP neighbor\n" AS_STR | |
4714 | "Internal BGP peer\n" | |
4715 | "External BGP peer\n") | |
718e3744 | 4716 | { |
d62a17ae | 4717 | int idx_peer = 2; |
f4b8ec07 CS |
4718 | char base_xpath[XPATH_MAXLEN]; |
4719 | char num_xpath[XPATH_MAXLEN]; | |
4720 | char unnbr_xpath[XPATH_MAXLEN]; | |
4721 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4722 | union sockunion su; |
d62a17ae | 4723 | |
f4b8ec07 CS |
4724 | if (str2sockunion(argv[idx_peer]->arg, &su) == 0) { |
4725 | snprintf(num_xpath, sizeof(num_xpath), | |
4726 | FRR_BGP_NEIGHBOR_NUM_XPATH, argv[idx_peer]->arg, ""); | |
3bb513c3 CH |
4727 | if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
4728 | VTY_CURR_XPATH, num_xpath + 1)) { | |
f4b8ec07 | 4729 | strlcpy(base_xpath, num_xpath, sizeof(base_xpath)); |
d62a17ae | 4730 | } |
f4b8ec07 CS |
4731 | } else { |
4732 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
4733 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, argv[idx_peer]->arg, ""); | |
4734 | ||
4735 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
4736 | FRR_BGP_PEER_GROUP_XPATH, argv[idx_peer]->arg, ""); | |
4737 | ||
3bb513c3 CH |
4738 | if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
4739 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
f4b8ec07 | 4740 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); |
3bb513c3 CH |
4741 | } else if (yang_dnode_existsf(vty->candidate_config->dnode, |
4742 | "%s%s", VTY_CURR_XPATH, | |
4743 | prgrp_xpath + 1)) { | |
f4b8ec07 | 4744 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); |
4e2786df | 4745 | } else { |
f4b8ec07 CS |
4746 | vty_out(vty, |
4747 | "%% Create the peer-group or interface first\n"); | |
d62a17ae | 4748 | return CMD_WARNING_CONFIG_FAILED; |
4749 | } | |
1ff9a340 | 4750 | } |
718e3744 | 4751 | |
f4b8ec07 CS |
4752 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); |
4753 | ||
fd396924 CH |
4754 | /* |
4755 | * Need to commit any pending so this command doesn't merge with a | |
4756 | * create into a modify, which BGP can't handle | |
4757 | */ | |
4758 | return nb_cli_apply_changes_clear_pending(vty, NULL); | |
718e3744 | 4759 | } |
4760 | ||
f4b8ec07 CS |
4761 | DEFUN_YANG(no_neighbor_interface_config, |
4762 | no_neighbor_interface_config_cmd, | |
4763 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4764 | NO_STR NEIGHBOR_STR | |
4765 | "Interface name\n" | |
4766 | "Configure BGP on interface\n" | |
4767 | "Enable BGP with v6 link-local only\n" | |
4768 | "Member of the peer-group\n" | |
4769 | "Peer-group name\n" | |
4770 | "Specify a BGP neighbor\n" AS_STR | |
4771 | "Internal BGP peer\n" | |
4772 | "External BGP peer\n") | |
a80beece | 4773 | { |
d62a17ae | 4774 | int idx_word = 2; |
f4b8ec07 | 4775 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4776 | |
f4b8ec07 CS |
4777 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4778 | argv[idx_word]->arg, ""); | |
4779 | ||
4780 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4781 | ||
fd396924 CH |
4782 | /* |
4783 | * Need to commit any pending so this command doesn't merge with a | |
4784 | * create into a modify, which BGP can't handle | |
4785 | */ | |
4786 | return nb_cli_apply_changes_clear_pending(vty, base_xpath); | |
a80beece DS |
4787 | } |
4788 | ||
f4b8ec07 CS |
4789 | DEFUN_YANG(no_neighbor_peer_group, |
4790 | no_neighbor_peer_group_cmd, | |
4791 | "no neighbor WORD peer-group", | |
4792 | NO_STR NEIGHBOR_STR | |
4793 | "Neighbor tag\n" | |
4794 | "Configure peer-group\n") | |
718e3744 | 4795 | { |
f4b8ec07 | 4796 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 4797 | int idx_word = 2; |
718e3744 | 4798 | |
f4b8ec07 CS |
4799 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4800 | argv[idx_word]->arg, ""); | |
4801 | ||
4802 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
4803 | ||
fd396924 CH |
4804 | /* |
4805 | * Need to commit any pending so this command doesn't merge with a | |
4806 | * create into a modify, which BGP can't handle | |
4807 | */ | |
4808 | return nb_cli_apply_changes_clear_pending(vty, base_xpath); | |
718e3744 | 4809 | } |
4810 | ||
f4b8ec07 CS |
4811 | DEFUN_YANG(no_neighbor_interface_peer_group_remote_as, |
4812 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4813 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4814 | NO_STR NEIGHBOR_STR | |
4815 | "Interface name or neighbor tag\n" | |
4816 | "Specify a BGP neighbor\n" AS_STR | |
4817 | "Internal BGP peer\n" | |
4818 | "External BGP peer\n") | |
718e3744 | 4819 | { |
f4b8ec07 CS |
4820 | int idx_peer = 2; |
4821 | char base_xpath[XPATH_MAXLEN]; | |
4822 | char unnbr_xpath[XPATH_MAXLEN]; | |
4823 | char prgrp_xpath[XPATH_MAXLEN]; | |
d62a17ae | 4824 | |
f4b8ec07 CS |
4825 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), FRR_BGP_NEIGHBOR_UNNUM_XPATH, |
4826 | argv[idx_peer]->arg, ""); | |
d62a17ae | 4827 | |
f4b8ec07 CS |
4828 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), FRR_BGP_PEER_GROUP_XPATH, |
4829 | argv[idx_peer]->arg, ""); | |
4830 | ||
3bb513c3 CH |
4831 | if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
4832 | VTY_CURR_XPATH, unnbr_xpath + 1)) { | |
f4b8ec07 | 4833 | strlcpy(base_xpath, unnbr_xpath, sizeof(base_xpath)); |
3bb513c3 CH |
4834 | } else if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
4835 | VTY_CURR_XPATH, prgrp_xpath + 1)) { | |
f4b8ec07 CS |
4836 | strlcpy(base_xpath, prgrp_xpath, sizeof(base_xpath)); |
4837 | } else { | |
d62a17ae | 4838 | vty_out(vty, "%% Create the peer-group or interface first\n"); |
4839 | return CMD_WARNING_CONFIG_FAILED; | |
4840 | } | |
f4b8ec07 CS |
4841 | |
4842 | strlcat(base_xpath, "/neighbor-remote-as/remote-as-type", | |
4843 | sizeof(base_xpath)); | |
4844 | ||
4845 | nb_cli_enqueue_change(vty, base_xpath, NB_OP_DESTROY, NULL); | |
4846 | ||
fd396924 CH |
4847 | /* |
4848 | * Need to commit any pending so this command doesn't merge with a | |
4849 | * create into a modify, which BGP can't handle | |
4850 | */ | |
4851 | return nb_cli_apply_changes_clear_pending(vty, NULL); | |
718e3744 | 4852 | } |
6b0655a2 | 4853 | |
f4b8ec07 CS |
4854 | DEFUN_YANG(neighbor_local_as, |
4855 | neighbor_local_as_cmd, | |
4856 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4857 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4858 | "Specify a local-as number\n" | |
4859 | "AS number used as local AS\n") | |
718e3744 | 4860 | { |
d62a17ae | 4861 | int idx_peer = 1; |
4862 | int idx_number = 3; | |
f4b8ec07 | 4863 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4864 | |
f4b8ec07 CS |
4865 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4866 | sizeof(base_xpath), NULL) | |
4867 | < 0) | |
d62a17ae | 4868 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4869 | |
f4b8ec07 CS |
4870 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4871 | argv[idx_number]->arg); | |
4872 | ||
4873 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4874 | } |
4875 | ||
f4b8ec07 CS |
4876 | DEFUN_YANG( |
4877 | neighbor_local_as_no_prepend, neighbor_local_as_no_prepend_cmd, | |
4878 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4879 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4880 | "Specify a local-as number\n" | |
4881 | "AS number used as local AS\n" | |
4882 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4883 | { |
d62a17ae | 4884 | int idx_peer = 1; |
4885 | int idx_number = 3; | |
f4b8ec07 | 4886 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4887 | |
f4b8ec07 CS |
4888 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4889 | sizeof(base_xpath), NULL) | |
4890 | < 0) | |
d62a17ae | 4891 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4892 | |
f4b8ec07 CS |
4893 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4894 | argv[idx_number]->arg); | |
4895 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4896 | "true"); | |
4897 | ||
4898 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4899 | } |
4900 | ||
f4b8ec07 CS |
4901 | DEFUN_YANG( |
4902 | neighbor_local_as_no_prepend_replace_as, | |
4903 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4904 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4905 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4906 | "Specify a local-as number\n" | |
4907 | "AS number used as local AS\n" | |
4908 | "Do not prepend local-as to updates from ebgp peers\n" | |
4909 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4910 | { |
d62a17ae | 4911 | int idx_peer = 1; |
4912 | int idx_number = 3; | |
f4b8ec07 | 4913 | char base_xpath[XPATH_MAXLEN]; |
9d3f9705 | 4914 | |
f4b8ec07 CS |
4915 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4916 | sizeof(base_xpath), NULL) | |
4917 | < 0) | |
d62a17ae | 4918 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4919 | |
f4b8ec07 CS |
4920 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_MODIFY, |
4921 | argv[idx_number]->arg); | |
4922 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4923 | "true"); | |
ba51dd26 | 4924 | nb_cli_enqueue_change(vty, "./local-as/replace-as", NB_OP_MODIFY, |
f4b8ec07 CS |
4925 | "true"); |
4926 | ||
4927 | return nb_cli_apply_changes(vty, base_xpath); | |
9d3f9705 AC |
4928 | } |
4929 | ||
f4b8ec07 CS |
4930 | DEFUN_YANG(no_neighbor_local_as, |
4931 | no_neighbor_local_as_cmd, | |
4932 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4933 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4934 | "Specify a local-as number\n" | |
4935 | "AS number used as local AS\n" | |
4936 | "Do not prepend local-as to updates from ebgp peers\n" | |
4937 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4938 | { |
d62a17ae | 4939 | int idx_peer = 2; |
f4b8ec07 | 4940 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 4941 | |
f4b8ec07 CS |
4942 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
4943 | sizeof(base_xpath), NULL) | |
4944 | < 0) | |
d62a17ae | 4945 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4946 | |
f4b8ec07 CS |
4947 | nb_cli_enqueue_change(vty, "./local-as/local-as", NB_OP_DESTROY, NULL); |
4948 | nb_cli_enqueue_change(vty, "./local-as/no-prepend", NB_OP_MODIFY, | |
4949 | "false"); | |
ba51dd26 | 4950 | nb_cli_enqueue_change(vty, "./local-as/replace-as", NB_OP_MODIFY, |
f4b8ec07 CS |
4951 | "false"); |
4952 | ||
4953 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 4954 | } |
4955 | ||
718e3744 | 4956 | |
3f9c7369 DS |
4957 | DEFUN (neighbor_solo, |
4958 | neighbor_solo_cmd, | |
9ccf14f7 | 4959 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4960 | NEIGHBOR_STR |
4961 | NEIGHBOR_ADDR_STR2 | |
4962 | "Solo peer - part of its own update group\n") | |
4963 | { | |
d62a17ae | 4964 | int idx_peer = 1; |
4965 | struct peer *peer; | |
4966 | int ret; | |
3f9c7369 | 4967 | |
d62a17ae | 4968 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4969 | if (!peer) | |
4970 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4971 | |
d62a17ae | 4972 | ret = update_group_adjust_soloness(peer, 1); |
4973 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4974 | } |
4975 | ||
4976 | DEFUN (no_neighbor_solo, | |
4977 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4978 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4979 | NO_STR |
4980 | NEIGHBOR_STR | |
4981 | NEIGHBOR_ADDR_STR2 | |
4982 | "Solo peer - part of its own update group\n") | |
4983 | { | |
d62a17ae | 4984 | int idx_peer = 2; |
4985 | struct peer *peer; | |
4986 | int ret; | |
3f9c7369 | 4987 | |
d62a17ae | 4988 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4989 | if (!peer) | |
4990 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4991 | |
d62a17ae | 4992 | ret = update_group_adjust_soloness(peer, 0); |
4993 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4994 | } |
4995 | ||
f4b8ec07 CS |
4996 | DEFUN_YANG(neighbor_password, |
4997 | neighbor_password_cmd, | |
4998 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4999 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5000 | "Set a password\n" | |
5001 | "The password\n") | |
0df7c91f | 5002 | { |
d62a17ae | 5003 | int idx_peer = 1; |
5004 | int idx_line = 3; | |
f4b8ec07 | 5005 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 5006 | |
f4b8ec07 CS |
5007 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5008 | sizeof(base_xpath), NULL) | |
5009 | < 0) | |
d62a17ae | 5010 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5011 | |
f4b8ec07 CS |
5012 | nb_cli_enqueue_change(vty, "./password", NB_OP_MODIFY, |
5013 | argv[idx_line]->arg); | |
5014 | ||
5015 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f PJ |
5016 | } |
5017 | ||
f4b8ec07 CS |
5018 | DEFUN_YANG(no_neighbor_password, |
5019 | no_neighbor_password_cmd, | |
5020 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
5021 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5022 | "Set a password\n" | |
5023 | "The password\n") | |
0df7c91f | 5024 | { |
d62a17ae | 5025 | int idx_peer = 2; |
f4b8ec07 | 5026 | char base_xpath[XPATH_MAXLEN]; |
0df7c91f | 5027 | |
f4b8ec07 CS |
5028 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5029 | sizeof(base_xpath), NULL) | |
5030 | < 0) | |
d62a17ae | 5031 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5032 | |
f4b8ec07 CS |
5033 | nb_cli_enqueue_change(vty, "./password", NB_OP_DESTROY, NULL); |
5034 | ||
5035 | return nb_cli_apply_changes(vty, base_xpath); | |
0df7c91f | 5036 | } |
6b0655a2 | 5037 | |
f4b8ec07 CS |
5038 | DEFUN_YANG(neighbor_activate, |
5039 | neighbor_activate_cmd, | |
5040 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5041 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5042 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5043 | { |
d62a17ae | 5044 | int idx_peer = 1; |
f4b8ec07 | 5045 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
5046 | char af_xpath[XPATH_MAXLEN]; |
5047 | afi_t afi = bgp_node_afi(vty); | |
5048 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 5049 | |
f4b8ec07 CS |
5050 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5051 | yang_afi_safi_value2identity(afi, safi)); | |
555c8ab7 CS |
5052 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5053 | sizeof(base_xpath), af_xpath) | |
f4b8ec07 | 5054 | < 0) |
d62a17ae | 5055 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5056 | |
555c8ab7 | 5057 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "true"); |
f4b8ec07 CS |
5058 | |
5059 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5060 | } |
5061 | ||
d62a17ae | 5062 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
5063 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5064 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5065 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5066 | |
f4b8ec07 CS |
5067 | DEFUN_YANG(no_neighbor_activate, |
5068 | no_neighbor_activate_cmd, | |
5069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5070 | NO_STR NEIGHBOR_STR | |
5071 | NEIGHBOR_ADDR_STR2 | |
5072 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5073 | { |
d62a17ae | 5074 | int idx_peer = 2; |
f4b8ec07 CS |
5075 | char base_xpath[XPATH_MAXLEN]; |
5076 | char af_xpath[XPATH_MAXLEN]; | |
5077 | afi_t afi = bgp_node_afi(vty); | |
5078 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 5079 | |
f4b8ec07 CS |
5080 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5081 | yang_afi_safi_value2identity(afi, safi)); | |
5082 | ||
5083 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5084 | sizeof(base_xpath), af_xpath) | |
5085 | < 0) | |
d62a17ae | 5086 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5087 | |
f4b8ec07 CS |
5088 | nb_cli_enqueue_change(vty, "./enabled", NB_OP_MODIFY, "false"); |
5089 | ||
5090 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5091 | } |
6b0655a2 | 5092 | |
d62a17ae | 5093 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
5094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5095 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5096 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5097 | |
2a059a54 DS |
5098 | DEFUN (neighbor_set_peer_group, |
5099 | neighbor_set_peer_group_cmd, | |
5100 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5101 | NEIGHBOR_STR | |
5102 | NEIGHBOR_ADDR_STR2 | |
5103 | "Member of the peer-group\n" | |
5104 | "Peer-group name\n") | |
718e3744 | 5105 | { |
2a059a54 | 5106 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5107 | int idx_peer = 1; |
5108 | int idx_word = 3; | |
2a059a54 DS |
5109 | int ret; |
5110 | as_t as; | |
5111 | union sockunion su; | |
5112 | struct peer *peer; | |
5113 | struct peer_group *group; | |
d62a17ae | 5114 | |
2a059a54 DS |
5115 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
5116 | if (ret < 0) { | |
5117 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
5118 | if (!peer) { | |
5119 | vty_out(vty, "%% Malformed address or name: %s\n", | |
5120 | argv[idx_peer]->arg); | |
5121 | return CMD_WARNING_CONFIG_FAILED; | |
5122 | } | |
5123 | } else { | |
5124 | if (peer_address_self_check(bgp, &su)) { | |
5125 | vty_out(vty, | |
5126 | "%% Can not configure the local system as neighbor\n"); | |
5127 | return CMD_WARNING_CONFIG_FAILED; | |
5128 | } | |
5129 | ||
5130 | /* Disallow for dynamic neighbor. */ | |
5131 | peer = peer_lookup(bgp, &su); | |
5132 | if (peer && peer_dynamic_neighbor(peer)) { | |
5133 | vty_out(vty, | |
5134 | "%% Operation not allowed on a dynamic neighbor\n"); | |
5135 | return CMD_WARNING_CONFIG_FAILED; | |
5136 | } | |
5137 | } | |
5138 | ||
5139 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5140 | if (!group) { | |
5141 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 5142 | return CMD_WARNING_CONFIG_FAILED; |
2a059a54 | 5143 | } |
d62a17ae | 5144 | |
2a059a54 | 5145 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
d62a17ae | 5146 | |
2a059a54 DS |
5147 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { |
5148 | vty_out(vty, | |
5149 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
5150 | as); | |
5151 | return CMD_WARNING_CONFIG_FAILED; | |
5152 | } | |
5153 | ||
5154 | return bgp_vty_return(vty, ret); | |
d62a17ae | 5155 | } |
5156 | ||
5157 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 5158 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5159 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5160 | "Member of the peer-group\n" | |
5161 | "Peer-group name\n") | |
596c17ba | 5162 | |
f4b8ec07 CS |
5163 | DEFUN_YANG (no_neighbor_set_peer_group, |
5164 | no_neighbor_set_peer_group_cmd, | |
71cc0c88 | 5165 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
f4b8ec07 CS |
5166 | NO_STR |
5167 | NEIGHBOR_STR | |
5168 | NEIGHBOR_ADDR_STR2 | |
5169 | "Member of the peer-group\n" | |
5170 | "Peer-group name\n") | |
718e3744 | 5171 | { |
d62a17ae | 5172 | int idx_peer = 2; |
f4b8ec07 | 5173 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 5174 | |
f4b8ec07 CS |
5175 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5176 | sizeof(base_xpath), NULL) | |
5177 | < 0) | |
d62a17ae | 5178 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 5179 | |
f4b8ec07 | 5180 | nb_cli_enqueue_change(vty, "./peer-group", NB_OP_DESTROY, NULL); |
718e3744 | 5181 | |
fd396924 CH |
5182 | /* |
5183 | * Need to commit any pending so this command doesn't merge with a | |
5184 | * create into a modify, which BGP can't handle | |
5185 | */ | |
5186 | return nb_cli_apply_changes_clear_pending(vty, base_xpath); | |
718e3744 | 5187 | } |
6b0655a2 | 5188 | |
d62a17ae | 5189 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 5190 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5191 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5192 | "Member of the peer-group\n" | |
5193 | "Peer-group name\n") | |
596c17ba | 5194 | |
d62a17ae | 5195 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5196 | uint32_t flag, int set) |
718e3744 | 5197 | { |
d62a17ae | 5198 | int ret; |
5199 | struct peer *peer; | |
718e3744 | 5200 | |
d62a17ae | 5201 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5202 | if (!peer) | |
5203 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5204 | |
7ebe625c QY |
5205 | /* |
5206 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5207 | * we should not accept disable-connected-check. | |
5208 | */ | |
5209 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5210 | vty_out(vty, | |
3efd0893 | 5211 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
5212 | ip_str); |
5213 | return CMD_WARNING_CONFIG_FAILED; | |
5214 | } | |
5215 | ||
d62a17ae | 5216 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
5217 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 5218 | |
d62a17ae | 5219 | if (set) |
5220 | ret = peer_flag_set(peer, flag); | |
5221 | else | |
5222 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 5223 | |
d62a17ae | 5224 | return bgp_vty_return(vty, ret); |
718e3744 | 5225 | } |
5226 | ||
47cbc09b | 5227 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 5228 | { |
d62a17ae | 5229 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5230 | } |
5231 | ||
d62a17ae | 5232 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5233 | uint32_t flag) |
718e3744 | 5234 | { |
d62a17ae | 5235 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5236 | } |
5237 | ||
f4b8ec07 CS |
5238 | int peer_flag_modify_nb(struct bgp *bgp, const char *ip_str, struct peer *peer, |
5239 | uint32_t flag, bool set, char *errmsg, | |
5240 | size_t errmsg_len) | |
5241 | { | |
5242 | int ret; | |
5243 | ||
5244 | /* | |
5245 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5246 | * we should not accept disable-connected-check. | |
5247 | */ | |
5248 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5249 | snprintf( | |
5250 | errmsg, errmsg_len, | |
5251 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
5252 | ip_str); | |
5253 | return -1; | |
5254 | } | |
5255 | ||
5256 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
5257 | peer_tx_shutdown_message_unset(peer); | |
5258 | ||
5259 | if (set) | |
5260 | ret = peer_flag_set(peer, flag); | |
5261 | else | |
5262 | ret = peer_flag_unset(peer, flag); | |
5263 | ||
5264 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
5265 | } | |
5266 | ||
718e3744 | 5267 | /* neighbor passive. */ |
f4b8ec07 CS |
5268 | DEFUN_YANG(neighbor_passive, |
5269 | neighbor_passive_cmd, | |
5270 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5271 | NEIGHBOR_STR | |
5272 | NEIGHBOR_ADDR_STR2 | |
5273 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5274 | { |
d62a17ae | 5275 | int idx_peer = 1; |
f4b8ec07 CS |
5276 | char base_xpath[XPATH_MAXLEN]; |
5277 | ||
5278 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5279 | sizeof(base_xpath), NULL) | |
5280 | < 0) | |
5281 | return CMD_WARNING_CONFIG_FAILED; | |
5282 | ||
5283 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "true"); | |
5284 | ||
5285 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5286 | } |
5287 | ||
f4b8ec07 CS |
5288 | DEFUN_YANG(no_neighbor_passive, |
5289 | no_neighbor_passive_cmd, | |
5290 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5291 | NO_STR NEIGHBOR_STR | |
5292 | NEIGHBOR_ADDR_STR2 | |
5293 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5294 | { |
d62a17ae | 5295 | int idx_peer = 2; |
f4b8ec07 CS |
5296 | char base_xpath[XPATH_MAXLEN]; |
5297 | ||
5298 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5299 | sizeof(base_xpath), NULL) | |
5300 | < 0) | |
5301 | return CMD_WARNING_CONFIG_FAILED; | |
5302 | ||
5303 | nb_cli_enqueue_change(vty, "./passive-mode", NB_OP_MODIFY, "false"); | |
5304 | ||
5305 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5306 | } |
6b0655a2 | 5307 | |
718e3744 | 5308 | /* neighbor shutdown. */ |
f4b8ec07 CS |
5309 | DEFUN_YANG(neighbor_shutdown_msg, |
5310 | neighbor_shutdown_msg_cmd, | |
5311 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5312 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5313 | "Administratively shut down this neighbor\n" | |
5314 | "Add a shutdown message (RFC 8203)\n" | |
5315 | "Shutdown message\n") | |
718e3744 | 5316 | { |
d62a17ae | 5317 | int idx_peer = 1; |
f4b8ec07 CS |
5318 | char base_xpath[XPATH_MAXLEN]; |
5319 | ||
5320 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5321 | sizeof(base_xpath), NULL) | |
5322 | < 0) | |
5323 | return CMD_WARNING_CONFIG_FAILED; | |
73d70fa6 | 5324 | |
d62a17ae | 5325 | if (argc >= 5) { |
d62a17ae | 5326 | char *message; |
73d70fa6 | 5327 | |
d62a17ae | 5328 | message = argv_concat(argv, argc, 4); |
f4b8ec07 CS |
5329 | nb_cli_enqueue_change(vty, "./admin-shutdown/message", |
5330 | NB_OP_MODIFY, message); | |
d62a17ae | 5331 | } |
73d70fa6 | 5332 | |
f4b8ec07 CS |
5333 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, |
5334 | "true"); | |
5335 | ||
5336 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5337 | } |
5338 | ||
232c75cd | 5339 | ALIAS_YANG(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5340 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5341 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5342 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5343 | |
f4b8ec07 CS |
5344 | DEFUN_YANG(no_neighbor_shutdown_msg, |
5345 | no_neighbor_shutdown_msg_cmd, | |
5346 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5347 | NO_STR NEIGHBOR_STR | |
5348 | NEIGHBOR_ADDR_STR2 | |
5349 | "Administratively shut down this neighbor\n" | |
5350 | "Remove a shutdown message (RFC 8203)\n" | |
5351 | "Shutdown message\n") | |
718e3744 | 5352 | { |
d62a17ae | 5353 | int idx_peer = 2; |
f4b8ec07 | 5354 | char base_xpath[XPATH_MAXLEN]; |
73d70fa6 | 5355 | |
f4b8ec07 CS |
5356 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
5357 | sizeof(base_xpath), NULL) | |
5358 | < 0) | |
5359 | return CMD_WARNING_CONFIG_FAILED; | |
5360 | ||
5361 | nb_cli_enqueue_change(vty, "./admin-shutdown/enable", NB_OP_MODIFY, | |
5362 | "false"); | |
5363 | ||
5364 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5365 | } |
6b0655a2 | 5366 | |
232c75cd | 5367 | ALIAS_YANG(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5368 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5369 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5370 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5371 | |
8336c896 DA |
5372 | DEFUN(neighbor_shutdown_rtt, |
5373 | neighbor_shutdown_rtt_cmd, | |
5374 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5375 | NEIGHBOR_STR | |
5376 | NEIGHBOR_ADDR_STR2 | |
5377 | "Administratively shut down this neighbor\n" | |
5378 | "Shutdown if round-trip-time is higher than expected\n" | |
5379 | "Round-trip-time in milliseconds\n" | |
5380 | "Specify the number of keepalives before shutdown\n" | |
5381 | "The number of keepalives with higher RTT to shutdown\n") | |
5382 | { | |
5383 | int idx_peer = 1; | |
5384 | int idx_rtt = 4; | |
5385 | int idx_count = 0; | |
5386 | struct peer *peer; | |
5387 | ||
5388 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5389 | ||
5390 | if (!peer) | |
5391 | return CMD_WARNING_CONFIG_FAILED; | |
5392 | ||
5393 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5394 | ||
5395 | if (argv_find(argv, argc, "count", &idx_count)) | |
5396 | peer->rtt_keepalive_conf = | |
5397 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5398 | ||
5399 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5400 | PEER_FLAG_RTT_SHUTDOWN); | |
5401 | } | |
5402 | ||
5403 | DEFUN(no_neighbor_shutdown_rtt, | |
5404 | no_neighbor_shutdown_rtt_cmd, | |
5405 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5406 | NO_STR | |
5407 | NEIGHBOR_STR | |
5408 | NEIGHBOR_ADDR_STR2 | |
5409 | "Administratively shut down this neighbor\n" | |
5410 | "Shutdown if round-trip-time is higher than expected\n" | |
5411 | "Round-trip-time in milliseconds\n" | |
5412 | "Specify the number of keepalives before shutdown\n" | |
5413 | "The number of keepalives with higher RTT to shutdown\n") | |
5414 | { | |
5415 | int idx_peer = 2; | |
5416 | struct peer *peer; | |
5417 | ||
5418 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5419 | ||
5420 | if (!peer) | |
5421 | return CMD_WARNING_CONFIG_FAILED; | |
5422 | ||
5423 | peer->rtt_expected = 0; | |
5424 | peer->rtt_keepalive_conf = 1; | |
5425 | ||
5426 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5427 | PEER_FLAG_RTT_SHUTDOWN); | |
5428 | } | |
5429 | ||
718e3744 | 5430 | /* neighbor capability dynamic. */ |
f4b8ec07 CS |
5431 | DEFUN_YANG (neighbor_capability_dynamic, |
5432 | neighbor_capability_dynamic_cmd, | |
5433 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5434 | NEIGHBOR_STR | |
5435 | NEIGHBOR_ADDR_STR2 | |
5436 | "Advertise capability to the peer\n" | |
5437 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5438 | { |
d62a17ae | 5439 | int idx_peer = 1; |
f4b8ec07 CS |
5440 | char base_xpath[XPATH_MAXLEN]; |
5441 | ||
5442 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5443 | sizeof(base_xpath), NULL) | |
5444 | < 0) | |
5445 | return CMD_WARNING_CONFIG_FAILED; | |
5446 | ||
5447 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5448 | NB_OP_MODIFY, "true"); | |
5449 | ||
5450 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5451 | } |
5452 | ||
f4b8ec07 CS |
5453 | DEFUN_YANG (no_neighbor_capability_dynamic, |
5454 | no_neighbor_capability_dynamic_cmd, | |
5455 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5456 | NO_STR | |
5457 | NEIGHBOR_STR | |
5458 | NEIGHBOR_ADDR_STR2 | |
5459 | "Advertise capability to the peer\n" | |
5460 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5461 | { |
d62a17ae | 5462 | int idx_peer = 2; |
f4b8ec07 CS |
5463 | char base_xpath[XPATH_MAXLEN]; |
5464 | ||
5465 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5466 | sizeof(base_xpath), NULL) | |
5467 | < 0) | |
5468 | return CMD_WARNING_CONFIG_FAILED; | |
5469 | ||
5470 | nb_cli_enqueue_change(vty, "./capability-options/dynamic-capability", | |
5471 | NB_OP_MODIFY, "false"); | |
5472 | ||
5473 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5474 | } |
6b0655a2 | 5475 | |
718e3744 | 5476 | /* neighbor dont-capability-negotiate */ |
5477 | DEFUN (neighbor_dont_capability_negotiate, | |
5478 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5479 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5480 | NEIGHBOR_STR |
5481 | NEIGHBOR_ADDR_STR2 | |
5482 | "Do not perform capability negotiation\n") | |
5483 | { | |
d62a17ae | 5484 | int idx_peer = 1; |
5485 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5486 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5487 | } |
5488 | ||
5489 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5490 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5491 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5492 | NO_STR |
5493 | NEIGHBOR_STR | |
5494 | NEIGHBOR_ADDR_STR2 | |
5495 | "Do not perform capability negotiation\n") | |
5496 | { | |
d62a17ae | 5497 | int idx_peer = 2; |
5498 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5499 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5500 | } |
6b0655a2 | 5501 | |
8a92a8a0 | 5502 | /* neighbor capability extended next hop encoding */ |
f4b8ec07 CS |
5503 | DEFUN_YANG (neighbor_capability_enhe, |
5504 | neighbor_capability_enhe_cmd, | |
5505 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5506 | NEIGHBOR_STR | |
5507 | NEIGHBOR_ADDR_STR2 | |
5508 | "Advertise capability to the peer\n" | |
5509 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5510 | { |
d62a17ae | 5511 | int idx_peer = 1; |
f4b8ec07 CS |
5512 | char base_xpath[XPATH_MAXLEN]; |
5513 | ||
5514 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5515 | sizeof(base_xpath), NULL) | |
5516 | < 0) | |
5517 | return CMD_WARNING_CONFIG_FAILED; | |
5518 | ||
5519 | nb_cli_enqueue_change( | |
5520 | vty, "./capability-options/extended-nexthop-capability", | |
5521 | NB_OP_MODIFY, "true"); | |
5522 | ||
5523 | return nb_cli_apply_changes(vty, base_xpath); | |
8a92a8a0 DS |
5524 | } |
5525 | ||
f4b8ec07 CS |
5526 | DEFUN_YANG (no_neighbor_capability_enhe, |
5527 | no_neighbor_capability_enhe_cmd, | |
5528 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5529 | NO_STR | |
5530 | NEIGHBOR_STR | |
5531 | NEIGHBOR_ADDR_STR2 | |
5532 | "Advertise capability to the peer\n" | |
5533 | "Advertise extended next-hop capability to the peer\n") | |
8a92a8a0 | 5534 | { |
d62a17ae | 5535 | int idx_peer = 2; |
f4b8ec07 CS |
5536 | char base_xpath[XPATH_MAXLEN]; |
5537 | ||
5538 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5539 | sizeof(base_xpath), NULL) | |
5540 | < 0) | |
5541 | return CMD_WARNING_CONFIG_FAILED; | |
5542 | ||
5543 | nb_cli_enqueue_change( | |
5544 | vty, "./capability-options/extended-nexthop-capability", | |
5545 | NB_OP_MODIFY, "false"); | |
5546 | ||
5547 | return nb_cli_apply_changes(vty, base_xpath); | |
5548 | } | |
5549 | ||
5550 | int peer_af_flag_modify_nb(struct peer *peer, afi_t afi, safi_t safi, | |
5551 | uint32_t flag, int set, char *errmsg, | |
5552 | size_t errmsg_len) | |
5553 | { | |
5554 | int ret; | |
5555 | ||
5556 | if (set) | |
5557 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5558 | else | |
5559 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
5560 | ||
5561 | return bgp_nb_errmsg_return(errmsg, errmsg_len, ret); | |
8a92a8a0 DS |
5562 | } |
5563 | ||
d62a17ae | 5564 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5565 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5566 | int set) |
718e3744 | 5567 | { |
d62a17ae | 5568 | int ret; |
5569 | struct peer *peer; | |
718e3744 | 5570 | |
d62a17ae | 5571 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5572 | if (!peer) | |
5573 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5574 | |
d62a17ae | 5575 | if (set) |
5576 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5577 | else | |
5578 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5579 | |
d62a17ae | 5580 | return bgp_vty_return(vty, ret); |
718e3744 | 5581 | } |
5582 | ||
d62a17ae | 5583 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5584 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5585 | { |
d62a17ae | 5586 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5587 | } |
5588 | ||
d62a17ae | 5589 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5590 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5591 | { |
d62a17ae | 5592 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5593 | } |
6b0655a2 | 5594 | |
718e3744 | 5595 | /* neighbor capability orf prefix-list. */ |
5596 | DEFUN (neighbor_capability_orf_prefix, | |
5597 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5598 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5599 | NEIGHBOR_STR |
5600 | NEIGHBOR_ADDR_STR2 | |
5601 | "Advertise capability to the peer\n" | |
5602 | "Advertise ORF capability to the peer\n" | |
5603 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5604 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5605 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5606 | "Capability to SEND the ORF to this neighbor\n") | |
5607 | { | |
d62a17ae | 5608 | int idx_send_recv = 5; |
db45f64d DS |
5609 | char *peer_str = argv[1]->arg; |
5610 | struct peer *peer; | |
5611 | afi_t afi = bgp_node_afi(vty); | |
5612 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5613 | |
db45f64d DS |
5614 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5615 | if (!peer) | |
d62a17ae | 5616 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5617 | |
db45f64d DS |
5618 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5619 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5620 | PEER_FLAG_ORF_PREFIX_SM); | |
5621 | ||
5622 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5623 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5624 | PEER_FLAG_ORF_PREFIX_RM); | |
5625 | ||
5626 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5627 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5628 | PEER_FLAG_ORF_PREFIX_SM) | |
5629 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5630 | PEER_FLAG_ORF_PREFIX_RM); | |
5631 | ||
5632 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5633 | } |
5634 | ||
5635 | ALIAS_HIDDEN( | |
5636 | neighbor_capability_orf_prefix, | |
5637 | neighbor_capability_orf_prefix_hidden_cmd, | |
5638 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5639 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5640 | "Advertise capability to the peer\n" | |
5641 | "Advertise ORF capability to the peer\n" | |
5642 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5643 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5644 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5645 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5646 | |
718e3744 | 5647 | DEFUN (no_neighbor_capability_orf_prefix, |
5648 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5650 | NO_STR |
5651 | NEIGHBOR_STR | |
5652 | NEIGHBOR_ADDR_STR2 | |
5653 | "Advertise capability to the peer\n" | |
5654 | "Advertise ORF capability to the peer\n" | |
5655 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5656 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5657 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5658 | "Capability to SEND the ORF to this neighbor\n") | |
5659 | { | |
d62a17ae | 5660 | int idx_send_recv = 6; |
db45f64d DS |
5661 | char *peer_str = argv[2]->arg; |
5662 | struct peer *peer; | |
5663 | afi_t afi = bgp_node_afi(vty); | |
5664 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5665 | |
db45f64d DS |
5666 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5667 | if (!peer) | |
d62a17ae | 5668 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5669 | |
db45f64d DS |
5670 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5671 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5672 | PEER_FLAG_ORF_PREFIX_SM); | |
5673 | ||
5674 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5675 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5676 | PEER_FLAG_ORF_PREFIX_RM); | |
5677 | ||
5678 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5679 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5680 | PEER_FLAG_ORF_PREFIX_SM) | |
5681 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5682 | PEER_FLAG_ORF_PREFIX_RM); | |
5683 | ||
5684 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5685 | } |
5686 | ||
5687 | ALIAS_HIDDEN( | |
5688 | no_neighbor_capability_orf_prefix, | |
5689 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5691 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5692 | "Advertise capability to the peer\n" | |
5693 | "Advertise ORF capability to the peer\n" | |
5694 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5695 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5696 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5697 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5698 | |
718e3744 | 5699 | /* neighbor next-hop-self. */ |
f4b8ec07 CS |
5700 | DEFUN_YANG (neighbor_nexthop_self, |
5701 | neighbor_nexthop_self_cmd, | |
5702 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5703 | NEIGHBOR_STR | |
5704 | NEIGHBOR_ADDR_STR2 | |
5705 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5706 | { |
d62a17ae | 5707 | int idx_peer = 1; |
f4b8ec07 CS |
5708 | char base_xpath[XPATH_MAXLEN]; |
5709 | char af_xpath[XPATH_MAXLEN]; | |
5710 | char attr_xpath[XPATH_MAXLEN]; | |
5711 | afi_t afi = bgp_node_afi(vty); | |
5712 | safi_t safi = bgp_node_safi(vty); | |
5713 | ||
f4b8ec07 CS |
5714 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5715 | yang_afi_safi_value2identity(afi, safi)); | |
5716 | ||
5717 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5718 | sizeof(base_xpath), af_xpath) | |
5719 | < 0) | |
5720 | return CMD_WARNING_CONFIG_FAILED; | |
5721 | ||
5722 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5723 | "./%s/nexthop-self/next-hop-self", | |
5724 | bgp_afi_safi_get_container_str(afi, safi)); | |
5725 | ||
5726 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5727 | ||
5728 | return nb_cli_apply_changes(vty, base_xpath); | |
a538debe | 5729 | } |
9e7a53c1 | 5730 | |
d62a17ae | 5731 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5732 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5734 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5735 | |
f4b8ec07 CS |
5736 | /* neighbor next-hop-self. */ |
5737 | DEFUN_YANG(neighbor_nexthop_self_force, | |
5738 | neighbor_nexthop_self_force_cmd, | |
5739 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5740 | NEIGHBOR_STR | |
5741 | NEIGHBOR_ADDR_STR2 | |
5742 | "Disable the next hop calculation for this neighbor\n" | |
5743 | "Set the next hop to self for reflected routes\n") | |
5744 | { | |
5745 | int idx_peer = 1; | |
5746 | char base_xpath[XPATH_MAXLEN]; | |
5747 | char af_xpath[XPATH_MAXLEN]; | |
5748 | char attr_xpath[XPATH_MAXLEN]; | |
5749 | afi_t afi = bgp_node_afi(vty); | |
5750 | safi_t safi = bgp_node_safi(vty); | |
5751 | ||
f4b8ec07 CS |
5752 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5753 | yang_afi_safi_value2identity(afi, safi)); | |
5754 | ||
5755 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5756 | sizeof(base_xpath), af_xpath) | |
5757 | < 0) | |
5758 | return CMD_WARNING_CONFIG_FAILED; | |
5759 | ||
5760 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5761 | "./%s/nexthop-self/next-hop-self-force", | |
5762 | bgp_afi_safi_get_container_str(afi, safi)); | |
5763 | ||
5764 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5765 | ||
5766 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5767 | } |
5768 | ||
d62a17ae | 5769 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5770 | neighbor_nexthop_self_force_hidden_cmd, | |
5771 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5772 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5773 | "Disable the next hop calculation for this neighbor\n" | |
5774 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5775 | |
1bc4e531 DA |
5776 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5777 | neighbor_nexthop_self_all_hidden_cmd, | |
5778 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5779 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5780 | "Disable the next hop calculation for this neighbor\n" | |
5781 | "Set the next hop to self for reflected routes\n") | |
5782 | ||
f4b8ec07 CS |
5783 | DEFUN_YANG (no_neighbor_nexthop_self, |
5784 | no_neighbor_nexthop_self_cmd, | |
5785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5786 | NO_STR | |
5787 | NEIGHBOR_STR | |
5788 | NEIGHBOR_ADDR_STR2 | |
5789 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5790 | { |
d62a17ae | 5791 | int idx_peer = 2; |
f4b8ec07 CS |
5792 | char base_xpath[XPATH_MAXLEN]; |
5793 | char af_xpath[XPATH_MAXLEN]; | |
5794 | char attr_xpath[XPATH_MAXLEN]; | |
5795 | afi_t afi = bgp_node_afi(vty); | |
5796 | safi_t safi = bgp_node_safi(vty); | |
5797 | ||
5798 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5799 | yang_afi_safi_value2identity(afi, safi)); | |
5800 | ||
5801 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5802 | sizeof(base_xpath), af_xpath) | |
5803 | < 0) | |
5804 | return CMD_WARNING_CONFIG_FAILED; | |
5805 | ||
5806 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5807 | "./%s/nexthop-self/next-hop-self", | |
5808 | bgp_afi_safi_get_container_str(afi, safi)); | |
5809 | ||
5810 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5811 | ||
5812 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5813 | } |
6b0655a2 | 5814 | |
d62a17ae | 5815 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5816 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5817 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5818 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5819 | |
f4b8ec07 CS |
5820 | DEFUN_YANG (no_neighbor_nexthop_self_force, |
5821 | no_neighbor_nexthop_self_force_cmd, | |
5822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5823 | NO_STR | |
5824 | NEIGHBOR_STR | |
5825 | NEIGHBOR_ADDR_STR2 | |
5826 | "Disable the next hop calculation for this neighbor\n" | |
5827 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5828 | { |
d62a17ae | 5829 | int idx_peer = 2; |
f4b8ec07 CS |
5830 | char base_xpath[XPATH_MAXLEN]; |
5831 | char af_xpath[XPATH_MAXLEN]; | |
5832 | char attr_xpath[XPATH_MAXLEN]; | |
5833 | afi_t afi = bgp_node_afi(vty); | |
5834 | safi_t safi = bgp_node_safi(vty); | |
5835 | ||
f4b8ec07 CS |
5836 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5837 | yang_afi_safi_value2identity(afi, safi)); | |
5838 | ||
5839 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5840 | sizeof(base_xpath), af_xpath) | |
5841 | < 0) | |
5842 | return CMD_WARNING_CONFIG_FAILED; | |
5843 | ||
5844 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5845 | "./%s/nexthop-self/next-hop-self-force", | |
5846 | bgp_afi_safi_get_container_str(afi, safi)); | |
5847 | ||
5848 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5849 | ||
5850 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 5851 | } |
a538debe | 5852 | |
d62a17ae | 5853 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5854 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5856 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5857 | "Disable the next hop calculation for this neighbor\n" | |
5858 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5859 | |
1bc4e531 DA |
5860 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5861 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5862 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5863 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5864 | "Disable the next hop calculation for this neighbor\n" | |
5865 | "Set the next hop to self for reflected routes\n") | |
5866 | ||
c7122e14 | 5867 | /* neighbor as-override */ |
f4b8ec07 CS |
5868 | DEFUN_YANG (neighbor_as_override, |
5869 | neighbor_as_override_cmd, | |
5870 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5871 | NEIGHBOR_STR | |
5872 | NEIGHBOR_ADDR_STR2 | |
5873 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5874 | { |
d62a17ae | 5875 | int idx_peer = 1; |
f4b8ec07 CS |
5876 | char base_xpath[XPATH_MAXLEN]; |
5877 | char af_xpath[XPATH_MAXLEN]; | |
5878 | char attr_xpath[XPATH_MAXLEN]; | |
5879 | afi_t afi = bgp_node_afi(vty); | |
5880 | safi_t safi = bgp_node_safi(vty); | |
5881 | ||
5882 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5883 | yang_afi_safi_value2identity(afi, safi)); | |
5884 | ||
5885 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5886 | sizeof(base_xpath), af_xpath) | |
5887 | < 0) | |
5888 | return CMD_WARNING_CONFIG_FAILED; | |
5889 | ||
5890 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5891 | "./%s/as-path-options/replace-peer-as", | |
5892 | bgp_afi_safi_get_container_str(afi, safi)); | |
5893 | ||
5894 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5895 | ||
5896 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5897 | } |
5898 | ||
d62a17ae | 5899 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5900 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5901 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5902 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5903 | |
f4b8ec07 CS |
5904 | DEFUN_YANG (no_neighbor_as_override, |
5905 | no_neighbor_as_override_cmd, | |
5906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5907 | NO_STR | |
5908 | NEIGHBOR_STR | |
5909 | NEIGHBOR_ADDR_STR2 | |
5910 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5911 | { |
d62a17ae | 5912 | int idx_peer = 2; |
f4b8ec07 CS |
5913 | char base_xpath[XPATH_MAXLEN]; |
5914 | char af_xpath[XPATH_MAXLEN]; | |
5915 | char attr_xpath[XPATH_MAXLEN]; | |
5916 | afi_t afi = bgp_node_afi(vty); | |
5917 | safi_t safi = bgp_node_safi(vty); | |
5918 | ||
5919 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5920 | yang_afi_safi_value2identity(afi, safi)); | |
5921 | ||
5922 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5923 | sizeof(base_xpath), af_xpath) | |
5924 | < 0) | |
5925 | return CMD_WARNING_CONFIG_FAILED; | |
5926 | ||
5927 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5928 | "./%s/as-path-options/replace-peer-as", | |
5929 | bgp_afi_safi_get_container_str(afi, safi)); | |
5930 | ||
5931 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
5932 | ||
5933 | return nb_cli_apply_changes(vty, base_xpath); | |
c7122e14 DS |
5934 | } |
5935 | ||
d62a17ae | 5936 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5937 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5938 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5939 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5940 | |
718e3744 | 5941 | /* neighbor remove-private-AS. */ |
f4b8ec07 CS |
5942 | DEFUN_YANG (neighbor_remove_private_as, |
5943 | neighbor_remove_private_as_cmd, | |
5944 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5945 | NEIGHBOR_STR | |
5946 | NEIGHBOR_ADDR_STR2 | |
5947 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5948 | { |
d62a17ae | 5949 | int idx_peer = 1; |
f4b8ec07 CS |
5950 | char base_xpath[XPATH_MAXLEN]; |
5951 | char af_xpath[XPATH_MAXLEN]; | |
5952 | char attr_xpath[XPATH_MAXLEN]; | |
5953 | afi_t afi = bgp_node_afi(vty); | |
5954 | safi_t safi = bgp_node_safi(vty); | |
5955 | ||
5956 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
5957 | yang_afi_safi_value2identity(afi, safi)); | |
5958 | ||
5959 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5960 | sizeof(base_xpath), af_xpath) | |
5961 | < 0) | |
5962 | return CMD_WARNING_CONFIG_FAILED; | |
5963 | ||
5964 | snprintf(attr_xpath, sizeof(attr_xpath), | |
5965 | "./%s/private-as/remove-private-as", | |
5966 | bgp_afi_safi_get_container_str(afi, safi)); | |
5967 | ||
5968 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
5969 | ||
5970 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 5971 | } |
5972 | ||
d62a17ae | 5973 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5974 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5975 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5976 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5977 | |
f4b8ec07 CS |
5978 | DEFUN_YANG (neighbor_remove_private_as_all, |
5979 | neighbor_remove_private_as_all_cmd, | |
5980 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5981 | NEIGHBOR_STR | |
5982 | NEIGHBOR_ADDR_STR2 | |
5983 | "Remove private ASNs in outbound updates\n" | |
5984 | "Apply to all AS numbers\n") | |
5000f21c | 5985 | { |
d62a17ae | 5986 | int idx_peer = 1; |
f4b8ec07 CS |
5987 | char base_xpath[XPATH_MAXLEN]; |
5988 | char af_xpath[XPATH_MAXLEN]; | |
5989 | char attr_xpath[XPATH_MAXLEN]; | |
5990 | afi_t afi = bgp_node_afi(vty); | |
5991 | safi_t safi = bgp_node_safi(vty); | |
5992 | ||
f4b8ec07 CS |
5993 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
5994 | yang_afi_safi_value2identity(afi, safi)); | |
5995 | ||
5996 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
5997 | sizeof(base_xpath), af_xpath) | |
5998 | < 0) | |
5999 | return CMD_WARNING_CONFIG_FAILED; | |
6000 | ||
6001 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6002 | "./%s/private-as/remove-private-as-all", | |
6003 | bgp_afi_safi_get_container_str(afi, safi)); | |
6004 | ||
6005 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6006 | ||
6007 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
6008 | } |
6009 | ||
d62a17ae | 6010 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
6011 | neighbor_remove_private_as_all_hidden_cmd, | |
6012 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6013 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6014 | "Remove private ASNs in outbound updates\n" | |
6015 | "Apply to all AS numbers") | |
596c17ba | 6016 | |
f4b8ec07 CS |
6017 | DEFUN_YANG (neighbor_remove_private_as_replace_as, |
6018 | neighbor_remove_private_as_replace_as_cmd, | |
6019 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6020 | NEIGHBOR_STR | |
6021 | NEIGHBOR_ADDR_STR2 | |
6022 | "Remove private ASNs in outbound updates\n" | |
6023 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 6024 | { |
d62a17ae | 6025 | int idx_peer = 1; |
f4b8ec07 CS |
6026 | char base_xpath[XPATH_MAXLEN]; |
6027 | char af_xpath[XPATH_MAXLEN]; | |
6028 | char attr_xpath[XPATH_MAXLEN]; | |
6029 | afi_t afi = bgp_node_afi(vty); | |
6030 | safi_t safi = bgp_node_safi(vty); | |
6031 | ||
f4b8ec07 CS |
6032 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6033 | yang_afi_safi_value2identity(afi, safi)); | |
6034 | ||
6035 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6036 | sizeof(base_xpath), af_xpath) | |
6037 | < 0) | |
6038 | return CMD_WARNING_CONFIG_FAILED; | |
6039 | ||
6040 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6041 | "./%s/private-as/remove-private-as-replace", | |
6042 | bgp_afi_safi_get_container_str(afi, safi)); | |
6043 | ||
6044 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6045 | ||
6046 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
6047 | } |
6048 | ||
d62a17ae | 6049 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
6050 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
6051 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6052 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6053 | "Remove private ASNs in outbound updates\n" | |
6054 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6055 | |
f4b8ec07 CS |
6056 | DEFUN_YANG (neighbor_remove_private_as_all_replace_as, |
6057 | neighbor_remove_private_as_all_replace_as_cmd, | |
6058 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6059 | NEIGHBOR_STR | |
6060 | NEIGHBOR_ADDR_STR2 | |
6061 | "Remove private ASNs in outbound updates\n" | |
6062 | "Apply to all AS numbers\n" | |
6063 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 6064 | { |
d62a17ae | 6065 | int idx_peer = 1; |
f4b8ec07 CS |
6066 | char base_xpath[XPATH_MAXLEN]; |
6067 | char af_xpath[XPATH_MAXLEN]; | |
6068 | char attr_xpath[XPATH_MAXLEN]; | |
6069 | afi_t afi = bgp_node_afi(vty); | |
6070 | safi_t safi = bgp_node_safi(vty); | |
6071 | ||
f4b8ec07 CS |
6072 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6073 | yang_afi_safi_value2identity(afi, safi)); | |
6074 | ||
6075 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6076 | sizeof(base_xpath), af_xpath) | |
6077 | < 0) | |
6078 | return CMD_WARNING_CONFIG_FAILED; | |
6079 | ||
6080 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6081 | "./%s/private-as/remove-private-as-all-replace", | |
6082 | bgp_afi_safi_get_container_str(afi, safi)); | |
6083 | ||
6084 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6085 | ||
6086 | return nb_cli_apply_changes(vty, base_xpath); | |
5000f21c DS |
6087 | } |
6088 | ||
d62a17ae | 6089 | ALIAS_HIDDEN( |
6090 | neighbor_remove_private_as_all_replace_as, | |
6091 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
6092 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6093 | NEIGHBOR_STR 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") | |
596c17ba | 6097 | |
f4b8ec07 CS |
6098 | DEFUN_YANG (no_neighbor_remove_private_as, |
6099 | no_neighbor_remove_private_as_cmd, | |
6100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
6101 | NO_STR | |
6102 | NEIGHBOR_STR | |
6103 | NEIGHBOR_ADDR_STR2 | |
6104 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 6105 | { |
d62a17ae | 6106 | int idx_peer = 2; |
f4b8ec07 CS |
6107 | char base_xpath[XPATH_MAXLEN]; |
6108 | char af_xpath[XPATH_MAXLEN]; | |
6109 | char attr_xpath[XPATH_MAXLEN]; | |
6110 | afi_t afi = bgp_node_afi(vty); | |
6111 | safi_t safi = bgp_node_safi(vty); | |
6112 | ||
6113 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6114 | yang_afi_safi_value2identity(afi, safi)); | |
6115 | ||
6116 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6117 | sizeof(base_xpath), af_xpath) | |
6118 | < 0) | |
6119 | return CMD_WARNING_CONFIG_FAILED; | |
6120 | ||
6121 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6122 | "./%s/private-as/remove-private-as", | |
6123 | bgp_afi_safi_get_container_str(afi, safi)); | |
6124 | ||
6125 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6126 | ||
6127 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6128 | } |
6b0655a2 | 6129 | |
d62a17ae | 6130 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
6131 | no_neighbor_remove_private_as_hidden_cmd, | |
6132 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
6133 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6134 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 6135 | |
f4b8ec07 CS |
6136 | DEFUN_YANG (no_neighbor_remove_private_as_all, |
6137 | no_neighbor_remove_private_as_all_cmd, | |
6138 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6139 | NO_STR | |
6140 | NEIGHBOR_STR | |
6141 | NEIGHBOR_ADDR_STR2 | |
6142 | "Remove private ASNs in outbound updates\n" | |
6143 | "Apply to all AS numbers\n") | |
88b8ed8d | 6144 | { |
d62a17ae | 6145 | int idx_peer = 2; |
f4b8ec07 CS |
6146 | char base_xpath[XPATH_MAXLEN]; |
6147 | char af_xpath[XPATH_MAXLEN]; | |
6148 | char attr_xpath[XPATH_MAXLEN]; | |
6149 | afi_t afi = bgp_node_afi(vty); | |
6150 | safi_t safi = bgp_node_safi(vty); | |
6151 | ||
f4b8ec07 CS |
6152 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6153 | yang_afi_safi_value2identity(afi, safi)); | |
6154 | ||
6155 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6156 | sizeof(base_xpath), af_xpath) | |
6157 | < 0) | |
6158 | return CMD_WARNING_CONFIG_FAILED; | |
6159 | ||
6160 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6161 | "./%s/private-as/remove-private-as-all", | |
6162 | bgp_afi_safi_get_container_str(afi, safi)); | |
6163 | ||
6164 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6165 | ||
6166 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 6167 | } |
5000f21c | 6168 | |
d62a17ae | 6169 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
6170 | no_neighbor_remove_private_as_all_hidden_cmd, | |
6171 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6172 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6173 | "Remove private ASNs in outbound updates\n" | |
6174 | "Apply to all AS numbers\n") | |
596c17ba | 6175 | |
f4b8ec07 CS |
6176 | DEFUN_YANG (no_neighbor_remove_private_as_replace_as, |
6177 | no_neighbor_remove_private_as_replace_as_cmd, | |
6178 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6179 | NO_STR | |
6180 | NEIGHBOR_STR | |
6181 | NEIGHBOR_ADDR_STR2 | |
6182 | "Remove private ASNs in outbound updates\n" | |
6183 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 6184 | { |
d62a17ae | 6185 | int idx_peer = 2; |
f4b8ec07 CS |
6186 | char base_xpath[XPATH_MAXLEN]; |
6187 | char af_xpath[XPATH_MAXLEN]; | |
6188 | char attr_xpath[XPATH_MAXLEN]; | |
6189 | afi_t afi = bgp_node_afi(vty); | |
6190 | safi_t safi = bgp_node_safi(vty); | |
6191 | ||
f4b8ec07 CS |
6192 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6193 | yang_afi_safi_value2identity(afi, safi)); | |
6194 | ||
6195 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6196 | sizeof(base_xpath), af_xpath) | |
6197 | < 0) | |
6198 | return CMD_WARNING_CONFIG_FAILED; | |
6199 | ||
6200 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6201 | "./%s/private-as/remove-private-as-replace", | |
6202 | bgp_afi_safi_get_container_str(afi, safi)); | |
6203 | ||
6204 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6205 | ||
6206 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 6207 | } |
5000f21c | 6208 | |
d62a17ae | 6209 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
6210 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
6211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6212 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6213 | "Remove private ASNs in outbound updates\n" | |
6214 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6215 | |
f4b8ec07 CS |
6216 | DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as, |
6217 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
6218 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6219 | NO_STR | |
6220 | NEIGHBOR_STR | |
6221 | NEIGHBOR_ADDR_STR2 | |
6222 | "Remove private ASNs in outbound updates\n" | |
6223 | "Apply to all AS numbers\n" | |
6224 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 6225 | { |
d62a17ae | 6226 | int idx_peer = 2; |
f4b8ec07 CS |
6227 | char base_xpath[XPATH_MAXLEN]; |
6228 | char af_xpath[XPATH_MAXLEN]; | |
6229 | char attr_xpath[XPATH_MAXLEN]; | |
6230 | afi_t afi = bgp_node_afi(vty); | |
6231 | safi_t safi = bgp_node_safi(vty); | |
6232 | ||
f4b8ec07 CS |
6233 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6234 | yang_afi_safi_value2identity(afi, safi)); | |
6235 | ||
6236 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6237 | sizeof(base_xpath), af_xpath) | |
6238 | < 0) | |
6239 | return CMD_WARNING_CONFIG_FAILED; | |
6240 | ||
6241 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6242 | "./%s/private-as/remove-private-as-all-replace", | |
6243 | bgp_afi_safi_get_container_str(afi, safi)); | |
6244 | ||
6245 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6246 | ||
6247 | return nb_cli_apply_changes(vty, base_xpath); | |
88b8ed8d | 6248 | } |
5000f21c | 6249 | |
d62a17ae | 6250 | ALIAS_HIDDEN( |
6251 | no_neighbor_remove_private_as_all_replace_as, | |
6252 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
6253 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6254 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6255 | "Remove private ASNs in outbound updates\n" | |
6256 | "Apply to all AS numbers\n" | |
6257 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6258 | |
5000f21c | 6259 | |
718e3744 | 6260 | /* neighbor send-community. */ |
f4b8ec07 CS |
6261 | DEFUN_YANG (neighbor_send_community, |
6262 | neighbor_send_community_cmd, | |
6263 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6264 | NEIGHBOR_STR | |
6265 | NEIGHBOR_ADDR_STR2 | |
6266 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6267 | { |
d62a17ae | 6268 | int idx_peer = 1; |
e48a9a90 CS |
6269 | char *peer_str = argv[idx_peer]->arg; |
6270 | char base_xpath[XPATH_MAXLEN]; | |
6271 | char af_xpath[XPATH_MAXLEN]; | |
6272 | char std_xpath[XPATH_MAXLEN]; | |
6273 | afi_t afi = bgp_node_afi(vty); | |
6274 | safi_t safi = bgp_node_safi(vty); | |
27c05d4d | 6275 | |
e48a9a90 CS |
6276 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6277 | yang_afi_safi_value2identity(afi, safi)); | |
6278 | ||
6279 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6280 | sizeof(base_xpath), af_xpath) | |
6281 | < 0) | |
6282 | return CMD_WARNING_CONFIG_FAILED; | |
6283 | ||
6284 | snprintf(std_xpath, sizeof(std_xpath), | |
6285 | "./%s/send-community/send-community", | |
6286 | bgp_afi_safi_get_container_str(afi, safi)); | |
6287 | ||
6288 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6289 | ||
6290 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6291 | } |
6292 | ||
d62a17ae | 6293 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
6294 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6295 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6296 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6297 | |
f4b8ec07 CS |
6298 | DEFUN_YANG (no_neighbor_send_community, |
6299 | no_neighbor_send_community_cmd, | |
6300 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6301 | NO_STR | |
6302 | NEIGHBOR_STR | |
6303 | NEIGHBOR_ADDR_STR2 | |
6304 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6305 | { |
d62a17ae | 6306 | int idx_peer = 2; |
e48a9a90 CS |
6307 | char *peer_str = argv[idx_peer]->arg; |
6308 | char base_xpath[XPATH_MAXLEN]; | |
6309 | char af_xpath[XPATH_MAXLEN]; | |
6310 | char std_xpath[XPATH_MAXLEN]; | |
6311 | afi_t afi = bgp_node_afi(vty); | |
6312 | safi_t safi = bgp_node_safi(vty); | |
27c05d4d | 6313 | |
e48a9a90 CS |
6314 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6315 | yang_afi_safi_value2identity(afi, safi)); | |
6316 | ||
6317 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6318 | sizeof(base_xpath), af_xpath) | |
6319 | < 0) | |
6320 | return CMD_WARNING_CONFIG_FAILED; | |
6321 | ||
6322 | snprintf(std_xpath, sizeof(std_xpath), | |
6323 | "./%s/send-community/send-community", | |
6324 | bgp_afi_safi_get_container_str(afi, safi)); | |
6325 | ||
6326 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6327 | ||
6328 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6329 | } |
6b0655a2 | 6330 | |
d62a17ae | 6331 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6332 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6333 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6334 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6335 | |
718e3744 | 6336 | /* neighbor send-community extended. */ |
f4b8ec07 CS |
6337 | DEFUN_YANG (neighbor_send_community_type, |
6338 | neighbor_send_community_type_cmd, | |
6339 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6340 | NEIGHBOR_STR | |
6341 | NEIGHBOR_ADDR_STR2 | |
6342 | "Send Community attribute to this neighbor\n" | |
6343 | "Send Standard and Extended Community attributes\n" | |
6344 | "Send Standard, Large and Extended Community attributes\n" | |
6345 | "Send Extended Community attributes\n" | |
6346 | "Send Standard Community attributes\n" | |
6347 | "Send Large Community attributes\n") | |
718e3744 | 6348 | { |
27c05d4d | 6349 | const char *type = argv[argc - 1]->text; |
db45f64d | 6350 | char *peer_str = argv[1]->arg; |
f4b8ec07 CS |
6351 | char base_xpath[XPATH_MAXLEN]; |
6352 | char af_xpath[XPATH_MAXLEN]; | |
6353 | char std_xpath[XPATH_MAXLEN]; | |
6354 | char ext_xpath[XPATH_MAXLEN]; | |
6355 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6356 | afi_t afi = bgp_node_afi(vty); |
6357 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 6358 | |
f4b8ec07 CS |
6359 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6360 | yang_afi_safi_value2identity(afi, safi)); | |
6361 | ||
6362 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6363 | sizeof(base_xpath), af_xpath) | |
6364 | < 0) | |
db45f64d | 6365 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6366 | |
f4b8ec07 CS |
6367 | if (strmatch(type, "standard")) { |
6368 | snprintf(std_xpath, sizeof(std_xpath), | |
6369 | "./%s/send-community/send-community", | |
6370 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6371 | |
f4b8ec07 CS |
6372 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); |
6373 | } | |
db45f64d | 6374 | |
f4b8ec07 CS |
6375 | if (strmatch(type, "extended")) { |
6376 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6377 | "./%s/send-community/send-ext-community", | |
6378 | bgp_afi_safi_get_container_str(afi, safi)); | |
6379 | ||
6380 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6381 | } | |
6382 | ||
6383 | if (strmatch(type, "large")) { | |
6384 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6385 | "./%s/send-community/send-large-community", | |
6386 | bgp_afi_safi_get_container_str(afi, safi)); | |
6387 | ||
6388 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6389 | } | |
db45f64d DS |
6390 | |
6391 | if (strmatch(type, "both")) { | |
f4b8ec07 CS |
6392 | snprintf(std_xpath, sizeof(std_xpath), |
6393 | "./%s/send-community/send-community", | |
6394 | bgp_afi_safi_get_container_str(afi, safi)); | |
6395 | ||
6396 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6397 | ||
6398 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6399 | "./%s/send-community/send-ext-community", | |
6400 | bgp_afi_safi_get_container_str(afi, safi)); | |
6401 | ||
6402 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
db45f64d | 6403 | } |
f4b8ec07 CS |
6404 | |
6405 | if (strmatch(type, "all")) { | |
6406 | snprintf(std_xpath, sizeof(std_xpath), | |
6407 | "./%s/send-community/send-community", | |
6408 | bgp_afi_safi_get_container_str(afi, safi)); | |
6409 | ||
6410 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "true"); | |
6411 | ||
6412 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6413 | "./%s/send-community/send-ext-community", | |
6414 | bgp_afi_safi_get_container_str(afi, safi)); | |
6415 | ||
6416 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "true"); | |
6417 | ||
6418 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6419 | "./%s/send-community/send-large-community", | |
6420 | bgp_afi_safi_get_container_str(afi, safi)); | |
6421 | ||
6422 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "true"); | |
6423 | } | |
6424 | ||
6425 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 6426 | } |
6427 | ||
6428 | ALIAS_HIDDEN( | |
6429 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6430 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6431 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6432 | "Send Community attribute to this neighbor\n" | |
6433 | "Send Standard and Extended Community attributes\n" | |
6434 | "Send Standard, Large and Extended Community attributes\n" | |
6435 | "Send Extended Community attributes\n" | |
6436 | "Send Standard Community attributes\n" | |
6437 | "Send Large Community attributes\n") | |
596c17ba | 6438 | |
f4b8ec07 CS |
6439 | DEFUN_YANG (no_neighbor_send_community_type, |
6440 | no_neighbor_send_community_type_cmd, | |
6441 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6442 | NO_STR | |
6443 | NEIGHBOR_STR | |
6444 | NEIGHBOR_ADDR_STR2 | |
6445 | "Send Community attribute to this neighbor\n" | |
6446 | "Send Standard and Extended Community attributes\n" | |
6447 | "Send Standard, Large and Extended Community attributes\n" | |
6448 | "Send Extended Community attributes\n" | |
6449 | "Send Standard Community attributes\n" | |
6450 | "Send Large Community attributes\n") | |
718e3744 | 6451 | { |
d62a17ae | 6452 | const char *type = argv[argc - 1]->text; |
db45f64d | 6453 | char *peer_str = argv[2]->arg; |
f4b8ec07 CS |
6454 | char base_xpath[XPATH_MAXLEN]; |
6455 | char af_xpath[XPATH_MAXLEN]; | |
6456 | char std_xpath[XPATH_MAXLEN]; | |
6457 | char ext_xpath[XPATH_MAXLEN]; | |
6458 | char lrg_xpath[XPATH_MAXLEN]; | |
db45f64d DS |
6459 | afi_t afi = bgp_node_afi(vty); |
6460 | safi_t safi = bgp_node_safi(vty); | |
6461 | ||
f4b8ec07 CS |
6462 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6463 | yang_afi_safi_value2identity(afi, safi)); | |
6464 | ||
6465 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6466 | sizeof(base_xpath), af_xpath) | |
6467 | < 0) | |
6468 | return CMD_WARNING_CONFIG_FAILED; | |
6469 | ||
6470 | if (strmatch(type, "standard")) { | |
6471 | snprintf(std_xpath, sizeof(std_xpath), | |
6472 | "./%s/send-community/send-community", | |
6473 | bgp_afi_safi_get_container_str(afi, safi)); | |
6474 | ||
6475 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6476 | } | |
6477 | ||
6478 | if (strmatch(type, "extended")) { | |
6479 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6480 | "./%s/send-community/send-ext-community", | |
6481 | bgp_afi_safi_get_container_str(afi, safi)); | |
6482 | ||
6483 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6484 | } | |
6485 | ||
6486 | if (strmatch(type, "large")) { | |
6487 | snprintf(lrg_xpath, sizeof(lrg_xpath), | |
6488 | "./%s/send-community/send-large-community", | |
6489 | bgp_afi_safi_get_container_str(afi, safi)); | |
6490 | ||
6491 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); | |
6492 | } | |
6493 | ||
6494 | if (strmatch(type, "both")) { | |
6495 | snprintf(std_xpath, sizeof(std_xpath), | |
6496 | "./%s/send-community/send-community", | |
6497 | bgp_afi_safi_get_container_str(afi, safi)); | |
6498 | ||
6499 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); | |
6500 | ||
6501 | snprintf(ext_xpath, sizeof(ext_xpath), | |
6502 | "./%s/send-community/send-ext-community", | |
6503 | bgp_afi_safi_get_container_str(afi, safi)); | |
6504 | ||
6505 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); | |
6506 | } | |
6507 | ||
6508 | if (strmatch(type, "all")) { | |
6509 | snprintf(std_xpath, sizeof(std_xpath), | |
6510 | "./%s/send-community/send-community", | |
6511 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6512 | |
f4b8ec07 | 6513 | nb_cli_enqueue_change(vty, std_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6514 | |
f4b8ec07 CS |
6515 | snprintf(ext_xpath, sizeof(ext_xpath), |
6516 | "./%s/send-community/send-ext-community", | |
6517 | bgp_afi_safi_get_container_str(afi, safi)); | |
db45f64d | 6518 | |
f4b8ec07 | 6519 | nb_cli_enqueue_change(vty, ext_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6520 | |
f4b8ec07 CS |
6521 | snprintf(lrg_xpath, sizeof(lrg_xpath), |
6522 | "./%s/send-community/send-large-community", | |
6523 | bgp_afi_safi_get_container_str(afi, safi)); | |
d62a17ae | 6524 | |
f4b8ec07 | 6525 | nb_cli_enqueue_change(vty, lrg_xpath, NB_OP_MODIFY, "false"); |
27c05d4d PM |
6526 | } |
6527 | ||
f4b8ec07 | 6528 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6529 | } |
6530 | ||
6531 | ALIAS_HIDDEN( | |
6532 | no_neighbor_send_community_type, | |
6533 | no_neighbor_send_community_type_hidden_cmd, | |
6534 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6535 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6536 | "Send Community attribute to this neighbor\n" | |
6537 | "Send Standard and Extended Community attributes\n" | |
6538 | "Send Standard, Large and Extended Community attributes\n" | |
6539 | "Send Extended Community attributes\n" | |
6540 | "Send Standard Community attributes\n" | |
6541 | "Send Large Community attributes\n") | |
596c17ba | 6542 | |
718e3744 | 6543 | /* neighbor soft-reconfig. */ |
f4b8ec07 CS |
6544 | DEFUN_YANG (neighbor_soft_reconfiguration, |
6545 | neighbor_soft_reconfiguration_cmd, | |
6546 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6547 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6548 | "Per neighbor soft reconfiguration\n" | |
6549 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6550 | { |
d62a17ae | 6551 | int idx_peer = 1; |
f4b8ec07 CS |
6552 | char base_xpath[XPATH_MAXLEN]; |
6553 | char af_xpath[XPATH_MAXLEN]; | |
6554 | char soft_xpath[XPATH_MAXLEN]; | |
6555 | afi_t afi = bgp_node_afi(vty); | |
6556 | safi_t safi = bgp_node_safi(vty); | |
6557 | ||
f4b8ec07 CS |
6558 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6559 | yang_afi_safi_value2identity(afi, safi)); | |
6560 | ||
6561 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6562 | sizeof(base_xpath), af_xpath) | |
6563 | < 0) | |
6564 | return CMD_WARNING_CONFIG_FAILED; | |
6565 | ||
6566 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6567 | bgp_afi_safi_get_container_str(afi, safi)); | |
6568 | ||
6569 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "true"); | |
6570 | ||
6571 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6572 | } |
6573 | ||
d62a17ae | 6574 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6575 | neighbor_soft_reconfiguration_hidden_cmd, | |
6576 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6577 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6578 | "Per neighbor soft reconfiguration\n" | |
6579 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6580 | |
f4b8ec07 CS |
6581 | DEFUN_YANG (no_neighbor_soft_reconfiguration, |
6582 | no_neighbor_soft_reconfiguration_cmd, | |
6583 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6584 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6585 | "Per neighbor soft reconfiguration\n" | |
6586 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6587 | { |
d62a17ae | 6588 | int idx_peer = 2; |
f4b8ec07 CS |
6589 | char base_xpath[XPATH_MAXLEN]; |
6590 | char af_xpath[XPATH_MAXLEN]; | |
6591 | char soft_xpath[XPATH_MAXLEN]; | |
6592 | afi_t afi = bgp_node_afi(vty); | |
6593 | safi_t safi = bgp_node_safi(vty); | |
6594 | ||
6595 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6596 | yang_afi_safi_value2identity(afi, safi)); | |
6597 | ||
6598 | snprintf(soft_xpath, sizeof(soft_xpath), "./%s/soft-reconfiguration", | |
6599 | bgp_afi_safi_get_container_str(afi, safi)); | |
6600 | ||
6601 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6602 | sizeof(base_xpath), af_xpath) | |
6603 | < 0) | |
6604 | return CMD_WARNING_CONFIG_FAILED; | |
6605 | ||
6606 | nb_cli_enqueue_change(vty, soft_xpath, NB_OP_MODIFY, "false"); | |
6607 | ||
6608 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6609 | } |
6b0655a2 | 6610 | |
d62a17ae | 6611 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6612 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6613 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6614 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6615 | "Per neighbor soft reconfiguration\n" | |
6616 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6617 | |
f4b8ec07 CS |
6618 | DEFUN_YANG (neighbor_route_reflector_client, |
6619 | neighbor_route_reflector_client_cmd, | |
6620 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6621 | NEIGHBOR_STR | |
6622 | NEIGHBOR_ADDR_STR2 | |
6623 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6624 | { |
d62a17ae | 6625 | int idx_peer = 1; |
f4b8ec07 CS |
6626 | char base_xpath[XPATH_MAXLEN]; |
6627 | char af_xpath[XPATH_MAXLEN]; | |
6628 | char attr_xpath[XPATH_MAXLEN]; | |
6629 | afi_t afi = bgp_node_afi(vty); | |
6630 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 6631 | |
f4b8ec07 CS |
6632 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6633 | yang_afi_safi_value2identity(afi, safi)); | |
718e3744 | 6634 | |
f4b8ec07 CS |
6635 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6636 | sizeof(base_xpath), af_xpath) | |
6637 | < 0) | |
d62a17ae | 6638 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6639 | |
f4b8ec07 CS |
6640 | snprintf(attr_xpath, sizeof(attr_xpath), |
6641 | "./%s/route-reflector/route-reflector-client", | |
6642 | bgp_afi_safi_get_container_str(afi, safi)); | |
6643 | ||
6644 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6645 | ||
6646 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6647 | } |
6648 | ||
d62a17ae | 6649 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6650 | neighbor_route_reflector_client_hidden_cmd, | |
6651 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6652 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6653 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6654 | |
f4b8ec07 CS |
6655 | DEFUN_YANG (no_neighbor_route_reflector_client, |
6656 | no_neighbor_route_reflector_client_cmd, | |
6657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6658 | NO_STR | |
6659 | NEIGHBOR_STR | |
6660 | NEIGHBOR_ADDR_STR2 | |
6661 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6662 | { |
d62a17ae | 6663 | int idx_peer = 2; |
f4b8ec07 CS |
6664 | char base_xpath[XPATH_MAXLEN]; |
6665 | char af_xpath[XPATH_MAXLEN]; | |
6666 | char attr_xpath[XPATH_MAXLEN]; | |
6667 | afi_t afi = bgp_node_afi(vty); | |
6668 | safi_t safi = bgp_node_safi(vty); | |
6669 | ||
6670 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6671 | yang_afi_safi_value2identity(afi, safi)); | |
6672 | ||
6673 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6674 | sizeof(base_xpath), af_xpath) | |
6675 | < 0) | |
6676 | return CMD_WARNING_CONFIG_FAILED; | |
6677 | ||
6678 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6679 | "./%s/route-reflector/route-reflector-client", | |
6680 | bgp_afi_safi_get_container_str(afi, safi)); | |
6681 | ||
6682 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6683 | ||
6684 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6685 | } |
6b0655a2 | 6686 | |
d62a17ae | 6687 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6688 | no_neighbor_route_reflector_client_hidden_cmd, | |
6689 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6690 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6691 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6692 | |
718e3744 | 6693 | /* neighbor route-server-client. */ |
f4b8ec07 CS |
6694 | DEFUN_YANG (neighbor_route_server_client, |
6695 | neighbor_route_server_client_cmd, | |
6696 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6697 | NEIGHBOR_STR | |
6698 | NEIGHBOR_ADDR_STR2 | |
6699 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6700 | { |
d62a17ae | 6701 | int idx_peer = 1; |
f4b8ec07 CS |
6702 | char base_xpath[XPATH_MAXLEN]; |
6703 | char af_xpath[XPATH_MAXLEN]; | |
6704 | char attr_xpath[XPATH_MAXLEN]; | |
6705 | afi_t afi = bgp_node_afi(vty); | |
6706 | safi_t safi = bgp_node_safi(vty); | |
2a3d5731 | 6707 | |
f4b8ec07 CS |
6708 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6709 | yang_afi_safi_value2identity(afi, safi)); | |
6710 | ||
6711 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6712 | sizeof(base_xpath), af_xpath) | |
6713 | < 0) | |
d62a17ae | 6714 | return CMD_WARNING_CONFIG_FAILED; |
f4b8ec07 CS |
6715 | |
6716 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6717 | "./%s/route-server/route-server-client", | |
6718 | bgp_afi_safi_get_container_str(afi, safi)); | |
6719 | ||
6720 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "true"); | |
6721 | ||
6722 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 6723 | } |
6724 | ||
d62a17ae | 6725 | ALIAS_HIDDEN(neighbor_route_server_client, |
6726 | neighbor_route_server_client_hidden_cmd, | |
6727 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6728 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6729 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6730 | |
f4b8ec07 CS |
6731 | DEFUN_YANG (no_neighbor_route_server_client, |
6732 | no_neighbor_route_server_client_cmd, | |
6733 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6734 | NO_STR | |
6735 | NEIGHBOR_STR | |
6736 | NEIGHBOR_ADDR_STR2 | |
6737 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6738 | { |
d62a17ae | 6739 | int idx_peer = 2; |
f4b8ec07 CS |
6740 | char base_xpath[XPATH_MAXLEN]; |
6741 | char af_xpath[XPATH_MAXLEN]; | |
6742 | char attr_xpath[XPATH_MAXLEN]; | |
6743 | afi_t afi = bgp_node_afi(vty); | |
6744 | safi_t safi = bgp_node_safi(vty); | |
6745 | ||
6746 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
6747 | yang_afi_safi_value2identity(afi, safi)); | |
6748 | ||
6749 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
6750 | sizeof(base_xpath), af_xpath) | |
6751 | < 0) | |
6752 | return CMD_WARNING_CONFIG_FAILED; | |
6753 | ||
6754 | snprintf(attr_xpath, sizeof(attr_xpath), | |
6755 | "./%s/route-server/route-server-client", | |
6756 | bgp_afi_safi_get_container_str(afi, safi)); | |
6757 | ||
6758 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, "false"); | |
6759 | ||
6760 | return nb_cli_apply_changes(vty, base_xpath); | |
fee0f4c6 | 6761 | } |
6b0655a2 | 6762 | |
d62a17ae | 6763 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6764 | no_neighbor_route_server_client_hidden_cmd, | |
6765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6766 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6767 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6768 | |
fee0f4c6 | 6769 | DEFUN (neighbor_nexthop_local_unchanged, |
6770 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6771 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6772 | NEIGHBOR_STR |
6773 | NEIGHBOR_ADDR_STR2 | |
6774 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6775 | "Leave link-local nexthop unchanged for this peer\n") | |
6776 | { | |
d62a17ae | 6777 | int idx_peer = 1; |
6778 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6779 | bgp_node_safi(vty), | |
6780 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6781 | } |
6b0655a2 | 6782 | |
fee0f4c6 | 6783 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6784 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6786 | NO_STR |
6787 | NEIGHBOR_STR | |
6788 | NEIGHBOR_ADDR_STR2 | |
6789 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6790 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6791 | { |
d62a17ae | 6792 | int idx_peer = 2; |
6793 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6794 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6795 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6796 | } |
6b0655a2 | 6797 | |
f4b8ec07 CS |
6798 | DEFUN_YANG (neighbor_attr_unchanged, |
6799 | neighbor_attr_unchanged_cmd, | |
6800 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6801 | NEIGHBOR_STR | |
6802 | NEIGHBOR_ADDR_STR2 | |
6803 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6804 | "As-path attribute\n" | |
6805 | "Nexthop attribute\n" | |
6806 | "Med attribute\n") | |
718e3744 | 6807 | { |
d62a17ae | 6808 | int idx = 0; |
8eeb0335 | 6809 | char *peer_str = argv[1]->arg; |
db45f64d DS |
6810 | bool aspath = false; |
6811 | bool nexthop = false; | |
6812 | bool med = false; | |
8eeb0335 DW |
6813 | afi_t afi = bgp_node_afi(vty); |
6814 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6815 | char base_xpath[XPATH_MAXLEN]; |
6816 | char af_xpath[XPATH_MAXLEN]; | |
6817 | char as_xpath[XPATH_MAXLEN]; | |
6818 | char nxthop_xpath[XPATH_MAXLEN]; | |
6819 | char med_xpath[XPATH_MAXLEN]; | |
8eeb0335 | 6820 | |
f4b8ec07 CS |
6821 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6822 | yang_afi_safi_value2identity(afi, safi)); | |
6823 | ||
6824 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6825 | sizeof(base_xpath), af_xpath) | |
6826 | < 0) | |
8eeb0335 | 6827 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6828 | |
6829 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6830 | aspath = true; |
6831 | ||
d62a17ae | 6832 | idx = 0; |
6833 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6834 | nexthop = true; |
6835 | ||
d62a17ae | 6836 | idx = 0; |
6837 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6838 | med = true; |
d62a17ae | 6839 | |
f4b8ec07 CS |
6840 | snprintf(as_xpath, sizeof(as_xpath), |
6841 | "./%s/attr-unchanged/as-path-unchanged", | |
6842 | bgp_afi_safi_get_container_str(afi, safi)); | |
6843 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6844 | "./%s/attr-unchanged/next-hop-unchanged", | |
6845 | bgp_afi_safi_get_container_str(afi, safi)); | |
6846 | snprintf(med_xpath, sizeof(med_xpath), | |
6847 | "./%s/attr-unchanged/med-unchanged", | |
6848 | bgp_afi_safi_get_container_str(afi, safi)); | |
6849 | ||
8eeb0335 | 6850 | /* no flags means all of them! */ |
db45f64d | 6851 | if (!aspath && !nexthop && !med) { |
f4b8ec07 CS |
6852 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "true"); |
6853 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "true"); | |
6854 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "true"); | |
8eeb0335 | 6855 | } else { |
f4b8ec07 CS |
6856 | if (!aspath) |
6857 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6858 | "false"); | |
6859 | else | |
6860 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, | |
6861 | "true"); | |
6862 | ||
6863 | if (!nexthop) | |
6864 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6865 | "false"); | |
6866 | else | |
6867 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, | |
6868 | "true"); | |
6869 | ||
6870 | if (!med) | |
6871 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6872 | "false"); | |
6873 | else | |
6874 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, | |
6875 | "true"); | |
d62a17ae | 6876 | } |
6877 | ||
f4b8ec07 | 6878 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6879 | } |
6880 | ||
6881 | ALIAS_HIDDEN( | |
6882 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6883 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6884 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6885 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6886 | "As-path attribute\n" | |
6887 | "Nexthop attribute\n" | |
6888 | "Med attribute\n") | |
596c17ba | 6889 | |
f4b8ec07 CS |
6890 | DEFUN_YANG (no_neighbor_attr_unchanged, |
6891 | no_neighbor_attr_unchanged_cmd, | |
6892 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6893 | NO_STR | |
6894 | NEIGHBOR_STR | |
6895 | NEIGHBOR_ADDR_STR2 | |
6896 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6897 | "As-path attribute\n" | |
6898 | "Nexthop attribute\n" | |
6899 | "Med attribute\n") | |
718e3744 | 6900 | { |
d62a17ae | 6901 | int idx = 0; |
db45f64d | 6902 | char *peer_str = argv[2]->arg; |
db45f64d DS |
6903 | bool aspath = false; |
6904 | bool nexthop = false; | |
6905 | bool med = false; | |
6906 | afi_t afi = bgp_node_afi(vty); | |
6907 | safi_t safi = bgp_node_safi(vty); | |
f4b8ec07 CS |
6908 | char base_xpath[XPATH_MAXLEN]; |
6909 | char af_xpath[XPATH_MAXLEN]; | |
6910 | char as_xpath[XPATH_MAXLEN]; | |
6911 | char nxthop_xpath[XPATH_MAXLEN]; | |
6912 | char med_xpath[XPATH_MAXLEN]; | |
db45f64d | 6913 | |
f4b8ec07 CS |
6914 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
6915 | yang_afi_safi_value2identity(afi, safi)); | |
6916 | ||
6917 | if (peer_and_group_lookup_nb(vty, peer_str, base_xpath, | |
6918 | sizeof(base_xpath), af_xpath) | |
6919 | < 0) | |
db45f64d | 6920 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6921 | |
6922 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6923 | aspath = true; |
6924 | ||
d62a17ae | 6925 | idx = 0; |
6926 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6927 | nexthop = true; |
6928 | ||
d62a17ae | 6929 | idx = 0; |
6930 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6931 | med = true; |
d62a17ae | 6932 | |
f4b8ec07 CS |
6933 | snprintf(as_xpath, sizeof(as_xpath), |
6934 | "./%s/attr-unchanged/as-path-unchanged", | |
6935 | bgp_afi_safi_get_container_str(afi, safi)); | |
6936 | snprintf(nxthop_xpath, sizeof(nxthop_xpath), | |
6937 | "./%s/attr-unchanged/next-hop-unchanged", | |
6938 | bgp_afi_safi_get_container_str(afi, safi)); | |
6939 | snprintf(med_xpath, sizeof(med_xpath), | |
6940 | "./%s/attr-unchanged/med-unchanged", | |
6941 | bgp_afi_safi_get_container_str(afi, safi)); | |
6942 | ||
6943 | /* no flags means all of them! */ | |
6944 | if (!aspath && !nexthop && !med) { | |
6945 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); | |
6946 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); | |
6947 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); | |
6948 | } | |
db45f64d DS |
6949 | |
6950 | if (aspath) | |
f4b8ec07 | 6951 | nb_cli_enqueue_change(vty, as_xpath, NB_OP_MODIFY, "false"); |
db45f64d DS |
6952 | |
6953 | if (nexthop) | |
f4b8ec07 | 6954 | nb_cli_enqueue_change(vty, nxthop_xpath, NB_OP_MODIFY, "false"); |
d62a17ae | 6955 | |
db45f64d | 6956 | if (med) |
f4b8ec07 | 6957 | nb_cli_enqueue_change(vty, med_xpath, NB_OP_MODIFY, "false"); |
db45f64d | 6958 | |
f4b8ec07 | 6959 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 6960 | } |
6961 | ||
6962 | ALIAS_HIDDEN( | |
6963 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6964 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6965 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6966 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6967 | "As-path attribute\n" | |
6968 | "Nexthop attribute\n" | |
6969 | "Med attribute\n") | |
718e3744 | 6970 | |
f4b8ec07 CS |
6971 | /* neighbor ebgp-multihop. */ |
6972 | DEFUN_YANG (neighbor_ebgp_multihop, | |
6973 | neighbor_ebgp_multihop_cmd, | |
6974 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6975 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6976 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6977 | { |
f4b8ec07 CS |
6978 | int idx_peer = 1; |
6979 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 6980 | |
f4b8ec07 CS |
6981 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
6982 | sizeof(base_xpath), NULL) | |
6983 | < 0) | |
d62a17ae | 6984 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6985 | |
f4b8ec07 CS |
6986 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", NB_OP_MODIFY, |
6987 | "true"); | |
718e3744 | 6988 | |
f4b8ec07 | 6989 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 6990 | } |
6991 | ||
f4b8ec07 CS |
6992 | DEFUN_YANG (neighbor_ebgp_multihop_ttl, |
6993 | neighbor_ebgp_multihop_ttl_cmd, | |
6994 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6995 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6996 | "Allow EBGP neighbors not on directly connected networks\n" | |
6997 | "maximum hop count\n") | |
718e3744 | 6998 | { |
f4b8ec07 CS |
6999 | int idx_peer = 1; |
7000 | int idx_number = 3; | |
7001 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7002 | |
f4b8ec07 CS |
7003 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7004 | sizeof(base_xpath), NULL) | |
7005 | < 0) | |
d62a17ae | 7006 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7007 | |
f4b8ec07 CS |
7008 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY, |
7009 | argv[idx_number]->arg); | |
718e3744 | 7010 | |
f4b8ec07 | 7011 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7012 | } |
7013 | ||
f4b8ec07 CS |
7014 | DEFUN_YANG (no_neighbor_ebgp_multihop, |
7015 | no_neighbor_ebgp_multihop_cmd, | |
7016 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
7017 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7018 | "Allow EBGP neighbors not on directly connected networks\n" | |
7019 | "maximum hop count\n") | |
718e3744 | 7020 | { |
d62a17ae | 7021 | int idx_peer = 2; |
f4b8ec07 CS |
7022 | char base_xpath[XPATH_MAXLEN]; |
7023 | ||
7024 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7025 | sizeof(base_xpath), NULL) | |
7026 | < 0) | |
7027 | return CMD_WARNING_CONFIG_FAILED; | |
7028 | ||
7029 | if (argc > 4) | |
7030 | nb_cli_enqueue_change(vty, "./ebgp-multihop/multihop-ttl", | |
7031 | NB_OP_DESTROY, NULL); | |
7032 | else | |
7033 | nb_cli_enqueue_change(vty, "./ebgp-multihop/enabled", | |
7034 | NB_OP_MODIFY, "false"); | |
7035 | ||
7036 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7037 | } |
7038 | ||
6b0655a2 | 7039 | |
6ffd2079 | 7040 | /* disable-connected-check */ |
f4b8ec07 CS |
7041 | DEFUN_YANG (neighbor_disable_connected_check, |
7042 | neighbor_disable_connected_check_cmd, | |
7043 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
7044 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7045 | "one-hop away EBGP peer using loopback address\n" | |
7046 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 7047 | { |
d62a17ae | 7048 | int idx_peer = 1; |
f4b8ec07 CS |
7049 | char base_xpath[XPATH_MAXLEN]; |
7050 | ||
7051 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7052 | sizeof(base_xpath), NULL) | |
7053 | < 0) | |
7054 | return CMD_WARNING_CONFIG_FAILED; | |
7055 | ||
7056 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
7057 | NB_OP_MODIFY, "true"); | |
7058 | ||
7059 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 7060 | } |
7061 | ||
f4b8ec07 CS |
7062 | DEFUN_YANG (no_neighbor_disable_connected_check, |
7063 | no_neighbor_disable_connected_check_cmd, | |
7064 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
7065 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7066 | "one-hop away EBGP peer using loopback address\n" | |
7067 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 7068 | { |
d62a17ae | 7069 | int idx_peer = 2; |
f4b8ec07 CS |
7070 | char base_xpath[XPATH_MAXLEN]; |
7071 | ||
7072 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7073 | sizeof(base_xpath), NULL) | |
7074 | < 0) | |
7075 | return CMD_WARNING_CONFIG_FAILED; | |
7076 | ||
7077 | nb_cli_enqueue_change(vty, "./ebgp-multihop/disable-connected-check", | |
7078 | NB_OP_MODIFY, "false"); | |
7079 | ||
7080 | return nb_cli_apply_changes(vty, base_xpath); | |
6ffd2079 | 7081 | } |
7082 | ||
47cbc09b PM |
7083 | |
7084 | /* enforce-first-as */ | |
f4b8ec07 CS |
7085 | DEFUN_YANG (neighbor_enforce_first_as, |
7086 | neighbor_enforce_first_as_cmd, | |
7087 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
7088 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7089 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
7090 | { |
7091 | int idx_peer = 1; | |
f4b8ec07 | 7092 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 7093 | |
f4b8ec07 CS |
7094 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7095 | sizeof(base_xpath), NULL) | |
7096 | < 0) | |
7097 | return CMD_WARNING_CONFIG_FAILED; | |
7098 | ||
7099 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "true"); | |
7100 | ||
7101 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
7102 | } |
7103 | ||
f4b8ec07 CS |
7104 | DEFUN_YANG (no_neighbor_enforce_first_as, |
7105 | no_neighbor_enforce_first_as_cmd, | |
7106 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
7107 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7108 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
7109 | { |
7110 | int idx_peer = 2; | |
f4b8ec07 | 7111 | char base_xpath[XPATH_MAXLEN]; |
47cbc09b | 7112 | |
f4b8ec07 CS |
7113 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7114 | sizeof(base_xpath), NULL) | |
7115 | < 0) | |
7116 | return CMD_WARNING_CONFIG_FAILED; | |
7117 | ||
7118 | nb_cli_enqueue_change(vty, "./enforce-first-as", NB_OP_MODIFY, "false"); | |
7119 | ||
7120 | return nb_cli_apply_changes(vty, base_xpath); | |
47cbc09b PM |
7121 | } |
7122 | ||
f4b8ec07 CS |
7123 | static int peer_and_group_lookup_nb(struct vty *vty, const char *peer_str, |
7124 | char *base_xpath, int xpath_len, | |
7125 | char *xpath) | |
7126 | { | |
7127 | union sockunion su; | |
7128 | char num_xpath[XPATH_MAXLEN]; | |
7129 | char unnbr_xpath[XPATH_MAXLEN]; | |
7130 | char prgrp_xpath[XPATH_MAXLEN]; | |
7131 | ||
7132 | if (str2sockunion(peer_str, &su) == 0) { | |
7133 | snprintf(num_xpath, sizeof(num_xpath), | |
7134 | "/neighbors/neighbor[remote-address='%s']", peer_str); | |
3bb513c3 CH |
7135 | if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
7136 | VTY_CURR_XPATH, num_xpath)) { | |
f4b8ec07 CS |
7137 | snprintf(base_xpath, xpath_len, |
7138 | FRR_BGP_NEIGHBOR_NUM_XPATH, peer_str, | |
7139 | xpath ? xpath : ""); | |
7140 | } else { | |
7141 | vty_out(vty, | |
7142 | "%% Specify remote-as or peer-group commands first\n"); | |
7143 | return -1; | |
7144 | } | |
7145 | ||
7146 | } else { | |
7147 | snprintf(unnbr_xpath, sizeof(unnbr_xpath), | |
7148 | "/neighbors/unnumbered-neighbor[interface='%s']", | |
7149 | peer_str); | |
7150 | ||
7151 | snprintf(prgrp_xpath, sizeof(prgrp_xpath), | |
7152 | "/peer-groups/peer-group[peer-group-name='%s']", | |
7153 | peer_str); | |
7154 | ||
3bb513c3 CH |
7155 | if (yang_dnode_existsf(vty->candidate_config->dnode, "%s%s", |
7156 | VTY_CURR_XPATH, unnbr_xpath)) { | |
f4b8ec07 CS |
7157 | snprintf(base_xpath, xpath_len, |
7158 | FRR_BGP_NEIGHBOR_UNNUM_XPATH, peer_str, | |
7159 | xpath ? xpath : ""); | |
3bb513c3 CH |
7160 | } else if (yang_dnode_existsf(vty->candidate_config->dnode, |
7161 | "%s%s", VTY_CURR_XPATH, | |
7162 | prgrp_xpath)) { | |
f4b8ec07 CS |
7163 | snprintf(base_xpath, xpath_len, |
7164 | FRR_BGP_PEER_GROUP_XPATH, peer_str, | |
7165 | xpath ? xpath : ""); | |
7166 | } else { | |
7167 | vty_out(vty, | |
7168 | "%% Create the peer-group or interface first\n"); | |
7169 | return -1; | |
7170 | } | |
7171 | } | |
7172 | ||
7173 | return 0; | |
7174 | } | |
47cbc09b | 7175 | |
f4b8ec07 CS |
7176 | DEFUN_YANG (neighbor_description, |
7177 | neighbor_description_cmd, | |
7178 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
7179 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7180 | "Neighbor specific description\n" | |
7181 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 7182 | { |
d62a17ae | 7183 | int idx_peer = 1; |
7184 | int idx_line = 3; | |
f4b8ec07 CS |
7185 | int ret; |
7186 | char base_xpath[XPATH_MAXLEN]; | |
d62a17ae | 7187 | char *str; |
718e3744 | 7188 | |
f4b8ec07 CS |
7189 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7190 | sizeof(base_xpath), NULL) | |
7191 | < 0) | |
d62a17ae | 7192 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7193 | |
d62a17ae | 7194 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 7195 | |
f4b8ec07 CS |
7196 | nb_cli_enqueue_change(vty, "./description", NB_OP_MODIFY, str); |
7197 | ||
7198 | ret = nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7199 | |
d62a17ae | 7200 | XFREE(MTYPE_TMP, str); |
718e3744 | 7201 | |
f4b8ec07 | 7202 | return ret; |
718e3744 | 7203 | } |
7204 | ||
f4b8ec07 CS |
7205 | DEFUN_YANG (no_neighbor_description, |
7206 | no_neighbor_description_cmd, | |
7207 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
7208 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7209 | "Neighbor specific description\n") | |
718e3744 | 7210 | { |
d62a17ae | 7211 | int idx_peer = 2; |
f4b8ec07 CS |
7212 | char base_xpath[XPATH_MAXLEN]; |
7213 | ||
7214 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7215 | sizeof(base_xpath), NULL) | |
7216 | < 0) | |
d62a17ae | 7217 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7218 | |
f4b8ec07 | 7219 | nb_cli_enqueue_change(vty, "./description", NB_OP_DESTROY, NULL); |
718e3744 | 7220 | |
f4b8ec07 | 7221 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7222 | } |
7223 | ||
232c75cd | 7224 | ALIAS_YANG(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
7225 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
7226 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7227 | "Neighbor specific description\n" | |
7228 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 7229 | |
d62a17ae | 7230 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
7231 | "IPv4 address\n" \ | |
7232 | "IPv6 address\n" \ | |
7233 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 7234 | |
f4b8ec07 CS |
7235 | DEFUN_YANG (neighbor_update_source, |
7236 | neighbor_update_source_cmd, | |
7237 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
7238 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7239 | "Source of routing updates\n" | |
7240 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 7241 | { |
d62a17ae | 7242 | int idx_peer = 1; |
7243 | int idx_peer_2 = 3; | |
f4b8ec07 CS |
7244 | union sockunion su; |
7245 | char base_xpath[XPATH_MAXLEN]; | |
7246 | ||
7247 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7248 | sizeof(base_xpath), NULL) | |
7249 | < 0) | |
7250 | return CMD_WARNING_CONFIG_FAILED; | |
7251 | ||
f4b8ec07 CS |
7252 | if (str2sockunion(argv[idx_peer_2]->arg, &su) == 0) |
7253 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_MODIFY, | |
d62a17ae | 7254 | argv[idx_peer_2]->arg); |
f4b8ec07 CS |
7255 | else |
7256 | nb_cli_enqueue_change(vty, "./update-source/interface", | |
7257 | NB_OP_MODIFY, argv[idx_peer_2]->arg); | |
7258 | ||
7259 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7260 | } |
7261 | ||
f4b8ec07 CS |
7262 | DEFUN_YANG (no_neighbor_update_source, |
7263 | no_neighbor_update_source_cmd, | |
7264 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
7265 | NO_STR NEIGHBOR_STR | |
7266 | NEIGHBOR_ADDR_STR2 | |
7267 | "Source of routing updates\n" | |
7268 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 7269 | { |
d62a17ae | 7270 | int idx_peer = 2; |
f4b8ec07 | 7271 | char base_xpath[XPATH_MAXLEN]; |
f4b8ec07 CS |
7272 | |
7273 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7274 | sizeof(base_xpath), NULL) | |
7275 | < 0) | |
7276 | return CMD_WARNING_CONFIG_FAILED; | |
7277 | ||
555c8ab7 CS |
7278 | nb_cli_enqueue_change(vty, "./update-source/ip", NB_OP_DESTROY, NULL); |
7279 | nb_cli_enqueue_change(vty, "./update-source/interface", NB_OP_DESTROY, | |
7280 | NULL); | |
f4b8ec07 CS |
7281 | |
7282 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7283 | } |
6b0655a2 | 7284 | |
d62a17ae | 7285 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
7286 | afi_t afi, safi_t safi, | |
7287 | const char *rmap, int set) | |
718e3744 | 7288 | { |
d62a17ae | 7289 | int ret; |
7290 | struct peer *peer; | |
80912664 | 7291 | struct route_map *route_map = NULL; |
718e3744 | 7292 | |
d62a17ae | 7293 | peer = peer_and_group_lookup_vty(vty, peer_str); |
7294 | if (!peer) | |
7295 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7296 | |
1de27621 | 7297 | if (set) { |
80912664 DS |
7298 | if (rmap) |
7299 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
7300 | ret = peer_default_originate_set(peer, afi, safi, |
7301 | rmap, route_map); | |
7302 | } else | |
d62a17ae | 7303 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 7304 | |
d62a17ae | 7305 | return bgp_vty_return(vty, ret); |
718e3744 | 7306 | } |
7307 | ||
7308 | /* neighbor default-originate. */ | |
7309 | DEFUN (neighbor_default_originate, | |
7310 | neighbor_default_originate_cmd, | |
9ccf14f7 | 7311 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 7312 | NEIGHBOR_STR |
7313 | NEIGHBOR_ADDR_STR2 | |
7314 | "Originate default route to this neighbor\n") | |
7315 | { | |
d62a17ae | 7316 | int idx_peer = 1; |
7317 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7318 | bgp_node_afi(vty), | |
7319 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 7320 | } |
7321 | ||
d62a17ae | 7322 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
7323 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
7324 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7325 | "Originate default route to this neighbor\n") | |
596c17ba | 7326 | |
718e3744 | 7327 | DEFUN (neighbor_default_originate_rmap, |
7328 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 7329 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 7330 | NEIGHBOR_STR |
7331 | NEIGHBOR_ADDR_STR2 | |
7332 | "Originate default route to this neighbor\n" | |
7333 | "Route-map to specify criteria to originate default\n" | |
7334 | "route-map name\n") | |
7335 | { | |
d62a17ae | 7336 | int idx_peer = 1; |
7337 | int idx_word = 4; | |
7338 | return peer_default_originate_set_vty( | |
7339 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7340 | argv[idx_word]->arg, 1); | |
718e3744 | 7341 | } |
7342 | ||
d62a17ae | 7343 | ALIAS_HIDDEN( |
7344 | neighbor_default_originate_rmap, | |
7345 | neighbor_default_originate_rmap_hidden_cmd, | |
7346 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
7347 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7348 | "Originate default route to this neighbor\n" | |
7349 | "Route-map to specify criteria to originate default\n" | |
7350 | "route-map name\n") | |
596c17ba | 7351 | |
718e3744 | 7352 | DEFUN (no_neighbor_default_originate, |
7353 | no_neighbor_default_originate_cmd, | |
a636c635 | 7354 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 7355 | NO_STR |
7356 | NEIGHBOR_STR | |
7357 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
7358 | "Originate default route to this neighbor\n" |
7359 | "Route-map to specify criteria to originate default\n" | |
7360 | "route-map name\n") | |
718e3744 | 7361 | { |
d62a17ae | 7362 | int idx_peer = 2; |
7363 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7364 | bgp_node_afi(vty), | |
7365 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 7366 | } |
7367 | ||
d62a17ae | 7368 | ALIAS_HIDDEN( |
7369 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
7370 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
7371 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7372 | "Originate default route to this neighbor\n" | |
7373 | "Route-map to specify criteria to originate default\n" | |
7374 | "route-map name\n") | |
596c17ba | 7375 | |
6b0655a2 | 7376 | |
f418446b | 7377 | /* Set specified peer's BGP port. */ |
f4b8ec07 CS |
7378 | DEFUN_YANG (neighbor_port, |
7379 | neighbor_port_cmd, | |
7380 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
7381 | NEIGHBOR_STR | |
7382 | NEIGHBOR_ADDR_STR | |
7383 | "Neighbor's BGP port\n" | |
7384 | "TCP port number\n") | |
718e3744 | 7385 | { |
d62a17ae | 7386 | int idx_ip = 1; |
7387 | int idx_number = 3; | |
f4b8ec07 | 7388 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 7389 | |
f4b8ec07 CS |
7390 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7391 | argv[idx_ip]->arg, ""); | |
718e3744 | 7392 | |
f4b8ec07 CS |
7393 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_MODIFY, |
7394 | argv[idx_number]->arg); | |
7395 | ||
7396 | return nb_cli_apply_changes(vty, base_xpath); | |
7397 | } | |
6b0655a2 | 7398 | |
f4b8ec07 CS |
7399 | DEFUN_YANG (no_neighbor_port, |
7400 | no_neighbor_port_cmd, | |
7401 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
7402 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7403 | "Neighbor's BGP port\n" | |
7404 | "TCP port number\n") | |
718e3744 | 7405 | { |
f4b8ec07 CS |
7406 | int idx_ip = 2; |
7407 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7408 | |
f4b8ec07 CS |
7409 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7410 | argv[idx_ip]->arg, ""); | |
718e3744 | 7411 | |
f4b8ec07 | 7412 | nb_cli_enqueue_change(vty, "./local-port", NB_OP_DESTROY, NULL); |
718e3744 | 7413 | |
f4b8ec07 | 7414 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7415 | } |
7416 | ||
f4b8ec07 CS |
7417 | DEFUN_YANG (neighbor_weight, |
7418 | neighbor_weight_cmd, | |
7419 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7420 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7421 | "Set default weight for routes from this neighbor\n" | |
7422 | "default weight\n") | |
718e3744 | 7423 | { |
f4b8ec07 CS |
7424 | int idx_peer = 1; |
7425 | int idx_number = 3; | |
7426 | char base_xpath[XPATH_MAXLEN]; | |
7427 | char af_xpath[XPATH_MAXLEN]; | |
7428 | char attr_xpath[XPATH_MAXLEN]; | |
7429 | afi_t afi = bgp_node_afi(vty); | |
7430 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 7431 | |
f4b8ec07 CS |
7432 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
7433 | yang_afi_safi_value2identity(afi, safi)); | |
7434 | ||
7435 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7436 | sizeof(base_xpath), af_xpath) | |
7437 | < 0) | |
d62a17ae | 7438 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7439 | |
f4b8ec07 CS |
7440 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", |
7441 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 7442 | |
f4b8ec07 CS |
7443 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_MODIFY, |
7444 | argv[idx_number]->arg); | |
7445 | ||
7446 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7447 | } |
7448 | ||
d62a17ae | 7449 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7450 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7451 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7452 | "Set default weight for routes from this neighbor\n" | |
7453 | "default weight\n") | |
596c17ba | 7454 | |
f4b8ec07 CS |
7455 | DEFUN_YANG (no_neighbor_weight, |
7456 | no_neighbor_weight_cmd, | |
7457 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7458 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7459 | "Set default weight for routes from this neighbor\n" | |
7460 | "default weight\n") | |
718e3744 | 7461 | { |
d62a17ae | 7462 | int idx_peer = 2; |
f4b8ec07 CS |
7463 | char base_xpath[XPATH_MAXLEN]; |
7464 | char af_xpath[XPATH_MAXLEN]; | |
7465 | char attr_xpath[XPATH_MAXLEN]; | |
7466 | afi_t afi = bgp_node_afi(vty); | |
7467 | safi_t safi = bgp_node_safi(vty); | |
7468 | ||
7469 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
7470 | yang_afi_safi_value2identity(afi, safi)); | |
7471 | ||
7472 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7473 | sizeof(base_xpath), af_xpath) | |
7474 | < 0) | |
7475 | return CMD_WARNING_CONFIG_FAILED; | |
7476 | ||
7477 | snprintf(attr_xpath, sizeof(attr_xpath), "./%s/weight/weight-attribute", | |
7478 | bgp_afi_safi_get_container_str(afi, safi)); | |
7479 | ||
7480 | nb_cli_enqueue_change(vty, attr_xpath, NB_OP_DESTROY, NULL); | |
7481 | ||
7482 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7483 | } |
7484 | ||
d62a17ae | 7485 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7486 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7487 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7488 | "Set default weight for routes from this neighbor\n" | |
7489 | "default weight\n") | |
596c17ba | 7490 | |
6b0655a2 | 7491 | |
718e3744 | 7492 | /* Override capability negotiation. */ |
8611c7f3 CS |
7493 | DEFUN_YANG (neighbor_override_capability, |
7494 | neighbor_override_capability_cmd, | |
7495 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7496 | NEIGHBOR_STR | |
7497 | NEIGHBOR_ADDR_STR2 | |
7498 | "Override capability negotiation result\n") | |
718e3744 | 7499 | { |
d62a17ae | 7500 | int idx_peer = 1; |
8611c7f3 CS |
7501 | char base_xpath[XPATH_MAXLEN]; |
7502 | ||
7503 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7504 | sizeof(base_xpath), NULL) | |
7505 | < 0) | |
7506 | return CMD_WARNING_CONFIG_FAILED; | |
7507 | ||
7508 | nb_cli_enqueue_change( | |
7509 | vty, "./capability-options/override-capability", | |
7510 | NB_OP_MODIFY, "true"); | |
7511 | ||
7512 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7513 | } |
7514 | ||
8611c7f3 CS |
7515 | DEFUN_YANG (no_neighbor_override_capability, |
7516 | no_neighbor_override_capability_cmd, | |
7517 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7518 | NO_STR | |
7519 | NEIGHBOR_STR | |
7520 | NEIGHBOR_ADDR_STR2 | |
7521 | "Override capability negotiation result\n") | |
718e3744 | 7522 | { |
d62a17ae | 7523 | int idx_peer = 2; |
8611c7f3 CS |
7524 | char base_xpath[XPATH_MAXLEN]; |
7525 | ||
7526 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7527 | sizeof(base_xpath), NULL) | |
7528 | < 0) | |
7529 | return CMD_WARNING_CONFIG_FAILED; | |
7530 | ||
7531 | nb_cli_enqueue_change( | |
7532 | vty, "./capability-options/override-capability", | |
7533 | NB_OP_MODIFY, "false"); | |
7534 | ||
7535 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7536 | } |
6b0655a2 | 7537 | |
8611c7f3 CS |
7538 | DEFUN_YANG (neighbor_strict_capability, |
7539 | neighbor_strict_capability_cmd, | |
7540 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7541 | NEIGHBOR_STR | |
7542 | NEIGHBOR_ADDR_STR2 | |
7543 | "Strict capability negotiation match\n") | |
718e3744 | 7544 | { |
9fb964de | 7545 | int idx_peer = 1; |
8611c7f3 | 7546 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7547 | |
8611c7f3 CS |
7548 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7549 | sizeof(base_xpath), NULL) | |
7550 | < 0) | |
7551 | return CMD_WARNING_CONFIG_FAILED; | |
7552 | ||
7553 | nb_cli_enqueue_change( | |
7554 | vty, "./capability-options/strict-capability", | |
7555 | NB_OP_MODIFY, "true"); | |
7556 | ||
7557 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7558 | } |
7559 | ||
8611c7f3 CS |
7560 | DEFUN_YANG (no_neighbor_strict_capability, |
7561 | no_neighbor_strict_capability_cmd, | |
7562 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7563 | NO_STR | |
7564 | NEIGHBOR_STR | |
7565 | NEIGHBOR_ADDR_STR2 | |
7566 | "Strict capability negotiation match\n") | |
718e3744 | 7567 | { |
9fb964de | 7568 | int idx_peer = 2; |
8611c7f3 | 7569 | char base_xpath[XPATH_MAXLEN]; |
9fb964de | 7570 | |
8611c7f3 CS |
7571 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7572 | sizeof(base_xpath), NULL) | |
7573 | < 0) | |
7574 | return CMD_WARNING_CONFIG_FAILED; | |
7575 | ||
7576 | nb_cli_enqueue_change( | |
7577 | vty, "./capability-options/strict-capability", | |
7578 | NB_OP_MODIFY, "false"); | |
7579 | ||
7580 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7581 | } |
6b0655a2 | 7582 | |
f4b8ec07 CS |
7583 | DEFUN_YANG (neighbor_timers, |
7584 | neighbor_timers_cmd, | |
7585 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7586 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7587 | "BGP per neighbor timers\n" | |
7588 | "Keepalive interval\n" | |
7589 | "Holdtime\n") | |
718e3744 | 7590 | { |
f4b8ec07 CS |
7591 | int idx_peer = 1; |
7592 | int idx_number = 3; | |
7593 | int idx_number_2 = 4; | |
7594 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7595 | |
f4b8ec07 CS |
7596 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7597 | sizeof(base_xpath), NULL) | |
7598 | < 0) | |
d62a17ae | 7599 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7600 | |
f4b8ec07 CS |
7601 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_MODIFY, |
7602 | argv[idx_number]->arg); | |
718e3744 | 7603 | |
f4b8ec07 CS |
7604 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_MODIFY, |
7605 | argv[idx_number_2]->arg); | |
718e3744 | 7606 | |
f4b8ec07 | 7607 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7608 | } |
6b0655a2 | 7609 | |
f4b8ec07 CS |
7610 | DEFUN_YANG (no_neighbor_timers, |
7611 | no_neighbor_timers_cmd, | |
7612 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7613 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7614 | "BGP per neighbor timers\n" | |
7615 | "Keepalive interval\n" | |
7616 | "Holdtime\n") | |
718e3744 | 7617 | { |
f4b8ec07 CS |
7618 | int idx_peer = 2; |
7619 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7620 | |
f4b8ec07 CS |
7621 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7622 | sizeof(base_xpath), NULL) | |
7623 | < 0) | |
d62a17ae | 7624 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7625 | |
f4b8ec07 | 7626 | nb_cli_enqueue_change(vty, "./timers/hold-time", NB_OP_DESTROY, NULL); |
718e3744 | 7627 | |
f4b8ec07 | 7628 | nb_cli_enqueue_change(vty, "./timers/keepalive", NB_OP_DESTROY, NULL); |
718e3744 | 7629 | |
f4b8ec07 | 7630 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7631 | } |
6b0655a2 | 7632 | |
f4b8ec07 CS |
7633 | DEFUN_YANG (neighbor_timers_connect, |
7634 | neighbor_timers_connect_cmd, | |
7635 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7636 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7637 | "BGP per neighbor timers\n" | |
7638 | "BGP connect timer\n" | |
7639 | "Connect timer\n") | |
718e3744 | 7640 | { |
f4b8ec07 CS |
7641 | int idx_peer = 1; |
7642 | int idx_number = 4; | |
7643 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7644 | |
f4b8ec07 CS |
7645 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7646 | sizeof(base_xpath), NULL) | |
7647 | < 0) | |
d62a17ae | 7648 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7649 | |
f4b8ec07 CS |
7650 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_MODIFY, |
7651 | argv[idx_number]->arg); | |
718e3744 | 7652 | |
f4b8ec07 | 7653 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7654 | } |
7655 | ||
f4b8ec07 CS |
7656 | DEFUN_YANG (no_neighbor_timers_connect, |
7657 | no_neighbor_timers_connect_cmd, | |
7658 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7659 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7660 | "BGP per neighbor timers\n" | |
7661 | "BGP connect timer\n" | |
7662 | "Connect timer\n") | |
718e3744 | 7663 | { |
f4b8ec07 CS |
7664 | int idx_peer = 2; |
7665 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7666 | |
f4b8ec07 CS |
7667 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7668 | sizeof(base_xpath), NULL) | |
7669 | < 0) | |
d62a17ae | 7670 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7671 | |
f4b8ec07 CS |
7672 | nb_cli_enqueue_change(vty, "./timers/connect-time", NB_OP_DESTROY, |
7673 | NULL); | |
718e3744 | 7674 | |
f4b8ec07 | 7675 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7676 | } |
7677 | ||
d43114f3 DS |
7678 | DEFPY (neighbor_timers_delayopen, |
7679 | neighbor_timers_delayopen_cmd, | |
7680 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7681 | NEIGHBOR_STR | |
7682 | NEIGHBOR_ADDR_STR2 | |
7683 | "BGP per neighbor timers\n" | |
7684 | "RFC 4271 DelayOpenTimer\n" | |
7685 | "DelayOpenTime timer interval\n") | |
7686 | { | |
7687 | struct peer *peer; | |
7688 | ||
7689 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7690 | if (!peer) | |
7691 | return CMD_WARNING_CONFIG_FAILED; | |
7692 | ||
7693 | if (!interval) { | |
7694 | if (peer_timers_delayopen_unset(peer)) | |
7695 | return CMD_WARNING_CONFIG_FAILED; | |
7696 | } else { | |
7697 | if (peer_timers_delayopen_set(peer, interval)) | |
7698 | return CMD_WARNING_CONFIG_FAILED; | |
7699 | } | |
7700 | ||
7701 | return CMD_SUCCESS; | |
7702 | } | |
7703 | ||
7704 | DEFPY (no_neighbor_timers_delayopen, | |
7705 | no_neighbor_timers_delayopen_cmd, | |
7706 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7707 | NO_STR | |
7708 | NEIGHBOR_STR | |
7709 | NEIGHBOR_ADDR_STR2 | |
7710 | "BGP per neighbor timers\n" | |
7711 | "RFC 4271 DelayOpenTimer\n" | |
7712 | "DelayOpenTime timer interval\n") | |
7713 | { | |
7714 | struct peer *peer; | |
7715 | ||
7716 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7717 | if (!peer) | |
7718 | return CMD_WARNING_CONFIG_FAILED; | |
7719 | ||
7720 | if (peer_timers_delayopen_unset(peer)) | |
7721 | return CMD_WARNING_CONFIG_FAILED; | |
7722 | ||
7723 | return CMD_SUCCESS; | |
7724 | } | |
7725 | ||
f4b8ec07 CS |
7726 | DEFUN_YANG (neighbor_advertise_interval, |
7727 | neighbor_advertise_interval_cmd, | |
7728 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7729 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7730 | "Minimum interval between sending BGP routing updates\n" | |
7731 | "time in seconds\n") | |
718e3744 | 7732 | { |
d62a17ae | 7733 | int idx_peer = 1; |
f4b8ec07 CS |
7734 | int idx_number = 3; |
7735 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7736 | |
f4b8ec07 CS |
7737 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
7738 | sizeof(base_xpath), NULL) | |
7739 | < 0) | |
d62a17ae | 7740 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7741 | |
f4b8ec07 CS |
7742 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_MODIFY, |
7743 | argv[idx_number]->arg); | |
718e3744 | 7744 | |
f4b8ec07 | 7745 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7746 | } |
7747 | ||
f4b8ec07 CS |
7748 | DEFUN_YANG (no_neighbor_advertise_interval, |
7749 | no_neighbor_advertise_interval_cmd, | |
7750 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7751 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7752 | "Minimum interval between sending BGP routing updates\n" | |
7753 | "time in seconds\n") | |
718e3744 | 7754 | { |
d62a17ae | 7755 | int idx_peer = 2; |
f4b8ec07 CS |
7756 | char base_xpath[XPATH_MAXLEN]; |
7757 | ||
7758 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
7759 | sizeof(base_xpath), NULL) | |
7760 | < 0) | |
7761 | return CMD_WARNING_CONFIG_FAILED; | |
7762 | ||
7763 | nb_cli_enqueue_change(vty, "./timers/advertise-interval", NB_OP_DESTROY, | |
7764 | NULL); | |
7765 | ||
7766 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7767 | } |
7768 | ||
6b0655a2 | 7769 | |
518f0eb1 DS |
7770 | /* Time to wait before processing route-map updates */ |
7771 | DEFUN (bgp_set_route_map_delay_timer, | |
7772 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7773 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7774 | SET_STR |
7775 | "BGP route-map delay timer\n" | |
7776 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7777 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7778 | { |
d62a17ae | 7779 | int idx_number = 3; |
d7c0a89a | 7780 | uint32_t rmap_delay_timer; |
d62a17ae | 7781 | |
7782 | if (argv[idx_number]->arg) { | |
7783 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7784 | bm->rmap_update_timer = rmap_delay_timer; | |
7785 | ||
7786 | /* if the dynamic update handling is being disabled, and a timer | |
7787 | * is | |
7788 | * running, stop the timer and act as if the timer has already | |
7789 | * fired. | |
7790 | */ | |
7791 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7792 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7793 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7794 | NULL, 0); | |
7795 | } | |
7796 | return CMD_SUCCESS; | |
7797 | } else { | |
7798 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7799 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7800 | } |
518f0eb1 DS |
7801 | } |
7802 | ||
7803 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7804 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7805 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7806 | NO_STR |
3a2d747c | 7807 | BGP_STR |
518f0eb1 | 7808 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7809 | "Reset to default time to wait for processing route-map changes\n" |
7810 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7811 | { |
518f0eb1 | 7812 | |
d62a17ae | 7813 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7814 | |
d62a17ae | 7815 | return CMD_SUCCESS; |
518f0eb1 DS |
7816 | } |
7817 | ||
f4b8ec07 CS |
7818 | DEFUN_YANG (neighbor_interface, |
7819 | neighbor_interface_cmd, | |
7820 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7821 | NEIGHBOR_STR NEIGHBOR_ADDR_STR | |
7822 | "Interface\n" | |
7823 | "Interface name\n") | |
718e3744 | 7824 | { |
f4b8ec07 CS |
7825 | int idx_ip = 1; |
7826 | int idx_word = 3; | |
7827 | char base_xpath[XPATH_MAXLEN]; | |
718e3744 | 7828 | |
f4b8ec07 CS |
7829 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, |
7830 | argv[idx_ip]->arg, ""); | |
718e3744 | 7831 | |
f4b8ec07 CS |
7832 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_MODIFY, |
7833 | argv[idx_word]->arg); | |
718e3744 | 7834 | |
f4b8ec07 | 7835 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7836 | } |
7837 | ||
f4b8ec07 CS |
7838 | DEFUN_YANG (no_neighbor_interface, |
7839 | no_neighbor_interface_cmd, | |
7840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", | |
7841 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7842 | "Interface\n" | |
7843 | "Interface name\n") | |
718e3744 | 7844 | { |
d62a17ae | 7845 | int idx_peer = 2; |
f4b8ec07 CS |
7846 | char base_xpath[XPATH_MAXLEN]; |
7847 | ||
7848 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_NEIGHBOR_NUM_XPATH, | |
7849 | argv[idx_peer]->arg, ""); | |
7850 | ||
7851 | nb_cli_enqueue_change(vty, "./local-interface", NB_OP_DESTROY, NULL); | |
7852 | ||
7853 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 7854 | } |
6b0655a2 | 7855 | |
718e3744 | 7856 | DEFUN (neighbor_distribute_list, |
7857 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 7858 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7859 | NEIGHBOR_STR |
7860 | NEIGHBOR_ADDR_STR2 | |
7861 | "Filter updates to/from this neighbor\n" | |
7862 | "IP access-list number\n" | |
7863 | "IP access-list number (expanded range)\n" | |
7864 | "IP Access-list name\n" | |
7865 | "Filter incoming updates\n" | |
7866 | "Filter outgoing updates\n") | |
7867 | { | |
d62a17ae | 7868 | int idx_peer = 1; |
7869 | int idx_acl = 3; | |
7870 | int direct, ret; | |
7871 | struct peer *peer; | |
a8206004 | 7872 | |
d62a17ae | 7873 | const char *pstr = argv[idx_peer]->arg; |
7874 | const char *acl = argv[idx_acl]->arg; | |
7875 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7876 | |
d62a17ae | 7877 | peer = peer_and_group_lookup_vty(vty, pstr); |
7878 | if (!peer) | |
7879 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7880 | |
d62a17ae | 7881 | /* Check filter direction. */ |
7882 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7883 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7884 | direct, acl); | |
a8206004 | 7885 | |
d62a17ae | 7886 | return bgp_vty_return(vty, ret); |
718e3744 | 7887 | } |
7888 | ||
d62a17ae | 7889 | ALIAS_HIDDEN( |
7890 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
7891 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7892 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7893 | "Filter updates to/from this neighbor\n" | |
7894 | "IP access-list number\n" | |
7895 | "IP access-list number (expanded range)\n" | |
7896 | "IP Access-list name\n" | |
7897 | "Filter incoming updates\n" | |
7898 | "Filter outgoing updates\n") | |
596c17ba | 7899 | |
718e3744 | 7900 | DEFUN (no_neighbor_distribute_list, |
7901 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 7902 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 7903 | NO_STR |
7904 | NEIGHBOR_STR | |
7905 | NEIGHBOR_ADDR_STR2 | |
7906 | "Filter updates to/from this neighbor\n" | |
7907 | "IP access-list number\n" | |
7908 | "IP access-list number (expanded range)\n" | |
7909 | "IP Access-list name\n" | |
7910 | "Filter incoming updates\n" | |
7911 | "Filter outgoing updates\n") | |
7912 | { | |
d62a17ae | 7913 | int idx_peer = 2; |
7914 | int direct, ret; | |
7915 | struct peer *peer; | |
a8206004 | 7916 | |
d62a17ae | 7917 | const char *pstr = argv[idx_peer]->arg; |
7918 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7919 | |
d62a17ae | 7920 | peer = peer_and_group_lookup_vty(vty, pstr); |
7921 | if (!peer) | |
7922 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7923 | |
d62a17ae | 7924 | /* Check filter direction. */ |
7925 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7926 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7927 | direct); | |
a8206004 | 7928 | |
d62a17ae | 7929 | return bgp_vty_return(vty, ret); |
718e3744 | 7930 | } |
6b0655a2 | 7931 | |
d62a17ae | 7932 | ALIAS_HIDDEN( |
7933 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7934 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
7935 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7936 | "Filter updates to/from this neighbor\n" | |
7937 | "IP access-list number\n" | |
7938 | "IP access-list number (expanded range)\n" | |
7939 | "IP Access-list name\n" | |
7940 | "Filter incoming updates\n" | |
7941 | "Filter outgoing updates\n") | |
596c17ba | 7942 | |
718e3744 | 7943 | /* Set prefix list to the peer. */ |
d9986d26 CS |
7944 | DEFPY_YANG( |
7945 | neighbor_prefix_list, neighbor_prefix_list_cmd, | |
7946 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str prefix-list WORD$prefix_str <in|out>$direction", | |
7947 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7948 | "Filter updates to/from this neighbor\n" | |
7949 | "Name of a prefix list\n" | |
7950 | "Filter incoming updates\n" | |
7951 | "Filter outgoing updates\n") | |
718e3744 | 7952 | { |
d9986d26 CS |
7953 | char base_xpath[XPATH_MAXLEN]; |
7954 | char af_xpath[XPATH_MAXLEN]; | |
c6685575 | 7955 | char plist_xpath[XPATH_MAXLEN]; |
d9986d26 CS |
7956 | afi_t afi = bgp_node_afi(vty); |
7957 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 7958 | |
d9986d26 CS |
7959 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
7960 | yang_afi_safi_value2identity(afi, safi)); | |
7961 | if (peer_and_group_lookup_nb(vty, neighbor_str, base_xpath, | |
7962 | sizeof(base_xpath), af_xpath) | |
7963 | < 0) | |
d62a17ae | 7964 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7965 | |
d9986d26 CS |
7966 | if (strmatch(direction, "in")) |
7967 | snprintf(plist_xpath, sizeof(plist_xpath), | |
7968 | "./%s/filter-config/plist-import", | |
7969 | bgp_afi_safi_get_container_str(afi, safi)); | |
7970 | else if (strmatch(direction, "out")) | |
7971 | snprintf(plist_xpath, sizeof(plist_xpath), | |
7972 | "./%s/filter-config/plist-export", | |
7973 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 7974 | |
d9986d26 CS |
7975 | if (!no) |
7976 | nb_cli_enqueue_change(vty, plist_xpath, NB_OP_MODIFY, | |
7977 | prefix_str); | |
7978 | else | |
7979 | nb_cli_enqueue_change(vty, plist_xpath, NB_OP_DESTROY, NULL); | |
718e3744 | 7980 | |
d9986d26 | 7981 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 7982 | } |
7983 | ||
d62a17ae | 7984 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7985 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7986 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7987 | "Filter updates to/from this neighbor\n" | |
7988 | "Name of a prefix list\n" | |
7989 | "Filter incoming updates\n" | |
7990 | "Filter outgoing updates\n") | |
596c17ba | 7991 | |
d62a17ae | 7992 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7993 | safi_t safi, const char *name_str, | |
7994 | const char *direct_str) | |
718e3744 | 7995 | { |
d62a17ae | 7996 | int ret; |
7997 | struct peer *peer; | |
7998 | int direct = FILTER_IN; | |
718e3744 | 7999 | |
d62a17ae | 8000 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8001 | if (!peer) | |
8002 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8003 | |
d62a17ae | 8004 | /* Check filter direction. */ |
8005 | if (strncmp(direct_str, "i", 1) == 0) | |
8006 | direct = FILTER_IN; | |
8007 | else if (strncmp(direct_str, "o", 1) == 0) | |
8008 | direct = FILTER_OUT; | |
718e3744 | 8009 | |
d62a17ae | 8010 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 8011 | |
d62a17ae | 8012 | return bgp_vty_return(vty, ret); |
718e3744 | 8013 | } |
8014 | ||
d62a17ae | 8015 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
8016 | safi_t safi, const char *direct_str) | |
718e3744 | 8017 | { |
d62a17ae | 8018 | int ret; |
8019 | struct peer *peer; | |
8020 | int direct = FILTER_IN; | |
718e3744 | 8021 | |
d62a17ae | 8022 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8023 | if (!peer) | |
8024 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8025 | |
d62a17ae | 8026 | /* Check filter direction. */ |
8027 | if (strncmp(direct_str, "i", 1) == 0) | |
8028 | direct = FILTER_IN; | |
8029 | else if (strncmp(direct_str, "o", 1) == 0) | |
8030 | direct = FILTER_OUT; | |
718e3744 | 8031 | |
d62a17ae | 8032 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 8033 | |
d62a17ae | 8034 | return bgp_vty_return(vty, ret); |
718e3744 | 8035 | } |
8036 | ||
8037 | DEFUN (neighbor_filter_list, | |
8038 | neighbor_filter_list_cmd, | |
9ccf14f7 | 8039 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 8040 | NEIGHBOR_STR |
8041 | NEIGHBOR_ADDR_STR2 | |
8042 | "Establish BGP filters\n" | |
8043 | "AS path access-list name\n" | |
8044 | "Filter incoming routes\n" | |
8045 | "Filter outgoing routes\n") | |
8046 | { | |
d62a17ae | 8047 | int idx_peer = 1; |
8048 | int idx_word = 3; | |
8049 | int idx_in_out = 4; | |
8050 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
8051 | bgp_node_safi(vty), argv[idx_word]->arg, | |
8052 | argv[idx_in_out]->arg); | |
718e3744 | 8053 | } |
8054 | ||
d62a17ae | 8055 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
8056 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
8057 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8058 | "Establish BGP filters\n" | |
8059 | "AS path access-list name\n" | |
8060 | "Filter incoming routes\n" | |
8061 | "Filter outgoing routes\n") | |
596c17ba | 8062 | |
718e3744 | 8063 | DEFUN (no_neighbor_filter_list, |
8064 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 8065 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 8066 | NO_STR |
8067 | NEIGHBOR_STR | |
8068 | NEIGHBOR_ADDR_STR2 | |
8069 | "Establish BGP filters\n" | |
8070 | "AS path access-list name\n" | |
8071 | "Filter incoming routes\n" | |
8072 | "Filter outgoing routes\n") | |
8073 | { | |
d62a17ae | 8074 | int idx_peer = 2; |
8075 | int idx_in_out = 5; | |
8076 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
8077 | bgp_node_afi(vty), bgp_node_safi(vty), | |
8078 | argv[idx_in_out]->arg); | |
718e3744 | 8079 | } |
6b0655a2 | 8080 | |
d62a17ae | 8081 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
8082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
8083 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8084 | "Establish BGP filters\n" | |
8085 | "AS path access-list name\n" | |
8086 | "Filter incoming routes\n" | |
8087 | "Filter outgoing routes\n") | |
596c17ba | 8088 | |
7f7940e6 MK |
8089 | /* Set advertise-map to the peer. */ |
8090 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
8091 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
8092 | const char *advertise_str, |
8093 | const char *condition_str, bool condition, | |
8094 | bool set) | |
7f7940e6 MK |
8095 | { |
8096 | int ret = CMD_WARNING_CONFIG_FAILED; | |
8097 | struct peer *peer; | |
8098 | struct route_map *advertise_map; | |
8099 | struct route_map *condition_map; | |
8100 | ||
8101 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8102 | if (!peer) | |
8103 | return ret; | |
8104 | ||
8105 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
8106 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
8107 | ||
cf2ad4d8 MK |
8108 | if (set) |
8109 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
8110 | advertise_map, condition_str, | |
8111 | condition_map, condition); | |
8112 | else | |
8113 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
8114 | advertise_map, condition_str, | |
8115 | condition_map, condition); | |
7f7940e6 MK |
8116 | |
8117 | return bgp_vty_return(vty, ret); | |
8118 | } | |
8119 | ||
389e4f92 QY |
8120 | DEFPY (bgp_condadv_period, |
8121 | bgp_condadv_period_cmd, | |
8122 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
8123 | NO_STR | |
8124 | BGP_STR | |
8125 | "Conditional advertisement settings\n" | |
8126 | "Set period to rescan BGP table to check if condition is met\n" | |
8127 | "Period between BGP table scans, in seconds; default 60\n") | |
8128 | { | |
8129 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8130 | ||
8131 | bgp->condition_check_period = | |
8132 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
8133 | ||
8134 | return CMD_SUCCESS; | |
8135 | } | |
8136 | ||
cf2ad4d8 | 8137 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 8138 | neighbor_advertise_map_cmd, |
52b84062 | 8139 | "[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 | 8140 | NO_STR |
7f7940e6 MK |
8141 | NEIGHBOR_STR |
8142 | NEIGHBOR_ADDR_STR2 | |
8143 | "Route-map to conditionally advertise routes\n" | |
8144 | "Name of advertise map\n" | |
8145 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 8146 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 8147 | "Name of the exist or non exist map\n") |
7f7940e6 | 8148 | { |
7f7940e6 MK |
8149 | bool condition = CONDITION_EXIST; |
8150 | ||
52b84062 | 8151 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
8152 | condition = CONDITION_NON_EXIST; |
8153 | ||
52b84062 MK |
8154 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
8155 | bgp_node_safi(vty), advertise_str, | |
8156 | condition_str, condition, !no); | |
7f7940e6 MK |
8157 | } |
8158 | ||
8159 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 8160 | "[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 |
8161 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8162 | "Route-map to conditionally advertise routes\n" | |
8163 | "Name of advertise map\n" | |
8164 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 8165 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 8166 | "Name of the exist or non exist map\n") |
7f7940e6 | 8167 | |
718e3744 | 8168 | /* Set route-map to the peer. */ |
c6685575 CS |
8169 | DEFPY_YANG( |
8170 | neighbor_route_map, neighbor_route_map_cmd, | |
8171 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str route-map WORD$rmap_str <in|out>$direction", | |
8172 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8173 | "Apply route map to neighbor\n" | |
8174 | "Name of route map\n" | |
8175 | "Apply map to incoming routes\n" | |
8176 | "Apply map to outbound routes\n") | |
718e3744 | 8177 | { |
c6685575 CS |
8178 | char base_xpath[XPATH_MAXLEN]; |
8179 | char af_xpath[XPATH_MAXLEN]; | |
8180 | char rmap_xpath[XPATH_MAXLEN]; | |
8181 | afi_t afi = bgp_node_afi(vty); | |
8182 | safi_t safi = bgp_node_safi(vty); | |
718e3744 | 8183 | |
c6685575 CS |
8184 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8185 | yang_afi_safi_value2identity(afi, safi)); | |
8186 | if (peer_and_group_lookup_nb(vty, neighbor_str, base_xpath, | |
8187 | sizeof(base_xpath), af_xpath) | |
8188 | < 0) | |
d62a17ae | 8189 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 8190 | |
c6685575 CS |
8191 | if (strmatch(direction, "in")) |
8192 | snprintf(rmap_xpath, sizeof(rmap_xpath), | |
8193 | "./%s/filter-config/rmap-import", | |
8194 | bgp_afi_safi_get_container_str(afi, safi)); | |
8195 | else if (strmatch(direction, "out")) | |
8196 | snprintf(rmap_xpath, sizeof(rmap_xpath), | |
8197 | "./%s/filter-config/rmap-export", | |
8198 | bgp_afi_safi_get_container_str(afi, safi)); | |
718e3744 | 8199 | |
c6685575 | 8200 | if (!no) { |
3bb513c3 | 8201 | if (!yang_dnode_existsf( |
c6685575 CS |
8202 | vty->candidate_config->dnode, |
8203 | "/frr-route-map:lib/route-map[name='%s']", | |
8204 | rmap_str)) { | |
8205 | if (vty_shell_serv(vty)) | |
8206 | vty_out(vty, | |
8207 | "The route-map '%s' does not exist.\n", | |
8208 | rmap_str); | |
8209 | } | |
8210 | nb_cli_enqueue_change(vty, rmap_xpath, NB_OP_MODIFY, rmap_str); | |
8211 | } else | |
8212 | nb_cli_enqueue_change(vty, rmap_xpath, NB_OP_DESTROY, NULL); | |
718e3744 | 8213 | |
c6685575 | 8214 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8215 | } |
8216 | ||
718e3744 | 8217 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 8218 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
8219 | afi_t afi, safi_t safi, | |
8220 | const char *name_str) | |
718e3744 | 8221 | { |
d62a17ae | 8222 | int ret; |
8223 | struct peer *peer; | |
1de27621 | 8224 | struct route_map *route_map; |
718e3744 | 8225 | |
d62a17ae | 8226 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8227 | if (!peer) | |
8228 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8229 | |
1de27621 DA |
8230 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
8231 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 8232 | |
d62a17ae | 8233 | return bgp_vty_return(vty, ret); |
718e3744 | 8234 | } |
8235 | ||
8236 | /* Unset route-map from the peer. */ | |
d62a17ae | 8237 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
8238 | afi_t afi, safi_t safi) | |
718e3744 | 8239 | { |
d62a17ae | 8240 | int ret; |
8241 | struct peer *peer; | |
718e3744 | 8242 | |
d62a17ae | 8243 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8244 | if (!peer) | |
8245 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8246 | |
d62a17ae | 8247 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 8248 | |
d62a17ae | 8249 | return bgp_vty_return(vty, ret); |
718e3744 | 8250 | } |
8251 | ||
8252 | DEFUN (neighbor_unsuppress_map, | |
8253 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8254 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8255 | NEIGHBOR_STR |
8256 | NEIGHBOR_ADDR_STR2 | |
8257 | "Route-map to selectively unsuppress suppressed routes\n" | |
8258 | "Name of route map\n") | |
8259 | { | |
d62a17ae | 8260 | int idx_peer = 1; |
8261 | int idx_word = 3; | |
8262 | return peer_unsuppress_map_set_vty( | |
8263 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8264 | argv[idx_word]->arg); | |
718e3744 | 8265 | } |
8266 | ||
d62a17ae | 8267 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
8268 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8269 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8270 | "Route-map to selectively unsuppress suppressed routes\n" | |
8271 | "Name of route map\n") | |
596c17ba | 8272 | |
718e3744 | 8273 | DEFUN (no_neighbor_unsuppress_map, |
8274 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8275 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8276 | NO_STR |
8277 | NEIGHBOR_STR | |
8278 | NEIGHBOR_ADDR_STR2 | |
8279 | "Route-map to selectively unsuppress suppressed routes\n" | |
8280 | "Name of route map\n") | |
8281 | { | |
d62a17ae | 8282 | int idx_peer = 2; |
8283 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8284 | bgp_node_afi(vty), | |
8285 | bgp_node_safi(vty)); | |
718e3744 | 8286 | } |
6b0655a2 | 8287 | |
d62a17ae | 8288 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8289 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8290 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8291 | "Route-map to selectively unsuppress suppressed routes\n" | |
8292 | "Name of route map\n") | |
596c17ba | 8293 | |
fde246e8 | 8294 | /* Maximum number of prefix to be sent to the neighbor. */ |
232c75cd CS |
8295 | DEFUN_YANG(neighbor_maximum_prefix_out, |
8296 | neighbor_maximum_prefix_out_cmd, | |
8297 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8298 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8299 | "Maximum number of prefixes to be sent to this peer\n" | |
8300 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8301 | { |
04261dec CS |
8302 | char base_xpath[XPATH_MAXLEN]; |
8303 | char af_xpath[XPATH_MAXLEN]; | |
8304 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 DA |
8305 | int idx_peer = 1; |
8306 | int idx_number = 3; | |
fde246e8 DA |
8307 | afi_t afi = bgp_node_afi(vty); |
8308 | safi_t safi = bgp_node_safi(vty); | |
8309 | ||
04261dec CS |
8310 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8311 | yang_afi_safi_value2identity(afi, safi)); | |
8312 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8313 | sizeof(base_xpath), af_xpath) | |
8314 | < 0) | |
fde246e8 DA |
8315 | return CMD_WARNING_CONFIG_FAILED; |
8316 | ||
04261dec CS |
8317 | snprintf(attr_xpath, sizeof(attr_xpath), |
8318 | "/%s/prefix-limit/direction-list[direction='out']", | |
8319 | bgp_afi_safi_get_container_str(afi, safi)); | |
8320 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
fde246e8 | 8321 | |
04261dec | 8322 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
fde246e8 | 8323 | |
04261dec CS |
8324 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8325 | argv[idx_number]->arg); | |
8326 | ||
8327 | return nb_cli_apply_changes(vty, base_xpath); | |
fde246e8 DA |
8328 | } |
8329 | ||
232c75cd CS |
8330 | DEFUN_YANG(no_neighbor_maximum_prefix_out, |
8331 | no_neighbor_maximum_prefix_out_cmd, | |
8332 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
8333 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8334 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 | 8335 | { |
04261dec CS |
8336 | char base_xpath[XPATH_MAXLEN]; |
8337 | char af_xpath[XPATH_MAXLEN]; | |
8338 | char attr_xpath[XPATH_MAXLEN]; | |
fde246e8 | 8339 | int idx_peer = 2; |
fde246e8 DA |
8340 | afi_t afi = bgp_node_afi(vty); |
8341 | safi_t safi = bgp_node_safi(vty); | |
8342 | ||
04261dec CS |
8343 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8344 | yang_afi_safi_value2identity(afi, safi)); | |
8345 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8346 | sizeof(base_xpath), af_xpath) | |
8347 | < 0) | |
fde246e8 DA |
8348 | return CMD_WARNING_CONFIG_FAILED; |
8349 | ||
04261dec CS |
8350 | snprintf(attr_xpath, sizeof(attr_xpath), |
8351 | "/%s/prefix-limit/direction-list[direction='out']", | |
8352 | bgp_afi_safi_get_container_str(afi, safi)); | |
8353 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8354 | ||
8355 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
fde246e8 | 8356 | |
04261dec | 8357 | return nb_cli_apply_changes(vty, base_xpath); |
fde246e8 DA |
8358 | } |
8359 | ||
9cbd06e0 DA |
8360 | /* Maximum number of prefix configuration. Prefix count is different |
8361 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8362 | each peer configuration. */ |
232c75cd CS |
8363 | DEFUN_YANG(neighbor_maximum_prefix, |
8364 | neighbor_maximum_prefix_cmd, | |
8365 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8366 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8367 | "Maximum number of prefix accept from this peer\n" | |
8368 | "maximum no. of prefix limit\n" | |
8369 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8370 | { |
d62a17ae | 8371 | int idx_peer = 1; |
8372 | int idx_number = 3; | |
9cbd06e0 | 8373 | int idx_force = 0; |
04261dec CS |
8374 | char base_xpath[XPATH_MAXLEN]; |
8375 | char af_xpath[XPATH_MAXLEN]; | |
8376 | char attr_xpath[XPATH_MAXLEN]; | |
8377 | afi_t afi = bgp_node_afi(vty); | |
8378 | safi_t safi = bgp_node_safi(vty); | |
8379 | ||
8380 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8381 | yang_afi_safi_value2identity(afi, safi)); | |
8382 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8383 | sizeof(base_xpath), af_xpath) | |
8384 | < 0) | |
8385 | return CMD_WARNING_CONFIG_FAILED; | |
8386 | ||
8387 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8388 | "/%s/prefix-limit/direction-list[direction='in']", | |
8389 | bgp_afi_safi_get_container_str(afi, safi)); | |
8390 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8391 | ||
8392 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
9cbd06e0 | 8393 | |
04261dec CS |
8394 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, |
8395 | argv[idx_number]->arg); | |
9cbd06e0 | 8396 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8397 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8398 | "true"); | |
9cbd06e0 | 8399 | |
04261dec | 8400 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8401 | } |
8402 | ||
d62a17ae | 8403 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8404 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8405 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8406 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8407 | "maximum no. of prefix limit\n" |
8408 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8409 | |
232c75cd CS |
8410 | DEFUN_YANG(neighbor_maximum_prefix_threshold, |
8411 | neighbor_maximum_prefix_threshold_cmd, | |
8412 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8413 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8414 | "Maximum number of prefix accept from this peer\n" | |
8415 | "maximum no. of prefix limit\n" | |
8416 | "Threshold value (%) at which to generate a warning msg\n" | |
8417 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8418 | { |
d62a17ae | 8419 | int idx_peer = 1; |
8420 | int idx_number = 3; | |
8421 | int idx_number_2 = 4; | |
9cbd06e0 | 8422 | int idx_force = 0; |
04261dec CS |
8423 | char base_xpath[XPATH_MAXLEN]; |
8424 | char af_xpath[XPATH_MAXLEN]; | |
8425 | char attr_xpath[XPATH_MAXLEN]; | |
8426 | afi_t afi = bgp_node_afi(vty); | |
8427 | safi_t safi = bgp_node_safi(vty); | |
8428 | ||
8429 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8430 | yang_afi_safi_value2identity(afi, safi)); | |
8431 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8432 | sizeof(base_xpath), af_xpath) | |
8433 | < 0) | |
8434 | return CMD_WARNING_CONFIG_FAILED; | |
8435 | ||
8436 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8437 | "/%s/prefix-limit/direction-list[direction='in']", | |
8438 | bgp_afi_safi_get_container_str(afi, safi)); | |
8439 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8440 | ||
8441 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8442 | ||
8443 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8444 | argv[idx_number]->arg); | |
8445 | ||
8446 | nb_cli_enqueue_change(vty, "./options/shutdown-threshold-pct", | |
8447 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
9cbd06e0 DA |
8448 | |
8449 | if (argv_find(argv, argc, "force", &idx_force)) | |
04261dec CS |
8450 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8451 | "true"); | |
9cbd06e0 | 8452 | |
04261dec | 8453 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8454 | } |
e0701b79 | 8455 | |
d62a17ae | 8456 | ALIAS_HIDDEN( |
8457 | neighbor_maximum_prefix_threshold, | |
8458 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8459 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8460 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8461 | "Maximum number of prefix accept from this peer\n" | |
8462 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8463 | "Threshold value (%) at which to generate a warning msg\n" |
8464 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8465 | |
232c75cd CS |
8466 | DEFUN_YANG(neighbor_maximum_prefix_warning, |
8467 | neighbor_maximum_prefix_warning_cmd, | |
8468 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8469 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8470 | "Maximum number of prefix accept from this peer\n" | |
8471 | "maximum no. of prefix limit\n" | |
8472 | "Only give warning message when limit is exceeded\n" | |
8473 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8474 | { |
d62a17ae | 8475 | int idx_peer = 1; |
8476 | int idx_number = 3; | |
9cbd06e0 | 8477 | int idx_force = 0; |
04261dec CS |
8478 | char base_xpath[XPATH_MAXLEN]; |
8479 | char af_xpath[XPATH_MAXLEN]; | |
8480 | char attr_xpath[XPATH_MAXLEN]; | |
8481 | afi_t afi = bgp_node_afi(vty); | |
8482 | safi_t safi = bgp_node_safi(vty); | |
8483 | ||
8484 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8485 | yang_afi_safi_value2identity(afi, safi)); | |
8486 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8487 | sizeof(base_xpath), af_xpath) | |
8488 | < 0) | |
8489 | return CMD_WARNING_CONFIG_FAILED; | |
9cbd06e0 | 8490 | |
04261dec CS |
8491 | snprintf(attr_xpath, sizeof(attr_xpath), |
8492 | "/%s/prefix-limit/direction-list[direction='in']", | |
8493 | bgp_afi_safi_get_container_str(afi, safi)); | |
8494 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8495 | ||
8496 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8497 | ||
8498 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8499 | argv[idx_number]->arg); | |
8500 | ||
8501 | nb_cli_enqueue_change(vty, "./options/warning-only", NB_OP_MODIFY, | |
8502 | "true"); | |
9cbd06e0 | 8503 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8504 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8505 | "true"); | |
9cbd06e0 | 8506 | |
04261dec | 8507 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 8508 | } |
8509 | ||
d62a17ae | 8510 | ALIAS_HIDDEN( |
8511 | neighbor_maximum_prefix_warning, | |
8512 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8513 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8514 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8515 | "Maximum number of prefix accept from this peer\n" | |
8516 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8517 | "Only give warning message when limit is exceeded\n" |
8518 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8519 | |
232c75cd CS |
8520 | DEFUN_YANG(neighbor_maximum_prefix_threshold_warning, |
8521 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8522 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8523 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8524 | "Maximum number of prefix accept from this peer\n" | |
8525 | "maximum no. of prefix limit\n" | |
8526 | "Threshold value (%) at which to generate a warning msg\n" | |
8527 | "Only give warning message when limit is exceeded\n" | |
8528 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8529 | { |
d62a17ae | 8530 | int idx_peer = 1; |
8531 | int idx_number = 3; | |
8532 | int idx_number_2 = 4; | |
9cbd06e0 | 8533 | int idx_force = 0; |
04261dec CS |
8534 | char base_xpath[XPATH_MAXLEN]; |
8535 | char af_xpath[XPATH_MAXLEN]; | |
8536 | char attr_xpath[XPATH_MAXLEN]; | |
8537 | afi_t afi = bgp_node_afi(vty); | |
8538 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8539 | |
04261dec CS |
8540 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8541 | yang_afi_safi_value2identity(afi, safi)); | |
8542 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8543 | sizeof(base_xpath), af_xpath) | |
8544 | < 0) | |
8545 | return CMD_WARNING_CONFIG_FAILED; | |
8546 | ||
8547 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8548 | "/%s/prefix-limit/direction-list[direction='in']", | |
8549 | bgp_afi_safi_get_container_str(afi, safi)); | |
8550 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8551 | ||
8552 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8553 | ||
8554 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8555 | argv[idx_number]->arg); | |
8556 | nb_cli_enqueue_change(vty, "./options/tw-shutdown-threshold-pct", | |
8557 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8558 | nb_cli_enqueue_change(vty, "./options/tw-warning-only", NB_OP_MODIFY, | |
8559 | "true"); | |
9cbd06e0 | 8560 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8561 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8562 | "true"); | |
9cbd06e0 | 8563 | |
04261dec | 8564 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8565 | } |
8566 | ||
d62a17ae | 8567 | ALIAS_HIDDEN( |
8568 | neighbor_maximum_prefix_threshold_warning, | |
8569 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8570 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8571 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8572 | "Maximum number of prefix accept from this peer\n" | |
8573 | "maximum no. of prefix limit\n" | |
8574 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8575 | "Only give warning message when limit is exceeded\n" |
8576 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8577 | |
232c75cd CS |
8578 | DEFUN_YANG(neighbor_maximum_prefix_restart, |
8579 | neighbor_maximum_prefix_restart_cmd, | |
8580 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8581 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8582 | "Maximum number of prefix accept from this peer\n" | |
8583 | "maximum no. of prefix limit\n" | |
8584 | "Restart bgp connection after limit is exceeded\n" | |
8585 | "Restart interval in minutes\n" | |
8586 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8587 | { |
d62a17ae | 8588 | int idx_peer = 1; |
8589 | int idx_number = 3; | |
8590 | int idx_number_2 = 5; | |
9cbd06e0 | 8591 | int idx_force = 0; |
04261dec CS |
8592 | char base_xpath[XPATH_MAXLEN]; |
8593 | char af_xpath[XPATH_MAXLEN]; | |
8594 | char attr_xpath[XPATH_MAXLEN]; | |
8595 | afi_t afi = bgp_node_afi(vty); | |
8596 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8597 | |
04261dec CS |
8598 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8599 | yang_afi_safi_value2identity(afi, safi)); | |
8600 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8601 | sizeof(base_xpath), af_xpath) | |
8602 | < 0) | |
8603 | return CMD_WARNING_CONFIG_FAILED; | |
8604 | ||
8605 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8606 | "/%s/prefix-limit/direction-list[direction='in']", | |
8607 | bgp_afi_safi_get_container_str(afi, safi)); | |
8608 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8609 | ||
8610 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8611 | ||
8612 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8613 | argv[idx_number]->arg); | |
8614 | nb_cli_enqueue_change(vty, "./options/restart-timer", NB_OP_MODIFY, | |
8615 | argv[idx_number_2]->arg); | |
9cbd06e0 | 8616 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8617 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8618 | "true"); | |
9cbd06e0 | 8619 | |
04261dec | 8620 | return nb_cli_apply_changes(vty, base_xpath); |
0a486e5f | 8621 | } |
8622 | ||
d62a17ae | 8623 | ALIAS_HIDDEN( |
8624 | neighbor_maximum_prefix_restart, | |
8625 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8626 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8627 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8628 | "Maximum number of prefix accept from this peer\n" | |
8629 | "maximum no. of prefix limit\n" | |
8630 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8631 | "Restart interval in minutes\n" |
8632 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8633 | |
232c75cd CS |
8634 | DEFUN_YANG(neighbor_maximum_prefix_threshold_restart, |
8635 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8636 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8637 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8638 | "Maximum number of prefixes to accept from this peer\n" | |
8639 | "maximum no. of prefix limit\n" | |
8640 | "Threshold value (%) at which to generate a warning msg\n" | |
8641 | "Restart bgp connection after limit is exceeded\n" | |
8642 | "Restart interval in minutes\n" | |
8643 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8644 | { |
d62a17ae | 8645 | int idx_peer = 1; |
8646 | int idx_number = 3; | |
8647 | int idx_number_2 = 4; | |
8648 | int idx_number_3 = 6; | |
9cbd06e0 | 8649 | int idx_force = 0; |
04261dec CS |
8650 | char base_xpath[XPATH_MAXLEN]; |
8651 | char af_xpath[XPATH_MAXLEN]; | |
8652 | char attr_xpath[XPATH_MAXLEN]; | |
8653 | afi_t afi = bgp_node_afi(vty); | |
8654 | safi_t safi = bgp_node_safi(vty); | |
9cbd06e0 | 8655 | |
04261dec CS |
8656 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, |
8657 | yang_afi_safi_value2identity(afi, safi)); | |
8658 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8659 | sizeof(base_xpath), af_xpath) | |
8660 | < 0) | |
8661 | return CMD_WARNING_CONFIG_FAILED; | |
8662 | ||
8663 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8664 | "/%s/prefix-limit/direction-list[direction='in']", | |
8665 | bgp_afi_safi_get_container_str(afi, safi)); | |
8666 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8667 | ||
8668 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
8669 | ||
8670 | nb_cli_enqueue_change(vty, "./max-prefixes", NB_OP_MODIFY, | |
8671 | argv[idx_number]->arg); | |
8672 | nb_cli_enqueue_change(vty, "./options/tr-shutdown-threshold-pct", | |
8673 | NB_OP_MODIFY, argv[idx_number_2]->arg); | |
8674 | nb_cli_enqueue_change(vty, "./options/tr-restart-timer", NB_OP_MODIFY, | |
8675 | argv[idx_number_3]->arg); | |
9cbd06e0 | 8676 | if (argv_find(argv, argc, "force", &idx_force)) |
04261dec CS |
8677 | nb_cli_enqueue_change(vty, "./force-check", NB_OP_MODIFY, |
8678 | "true"); | |
9cbd06e0 | 8679 | |
04261dec | 8680 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 8681 | } |
8682 | ||
8683 | ALIAS_HIDDEN( | |
8684 | neighbor_maximum_prefix_threshold_restart, | |
8685 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8686 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8687 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8688 | "Maximum number of prefixes to accept from this peer\n" | |
8689 | "maximum no. of prefix limit\n" | |
8690 | "Threshold value (%) at which to generate a warning msg\n" | |
8691 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8692 | "Restart interval in minutes\n" |
8693 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8694 | |
232c75cd CS |
8695 | DEFUN_YANG(no_neighbor_maximum_prefix, |
8696 | no_neighbor_maximum_prefix_cmd, | |
8697 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8698 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8699 | "Maximum number of prefixes to accept from this peer\n" | |
8700 | "maximum no. of prefix limit\n" | |
8701 | "Threshold value (%) at which to generate a warning msg\n" | |
8702 | "Restart bgp connection after limit is exceeded\n" | |
8703 | "Restart interval in minutes\n" | |
8704 | "Only give warning message when limit is exceeded\n" | |
8705 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8706 | { |
d62a17ae | 8707 | int idx_peer = 2; |
04261dec CS |
8708 | char base_xpath[XPATH_MAXLEN]; |
8709 | char af_xpath[XPATH_MAXLEN]; | |
8710 | char attr_xpath[XPATH_MAXLEN]; | |
8711 | afi_t afi = bgp_node_afi(vty); | |
8712 | safi_t safi = bgp_node_safi(vty); | |
8713 | ||
8714 | snprintf(af_xpath, sizeof(af_xpath), FRR_BGP_AF_XPATH, | |
8715 | yang_afi_safi_value2identity(afi, safi)); | |
8716 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, | |
8717 | sizeof(base_xpath), af_xpath) | |
8718 | < 0) | |
8719 | return CMD_WARNING_CONFIG_FAILED; | |
8720 | ||
8721 | snprintf(attr_xpath, sizeof(attr_xpath), | |
8722 | "/%s/prefix-limit/direction-list[direction='in']", | |
8723 | bgp_afi_safi_get_container_str(afi, safi)); | |
8724 | strlcat(base_xpath, attr_xpath, sizeof(base_xpath)); | |
8725 | ||
8726 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
8727 | ||
8728 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 8729 | } |
e52702f2 | 8730 | |
d62a17ae | 8731 | ALIAS_HIDDEN( |
8732 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8733 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8734 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8735 | "Maximum number of prefixes to accept from this peer\n" | |
8736 | "maximum no. of prefix limit\n" | |
8737 | "Threshold value (%) at which to generate a warning msg\n" | |
8738 | "Restart bgp connection after limit is exceeded\n" | |
8739 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8740 | "Only give warning message when limit is exceeded\n" |
8741 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8742 | |
718e3744 | 8743 | |
718e3744 | 8744 | /* "neighbor allowas-in" */ |
8745 | DEFUN (neighbor_allowas_in, | |
8746 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8747 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8748 | NEIGHBOR_STR |
8749 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8750 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8751 | "Number of occurrences of AS number\n" |
fd8503f5 | 8752 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8753 | { |
d62a17ae | 8754 | int idx_peer = 1; |
8755 | int idx_number_origin = 3; | |
8756 | int ret; | |
8757 | int origin = 0; | |
8758 | struct peer *peer; | |
8759 | int allow_num = 0; | |
8760 | ||
8761 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8762 | if (!peer) | |
8763 | return CMD_WARNING_CONFIG_FAILED; | |
8764 | ||
8765 | if (argc <= idx_number_origin) | |
8766 | allow_num = 3; | |
8767 | else { | |
8768 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8769 | origin = 1; | |
8770 | else | |
8771 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8772 | } | |
8773 | ||
8774 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8775 | allow_num, origin); | |
8776 | ||
8777 | return bgp_vty_return(vty, ret); | |
8778 | } | |
8779 | ||
8780 | ALIAS_HIDDEN( | |
8781 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8782 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8783 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8784 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8785 | "Number of occurrences of AS number\n" |
d62a17ae | 8786 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8787 | |
718e3744 | 8788 | DEFUN (no_neighbor_allowas_in, |
8789 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8790 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8791 | NO_STR |
8792 | NEIGHBOR_STR | |
8793 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8794 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8795 | "Number of occurrences of AS number\n" |
fd8503f5 | 8796 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8797 | { |
d62a17ae | 8798 | int idx_peer = 2; |
8799 | int ret; | |
8800 | struct peer *peer; | |
718e3744 | 8801 | |
d62a17ae | 8802 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8803 | if (!peer) | |
8804 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8805 | |
d62a17ae | 8806 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8807 | bgp_node_safi(vty)); | |
718e3744 | 8808 | |
d62a17ae | 8809 | return bgp_vty_return(vty, ret); |
718e3744 | 8810 | } |
6b0655a2 | 8811 | |
d62a17ae | 8812 | ALIAS_HIDDEN( |
8813 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8815 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8816 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8817 | "Number of occurrences of AS number\n" |
d62a17ae | 8818 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8819 | |
f4b8ec07 CS |
8820 | DEFUN_YANG (neighbor_ttl_security, |
8821 | neighbor_ttl_security_cmd, | |
8822 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8823 | NEIGHBOR_STR | |
8824 | NEIGHBOR_ADDR_STR2 | |
8825 | "BGP ttl-security parameters\n" | |
8826 | "Specify the maximum number of hops to the BGP peer\n" | |
8827 | "Number of hops to BGP peer\n") | |
fa411a21 | 8828 | { |
d62a17ae | 8829 | int idx_peer = 1; |
8830 | int idx_number = 4; | |
f4b8ec07 | 8831 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 8832 | |
f4b8ec07 CS |
8833 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8834 | sizeof(base_xpath), NULL) | |
8835 | < 0) | |
d62a17ae | 8836 | return CMD_WARNING_CONFIG_FAILED; |
8837 | ||
f4b8ec07 CS |
8838 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_MODIFY, |
8839 | argv[idx_number]->arg); | |
7ebe625c | 8840 | |
f4b8ec07 | 8841 | return nb_cli_apply_changes(vty, base_xpath); |
fa411a21 NH |
8842 | } |
8843 | ||
232c75cd CS |
8844 | DEFUN_YANG(no_neighbor_ttl_security, |
8845 | no_neighbor_ttl_security_cmd, | |
8846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8847 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8848 | "BGP ttl-security parameters\n" | |
8849 | "Specify the maximum number of hops to the BGP peer\n" | |
8850 | "Number of hops to BGP peer\n") | |
fa411a21 | 8851 | { |
d62a17ae | 8852 | int idx_peer = 2; |
f4b8ec07 | 8853 | char base_xpath[XPATH_MAXLEN]; |
fa411a21 | 8854 | |
f4b8ec07 CS |
8855 | if (peer_and_group_lookup_nb(vty, argv[idx_peer]->arg, base_xpath, |
8856 | sizeof(base_xpath), NULL) | |
8857 | < 0) | |
d62a17ae | 8858 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8859 | |
f4b8ec07 CS |
8860 | nb_cli_enqueue_change(vty, "./ttl-security", NB_OP_DESTROY, NULL); |
8861 | ||
8862 | return nb_cli_apply_changes(vty, base_xpath); | |
fa411a21 | 8863 | } |
6b0655a2 | 8864 | |
adbac85e DW |
8865 | DEFUN (neighbor_addpath_tx_all_paths, |
8866 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8867 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8868 | NEIGHBOR_STR |
8869 | NEIGHBOR_ADDR_STR2 | |
8870 | "Use addpath to advertise all paths to a neighbor\n") | |
8871 | { | |
d62a17ae | 8872 | int idx_peer = 1; |
8873 | struct peer *peer; | |
adbac85e | 8874 | |
d62a17ae | 8875 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8876 | if (!peer) | |
8877 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8878 | |
dcc68b5e MS |
8879 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8880 | BGP_ADDPATH_ALL); | |
8881 | return CMD_SUCCESS; | |
adbac85e DW |
8882 | } |
8883 | ||
d62a17ae | 8884 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8885 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8886 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8887 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8888 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8889 | |
adbac85e DW |
8890 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8891 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8892 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8893 | NO_STR |
8894 | NEIGHBOR_STR | |
8895 | NEIGHBOR_ADDR_STR2 | |
8896 | "Use addpath to advertise all paths to a neighbor\n") | |
8897 | { | |
d62a17ae | 8898 | int idx_peer = 2; |
dcc68b5e MS |
8899 | struct peer *peer; |
8900 | ||
8901 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8902 | if (!peer) | |
8903 | return CMD_WARNING_CONFIG_FAILED; | |
8904 | ||
8905 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8906 | != BGP_ADDPATH_ALL) { | |
8907 | vty_out(vty, | |
8908 | "%% Peer not currently configured to transmit all paths."); | |
8909 | return CMD_WARNING_CONFIG_FAILED; | |
8910 | } | |
8911 | ||
8912 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8913 | BGP_ADDPATH_NONE); | |
8914 | ||
8915 | return CMD_SUCCESS; | |
adbac85e DW |
8916 | } |
8917 | ||
d62a17ae | 8918 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8919 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8920 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8921 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8922 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8923 | |
06370dac DW |
8924 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8925 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8926 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8927 | NEIGHBOR_STR |
8928 | NEIGHBOR_ADDR_STR2 | |
8929 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8930 | { | |
d62a17ae | 8931 | int idx_peer = 1; |
8932 | struct peer *peer; | |
06370dac | 8933 | |
d62a17ae | 8934 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8935 | if (!peer) | |
8936 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8937 | |
dcc68b5e MS |
8938 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8939 | BGP_ADDPATH_BEST_PER_AS); | |
8940 | ||
8941 | return CMD_SUCCESS; | |
06370dac DW |
8942 | } |
8943 | ||
d62a17ae | 8944 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8945 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8946 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8947 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8948 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8949 | |
06370dac DW |
8950 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8951 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8953 | NO_STR |
8954 | NEIGHBOR_STR | |
8955 | NEIGHBOR_ADDR_STR2 | |
8956 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8957 | { | |
d62a17ae | 8958 | int idx_peer = 2; |
dcc68b5e MS |
8959 | struct peer *peer; |
8960 | ||
8961 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8962 | if (!peer) | |
8963 | return CMD_WARNING_CONFIG_FAILED; | |
8964 | ||
8965 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8966 | != BGP_ADDPATH_BEST_PER_AS) { | |
8967 | vty_out(vty, | |
8968 | "%% Peer not currently configured to transmit all best path per as."); | |
8969 | return CMD_WARNING_CONFIG_FAILED; | |
8970 | } | |
8971 | ||
8972 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8973 | BGP_ADDPATH_NONE); | |
8974 | ||
8975 | return CMD_SUCCESS; | |
06370dac DW |
8976 | } |
8977 | ||
d62a17ae | 8978 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8979 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8980 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8981 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8982 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8983 | |
2b31007c RZ |
8984 | DEFPY( |
8985 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8986 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8987 | NEIGHBOR_STR | |
8988 | NEIGHBOR_ADDR_STR2 | |
8989 | "Detect AS loops before sending to neighbor\n") | |
8990 | { | |
8991 | struct peer *peer; | |
8992 | ||
8993 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8994 | if (!peer) | |
8995 | return CMD_WARNING_CONFIG_FAILED; | |
8996 | ||
8997 | peer->as_path_loop_detection = true; | |
8998 | ||
8999 | return CMD_SUCCESS; | |
9000 | } | |
9001 | ||
9002 | DEFPY( | |
9003 | no_neighbor_aspath_loop_detection, | |
9004 | no_neighbor_aspath_loop_detection_cmd, | |
9005 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
9006 | NO_STR | |
9007 | NEIGHBOR_STR | |
9008 | NEIGHBOR_ADDR_STR2 | |
9009 | "Detect AS loops before sending to neighbor\n") | |
9010 | { | |
9011 | struct peer *peer; | |
9012 | ||
9013 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
9014 | if (!peer) | |
9015 | return CMD_WARNING_CONFIG_FAILED; | |
9016 | ||
9017 | peer->as_path_loop_detection = false; | |
9018 | ||
9019 | return CMD_SUCCESS; | |
9020 | } | |
9021 | ||
0221327c DS |
9022 | DEFPY(neighbor_damp, |
9023 | neighbor_damp_cmd, | |
9024 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]", | |
9025 | NEIGHBOR_STR | |
9026 | NEIGHBOR_ADDR_STR2 | |
9027 | "Enable neighbor route-flap dampening\n" | |
9028 | "Half-life time for the penalty\n" | |
9029 | "Value to start reusing a route\n" | |
9030 | "Value to start suppressing a route\n" | |
9031 | "Maximum duration to suppress a stable route\n") | |
9032 | { | |
9033 | struct peer *peer = peer_and_group_lookup_vty(vty, neighbor); | |
9034 | ||
9035 | if (!peer) | |
9036 | return CMD_WARNING_CONFIG_FAILED; | |
9037 | if (!half) | |
9038 | half = DEFAULT_HALF_LIFE; | |
9039 | if (!reuse) { | |
9040 | reuse = DEFAULT_REUSE; | |
9041 | suppress = DEFAULT_SUPPRESS; | |
9042 | max = half * 4; | |
9043 | } | |
9044 | if (suppress < reuse) { | |
9045 | vty_out(vty, | |
9046 | "Suppress value cannot be less than reuse value\n"); | |
9047 | return CMD_WARNING_CONFIG_FAILED; | |
9048 | } | |
9049 | bgp_peer_damp_enable(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
9050 | half * 60, reuse, suppress, max * 60); | |
9051 | return CMD_SUCCESS; | |
9052 | } | |
9053 | ||
9054 | DEFPY(no_neighbor_damp, | |
9055 | no_neighbor_damp_cmd, | |
9056 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]", | |
9057 | NO_STR | |
9058 | NEIGHBOR_STR | |
9059 | NEIGHBOR_ADDR_STR2 | |
9060 | "Enable neighbor route-flap dampening\n" | |
9061 | "Half-life time for the penalty\n" | |
9062 | "Value to start reusing a route\n" | |
9063 | "Value to start suppressing a route\n" | |
9064 | "Maximum duration to suppress a stable route\n") | |
9065 | { | |
9066 | struct peer *peer = peer_and_group_lookup_vty(vty, neighbor); | |
9067 | ||
9068 | if (!peer) | |
9069 | return CMD_WARNING_CONFIG_FAILED; | |
9070 | bgp_peer_damp_disable(peer, bgp_node_afi(vty), bgp_node_safi(vty)); | |
9071 | return CMD_SUCCESS; | |
9072 | } | |
9073 | ||
9074 | DEFPY (show_ip_bgp_neighbor_damp_param, | |
9075 | show_ip_bgp_neighbor_damp_param_cmd, | |
9076 | "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json", | |
9077 | SHOW_STR | |
9078 | IP_STR | |
9079 | BGP_STR | |
9080 | BGP_AFI_HELP_STR | |
9081 | "Address Family modifier\n" | |
9082 | NEIGHBOR_STR | |
9083 | NEIGHBOR_ADDR_STR2 | |
9084 | "Neighbor route-flap dampening information\n" | |
9085 | "Display detail of configured dampening parameters\n" | |
9086 | JSON_STR) | |
9087 | { | |
9088 | bool use_json = false; | |
9089 | int idx = 0; | |
9090 | afi_t afi = AFI_IP; | |
9091 | safi_t safi = SAFI_UNICAST; | |
9092 | struct peer *peer; | |
9093 | ||
9094 | if (argv_find(argv, argc, "ip", &idx)) | |
9095 | afi = AFI_IP; | |
9096 | if (argv_find(argv, argc, "ipv4", &idx)) | |
9097 | afi = AFI_IP; | |
9098 | if (argv_find(argv, argc, "ipv6", &idx)) | |
9099 | afi = AFI_IP6; | |
9100 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
9101 | if (!peer) | |
9102 | return CMD_WARNING; | |
9103 | if (json) | |
9104 | use_json = true; | |
9105 | bgp_show_peer_dampening_parameters(vty, peer, afi, safi, use_json); | |
9106 | return CMD_SUCCESS; | |
9107 | } | |
9108 | ||
b9c7bc5a | 9109 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 9110 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 9111 | { |
b9c7bc5a PZ |
9112 | struct ecommunity *ecom = NULL; |
9113 | struct ecommunity *ecomadd; | |
ddb5b488 | 9114 | |
b9c7bc5a | 9115 | for (; argc; --argc, ++argv) { |
9a659715 PG |
9116 | if (is_rt6) |
9117 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
9118 | ECOMMUNITY_ROUTE_TARGET, | |
9119 | 0); | |
9120 | else | |
9121 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
9122 | ECOMMUNITY_ROUTE_TARGET, | |
9123 | 0); | |
b9c7bc5a PZ |
9124 | if (!ecomadd) { |
9125 | vty_out(vty, "Malformed community-list value\n"); | |
9126 | if (ecom) | |
9127 | ecommunity_free(&ecom); | |
9128 | return CMD_WARNING_CONFIG_FAILED; | |
9129 | } | |
ddb5b488 | 9130 | |
b9c7bc5a PZ |
9131 | if (ecom) { |
9132 | ecommunity_merge(ecom, ecomadd); | |
9133 | ecommunity_free(&ecomadd); | |
9134 | } else { | |
9135 | ecom = ecomadd; | |
9136 | } | |
9137 | } | |
9138 | ||
9139 | if (*list) { | |
9140 | ecommunity_free(&*list); | |
ddb5b488 | 9141 | } |
b9c7bc5a PZ |
9142 | *list = ecom; |
9143 | ||
9144 | return CMD_SUCCESS; | |
ddb5b488 PZ |
9145 | } |
9146 | ||
37a87b8f CS |
9147 | bool vpn_policy_check_import(struct bgp *bgp, afi_t afi, safi_t safi, |
9148 | bool v2vimport, char *errmsg, size_t errmsg_len) | |
9149 | { | |
9150 | if (!v2vimport) { | |
9151 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9152 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
9153 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9154 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
9155 | snprintf( | |
9156 | errmsg, errmsg_len, "%s", | |
9157 | "%% error: Please unconfigure import vrf commands before using vpn commands"); | |
9158 | return false; | |
9159 | } | |
9160 | } else { | |
9161 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9162 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
9163 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9164 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
9165 | snprintf( | |
9166 | errmsg, errmsg_len, "%s", | |
9167 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands"); | |
9168 | return false; | |
9169 | } | |
9170 | } | |
9171 | return true; | |
9172 | } | |
9173 | ||
0ca70ba5 DS |
9174 | /* |
9175 | * v2vimport is true if we are handling a `import vrf ...` command | |
9176 | */ | |
9177 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 9178 | { |
0ca70ba5 DS |
9179 | afi_t afi; |
9180 | ||
ddb5b488 | 9181 | switch (vty->node) { |
b9c7bc5a | 9182 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
9183 | afi = AFI_IP; |
9184 | break; | |
b9c7bc5a | 9185 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
9186 | afi = AFI_IP6; |
9187 | break; | |
ddb5b488 PZ |
9188 | default: |
9189 | vty_out(vty, | |
b9c7bc5a | 9190 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 9191 | return AFI_MAX; |
ddb5b488 | 9192 | } |
69b07479 | 9193 | |
0ca70ba5 DS |
9194 | if (!v2vimport) { |
9195 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9196 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
9197 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9198 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
9199 | vty_out(vty, | |
9200 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
9201 | return AFI_MAX; | |
9202 | } | |
9203 | } else { | |
9204 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9205 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
9206 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9207 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
9208 | vty_out(vty, | |
9209 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
9210 | return AFI_MAX; | |
9211 | } | |
9212 | } | |
9213 | return afi; | |
ddb5b488 PZ |
9214 | } |
9215 | ||
37a87b8f CS |
9216 | DEFPY_YANG( |
9217 | af_rd_vpn_export, | |
9218 | af_rd_vpn_export_cmd, | |
9219 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
9220 | NO_STR | |
9221 | "Specify route distinguisher\n" | |
9222 | "Between current address-family and vpn\n" | |
9223 | "For routes leaked from current address-family to vpn\n" | |
9224 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 9225 | { |
37a87b8f | 9226 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9227 | afi_t afi; |
37a87b8f | 9228 | safi_t safi; |
b9c7bc5a | 9229 | int idx = 0; |
b9c7bc5a | 9230 | |
37a87b8f CS |
9231 | afi = bgp_node_afi(vty); |
9232 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9233 | |
37a87b8f CS |
9234 | snprintf( |
9235 | base_xpath, sizeof(base_xpath), | |
9236 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9237 | yang_afi_safi_value2identity(afi, safi), | |
9238 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 9239 | |
37a87b8f CS |
9240 | if (argv_find(argv, argc, "no", &idx)) |
9241 | nb_cli_enqueue_change(vty, "./rd", NB_OP_DESTROY, NULL); | |
9242 | else | |
9243 | nb_cli_enqueue_change(vty, "./rd", NB_OP_MODIFY, rd_str); | |
ddb5b488 | 9244 | |
37a87b8f CS |
9245 | return nb_cli_apply_changes(vty, base_xpath); |
9246 | } | |
ddb5b488 | 9247 | |
37a87b8f CS |
9248 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd( |
9249 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9250 | { | |
9251 | int indent = 2; | |
69b07479 | 9252 | |
37a87b8f CS |
9253 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
9254 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9255 | } |
9256 | ||
b9c7bc5a PZ |
9257 | ALIAS (af_rd_vpn_export, |
9258 | af_no_rd_vpn_export_cmd, | |
9259 | "no rd vpn export", | |
ddb5b488 | 9260 | NO_STR |
b9c7bc5a PZ |
9261 | "Specify route distinguisher\n" |
9262 | "Between current address-family and vpn\n" | |
9263 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9264 | |
b9c7bc5a PZ |
9265 | DEFPY (af_label_vpn_export, |
9266 | af_label_vpn_export_cmd, | |
e70e9f8e | 9267 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 9268 | NO_STR |
ddb5b488 | 9269 | "label value for VRF\n" |
b9c7bc5a PZ |
9270 | "Between current address-family and vpn\n" |
9271 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
9272 | "Label Value <0-1048575>\n" |
9273 | "Automatically assign a label\n") | |
ddb5b488 PZ |
9274 | { |
9275 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 9276 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 9277 | afi_t afi; |
b9c7bc5a | 9278 | int idx = 0; |
c6423c31 | 9279 | bool yes = true; |
b9c7bc5a PZ |
9280 | |
9281 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9282 | yes = false; |
ddb5b488 | 9283 | |
21a16cc2 PZ |
9284 | /* If "no ...", squash trailing parameter */ |
9285 | if (!yes) | |
9286 | label_auto = NULL; | |
9287 | ||
e70e9f8e PZ |
9288 | if (yes) { |
9289 | if (!label_auto) | |
9290 | label = label_val; /* parser should force unsigned */ | |
9291 | } | |
ddb5b488 | 9292 | |
0ca70ba5 | 9293 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9294 | if (afi == AFI_MAX) |
9295 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 9296 | |
e70e9f8e | 9297 | |
69b07479 DS |
9298 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
9299 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
9300 | /* no change */ | |
9301 | return CMD_SUCCESS; | |
e70e9f8e | 9302 | |
69b07479 DS |
9303 | /* |
9304 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9305 | */ | |
9306 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9307 | bgp_get_default(), bgp); | |
9308 | ||
9309 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9310 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
9311 | ||
9312 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
9313 | ||
9314 | /* | |
9315 | * label has previously been automatically | |
9316 | * assigned by labelpool: release it | |
9317 | * | |
9318 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
9319 | * means the automatic assignment is in flight | |
9320 | * and therefore the labelpool callback must | |
9321 | * detect that the auto label is not needed. | |
9322 | */ | |
9323 | ||
9324 | bgp_lp_release(LP_TYPE_VRF, | |
9325 | &bgp->vpn_policy[afi], | |
9326 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 9327 | } |
69b07479 DS |
9328 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
9329 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9330 | } | |
ddb5b488 | 9331 | |
69b07479 DS |
9332 | bgp->vpn_policy[afi].tovpn_label = label; |
9333 | if (label_auto) { | |
9334 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9335 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9336 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
9337 | vpn_leak_label_callback); | |
ddb5b488 PZ |
9338 | } |
9339 | ||
69b07479 DS |
9340 | /* post-change: re-export vpn routes */ |
9341 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9342 | bgp_get_default(), bgp); | |
9343 | ||
0d020cd6 | 9344 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
9345 | return CMD_SUCCESS; |
9346 | } | |
9347 | ||
b72c9e14 HS |
9348 | DEFPY (af_sid_vpn_export, |
9349 | af_sid_vpn_export_cmd, | |
9350 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
9351 | NO_STR | |
9352 | "sid value for VRF\n" | |
9353 | "Between current address-family and vpn\n" | |
9354 | "For routes leaked from current address-family to vpn\n" | |
9355 | "Sid allocation index\n" | |
9356 | "Automatically assign a label\n") | |
9357 | { | |
9358 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9359 | afi_t afi; | |
9360 | int debug = 0; | |
9361 | int idx = 0; | |
9362 | bool yes = true; | |
9363 | ||
9364 | if (argv_find(argv, argc, "no", &idx)) | |
9365 | yes = false; | |
9366 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9367 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9368 | ||
9369 | afi = vpn_policy_getafi(vty, bgp, false); | |
9370 | if (afi == AFI_MAX) | |
9371 | return CMD_WARNING_CONFIG_FAILED; | |
9372 | ||
9373 | if (!yes) { | |
9374 | /* implement me */ | |
9375 | vty_out(vty, "It's not implemented"); | |
9376 | return CMD_WARNING_CONFIG_FAILED; | |
9377 | } | |
9378 | ||
9379 | /* skip when it's already configured */ | |
9380 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
9381 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9382 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
9383 | return CMD_SUCCESS; | |
9384 | ||
7de4c885 HS |
9385 | /* |
9386 | * mode change between sid_idx and sid_auto isn't supported. | |
9387 | * user must negate sid vpn export when they want to change the mode | |
9388 | */ | |
b72c9e14 HS |
9389 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
9390 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9391 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
9392 | vty_out(vty, "it's already configured as %s.\n", | |
9393 | sid_auto ? "auto-mode" : "idx-mode"); | |
9394 | return CMD_WARNING_CONFIG_FAILED; | |
9395 | } | |
9396 | ||
9397 | /* pre-change */ | |
9398 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9399 | bgp_get_default(), bgp); | |
9400 | ||
9401 | if (sid_auto) { | |
9402 | /* SID allocation auto-mode */ | |
9403 | if (debug) | |
9404 | zlog_debug("%s: auto sid alloc.", __func__); | |
9405 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9406 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
9407 | } else { | |
9408 | /* SID allocation index-mode */ | |
9409 | if (debug) | |
9410 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
9411 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
9412 | } | |
9413 | ||
9414 | /* post-change */ | |
9415 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9416 | bgp_get_default(), bgp); | |
9417 | return CMD_SUCCESS; | |
9418 | } | |
9419 | ||
b9c7bc5a PZ |
9420 | ALIAS (af_label_vpn_export, |
9421 | af_no_label_vpn_export_cmd, | |
9422 | "no label vpn export", | |
9423 | NO_STR | |
9424 | "label value for VRF\n" | |
9425 | "Between current address-family and vpn\n" | |
9426 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9427 | |
37a87b8f | 9428 | DEFPY_YANG (af_nexthop_vpn_export, |
b9c7bc5a | 9429 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9430 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9431 | NO_STR |
ddb5b488 | 9432 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9433 | "Between current address-family and vpn\n" |
9434 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9435 | "IPv4 prefix\n" |
9436 | "IPv6 prefix\n") | |
9437 | { | |
37a87b8f | 9438 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9439 | afi_t afi; |
37a87b8f CS |
9440 | safi_t safi; |
9441 | int idx = 0; | |
ddb5b488 PZ |
9442 | struct prefix p; |
9443 | ||
8c85ca28 QY |
9444 | if (!no) { |
9445 | if (!nexthop_su) { | |
9446 | vty_out(vty, "%% Nexthop required\n"); | |
9447 | return CMD_WARNING_CONFIG_FAILED; | |
9448 | } | |
8c85ca28 | 9449 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9450 | return CMD_WARNING_CONFIG_FAILED; |
9451 | } | |
ddb5b488 | 9452 | |
37a87b8f CS |
9453 | afi = bgp_node_afi(vty); |
9454 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9455 | |
37a87b8f CS |
9456 | snprintf( |
9457 | base_xpath, sizeof(base_xpath), | |
9458 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9459 | yang_afi_safi_value2identity(afi, safi), | |
9460 | bgp_afi_safi_get_container_str(afi, safi)); | |
ddb5b488 | 9461 | |
37a87b8f CS |
9462 | if (argv_find(argv, argc, "no", &idx)) |
9463 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_DESTROY, NULL); | |
9464 | else | |
9465 | nb_cli_enqueue_change(vty, "./nexthop", NB_OP_MODIFY, | |
9466 | nexthop_su_str); | |
ddb5b488 | 9467 | |
37a87b8f CS |
9468 | return nb_cli_apply_changes(vty, base_xpath); |
9469 | } | |
69b07479 | 9470 | |
37a87b8f CS |
9471 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop( |
9472 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9473 | { | |
9474 | int indent = 2; | |
9475 | ||
9476 | vty_out(vty, "%*snexthop vpn export %s\n", indent, "", | |
9477 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9478 | } |
9479 | ||
b9c7bc5a | 9480 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9481 | { |
b9c7bc5a PZ |
9482 | if (!strcmp(dstr, "import")) { |
9483 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9484 | } else if (!strcmp(dstr, "export")) { | |
9485 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9486 | } else if (!strcmp(dstr, "both")) { | |
9487 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9488 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9489 | } else { | |
9490 | vty_out(vty, "%% direction parse error\n"); | |
9491 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9492 | } |
ddb5b488 PZ |
9493 | return CMD_SUCCESS; |
9494 | } | |
9495 | ||
b9c7bc5a PZ |
9496 | DEFPY (af_rt_vpn_imexport, |
9497 | af_rt_vpn_imexport_cmd, | |
9498 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9499 | NO_STR | |
9500 | "Specify route target list\n" | |
ddb5b488 | 9501 | "Specify route target list\n" |
b9c7bc5a PZ |
9502 | "Between current address-family and vpn\n" |
9503 | "For routes leaked from vpn to current address-family: match any\n" | |
9504 | "For routes leaked from current address-family to vpn: set\n" | |
9505 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9506 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9507 | { | |
9508 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9509 | int ret; | |
9510 | struct ecommunity *ecom = NULL; | |
9511 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
9512 | vpn_policy_direction_t dir; |
9513 | afi_t afi; | |
9514 | int idx = 0; | |
c6423c31 | 9515 | bool yes = true; |
ddb5b488 | 9516 | |
b9c7bc5a | 9517 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9518 | yes = false; |
b9c7bc5a | 9519 | |
0ca70ba5 | 9520 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9521 | if (afi == AFI_MAX) |
9522 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9523 | |
b9c7bc5a | 9524 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9525 | if (ret != CMD_SUCCESS) |
9526 | return ret; | |
9527 | ||
b9c7bc5a PZ |
9528 | if (yes) { |
9529 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9530 | vty_out(vty, "%% Missing RTLIST\n"); | |
9531 | return CMD_WARNING_CONFIG_FAILED; | |
9532 | } | |
c6423c31 | 9533 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9534 | if (ret != CMD_SUCCESS) { |
9535 | return ret; | |
9536 | } | |
ddb5b488 PZ |
9537 | } |
9538 | ||
69b07479 DS |
9539 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9540 | if (!dodir[dir]) | |
ddb5b488 | 9541 | continue; |
ddb5b488 | 9542 | |
69b07479 | 9543 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9544 | |
69b07479 DS |
9545 | if (yes) { |
9546 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9547 | ecommunity_free( | |
9548 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9549 | bgp->vpn_policy[afi].rtlist[dir] = | |
9550 | ecommunity_dup(ecom); | |
9551 | } else { | |
9552 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9553 | ecommunity_free( | |
9554 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9555 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9556 | } |
69b07479 DS |
9557 | |
9558 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9559 | } |
69b07479 | 9560 | |
d555f3e9 PZ |
9561 | if (ecom) |
9562 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9563 | |
9564 | return CMD_SUCCESS; | |
9565 | } | |
9566 | ||
b9c7bc5a PZ |
9567 | ALIAS (af_rt_vpn_imexport, |
9568 | af_no_rt_vpn_imexport_cmd, | |
9569 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9570 | NO_STR |
9571 | "Specify route target list\n" | |
b9c7bc5a PZ |
9572 | "Specify route target list\n" |
9573 | "Between current address-family and vpn\n" | |
9574 | "For routes leaked from vpn to current address-family\n" | |
9575 | "For routes leaked from current address-family to vpn\n" | |
9576 | "both import and export\n") | |
9577 | ||
37a87b8f | 9578 | DEFPY_YANG (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9579 | af_route_map_vpn_imexport_cmd, |
9580 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9581 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9582 | NO_STR | |
ddb5b488 | 9583 | "Specify route map\n" |
b9c7bc5a PZ |
9584 | "Between current address-family and vpn\n" |
9585 | "For routes leaked from vpn to current address-family\n" | |
9586 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9587 | "name of route-map\n") |
9588 | { | |
37a87b8f | 9589 | char base_xpath[XPATH_MAXLEN]; |
ddb5b488 | 9590 | afi_t afi; |
37a87b8f | 9591 | safi_t safi; |
ddb5b488 | 9592 | int idx = 0; |
ddb5b488 | 9593 | |
37a87b8f CS |
9594 | afi = bgp_node_afi(vty); |
9595 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9596 | |
37a87b8f CS |
9597 | snprintf( |
9598 | base_xpath, sizeof(base_xpath), | |
9599 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config", | |
9600 | yang_afi_safi_value2identity(afi, safi), | |
9601 | bgp_afi_safi_get_container_str(afi, safi)); | |
9602 | ||
9603 | if (argv_find(argv, argc, "no", &idx)) { | |
9604 | if (!strcmp(direction_str, "import")) | |
9605 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9606 | NB_OP_DESTROY, NULL); | |
9607 | else if (!strcmp(direction_str, "export")) | |
9608 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9609 | NB_OP_DESTROY, NULL); | |
9610 | } else { | |
9611 | if (!strcmp(direction_str, "import")) | |
9612 | nb_cli_enqueue_change(vty, "./rmap-import", | |
9613 | NB_OP_MODIFY, rmap_str); | |
9614 | if (!strcmp(direction_str, "export")) | |
9615 | nb_cli_enqueue_change(vty, "./rmap-export", | |
9616 | NB_OP_MODIFY, rmap_str); | |
9617 | } | |
9618 | return nb_cli_apply_changes(vty, base_xpath); | |
9619 | } | |
ddb5b488 | 9620 | |
37a87b8f CS |
9621 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import( |
9622 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9623 | { | |
9624 | int indent = 2; | |
ddb5b488 | 9625 | |
37a87b8f CS |
9626 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9627 | yang_dnode_get_string(dnode, NULL)); | |
9628 | } | |
69b07479 | 9629 | |
37a87b8f CS |
9630 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export( |
9631 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9632 | { | |
9633 | int indent = 2; | |
ddb5b488 | 9634 | |
37a87b8f CS |
9635 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", |
9636 | yang_dnode_get_string(dnode, NULL)); | |
ddb5b488 PZ |
9637 | } |
9638 | ||
b9c7bc5a PZ |
9639 | ALIAS (af_route_map_vpn_imexport, |
9640 | af_no_route_map_vpn_imexport_cmd, | |
9641 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9642 | NO_STR |
9643 | "Specify route map\n" | |
b9c7bc5a PZ |
9644 | "Between current address-family and vpn\n" |
9645 | "For routes leaked from vpn to current address-family\n" | |
9646 | "For routes leaked from current address-family to vpn\n") | |
9647 | ||
bb4f6190 | 9648 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9649 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9650 | "Import routes from another VRF\n" |
9651 | "Vrf routes being filtered\n" | |
9652 | "Specify route map\n" | |
9653 | "name of route-map\n") | |
9654 | { | |
9655 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
9656 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
9657 | afi_t afi; | |
bb4f6190 DS |
9658 | struct bgp *bgp_default; |
9659 | ||
0ca70ba5 | 9660 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9661 | if (afi == AFI_MAX) |
9662 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9663 | |
9664 | bgp_default = bgp_get_default(); | |
9665 | if (!bgp_default) { | |
9666 | int32_t ret; | |
9667 | as_t as = bgp->as; | |
9668 | ||
9669 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9670 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9671 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9672 | |
9673 | if (ret) { | |
9674 | vty_out(vty, | |
9675 | "VRF default is not configured as a bgp instance\n"); | |
9676 | return CMD_WARNING; | |
9677 | } | |
9678 | } | |
9679 | ||
69b07479 | 9680 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9681 | |
ae6a6fb4 DS |
9682 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9683 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9684 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9685 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9686 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9687 | bgp->vpn_policy[afi].rmap[dir] = | |
9688 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9689 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9690 | return CMD_SUCCESS; | |
9691 | ||
9692 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9693 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9694 | |
69b07479 DS |
9695 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9696 | ||
bb4f6190 DS |
9697 | return CMD_SUCCESS; |
9698 | } | |
9699 | ||
ae6a6fb4 DS |
9700 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9701 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9702 | NO_STR |
9703 | "Import routes from another VRF\n" | |
9704 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9705 | "Specify route map\n" |
9706 | "name of route-map\n") | |
9707 | { | |
9708 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9709 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
9710 | afi_t afi; | |
9711 | ||
9712 | afi = vpn_policy_getafi(vty, bgp, true); | |
9713 | if (afi == AFI_MAX) | |
9714 | return CMD_WARNING_CONFIG_FAILED; | |
9715 | ||
9716 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9717 | ||
9718 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9719 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9720 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9721 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9722 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9723 | ||
9724 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9725 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9726 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9727 | ||
9728 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9729 | ||
9730 | return CMD_SUCCESS; | |
9731 | } | |
bb4f6190 | 9732 | |
37a87b8f CS |
9733 | DEFPY_YANG(bgp_imexport_vrf, |
9734 | bgp_imexport_vrf_cmd, | |
9735 | "[no] import vrf VIEWVRFNAME$import_name", | |
9736 | NO_STR | |
9737 | "Import routes from another VRF\n" | |
9738 | "VRF to import from\n" | |
9739 | "The name of the VRF\n") | |
12a844a5 | 9740 | { |
37a87b8f | 9741 | char base_xpath[XPATH_MAXLEN]; |
12a844a5 DS |
9742 | safi_t safi; |
9743 | afi_t afi; | |
37a87b8f | 9744 | int32_t idx = 0; |
12a844a5 | 9745 | |
867f0cca | 9746 | if (import_name == NULL) { |
9747 | vty_out(vty, "%% Missing import name\n"); | |
9748 | return CMD_WARNING; | |
9749 | } | |
9750 | ||
ae6a6fb4 DS |
9751 | if (strcmp(import_name, "route-map") == 0) { |
9752 | vty_out(vty, "%% Must include route-map name\n"); | |
9753 | return CMD_WARNING; | |
9754 | } | |
9755 | ||
37a87b8f | 9756 | afi = bgp_node_afi(vty); |
12a844a5 DS |
9757 | safi = bgp_node_safi(vty); |
9758 | ||
37a87b8f CS |
9759 | snprintf( |
9760 | base_xpath, sizeof(base_xpath), | |
9761 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']", | |
9762 | yang_afi_safi_value2identity(afi, safi), | |
9763 | bgp_afi_safi_get_container_str(afi, safi), import_name); | |
25679caa | 9764 | |
37a87b8f CS |
9765 | if (argv_find(argv, argc, "no", &idx)) |
9766 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9767 | else | |
9768 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
12a844a5 | 9769 | |
37a87b8f CS |
9770 | return nb_cli_apply_changes(vty, base_xpath); |
9771 | } | |
12a844a5 | 9772 | |
37a87b8f CS |
9773 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs( |
9774 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9775 | { | |
9776 | vty_out(vty, " import vrf %s\n", | |
9777 | yang_dnode_get_string(dnode, "./vrf")); | |
12a844a5 DS |
9778 | } |
9779 | ||
b9c7bc5a | 9780 | /* This command is valid only in a bgp vrf instance or the default instance */ |
37a87b8f | 9781 | DEFPY_YANG (bgp_imexport_vpn, |
b9c7bc5a PZ |
9782 | bgp_imexport_vpn_cmd, |
9783 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9784 | NO_STR |
9785 | "Import routes to this address-family\n" | |
9786 | "Export routes from this address-family\n" | |
9787 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9788 | { |
37a87b8f | 9789 | char base_xpath[XPATH_MAXLEN]; |
b9c7bc5a | 9790 | safi_t safi; |
37a87b8f CS |
9791 | afi_t afi; |
9792 | int32_t idx = 0; | |
ddb5b488 | 9793 | |
b9c7bc5a PZ |
9794 | afi = bgp_node_afi(vty); |
9795 | safi = bgp_node_safi(vty); | |
ddb5b488 | 9796 | |
b9c7bc5a | 9797 | if (!strcmp(direction_str, "import")) { |
37a87b8f CS |
9798 | snprintf( |
9799 | base_xpath, sizeof(base_xpath), | |
9800 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn", | |
9801 | yang_afi_safi_value2identity(afi, safi), | |
9802 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a | 9803 | } else if (!strcmp(direction_str, "export")) { |
37a87b8f CS |
9804 | snprintf( |
9805 | base_xpath, sizeof(base_xpath), | |
9806 | "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn", | |
9807 | yang_afi_safi_value2identity(afi, safi), | |
9808 | bgp_afi_safi_get_container_str(afi, safi)); | |
b9c7bc5a PZ |
9809 | } else { |
9810 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9811 | return CMD_WARNING_CONFIG_FAILED; | |
9812 | } | |
9813 | ||
37a87b8f CS |
9814 | if (argv_find(argv, argc, "no", &idx)) |
9815 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
9816 | else | |
9817 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, "true"); | |
ddb5b488 | 9818 | |
37a87b8f CS |
9819 | return nb_cli_apply_changes(vty, base_xpath); |
9820 | } | |
ddb5b488 | 9821 | |
37a87b8f CS |
9822 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn( |
9823 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9824 | { | |
9825 | if (yang_dnode_get_bool(dnode, NULL)) | |
9826 | vty_out(vty, " import vpn\n"); | |
9827 | } | |
9828 | ||
9829 | void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn( | |
9830 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
9831 | { | |
9832 | if (yang_dnode_get_bool(dnode, NULL)) | |
9833 | vty_out(vty, " export vpn\n"); | |
ddb5b488 PZ |
9834 | } |
9835 | ||
301ad80a PG |
9836 | DEFPY (af_routetarget_import, |
9837 | af_routetarget_import_cmd, | |
9a659715 | 9838 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9839 | NO_STR |
9840 | "Specify route target list\n" | |
9841 | "Specify route target list\n" | |
9a659715 PG |
9842 | "Specify route target list\n" |
9843 | "Specify route target list\n" | |
301ad80a PG |
9844 | "Flow-spec redirect type route target\n" |
9845 | "Import routes to this address-family\n" | |
9a659715 | 9846 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9847 | { |
9848 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9849 | int ret; | |
9850 | struct ecommunity *ecom = NULL; | |
301ad80a | 9851 | afi_t afi; |
9a659715 | 9852 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9853 | bool yes = true; |
9854 | bool rt6 = false; | |
301ad80a PG |
9855 | |
9856 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9857 | yes = false; |
301ad80a | 9858 | |
9a659715 PG |
9859 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9860 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9861 | rt6 = true; |
301ad80a | 9862 | |
0ca70ba5 | 9863 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9864 | if (afi == AFI_MAX) |
9865 | return CMD_WARNING_CONFIG_FAILED; | |
9866 | ||
9a659715 PG |
9867 | if (rt6 && afi != AFI_IP6) |
9868 | return CMD_WARNING_CONFIG_FAILED; | |
9869 | ||
301ad80a PG |
9870 | if (yes) { |
9871 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9872 | vty_out(vty, "%% Missing RTLIST\n"); | |
9873 | return CMD_WARNING_CONFIG_FAILED; | |
9874 | } | |
9a659715 | 9875 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9876 | if (ret != CMD_SUCCESS) |
9877 | return ret; | |
9878 | } | |
69b07479 DS |
9879 | |
9880 | if (yes) { | |
9881 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9882 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9883 | .import_redirect_rtlist); |
69b07479 DS |
9884 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9885 | ecommunity_dup(ecom); | |
9886 | } else { | |
9887 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9888 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9889 | .import_redirect_rtlist); |
69b07479 | 9890 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9891 | } |
69b07479 | 9892 | |
301ad80a PG |
9893 | if (ecom) |
9894 | ecommunity_free(&ecom); | |
9895 | ||
9896 | return CMD_SUCCESS; | |
9897 | } | |
9898 | ||
37a87b8f CS |
9899 | void cli_show_bgp_global_afi_safi_header(struct vty *vty, |
9900 | struct lyd_node *dnode, | |
9901 | bool show_defaults) | |
9902 | { | |
9903 | const char *af_name; | |
9904 | afi_t afi; | |
9905 | safi_t safi; | |
9906 | ||
9907 | af_name = yang_dnode_get_string(dnode, "./afi-safi-name"); | |
9908 | yang_afi_safi_identity2value(af_name, &afi, &safi); | |
9909 | ||
9910 | vty_out(vty, " !\n address-family "); | |
9911 | if (afi == AFI_IP) { | |
9912 | if (safi == SAFI_UNICAST) | |
9913 | vty_out(vty, "ipv4 unicast"); | |
9914 | else if (safi == SAFI_LABELED_UNICAST) | |
9915 | vty_out(vty, "ipv4 labeled-unicast"); | |
9916 | else if (safi == SAFI_MULTICAST) | |
9917 | vty_out(vty, "ipv4 multicast"); | |
9918 | else if (safi == SAFI_MPLS_VPN) | |
9919 | vty_out(vty, "ipv4 vpn"); | |
9920 | else if (safi == SAFI_ENCAP) | |
9921 | vty_out(vty, "ipv4 encap"); | |
9922 | else if (safi == SAFI_FLOWSPEC) | |
9923 | vty_out(vty, "ipv4 flowspec"); | |
9924 | } else if (afi == AFI_IP6) { | |
9925 | if (safi == SAFI_UNICAST) | |
9926 | vty_out(vty, "ipv6 unicast"); | |
9927 | else if (safi == SAFI_LABELED_UNICAST) | |
9928 | vty_out(vty, "ipv6 labeled-unicast"); | |
9929 | else if (safi == SAFI_MULTICAST) | |
9930 | vty_out(vty, "ipv6 multicast"); | |
9931 | else if (safi == SAFI_MPLS_VPN) | |
9932 | vty_out(vty, "ipv6 vpn"); | |
9933 | else if (safi == SAFI_ENCAP) | |
9934 | vty_out(vty, "ipv6 encap"); | |
9935 | else if (safi == SAFI_FLOWSPEC) | |
9936 | vty_out(vty, "ipv6 flowspec"); | |
9937 | } else if (afi == AFI_L2VPN) { | |
9938 | if (safi == SAFI_EVPN) | |
9939 | vty_out(vty, "l2vpn evpn"); | |
9940 | } | |
9941 | vty_out(vty, "\n"); | |
9942 | } | |
9943 | ||
505e5056 | 9944 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9945 | address_family_ipv4_safi_cmd, |
9946 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9947 | "Enter Address Family command mode\n" | |
9948 | "Address Family\n" | |
9949 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9950 | { |
f51bae9c | 9951 | |
37a87b8f CS |
9952 | safi_t safi = SAFI_UNICAST; |
9953 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9954 | const char *vrf_name = NULL; | |
9955 | ||
d62a17ae | 9956 | if (argc == 3) { |
37a87b8f CS |
9957 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9958 | ||
9959 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9960 | VTY_CURR_XPATH); | |
9961 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9962 | "control-plane-protocol"); | |
9963 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9964 | ||
9965 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9966 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9967 | && safi != SAFI_EVPN) { |
31947174 MK |
9968 | vty_out(vty, |
9969 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9970 | return CMD_WARNING_CONFIG_FAILED; |
9971 | } | |
37a87b8f CS |
9972 | } |
9973 | vty->node = bgp_node_type(AFI_IP, safi); | |
718e3744 | 9974 | |
d62a17ae | 9975 | return CMD_SUCCESS; |
718e3744 | 9976 | } |
9977 | ||
505e5056 | 9978 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9979 | address_family_ipv6_safi_cmd, |
9980 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9981 | "Enter Address Family command mode\n" | |
9982 | "Address Family\n" | |
9983 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9984 | { |
37a87b8f CS |
9985 | safi_t safi = SAFI_UNICAST; |
9986 | const struct lyd_node *vrf_dnode, *bgp_glb_dnode; | |
9987 | const char *vrf_name = NULL; | |
9988 | ||
d62a17ae | 9989 | if (argc == 3) { |
37a87b8f CS |
9990 | safi = bgp_vty_safi_from_str(argv[2]->text); |
9991 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, | |
9992 | VTY_CURR_XPATH); | |
9993 | vrf_dnode = yang_dnode_get_parent(bgp_glb_dnode, | |
9994 | "control-plane-protocol"); | |
9995 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
9996 | ||
9997 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME) | |
a4d82a8a | 9998 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9999 | && safi != SAFI_EVPN) { |
31947174 MK |
10000 | vty_out(vty, |
10001 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
10002 | return CMD_WARNING_CONFIG_FAILED; |
10003 | } | |
37a87b8f CS |
10004 | } |
10005 | vty->node = bgp_node_type(AFI_IP6, safi); | |
25ffbdc1 | 10006 | |
d62a17ae | 10007 | return CMD_SUCCESS; |
25ffbdc1 | 10008 | } |
718e3744 | 10009 | |
d6902373 | 10010 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 10011 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 10012 | address_family_vpnv4_cmd, |
8334fd5a | 10013 | "address-family vpnv4 [unicast]", |
718e3744 | 10014 | "Enter Address Family command mode\n" |
8c3deaae | 10015 | "Address Family\n" |
3a2d747c | 10016 | "Address Family modifier\n") |
718e3744 | 10017 | { |
d62a17ae | 10018 | vty->node = BGP_VPNV4_NODE; |
10019 | return CMD_SUCCESS; | |
718e3744 | 10020 | } |
10021 | ||
505e5056 | 10022 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 10023 | address_family_vpnv6_cmd, |
8334fd5a | 10024 | "address-family vpnv6 [unicast]", |
8ecd3266 | 10025 | "Enter Address Family command mode\n" |
8c3deaae | 10026 | "Address Family\n" |
3a2d747c | 10027 | "Address Family modifier\n") |
8ecd3266 | 10028 | { |
d62a17ae | 10029 | vty->node = BGP_VPNV6_NODE; |
10030 | return CMD_SUCCESS; | |
8ecd3266 | 10031 | } |
64e4a6c5 | 10032 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 10033 | |
505e5056 | 10034 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 10035 | address_family_evpn_cmd, |
7111c1a0 | 10036 | "address-family l2vpn evpn", |
4e0b7b6d | 10037 | "Enter Address Family command mode\n" |
7111c1a0 QY |
10038 | "Address Family\n" |
10039 | "Address Family modifier\n") | |
4e0b7b6d | 10040 | { |
2131d5cf | 10041 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 10042 | vty->node = BGP_EVPN_NODE; |
10043 | return CMD_SUCCESS; | |
4e0b7b6d PG |
10044 | } |
10045 | ||
bfaab44d HS |
10046 | DEFUN_NOSH (bgp_segment_routing_srv6, |
10047 | bgp_segment_routing_srv6_cmd, | |
10048 | "segment-routing srv6", | |
10049 | "Segment-Routing configuration\n" | |
10050 | "Segment-Routing SRv6 configuration\n") | |
10051 | { | |
10052 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 10053 | bgp->srv6_enabled = true; |
bfaab44d HS |
10054 | vty->node = BGP_SRV6_NODE; |
10055 | return CMD_SUCCESS; | |
10056 | } | |
10057 | ||
a0281b2e HS |
10058 | DEFPY (bgp_srv6_locator, |
10059 | bgp_srv6_locator_cmd, | |
10060 | "locator NAME$name", | |
10061 | "Specify SRv6 locator\n" | |
10062 | "Specify SRv6 locator\n") | |
10063 | { | |
10064 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 10065 | int ret; |
a0281b2e HS |
10066 | |
10067 | if (strlen(bgp->srv6_locator_name) > 0 | |
10068 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
10069 | vty_out(vty, "srv6 locator is already configured\n"); | |
10070 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
10071 | } |
10072 | ||
10073 | snprintf(bgp->srv6_locator_name, | |
10074 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 10075 | |
7de4c885 | 10076 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
10077 | if (ret < 0) |
10078 | return CMD_WARNING_CONFIG_FAILED; | |
10079 | ||
10080 | return CMD_SUCCESS; | |
10081 | } | |
10082 | ||
ea372e81 HS |
10083 | DEFPY (show_bgp_srv6, |
10084 | show_bgp_srv6_cmd, | |
10085 | "show bgp segment-routing srv6", | |
10086 | SHOW_STR | |
10087 | BGP_STR | |
10088 | "BGP Segment Routing\n" | |
10089 | "BGP Segment Routing SRv6\n") | |
10090 | { | |
10091 | struct bgp *bgp; | |
10092 | struct listnode *node; | |
10093 | struct prefix_ipv6 *chunk; | |
10094 | struct bgp_srv6_function *func; | |
10095 | struct in6_addr *tovpn4_sid; | |
10096 | struct in6_addr *tovpn6_sid; | |
10097 | char buf[256]; | |
10098 | char buf_tovpn4_sid[256]; | |
10099 | char buf_tovpn6_sid[256]; | |
10100 | ||
10101 | bgp = bgp_get_default(); | |
96db4340 | 10102 | if (!bgp) |
ea372e81 HS |
10103 | return CMD_SUCCESS; |
10104 | ||
10105 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
10106 | vty_out(vty, "locator_chunks:\n"); | |
10107 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
10108 | prefix2str(chunk, buf, sizeof(buf)); | |
10109 | vty_out(vty, "- %s\n", buf); | |
10110 | } | |
10111 | ||
10112 | vty_out(vty, "functions:\n"); | |
10113 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
10114 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
10115 | vty_out(vty, "- sid: %s\n", buf); | |
10116 | vty_out(vty, " locator: %s\n", func->locator_name); | |
10117 | } | |
10118 | ||
10119 | vty_out(vty, "bgps:\n"); | |
10120 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
10121 | vty_out(vty, "- name: %s\n", | |
10122 | bgp->name ? bgp->name : "default"); | |
10123 | ||
10124 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
10125 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
10126 | if (tovpn4_sid) | |
10127 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
10128 | sizeof(buf_tovpn4_sid)); | |
10129 | if (tovpn6_sid) | |
10130 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
10131 | sizeof(buf_tovpn6_sid)); | |
10132 | ||
10133 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
10134 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
10135 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
10136 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
10137 | } | |
10138 | ||
10139 | return CMD_SUCCESS; | |
10140 | } | |
10141 | ||
505e5056 | 10142 | DEFUN_NOSH (exit_address_family, |
718e3744 | 10143 | exit_address_family_cmd, |
10144 | "exit-address-family", | |
10145 | "Exit from Address Family configuration mode\n") | |
10146 | { | |
d62a17ae | 10147 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
10148 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
10149 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
10150 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
10151 | || vty->node == BGP_EVPN_NODE |
10152 | || vty->node == BGP_FLOWSPECV4_NODE | |
10153 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 10154 | vty->node = BGP_NODE; |
10155 | return CMD_SUCCESS; | |
718e3744 | 10156 | } |
6b0655a2 | 10157 | |
37a87b8f CS |
10158 | void cli_show_bgp_global_afi_safi_header_end(struct vty *vty, |
10159 | struct lyd_node *dnode | |
10160 | __attribute__((__unused__))) | |
10161 | { | |
10162 | vty_out(vty, " exit-address-family\n"); | |
10163 | } | |
10164 | ||
8ad7271d | 10165 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 10166 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
10167 | const char *ip_str, afi_t afi, safi_t safi, | |
10168 | struct prefix_rd *prd) | |
10169 | { | |
10170 | int ret; | |
10171 | struct prefix match; | |
9bcb3eef DS |
10172 | struct bgp_dest *dest; |
10173 | struct bgp_dest *rm; | |
d62a17ae | 10174 | struct bgp *bgp; |
10175 | struct bgp_table *table; | |
10176 | struct bgp_table *rib; | |
10177 | ||
10178 | /* BGP structure lookup. */ | |
10179 | if (view_name) { | |
10180 | bgp = bgp_lookup_by_name(view_name); | |
10181 | if (bgp == NULL) { | |
10182 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
10183 | view_name); | |
10184 | return CMD_WARNING; | |
10185 | } | |
10186 | } else { | |
10187 | bgp = bgp_get_default(); | |
10188 | if (bgp == NULL) { | |
10189 | vty_out(vty, "%% No BGP process is configured\n"); | |
10190 | return CMD_WARNING; | |
10191 | } | |
10192 | } | |
10193 | ||
10194 | /* Check IP address argument. */ | |
10195 | ret = str2prefix(ip_str, &match); | |
10196 | if (!ret) { | |
10197 | vty_out(vty, "%% address is malformed\n"); | |
10198 | return CMD_WARNING; | |
10199 | } | |
10200 | ||
10201 | match.family = afi2family(afi); | |
10202 | rib = bgp->rib[afi][safi]; | |
10203 | ||
10204 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
10205 | for (dest = bgp_table_top(rib); dest; |
10206 | dest = bgp_route_next(dest)) { | |
10207 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 10208 | |
9bcb3eef | 10209 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 10210 | continue; |
10211 | ||
9bcb3eef | 10212 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
10213 | if (table == NULL) |
10214 | continue; | |
10215 | ||
4953391b DA |
10216 | rm = bgp_node_match(table, &match); |
10217 | if (rm != NULL) { | |
b54892e0 | 10218 | const struct prefix *rm_p = |
9bcb3eef | 10219 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
10220 | |
10221 | if (rm_p->prefixlen == match.prefixlen) { | |
10222 | SET_FLAG(rm->flags, | |
10223 | BGP_NODE_USER_CLEAR); | |
10224 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 10225 | } |
9bcb3eef | 10226 | bgp_dest_unlock_node(rm); |
d62a17ae | 10227 | } |
10228 | } | |
10229 | } else { | |
4953391b DA |
10230 | dest = bgp_node_match(rib, &match); |
10231 | if (dest != NULL) { | |
9bcb3eef | 10232 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 10233 | |
9bcb3eef DS |
10234 | if (dest_p->prefixlen == match.prefixlen) { |
10235 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
10236 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 10237 | } |
9bcb3eef | 10238 | bgp_dest_unlock_node(dest); |
d62a17ae | 10239 | } |
10240 | } | |
10241 | ||
10242 | return CMD_SUCCESS; | |
8ad7271d DS |
10243 | } |
10244 | ||
b09b5ae0 | 10245 | /* one clear bgp command to rule them all */ |
718e3744 | 10246 | DEFUN (clear_ip_bgp_all, |
10247 | clear_ip_bgp_all_cmd, | |
453c92f6 | 10248 | "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 | 10249 | CLEAR_STR |
10250 | IP_STR | |
10251 | BGP_STR | |
838758ac | 10252 | BGP_INSTANCE_HELP_STR |
510afcd6 | 10253 | BGP_AFI_HELP_STR |
fd5e7b70 | 10254 | "Address Family\n" |
510afcd6 | 10255 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 10256 | "Address Family modifier\n" |
b09b5ae0 | 10257 | "Clear all peers\n" |
453c92f6 | 10258 | "BGP IPv4 neighbor to clear\n" |
a80beece | 10259 | "BGP IPv6 neighbor to clear\n" |
838758ac | 10260 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
10261 | "Clear peers with the AS number\n" |
10262 | "Clear all external peers\n" | |
718e3744 | 10263 | "Clear all members of peer-group\n" |
b09b5ae0 | 10264 | "BGP peer-group name\n" |
b09b5ae0 DW |
10265 | BGP_SOFT_STR |
10266 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
10267 | BGP_SOFT_OUT_STR |
10268 | BGP_SOFT_IN_STR | |
10269 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 10270 | BGP_SOFT_OUT_STR) |
718e3744 | 10271 | { |
d62a17ae | 10272 | char *vrf = NULL; |
10273 | ||
dc912615 DS |
10274 | afi_t afi = AFI_UNSPEC; |
10275 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 10276 | enum clear_sort clr_sort = clear_peer; |
10277 | enum bgp_clear_type clr_type; | |
10278 | char *clr_arg = NULL; | |
10279 | ||
10280 | int idx = 0; | |
ff8a8a7a CS |
10281 | char errmsg[BUFSIZ] = {'\0'}; |
10282 | int ret; | |
d62a17ae | 10283 | |
10284 | /* clear [ip] bgp */ | |
10285 | if (argv_find(argv, argc, "ip", &idx)) | |
10286 | afi = AFI_IP; | |
10287 | ||
9a8bdf1c PG |
10288 | /* [<vrf> VIEWVRFNAME] */ |
10289 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10290 | vrf = argv[idx + 1]->arg; | |
10291 | idx += 2; | |
10292 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10293 | vrf = NULL; | |
10294 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10295 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 10296 | vrf = argv[idx + 1]->arg; |
10297 | idx += 2; | |
10298 | } | |
d62a17ae | 10299 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10300 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
10301 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10302 | ||
d7b9898c | 10303 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 10304 | if (argv_find(argv, argc, "*", &idx)) { |
10305 | clr_sort = clear_all; | |
10306 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
10307 | clr_sort = clear_peer; | |
10308 | clr_arg = argv[idx]->arg; | |
10309 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
10310 | clr_sort = clear_peer; | |
10311 | clr_arg = argv[idx]->arg; | |
10312 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
10313 | clr_sort = clear_group; | |
10314 | idx++; | |
10315 | clr_arg = argv[idx]->arg; | |
d7b9898c | 10316 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 10317 | clr_sort = clear_peer; |
10318 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
10319 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
10320 | clr_sort = clear_peer; | |
10321 | clr_arg = argv[idx]->arg; | |
d62a17ae | 10322 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
10323 | clr_sort = clear_as; | |
10324 | clr_arg = argv[idx]->arg; | |
10325 | } else if (argv_find(argv, argc, "external", &idx)) { | |
10326 | clr_sort = clear_external; | |
10327 | } | |
10328 | ||
10329 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
10330 | if (argv_find(argv, argc, "soft", &idx)) { | |
10331 | if (argv_find(argv, argc, "in", &idx) | |
10332 | || argv_find(argv, argc, "out", &idx)) | |
10333 | clr_type = strmatch(argv[idx]->text, "in") | |
10334 | ? BGP_CLEAR_SOFT_IN | |
10335 | : BGP_CLEAR_SOFT_OUT; | |
10336 | else | |
10337 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
10338 | } else if (argv_find(argv, argc, "in", &idx)) { | |
10339 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
10340 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
10341 | : BGP_CLEAR_SOFT_IN; | |
10342 | } else if (argv_find(argv, argc, "out", &idx)) { | |
10343 | clr_type = BGP_CLEAR_SOFT_OUT; | |
10344 | } else | |
10345 | clr_type = BGP_CLEAR_SOFT_NONE; | |
10346 | ||
ff8a8a7a CS |
10347 | ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg, |
10348 | sizeof(errmsg)); | |
10349 | if (ret != NB_OK) | |
10350 | vty_out(vty, "Error description: %s\n", errmsg); | |
10351 | ||
10352 | return ret; | |
838758ac | 10353 | } |
01080f7c | 10354 | |
8ad7271d DS |
10355 | DEFUN (clear_ip_bgp_prefix, |
10356 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 10357 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
10358 | CLEAR_STR |
10359 | IP_STR | |
10360 | BGP_STR | |
838758ac | 10361 | BGP_INSTANCE_HELP_STR |
8ad7271d | 10362 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10363 | "IPv4 prefix\n") |
8ad7271d | 10364 | { |
d62a17ae | 10365 | char *vrf = NULL; |
10366 | char *prefix = NULL; | |
8ad7271d | 10367 | |
d62a17ae | 10368 | int idx = 0; |
01080f7c | 10369 | |
d62a17ae | 10370 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
10371 | if (argv_find(argv, argc, "vrf", &idx)) { |
10372 | vrf = argv[idx + 1]->arg; | |
10373 | idx += 2; | |
10374 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10375 | vrf = NULL; | |
10376 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10377 | /* [<view> VIEWVRFNAME] */ | |
10378 | vrf = argv[idx + 1]->arg; | |
10379 | idx += 2; | |
10380 | } | |
0c7b1b01 | 10381 | |
d62a17ae | 10382 | prefix = argv[argc - 1]->arg; |
8ad7271d | 10383 | |
d62a17ae | 10384 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 10385 | } |
8ad7271d | 10386 | |
b09b5ae0 DW |
10387 | DEFUN (clear_bgp_ipv6_safi_prefix, |
10388 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 10389 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10390 | CLEAR_STR |
3a2d747c | 10391 | IP_STR |
718e3744 | 10392 | BGP_STR |
8c3deaae | 10393 | "Address Family\n" |
46f296b4 | 10394 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10395 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10396 | "IPv6 prefix\n") |
718e3744 | 10397 | { |
9b475e76 PG |
10398 | int idx_safi = 0; |
10399 | int idx_ipv6_prefix = 0; | |
10400 | safi_t safi = SAFI_UNICAST; | |
10401 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10402 | argv[idx_ipv6_prefix]->arg : NULL; | |
10403 | ||
10404 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 10405 | return bgp_clear_prefix( |
9b475e76 PG |
10406 | vty, NULL, prefix, AFI_IP6, |
10407 | safi, NULL); | |
838758ac | 10408 | } |
01080f7c | 10409 | |
b09b5ae0 DW |
10410 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
10411 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 10412 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10413 | CLEAR_STR |
3a2d747c | 10414 | IP_STR |
718e3744 | 10415 | BGP_STR |
838758ac | 10416 | BGP_INSTANCE_HELP_STR |
8c3deaae | 10417 | "Address Family\n" |
46f296b4 | 10418 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10419 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10420 | "IPv6 prefix\n") |
718e3744 | 10421 | { |
9b475e76 | 10422 | int idx_safi = 0; |
9a8bdf1c | 10423 | int idx_vrfview = 0; |
9b475e76 PG |
10424 | int idx_ipv6_prefix = 0; |
10425 | safi_t safi = SAFI_UNICAST; | |
10426 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10427 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 10428 | char *vrfview = NULL; |
9b475e76 | 10429 | |
9a8bdf1c PG |
10430 | /* [<view|vrf> VIEWVRFNAME] */ |
10431 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
10432 | vrfview = argv[idx_vrfview + 1]->arg; | |
10433 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
10434 | vrfview = NULL; | |
10435 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
10436 | /* [<view> VIEWVRFNAME] */ | |
10437 | vrfview = argv[idx_vrfview + 1]->arg; | |
10438 | } | |
9b475e76 PG |
10439 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
10440 | ||
d62a17ae | 10441 | return bgp_clear_prefix( |
9b475e76 PG |
10442 | vty, vrfview, prefix, |
10443 | AFI_IP6, safi, NULL); | |
718e3744 | 10444 | } |
10445 | ||
b09b5ae0 DW |
10446 | DEFUN (show_bgp_views, |
10447 | show_bgp_views_cmd, | |
d6e3c605 | 10448 | "show [ip] bgp views", |
b09b5ae0 | 10449 | SHOW_STR |
d6e3c605 | 10450 | IP_STR |
01080f7c | 10451 | BGP_STR |
b09b5ae0 | 10452 | "Show the defined BGP views\n") |
01080f7c | 10453 | { |
d62a17ae | 10454 | struct list *inst = bm->bgp; |
10455 | struct listnode *node; | |
10456 | struct bgp *bgp; | |
01080f7c | 10457 | |
d62a17ae | 10458 | vty_out(vty, "Defined BGP views:\n"); |
10459 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10460 | /* Skip VRFs. */ | |
10461 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
10462 | continue; | |
10463 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
10464 | bgp->as); | |
10465 | } | |
e52702f2 | 10466 | |
d62a17ae | 10467 | return CMD_SUCCESS; |
e0081f70 ML |
10468 | } |
10469 | ||
8386ac43 | 10470 | DEFUN (show_bgp_vrfs, |
10471 | show_bgp_vrfs_cmd, | |
d6e3c605 | 10472 | "show [ip] bgp vrfs [json]", |
8386ac43 | 10473 | SHOW_STR |
d6e3c605 | 10474 | IP_STR |
8386ac43 | 10475 | BGP_STR |
10476 | "Show BGP VRFs\n" | |
9973d184 | 10477 | JSON_STR) |
8386ac43 | 10478 | { |
fe1dc5a3 | 10479 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 10480 | struct list *inst = bm->bgp; |
10481 | struct listnode *node; | |
10482 | struct bgp *bgp; | |
9f049418 | 10483 | bool uj = use_json(argc, argv); |
d62a17ae | 10484 | json_object *json = NULL; |
10485 | json_object *json_vrfs = NULL; | |
10486 | int count = 0; | |
d62a17ae | 10487 | |
d62a17ae | 10488 | if (uj) { |
10489 | json = json_object_new_object(); | |
10490 | json_vrfs = json_object_new_object(); | |
10491 | } | |
10492 | ||
10493 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10494 | const char *name, *type; | |
10495 | struct peer *peer; | |
7fe96307 | 10496 | struct listnode *node2, *nnode2; |
d62a17ae | 10497 | int peers_cfg, peers_estb; |
10498 | json_object *json_vrf = NULL; | |
d62a17ae | 10499 | |
10500 | /* Skip Views. */ | |
10501 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
10502 | continue; | |
10503 | ||
10504 | count++; | |
efb4077a | 10505 | if (!uj && count == 1) { |
fe1dc5a3 | 10506 | vty_out(vty, |
efb4077a | 10507 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10508 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10509 | "#PeersEstb", "Name"); |
10510 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10511 | "L3-VNI", "RouterMAC", "Interface"); | |
10512 | } | |
d62a17ae | 10513 | |
10514 | peers_cfg = peers_estb = 0; | |
10515 | if (uj) | |
10516 | json_vrf = json_object_new_object(); | |
10517 | ||
10518 | ||
7fe96307 | 10519 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 10520 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10521 | continue; | |
10522 | peers_cfg++; | |
feb17238 | 10523 | if (peer_established(peer)) |
d62a17ae | 10524 | peers_estb++; |
10525 | } | |
10526 | ||
10527 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 10528 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10529 | type = "DFLT"; |
10530 | } else { | |
10531 | name = bgp->name; | |
10532 | type = "VRF"; | |
10533 | } | |
10534 | ||
a8bf7d9c | 10535 | |
d62a17ae | 10536 | if (uj) { |
a4d82a8a PZ |
10537 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10538 | ? -1 | |
10539 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
10540 | char buf[BUFSIZ] = {0}; |
10541 | ||
d62a17ae | 10542 | json_object_string_add(json_vrf, "type", type); |
10543 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
10544 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
10545 | inet_ntop(AF_INET, |
10546 | &bgp->router_id, buf, | |
10547 | sizeof(buf))); | |
d62a17ae | 10548 | json_object_int_add(json_vrf, "numConfiguredPeers", |
10549 | peers_cfg); | |
10550 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
10551 | peers_estb); | |
10552 | ||
fe1dc5a3 | 10553 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
10554 | json_object_string_add( |
10555 | json_vrf, "rmac", | |
10556 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
10557 | json_object_string_add(json_vrf, "interface", |
10558 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10559 | bgp->vrf_id)); | |
d62a17ae | 10560 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 10561 | } else { |
23d0a753 | 10562 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
10563 | type, |
10564 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10565 | : (int)bgp->vrf_id, | |
23d0a753 | 10566 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
10567 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
10568 | bgp->l3vni, | |
10569 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
10570 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10571 | bgp->vrf_id)); | |
10572 | } | |
d62a17ae | 10573 | } |
10574 | ||
10575 | if (uj) { | |
10576 | json_object_object_add(json, "vrfs", json_vrfs); | |
10577 | ||
10578 | json_object_int_add(json, "totalVrfs", count); | |
10579 | ||
996c9314 LB |
10580 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10581 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10582 | json_object_free(json); |
10583 | } else { | |
10584 | if (count) | |
10585 | vty_out(vty, | |
10586 | "\nTotal number of VRFs (including default): %d\n", | |
10587 | count); | |
10588 | } | |
10589 | ||
10590 | return CMD_SUCCESS; | |
8386ac43 | 10591 | } |
10592 | ||
48ecf8f5 DS |
10593 | DEFUN (show_bgp_mac_hash, |
10594 | show_bgp_mac_hash_cmd, | |
10595 | "show bgp mac hash", | |
10596 | SHOW_STR | |
10597 | BGP_STR | |
10598 | "Mac Address\n" | |
10599 | "Mac Address database\n") | |
10600 | { | |
10601 | bgp_mac_dump_table(vty); | |
10602 | ||
10603 | return CMD_SUCCESS; | |
10604 | } | |
acf71666 | 10605 | |
e3b78da8 | 10606 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10607 | { |
0291c246 | 10608 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10609 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10610 | |
23d0a753 | 10611 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10612 | } |
10613 | ||
10614 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10615 | { | |
10616 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10617 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10618 | |
10619 | vty_out(vty, "Tunnel-ip database:\n"); | |
10620 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10621 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10622 | vty); |
10623 | } | |
10624 | ||
15c81ca4 DS |
10625 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10626 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10627 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10628 | "martian next-hops\n" |
10629 | "martian next-hop database\n") | |
acf71666 | 10630 | { |
0291c246 | 10631 | struct bgp *bgp = NULL; |
15c81ca4 | 10632 | int idx = 0; |
9a8bdf1c PG |
10633 | char *name = NULL; |
10634 | ||
10635 | /* [<vrf> VIEWVRFNAME] */ | |
10636 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10637 | name = argv[idx + 1]->arg; | |
10638 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10639 | name = NULL; | |
10640 | } else if (argv_find(argv, argc, "view", &idx)) | |
10641 | /* [<view> VIEWVRFNAME] */ | |
10642 | name = argv[idx + 1]->arg; | |
10643 | if (name) | |
10644 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10645 | else |
10646 | bgp = bgp_get_default(); | |
acf71666 | 10647 | |
acf71666 MK |
10648 | if (!bgp) { |
10649 | vty_out(vty, "%% No BGP process is configured\n"); | |
10650 | return CMD_WARNING; | |
10651 | } | |
10652 | bgp_show_martian_nexthops(vty, bgp); | |
10653 | ||
10654 | return CMD_SUCCESS; | |
10655 | } | |
10656 | ||
f412b39a | 10657 | DEFUN (show_bgp_memory, |
4bf6a362 | 10658 | show_bgp_memory_cmd, |
7fa12b13 | 10659 | "show [ip] bgp memory", |
4bf6a362 | 10660 | SHOW_STR |
3a2d747c | 10661 | IP_STR |
4bf6a362 PJ |
10662 | BGP_STR |
10663 | "Global BGP memory statistics\n") | |
10664 | { | |
d62a17ae | 10665 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10666 | unsigned long count; | |
10667 | ||
10668 | /* RIB related usage stats */ | |
10669 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10670 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10671 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10672 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10673 | |
10674 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10675 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10676 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10677 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10678 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10679 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10680 | count, | |
4b7e6066 DS |
10681 | mtype_memstr( |
10682 | memstrbuf, sizeof(memstrbuf), | |
10683 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10684 | |
10685 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10686 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10687 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10688 | count * sizeof(struct bgp_static))); | |
10689 | ||
10690 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10691 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10692 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10693 | count * sizeof(struct bpacket))); | |
10694 | ||
10695 | /* Adj-In/Out */ | |
10696 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10697 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10698 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10699 | count * sizeof(struct bgp_adj_in))); | |
10700 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10701 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10702 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10703 | count * sizeof(struct bgp_adj_out))); | |
10704 | ||
10705 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10706 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10707 | count, | |
10708 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10709 | count * sizeof(struct bgp_nexthop_cache))); | |
10710 | ||
10711 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10712 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10713 | count, | |
10714 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10715 | count * sizeof(struct bgp_damp_info))); | |
10716 | ||
10717 | /* Attributes */ | |
10718 | count = attr_count(); | |
10719 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10720 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10721 | count * sizeof(struct attr))); | |
10722 | ||
10723 | if ((count = attr_unknown_count())) | |
10724 | vty_out(vty, "%ld unknown attributes\n", count); | |
10725 | ||
10726 | /* AS_PATH attributes */ | |
10727 | count = aspath_count(); | |
10728 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10729 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10730 | count * sizeof(struct aspath))); | |
10731 | ||
10732 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10733 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10734 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10735 | count * sizeof(struct assegment))); | |
10736 | ||
10737 | /* Other attributes */ | |
10738 | if ((count = community_count())) | |
10739 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10740 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10741 | count * sizeof(struct community))); | |
d62a17ae | 10742 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
10743 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10744 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10745 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10746 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10747 | vty_out(vty, | |
10748 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10749 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10750 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10751 | |
10752 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10753 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10754 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10755 | count * sizeof(struct cluster_list))); | |
10756 | ||
10757 | /* Peer related usage */ | |
10758 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10759 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10760 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10761 | count * sizeof(struct peer))); | |
10762 | ||
10763 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10764 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10765 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10766 | count * sizeof(struct peer_group))); | |
10767 | ||
10768 | /* Other */ | |
d62a17ae | 10769 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10770 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10771 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10772 | count * sizeof(regex_t))); | |
d62a17ae | 10773 | return CMD_SUCCESS; |
4bf6a362 | 10774 | } |
fee0f4c6 | 10775 | |
57a9c8a8 DS |
10776 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10777 | { | |
10778 | json_object *bestpath = json_object_new_object(); | |
10779 | ||
892fedb6 | 10780 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10781 | json_object_string_add(bestpath, "asPath", "ignore"); |
10782 | ||
892fedb6 | 10783 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10784 | json_object_string_add(bestpath, "asPath", "confed"); |
10785 | ||
892fedb6 DA |
10786 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10787 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10788 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10789 | "as-set"); |
10790 | else | |
a4d82a8a | 10791 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10792 | "true"); |
10793 | } else | |
a4d82a8a | 10794 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10795 | |
ee88563a JM |
10796 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
10797 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10798 | ||
892fedb6 | 10799 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10800 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10801 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10802 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10803 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10804 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10805 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10806 | json_object_string_add(bestpath, "med", |
10807 | "missing-as-worst"); | |
10808 | else | |
10809 | json_object_string_add(bestpath, "med", "true"); | |
10810 | } | |
10811 | ||
10812 | json_object_object_add(json, "bestPath", bestpath); | |
10813 | } | |
10814 | ||
3577f1c5 DD |
10815 | /* Print the error code/subcode for why the peer is down */ |
10816 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10817 | json_object *json_peer, bool use_json) | |
10818 | { | |
10819 | const char *code_str; | |
10820 | const char *subcode_str; | |
10821 | ||
10822 | if (use_json) { | |
10823 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10824 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10825 | char errorcodesubcode_hexstr[5]; | |
10826 | char errorcodesubcode_str[256]; | |
10827 | ||
10828 | code_str = bgp_notify_code_str(peer->notify.code); | |
10829 | subcode_str = bgp_notify_subcode_str( | |
10830 | peer->notify.code, | |
10831 | peer->notify.subcode); | |
10832 | ||
772270f3 QY |
10833 | snprintf(errorcodesubcode_hexstr, |
10834 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10835 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10836 | json_object_string_add(json_peer, |
10837 | "lastErrorCodeSubcode", | |
10838 | errorcodesubcode_hexstr); | |
10839 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10840 | code_str, subcode_str); | |
10841 | json_object_string_add(json_peer, | |
10842 | "lastNotificationReason", | |
10843 | errorcodesubcode_str); | |
10844 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10845 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10846 | && (peer->notify.subcode | |
10847 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10848 | || peer->notify.subcode | |
10849 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10850 | && peer->notify.length) { | |
10851 | char msgbuf[1024]; | |
10852 | const char *msg_str; | |
10853 | ||
10854 | msg_str = bgp_notify_admin_message( | |
10855 | msgbuf, sizeof(msgbuf), | |
10856 | (uint8_t *)peer->notify.data, | |
10857 | peer->notify.length); | |
10858 | if (msg_str) | |
10859 | json_object_string_add( | |
10860 | json_peer, | |
10861 | "lastShutdownDescription", | |
10862 | msg_str); | |
10863 | } | |
10864 | ||
c258527b | 10865 | } |
3577f1c5 DD |
10866 | json_object_string_add(json_peer, "lastResetDueTo", |
10867 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10868 | json_object_int_add(json_peer, "lastResetCode", |
10869 | peer->last_reset); | |
3577f1c5 DD |
10870 | } else { |
10871 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10872 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10873 | code_str = bgp_notify_code_str(peer->notify.code); | |
10874 | subcode_str = | |
10875 | bgp_notify_subcode_str(peer->notify.code, | |
10876 | peer->notify.subcode); | |
10877 | vty_out(vty, " Notification %s (%s%s)\n", | |
10878 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10879 | ? "sent" | |
10880 | : "received", | |
10881 | code_str, subcode_str); | |
10882 | } else { | |
e91c24c8 | 10883 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10884 | peer_down_str[(int)peer->last_reset]); |
10885 | } | |
10886 | } | |
10887 | } | |
10888 | ||
10889 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10890 | safi_t safi) | |
10891 | { | |
feb17238 | 10892 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10893 | } |
10894 | ||
10895 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10896 | struct peer *peer, json_object *json_peer, | |
10897 | int max_neighbor_width, bool use_json) | |
10898 | { | |
10899 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10900 | int len; | |
10901 | ||
10902 | if (use_json) { | |
10903 | if (peer_dynamic_neighbor(peer)) | |
10904 | json_object_boolean_true_add(json_peer, | |
10905 | "dynamicPeer"); | |
10906 | if (peer->hostname) | |
10907 | json_object_string_add(json_peer, "hostname", | |
10908 | peer->hostname); | |
10909 | ||
10910 | if (peer->domainname) | |
10911 | json_object_string_add(json_peer, "domainname", | |
10912 | peer->domainname); | |
10913 | json_object_int_add(json_peer, "connectionsEstablished", | |
10914 | peer->established); | |
10915 | json_object_int_add(json_peer, "connectionsDropped", | |
10916 | peer->dropped); | |
10917 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10918 | use_json, json_peer); | |
feb17238 | 10919 | if (peer_established(peer)) |
3577f1c5 DD |
10920 | json_object_string_add(json_peer, "lastResetDueTo", |
10921 | "AFI/SAFI Not Negotiated"); | |
10922 | else | |
10923 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10924 | } else { | |
10925 | dn_flag[1] = '\0'; | |
10926 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10927 | if (peer->hostname | |
892fedb6 | 10928 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10929 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10930 | peer->hostname, peer->host); | |
10931 | else | |
10932 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10933 | ||
10934 | /* pad the neighbor column with spaces */ | |
10935 | if (len < max_neighbor_width) | |
10936 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10937 | " "); | |
e91c24c8 | 10938 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10939 | peer->dropped, |
10940 | peer_uptime(peer->uptime, timebuf, | |
10941 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10942 | if (peer_established(peer)) |
3577f1c5 DD |
10943 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10944 | else | |
10945 | bgp_show_peer_reset(vty, peer, NULL, | |
10946 | false); | |
10947 | } | |
10948 | } | |
c258527b | 10949 | |
cb75bb31 DA |
10950 | /* If the peer's description includes whitespaces |
10951 | * then return the first occurrence. Also strip description | |
10952 | * to the given size if needed. | |
10953 | */ | |
10954 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) | |
10955 | { | |
10956 | static char stripped[BUFSIZ]; | |
10957 | char *pnt; | |
10958 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; | |
10959 | ||
10960 | pnt = strchr(desc, ' '); | |
10961 | if (pnt) | |
10962 | len = size > (uint32_t)(pnt - desc) ? (uint32_t)(pnt - desc) | |
10963 | : size; | |
10964 | ||
10965 | strlcpy(stripped, desc, len + 1); | |
10966 | ||
10967 | return stripped; | |
10968 | } | |
3577f1c5 | 10969 | |
8c1d4cd5 LS |
10970 | /* Determine whether var peer should be filtered out of the summary. */ |
10971 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10972 | struct peer *fpeer, int as_type, | |
10973 | as_t as) | |
10974 | { | |
10975 | ||
10976 | /* filter neighbor XXXX */ | |
10977 | if (fpeer && fpeer != peer) | |
10978 | return true; | |
10979 | ||
10980 | /* filter remote-as (internal|external) */ | |
10981 | if (as_type != AS_UNSPECIFIED) { | |
10982 | if (peer->as_type == AS_SPECIFIED) { | |
10983 | if (as_type == AS_INTERNAL) { | |
10984 | if (peer->as != peer->local_as) | |
10985 | return true; | |
10986 | } else if (peer->as == peer->local_as) | |
10987 | return true; | |
10988 | } else if (as_type != peer->as_type) | |
10989 | return true; | |
10990 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10991 | return true; | |
10992 | ||
10993 | return false; | |
10994 | } | |
10995 | ||
718e3744 | 10996 | /* Show BGP peer's summary information. */ |
d62a17ae | 10997 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10998 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10999 | uint16_t show_flags) |
d62a17ae | 11000 | { |
11001 | struct peer *peer; | |
11002 | struct listnode *node, *nnode; | |
11003 | unsigned int count = 0, dn_count = 0; | |
11004 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
11005 | char neighbor_buf[VTY_BUFSIZ]; | |
11006 | int neighbor_col_default_width = 16; | |
3577f1c5 | 11007 | int len, failed_count = 0; |
ce1944f0 | 11008 | unsigned int filtered_count = 0; |
d62a17ae | 11009 | int max_neighbor_width = 0; |
11010 | int pfx_rcd_safi; | |
3c13337d | 11011 | json_object *json = NULL; |
d62a17ae | 11012 | json_object *json_peer = NULL; |
11013 | json_object *json_peers = NULL; | |
50e05855 | 11014 | struct peer_af *paf; |
d3ada366 | 11015 | struct bgp_filter *filter; |
85eeb029 DA |
11016 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
11017 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
11018 | bool show_established = | |
11019 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
11020 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 11021 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 11022 | |
11023 | /* labeled-unicast routes are installed in the unicast table so in order | |
11024 | * to | |
11025 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
11026 | */ | |
3577f1c5 | 11027 | |
d62a17ae | 11028 | if (safi == SAFI_LABELED_UNICAST) |
11029 | pfx_rcd_safi = SAFI_UNICAST; | |
11030 | else | |
11031 | pfx_rcd_safi = safi; | |
11032 | ||
11033 | if (use_json) { | |
3c13337d | 11034 | json = json_object_new_object(); |
d62a17ae | 11035 | json_peers = json_object_new_object(); |
3577f1c5 | 11036 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
11037 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
11038 | as_type, as)) { | |
ce1944f0 | 11039 | filtered_count++; |
8c1d4cd5 LS |
11040 | count++; |
11041 | continue; | |
11042 | } | |
11043 | ||
3577f1c5 DD |
11044 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
11045 | continue; | |
11046 | ||
11047 | if (peer->afc[afi][safi]) { | |
11048 | /* See if we have at least a single failed peer */ | |
11049 | if (bgp_has_peer_failed(peer, afi, safi)) | |
11050 | failed_count++; | |
11051 | count++; | |
11052 | } | |
11053 | if (peer_dynamic_neighbor(peer)) | |
11054 | dn_count++; | |
11055 | } | |
c258527b | 11056 | |
d62a17ae | 11057 | } else { |
11058 | /* Loop over all neighbors that will be displayed to determine | |
11059 | * how many | |
11060 | * characters are needed for the Neighbor column | |
11061 | */ | |
11062 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
11063 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
11064 | as_type, as)) { | |
ce1944f0 | 11065 | filtered_count++; |
8c1d4cd5 LS |
11066 | count++; |
11067 | continue; | |
11068 | } | |
11069 | ||
d62a17ae | 11070 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
11071 | continue; | |
11072 | ||
11073 | if (peer->afc[afi][safi]) { | |
11074 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
11075 | if (peer_dynamic_neighbor(peer)) | |
11076 | dn_flag[0] = '*'; | |
11077 | ||
11078 | if (peer->hostname | |
892fedb6 DA |
11079 | && CHECK_FLAG(bgp->flags, |
11080 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
11081 | snprintf(neighbor_buf, |
11082 | sizeof(neighbor_buf), | |
11083 | "%s%s(%s) ", dn_flag, | |
11084 | peer->hostname, peer->host); | |
d62a17ae | 11085 | else |
772270f3 QY |
11086 | snprintf(neighbor_buf, |
11087 | sizeof(neighbor_buf), "%s%s ", | |
11088 | dn_flag, peer->host); | |
d62a17ae | 11089 | |
11090 | len = strlen(neighbor_buf); | |
11091 | ||
11092 | if (len > max_neighbor_width) | |
11093 | max_neighbor_width = len; | |
c258527b | 11094 | |
3577f1c5 DD |
11095 | /* See if we have at least a single failed peer */ |
11096 | if (bgp_has_peer_failed(peer, afi, safi)) | |
11097 | failed_count++; | |
11098 | count++; | |
d62a17ae | 11099 | } |
11100 | } | |
f933309e | 11101 | |
d62a17ae | 11102 | /* Originally we displayed the Neighbor column as 16 |
11103 | * characters wide so make that the default | |
11104 | */ | |
11105 | if (max_neighbor_width < neighbor_col_default_width) | |
11106 | max_neighbor_width = neighbor_col_default_width; | |
11107 | } | |
f933309e | 11108 | |
3577f1c5 DD |
11109 | if (show_failed && !failed_count) { |
11110 | if (use_json) { | |
11111 | json_object_int_add(json, "failedPeersCount", 0); | |
11112 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 11113 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
11114 | |
11115 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
11116 | json, JSON_C_TO_STRING_PRETTY)); | |
11117 | json_object_free(json); | |
11118 | } else { | |
11119 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
11120 | } |
11121 | return CMD_SUCCESS; | |
11122 | } | |
c258527b | 11123 | |
3577f1c5 | 11124 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 11125 | filtered_count = 0; |
d62a17ae | 11126 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
11127 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
11128 | continue; | |
11129 | ||
ea47320b DL |
11130 | if (!peer->afc[afi][safi]) |
11131 | continue; | |
d62a17ae | 11132 | |
ea47320b DL |
11133 | if (!count) { |
11134 | unsigned long ents; | |
11135 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 11136 | int64_t vrf_id_ui; |
d62a17ae | 11137 | |
a4d82a8a PZ |
11138 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
11139 | ? -1 | |
11140 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
11141 | |
11142 | /* Usage summary and header */ | |
11143 | if (use_json) { | |
23d0a753 DA |
11144 | char buf[BUFSIZ] = {0}; |
11145 | ||
ea47320b DL |
11146 | json_object_string_add( |
11147 | json, "routerId", | |
23d0a753 DA |
11148 | inet_ntop(AF_INET, &bgp->router_id, buf, |
11149 | sizeof(buf))); | |
60466a63 QY |
11150 | json_object_int_add(json, "as", bgp->as); |
11151 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
11152 | json_object_string_add( |
11153 | json, "vrfName", | |
11154 | (bgp->inst_type | |
11155 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11156 | ? VRF_DEFAULT_NAME |
ea47320b DL |
11157 | : bgp->name); |
11158 | } else { | |
11159 | vty_out(vty, | |
23d0a753 DA |
11160 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
11161 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
11162 | bgp->vrf_id == VRF_UNKNOWN |
11163 | ? -1 | |
11164 | : (int)bgp->vrf_id); | |
ea47320b DL |
11165 | vty_out(vty, "\n"); |
11166 | } | |
d62a17ae | 11167 | |
ea47320b | 11168 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 11169 | if (use_json) { |
ea47320b | 11170 | json_object_int_add( |
60466a63 | 11171 | json, "updateDelayLimit", |
ea47320b | 11172 | bgp->v_update_delay); |
d62a17ae | 11173 | |
ea47320b DL |
11174 | if (bgp->v_update_delay |
11175 | != bgp->v_establish_wait) | |
d62a17ae | 11176 | json_object_int_add( |
11177 | json, | |
ea47320b DL |
11178 | "updateDelayEstablishWait", |
11179 | bgp->v_establish_wait); | |
d62a17ae | 11180 | |
60466a63 | 11181 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11182 | json_object_string_add( |
11183 | json, | |
11184 | "updateDelayFirstNeighbor", | |
11185 | bgp->update_delay_begin_time); | |
11186 | json_object_boolean_true_add( | |
11187 | json, | |
11188 | "updateDelayInProgress"); | |
11189 | } else { | |
11190 | if (bgp->update_delay_over) { | |
d62a17ae | 11191 | json_object_string_add( |
11192 | json, | |
11193 | "updateDelayFirstNeighbor", | |
11194 | bgp->update_delay_begin_time); | |
ea47320b | 11195 | json_object_string_add( |
d62a17ae | 11196 | json, |
ea47320b DL |
11197 | "updateDelayBestpathResumed", |
11198 | bgp->update_delay_end_time); | |
11199 | json_object_string_add( | |
d62a17ae | 11200 | json, |
ea47320b DL |
11201 | "updateDelayZebraUpdateResume", |
11202 | bgp->update_delay_zebra_resume_time); | |
11203 | json_object_string_add( | |
11204 | json, | |
11205 | "updateDelayPeerUpdateResume", | |
11206 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11207 | } |
ea47320b DL |
11208 | } |
11209 | } else { | |
11210 | vty_out(vty, | |
11211 | "Read-only mode update-delay limit: %d seconds\n", | |
11212 | bgp->v_update_delay); | |
11213 | if (bgp->v_update_delay | |
11214 | != bgp->v_establish_wait) | |
d62a17ae | 11215 | vty_out(vty, |
ea47320b DL |
11216 | " Establish wait: %d seconds\n", |
11217 | bgp->v_establish_wait); | |
d62a17ae | 11218 | |
60466a63 | 11219 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11220 | vty_out(vty, |
11221 | " First neighbor established: %s\n", | |
11222 | bgp->update_delay_begin_time); | |
11223 | vty_out(vty, | |
11224 | " Delay in progress\n"); | |
11225 | } else { | |
11226 | if (bgp->update_delay_over) { | |
d62a17ae | 11227 | vty_out(vty, |
11228 | " First neighbor established: %s\n", | |
11229 | bgp->update_delay_begin_time); | |
11230 | vty_out(vty, | |
ea47320b DL |
11231 | " Best-paths resumed: %s\n", |
11232 | bgp->update_delay_end_time); | |
11233 | vty_out(vty, | |
11234 | " zebra update resumed: %s\n", | |
11235 | bgp->update_delay_zebra_resume_time); | |
11236 | vty_out(vty, | |
11237 | " peers update resumed: %s\n", | |
11238 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11239 | } |
11240 | } | |
11241 | } | |
ea47320b | 11242 | } |
d62a17ae | 11243 | |
ea47320b DL |
11244 | if (use_json) { |
11245 | if (bgp_maxmed_onstartup_configured(bgp) | |
11246 | && bgp->maxmed_active) | |
11247 | json_object_boolean_true_add( | |
60466a63 | 11248 | json, "maxMedOnStartup"); |
ea47320b DL |
11249 | if (bgp->v_maxmed_admin) |
11250 | json_object_boolean_true_add( | |
60466a63 | 11251 | json, "maxMedAdministrative"); |
d62a17ae | 11252 | |
ea47320b DL |
11253 | json_object_int_add( |
11254 | json, "tableVersion", | |
60466a63 | 11255 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 11256 | |
60466a63 QY |
11257 | ents = bgp_table_count(bgp->rib[afi][safi]); |
11258 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
11259 | json_object_int_add( |
11260 | json, "ribMemory", | |
9bcb3eef | 11261 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 11262 | |
210ec2a0 | 11263 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
11264 | json_object_int_add(json, "peerCount", ents); |
11265 | json_object_int_add(json, "peerMemory", | |
11266 | ents * sizeof(struct peer)); | |
d62a17ae | 11267 | |
ea47320b DL |
11268 | if ((ents = listcount(bgp->group))) { |
11269 | json_object_int_add( | |
60466a63 | 11270 | json, "peerGroupCount", ents); |
ea47320b DL |
11271 | json_object_int_add( |
11272 | json, "peerGroupMemory", | |
996c9314 LB |
11273 | ents * sizeof(struct |
11274 | peer_group)); | |
ea47320b | 11275 | } |
d62a17ae | 11276 | |
ea47320b DL |
11277 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
11278 | BGP_CONFIG_DAMPENING)) | |
11279 | json_object_boolean_true_add( | |
60466a63 | 11280 | json, "dampeningEnabled"); |
ea47320b | 11281 | } else { |
96c81f66 LS |
11282 | if (!show_terse) { |
11283 | if (bgp_maxmed_onstartup_configured(bgp) | |
11284 | && bgp->maxmed_active) | |
11285 | vty_out(vty, | |
11286 | "Max-med on-startup active\n"); | |
11287 | if (bgp->v_maxmed_admin) | |
11288 | vty_out(vty, | |
11289 | "Max-med administrative active\n"); | |
d62a17ae | 11290 | |
96c81f66 LS |
11291 | vty_out(vty, |
11292 | "BGP table version %" PRIu64 | |
11293 | "\n", | |
11294 | bgp_table_version( | |
11295 | bgp->rib[afi][safi])); | |
ea47320b | 11296 | |
96c81f66 LS |
11297 | ents = bgp_table_count( |
11298 | bgp->rib[afi][safi]); | |
d62a17ae | 11299 | vty_out(vty, |
96c81f66 | 11300 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 11301 | ents, |
11302 | mtype_memstr( | |
11303 | memstrbuf, | |
11304 | sizeof(memstrbuf), | |
96c81f66 LS |
11305 | ents |
11306 | * sizeof( | |
11307 | struct | |
11308 | bgp_dest))); | |
d62a17ae | 11309 | |
96c81f66 LS |
11310 | /* Peer related usage */ |
11311 | ents = bgp->af_peer_count[afi][safi]; | |
11312 | vty_out(vty, | |
11313 | "Peers %ld, using %s of memory\n", | |
11314 | ents, | |
11315 | mtype_memstr( | |
11316 | memstrbuf, | |
11317 | sizeof(memstrbuf), | |
11318 | ents | |
11319 | * sizeof( | |
11320 | struct | |
11321 | peer))); | |
d62a17ae | 11322 | |
96c81f66 LS |
11323 | if ((ents = listcount(bgp->group))) |
11324 | vty_out(vty, | |
11325 | "Peer groups %ld, using %s of memory\n", | |
11326 | ents, | |
11327 | mtype_memstr( | |
11328 | memstrbuf, | |
11329 | sizeof(memstrbuf), | |
11330 | ents | |
11331 | * sizeof( | |
11332 | struct | |
11333 | peer_group))); | |
11334 | ||
11335 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
11336 | BGP_CONFIG_DAMPENING)) | |
11337 | vty_out(vty, | |
11338 | "Dampening enabled.\n"); | |
11339 | } | |
11340 | if (show_failed) { | |
11341 | vty_out(vty, "\n"); | |
11342 | ||
11343 | /* Subtract 8 here because 'Neighbor' is | |
11344 | * 8 characters */ | |
11345 | vty_out(vty, "Neighbor"); | |
11346 | vty_out(vty, "%*s", | |
11347 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
11348 | vty_out(vty, |
11349 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 11350 | } |
d62a17ae | 11351 | } |
ea47320b | 11352 | } |
d62a17ae | 11353 | |
d55811cc | 11354 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 11355 | filter = &peer->filter[afi][safi]; |
db92d226 | 11356 | |
ea47320b | 11357 | count++; |
3577f1c5 DD |
11358 | /* Works for both failed & successful cases */ |
11359 | if (peer_dynamic_neighbor(peer)) | |
11360 | dn_count++; | |
d62a17ae | 11361 | |
ea47320b | 11362 | if (use_json) { |
3577f1c5 | 11363 | json_peer = NULL; |
8c1d4cd5 | 11364 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11365 | as_type, as)) { |
11366 | filtered_count++; | |
8c1d4cd5 | 11367 | continue; |
ce1944f0 | 11368 | } |
3577f1c5 DD |
11369 | if (show_failed && |
11370 | bgp_has_peer_failed(peer, afi, safi)) { | |
11371 | json_peer = json_object_new_object(); | |
11372 | bgp_show_failed_summary(vty, bgp, peer, | |
11373 | json_peer, 0, use_json); | |
11374 | } else if (!show_failed) { | |
10b49f14 | 11375 | if (show_established |
ce1944f0 LS |
11376 | && bgp_has_peer_failed(peer, afi, safi)) { |
11377 | filtered_count++; | |
10b49f14 | 11378 | continue; |
ce1944f0 | 11379 | } |
10b49f14 | 11380 | |
3577f1c5 DD |
11381 | json_peer = json_object_new_object(); |
11382 | if (peer_dynamic_neighbor(peer)) { | |
11383 | json_object_boolean_true_add(json_peer, | |
11384 | "dynamicPeer"); | |
11385 | } | |
d62a17ae | 11386 | |
3577f1c5 DD |
11387 | if (peer->hostname) |
11388 | json_object_string_add(json_peer, "hostname", | |
11389 | peer->hostname); | |
11390 | ||
11391 | if (peer->domainname) | |
11392 | json_object_string_add(json_peer, "domainname", | |
11393 | peer->domainname); | |
11394 | ||
11395 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
11396 | json_object_int_add( |
11397 | json_peer, "localAs", | |
11398 | peer->change_local_as | |
11399 | ? peer->change_local_as | |
11400 | : peer->local_as); | |
3577f1c5 DD |
11401 | json_object_int_add(json_peer, "version", 4); |
11402 | json_object_int_add(json_peer, "msgRcvd", | |
11403 | PEER_TOTAL_RX(peer)); | |
11404 | json_object_int_add(json_peer, "msgSent", | |
11405 | PEER_TOTAL_TX(peer)); | |
11406 | ||
43aa5965 QY |
11407 | atomic_size_t outq_count, inq_count; |
11408 | outq_count = atomic_load_explicit( | |
11409 | &peer->obuf->count, | |
11410 | memory_order_relaxed); | |
11411 | inq_count = atomic_load_explicit( | |
11412 | &peer->ibuf->count, | |
11413 | memory_order_relaxed); | |
11414 | ||
3577f1c5 DD |
11415 | json_object_int_add(json_peer, "tableVersion", |
11416 | peer->version[afi][safi]); | |
11417 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
11418 | outq_count); |
11419 | json_object_int_add(json_peer, "inq", | |
11420 | inq_count); | |
3577f1c5 DD |
11421 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
11422 | use_json, json_peer); | |
11423 | ||
3577f1c5 DD |
11424 | json_object_int_add(json_peer, "pfxRcd", |
11425 | peer->pcount[afi][pfx_rcd_safi]); | |
11426 | ||
3577f1c5 | 11427 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
11428 | json_object_int_add( |
11429 | json_peer, "pfxSnt", | |
11430 | (PAF_SUBGRP(paf))->scount); | |
11431 | else | |
11432 | json_object_int_add(json_peer, "pfxSnt", | |
11433 | 0); | |
0e1f8ab5 DA |
11434 | |
11435 | /* BGP FSM state */ | |
cb9196e7 | 11436 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
11437 | || CHECK_FLAG(peer->bgp->flags, |
11438 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
11439 | json_object_string_add(json_peer, |
11440 | "state", | |
3577f1c5 DD |
11441 | "Idle (Admin)"); |
11442 | else if (peer->afc_recv[afi][safi]) | |
11443 | json_object_string_add( | |
0e1f8ab5 DA |
11444 | json_peer, "state", |
11445 | lookup_msg(bgp_status_msg, | |
11446 | peer->status, NULL)); | |
11447 | else if (CHECK_FLAG( | |
11448 | peer->sflags, | |
11449 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11450 | json_object_string_add(json_peer, | |
11451 | "state", | |
3577f1c5 DD |
11452 | "Idle (PfxCt)"); |
11453 | else | |
11454 | json_object_string_add( | |
0e1f8ab5 DA |
11455 | json_peer, "state", |
11456 | lookup_msg(bgp_status_msg, | |
11457 | peer->status, NULL)); | |
11458 | ||
11459 | /* BGP peer state */ | |
11460 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
11461 | || CHECK_FLAG(peer->bgp->flags, | |
11462 | BGP_FLAG_SHUTDOWN)) | |
11463 | json_object_string_add(json_peer, | |
11464 | "peerState", | |
11465 | "Admin"); | |
11466 | else if (CHECK_FLAG( | |
11467 | peer->sflags, | |
11468 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11469 | json_object_string_add(json_peer, | |
11470 | "peerState", | |
11471 | "PfxCt"); | |
11472 | else if (CHECK_FLAG(peer->flags, | |
11473 | PEER_FLAG_PASSIVE)) | |
11474 | json_object_string_add(json_peer, | |
11475 | "peerState", | |
11476 | "Passive"); | |
11477 | else if (CHECK_FLAG(peer->sflags, | |
11478 | PEER_STATUS_NSF_WAIT)) | |
11479 | json_object_string_add(json_peer, | |
11480 | "peerState", | |
11481 | "NSF passive"); | |
11482 | else if (CHECK_FLAG( | |
11483 | peer->bgp->flags, | |
11484 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11485 | && (!bgp_inbound_policy_exists(peer, | |
11486 | filter) | |
11487 | || !bgp_outbound_policy_exists( | |
11488 | peer, filter))) | |
11489 | json_object_string_add(json_peer, | |
11490 | "peerState", | |
11491 | "Policy"); | |
11492 | else | |
11493 | json_object_string_add( | |
11494 | json_peer, "peerState", "OK"); | |
11495 | ||
200116db DD |
11496 | json_object_int_add(json_peer, "connectionsEstablished", |
11497 | peer->established); | |
11498 | json_object_int_add(json_peer, "connectionsDropped", | |
11499 | peer->dropped); | |
aa72bd7e PG |
11500 | if (peer->desc) |
11501 | json_object_string_add( | |
11502 | json_peer, "desc", peer->desc); | |
b4e9dcba | 11503 | } |
3577f1c5 DD |
11504 | /* Avoid creating empty peer dicts in JSON */ |
11505 | if (json_peer == NULL) | |
11506 | continue; | |
ea47320b DL |
11507 | |
11508 | if (peer->conf_if) | |
60466a63 | 11509 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
11510 | "interface"); |
11511 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
11512 | json_object_string_add(json_peer, "idType", |
11513 | "ipv4"); | |
ea47320b | 11514 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
11515 | json_object_string_add(json_peer, "idType", |
11516 | "ipv6"); | |
ea47320b DL |
11517 | json_object_object_add(json_peers, peer->host, |
11518 | json_peer); | |
11519 | } else { | |
8c1d4cd5 | 11520 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11521 | as_type, as)) { |
11522 | filtered_count++; | |
8c1d4cd5 | 11523 | continue; |
ce1944f0 | 11524 | } |
3577f1c5 DD |
11525 | if (show_failed && |
11526 | bgp_has_peer_failed(peer, afi, safi)) { | |
11527 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
11528 | max_neighbor_width, | |
11529 | use_json); | |
11530 | } else if (!show_failed) { | |
10b49f14 | 11531 | if (show_established |
ce1944f0 LS |
11532 | && bgp_has_peer_failed(peer, afi, safi)) { |
11533 | filtered_count++; | |
10b49f14 | 11534 | continue; |
ce1944f0 | 11535 | } |
96c81f66 LS |
11536 | |
11537 | if ((count - filtered_count) == 1) { | |
11538 | /* display headline before the first | |
11539 | * neighbor line */ | |
11540 | vty_out(vty, "\n"); | |
11541 | ||
11542 | /* Subtract 8 here because 'Neighbor' is | |
11543 | * 8 characters */ | |
11544 | vty_out(vty, "Neighbor"); | |
11545 | vty_out(vty, "%*s", | |
11546 | max_neighbor_width - 8, " "); | |
11547 | vty_out(vty, | |
11548 | show_wide | |
11549 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
11550 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
11551 | } | |
11552 | ||
3577f1c5 DD |
11553 | memset(dn_flag, '\0', sizeof(dn_flag)); |
11554 | if (peer_dynamic_neighbor(peer)) { | |
11555 | dn_flag[0] = '*'; | |
11556 | } | |
d62a17ae | 11557 | |
3577f1c5 | 11558 | if (peer->hostname |
892fedb6 DA |
11559 | && CHECK_FLAG(bgp->flags, |
11560 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 11561 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
11562 | peer->hostname, |
11563 | peer->host); | |
d62a17ae | 11564 | else |
3577f1c5 DD |
11565 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
11566 | ||
11567 | /* pad the neighbor column with spaces */ | |
11568 | if (len < max_neighbor_width) | |
11569 | vty_out(vty, "%*s", max_neighbor_width - len, | |
11570 | " "); | |
11571 | ||
43aa5965 QY |
11572 | atomic_size_t outq_count, inq_count; |
11573 | outq_count = atomic_load_explicit( | |
11574 | &peer->obuf->count, | |
11575 | memory_order_relaxed); | |
11576 | inq_count = atomic_load_explicit( | |
11577 | &peer->ibuf->count, | |
11578 | memory_order_relaxed); | |
11579 | ||
85eeb029 DA |
11580 | if (show_wide) |
11581 | vty_out(vty, | |
11582 | "4 %10u %10u %9u %9u %8" PRIu64 | |
11583 | " %4zu %4zu %8s", | |
11584 | peer->as, | |
11585 | peer->change_local_as | |
11586 | ? peer->change_local_as | |
11587 | : peer->local_as, | |
11588 | PEER_TOTAL_RX(peer), | |
11589 | PEER_TOTAL_TX(peer), | |
11590 | peer->version[afi][safi], | |
11591 | inq_count, outq_count, | |
11592 | peer_uptime(peer->uptime, | |
11593 | timebuf, | |
11594 | BGP_UPTIME_LEN, 0, | |
11595 | NULL)); | |
11596 | else | |
11597 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
11598 | " %4zu %4zu %8s", | |
11599 | peer->as, PEER_TOTAL_RX(peer), | |
11600 | PEER_TOTAL_TX(peer), | |
11601 | peer->version[afi][safi], | |
11602 | inq_count, outq_count, | |
11603 | peer_uptime(peer->uptime, | |
11604 | timebuf, | |
11605 | BGP_UPTIME_LEN, 0, | |
11606 | NULL)); | |
3577f1c5 | 11607 | |
feb17238 | 11608 | if (peer_established(peer)) { |
d3ada366 DA |
11609 | if (peer->afc_recv[afi][safi]) { |
11610 | if (CHECK_FLAG( | |
11611 | bgp->flags, | |
11612 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11613 | && !bgp_inbound_policy_exists( | |
11614 | peer, filter)) | |
11615 | vty_out(vty, " %12s", | |
11616 | "(Policy)"); | |
11617 | else | |
11618 | vty_out(vty, | |
6cde4b45 | 11619 | " %12u", |
d3ada366 DA |
11620 | peer->pcount |
11621 | [afi] | |
11622 | [pfx_rcd_safi]); | |
11623 | } else { | |
749d0f27 | 11624 | vty_out(vty, " NoNeg"); |
d3ada366 | 11625 | } |
db92d226 | 11626 | |
d3ada366 DA |
11627 | if (paf && PAF_SUBGRP(paf)) { |
11628 | if (CHECK_FLAG( | |
11629 | bgp->flags, | |
11630 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11631 | && !bgp_outbound_policy_exists( | |
11632 | peer, filter)) | |
11633 | vty_out(vty, " %8s", | |
11634 | "(Policy)"); | |
11635 | else | |
11636 | vty_out(vty, | |
6cde4b45 | 11637 | " %8u", |
d3ada366 DA |
11638 | (PAF_SUBGRP( |
11639 | paf)) | |
11640 | ->scount); | |
749d0f27 DA |
11641 | } else { |
11642 | vty_out(vty, " NoNeg"); | |
d3ada366 | 11643 | } |
db92d226 | 11644 | } else { |
736b68f3 DS |
11645 | if (CHECK_FLAG(peer->flags, |
11646 | PEER_FLAG_SHUTDOWN) | |
11647 | || CHECK_FLAG(peer->bgp->flags, | |
11648 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
11649 | vty_out(vty, " Idle (Admin)"); |
11650 | else if (CHECK_FLAG( | |
11651 | peer->sflags, | |
11652 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11653 | vty_out(vty, " Idle (PfxCt)"); | |
11654 | else | |
11655 | vty_out(vty, " %12s", | |
11656 | lookup_msg(bgp_status_msg, | |
11657 | peer->status, NULL)); | |
db92d226 | 11658 | |
6cde4b45 | 11659 | vty_out(vty, " %8u", 0); |
3577f1c5 | 11660 | } |
aa72bd7e | 11661 | if (peer->desc) |
cb75bb31 DA |
11662 | vty_out(vty, " %s", |
11663 | bgp_peer_description_stripped( | |
85eeb029 DA |
11664 | peer->desc, |
11665 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
11666 | else |
11667 | vty_out(vty, " N/A"); | |
3577f1c5 | 11668 | vty_out(vty, "\n"); |
d62a17ae | 11669 | } |
3577f1c5 | 11670 | |
d62a17ae | 11671 | } |
11672 | } | |
f933309e | 11673 | |
d62a17ae | 11674 | if (use_json) { |
11675 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11676 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
11677 | json_object_int_add(json, "displayedPeers", |
11678 | count - filtered_count); | |
d62a17ae | 11679 | json_object_int_add(json, "totalPeers", count); |
11680 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11681 | ||
3577f1c5 DD |
11682 | if (!show_failed) |
11683 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11684 | |
996c9314 LB |
11685 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11686 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11687 | json_object_free(json); |
11688 | } else { | |
ce1944f0 | 11689 | if (count) { |
96c81f66 LS |
11690 | if (filtered_count == count) |
11691 | vty_out(vty, "\n%% No matching neighbor\n"); | |
11692 | else { | |
11693 | if (show_failed) | |
11694 | vty_out(vty, "\nDisplayed neighbors %d", | |
11695 | failed_count); | |
11696 | else if (as_type != AS_UNSPECIFIED || as | |
11697 | || fpeer || show_established) | |
ce1944f0 LS |
11698 | vty_out(vty, "\nDisplayed neighbors %d", |
11699 | count - filtered_count); | |
96c81f66 LS |
11700 | |
11701 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
11702 | count); | |
ce1944f0 | 11703 | } |
ce1944f0 | 11704 | } else { |
d6ceaca3 | 11705 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11706 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11707 | } |
b05a1c8b | 11708 | |
d6ceaca3 | 11709 | if (dn_count) { |
d62a17ae | 11710 | vty_out(vty, "* - dynamic neighbor\n"); |
11711 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11712 | dn_count, bgp->dynamic_neighbors_limit); | |
11713 | } | |
11714 | } | |
1ff9a340 | 11715 | |
d62a17ae | 11716 | return CMD_SUCCESS; |
718e3744 | 11717 | } |
11718 | ||
d62a17ae | 11719 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 11720 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 11721 | as_t as, uint16_t show_flags) |
d62a17ae | 11722 | { |
11723 | int is_first = 1; | |
11724 | int afi_wildcard = (afi == AFI_MAX); | |
11725 | int safi_wildcard = (safi == SAFI_MAX); | |
11726 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11727 | bool nbr_output = false; |
85eeb029 | 11728 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11729 | |
11730 | if (use_json && is_wildcard) | |
11731 | vty_out(vty, "{\n"); | |
11732 | if (afi_wildcard) | |
11733 | afi = 1; /* AFI_IP */ | |
11734 | while (afi < AFI_MAX) { | |
11735 | if (safi_wildcard) | |
11736 | safi = 1; /* SAFI_UNICAST */ | |
11737 | while (safi < SAFI_MAX) { | |
318cac96 | 11738 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11739 | nbr_output = true; |
f86897b9 | 11740 | |
d62a17ae | 11741 | if (is_wildcard) { |
11742 | /* | |
11743 | * So limit output to those afi/safi | |
11744 | * pairs that | |
11745 | * actualy have something interesting in | |
11746 | * them | |
11747 | */ | |
11748 | if (use_json) { | |
d62a17ae | 11749 | if (!is_first) |
11750 | vty_out(vty, ",\n"); | |
11751 | else | |
11752 | is_first = 0; | |
11753 | ||
11754 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11755 | get_afi_safi_str(afi, |
11756 | safi, | |
11757 | true)); | |
d62a17ae | 11758 | } else { |
6cac2fcc LS |
11759 | vty_out(vty, |
11760 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
11761 | get_afi_safi_str(afi, |
11762 | safi, | |
6cac2fcc LS |
11763 | false), |
11764 | bgp->name_pretty); | |
d62a17ae | 11765 | } |
11766 | } | |
8c1d4cd5 LS |
11767 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
11768 | as_type, as, show_flags); | |
d62a17ae | 11769 | } |
11770 | safi++; | |
d62a17ae | 11771 | if (!safi_wildcard) |
11772 | safi = SAFI_MAX; | |
11773 | } | |
11774 | afi++; | |
ee851c8c | 11775 | if (!afi_wildcard) |
d62a17ae | 11776 | afi = AFI_MAX; |
11777 | } | |
11778 | ||
11779 | if (use_json && is_wildcard) | |
11780 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11781 | else if (!nbr_output) { |
11782 | if (use_json) | |
11783 | vty_out(vty, "{}\n"); | |
11784 | else | |
6cac2fcc LS |
11785 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
11786 | bgp->name_pretty); | |
ca61fd25 | 11787 | } |
d62a17ae | 11788 | } |
11789 | ||
11790 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
11791 | safi_t safi, |
11792 | const char *neighbor, | |
11793 | int as_type, as_t as, | |
96c81f66 | 11794 | uint16_t show_flags) |
d62a17ae | 11795 | { |
11796 | struct listnode *node, *nnode; | |
11797 | struct bgp *bgp; | |
8c1d4cd5 | 11798 | struct peer *fpeer = NULL; |
d62a17ae | 11799 | int is_first = 1; |
9f049418 | 11800 | bool nbr_output = false; |
85eeb029 | 11801 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11802 | |
11803 | if (use_json) | |
11804 | vty_out(vty, "{\n"); | |
11805 | ||
11806 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11807 | nbr_output = true; |
d62a17ae | 11808 | if (use_json) { |
d62a17ae | 11809 | if (!is_first) |
11810 | vty_out(vty, ",\n"); | |
11811 | else | |
11812 | is_first = 0; | |
11813 | ||
11814 | vty_out(vty, "\"%s\":", | |
11815 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11816 | ? VRF_DEFAULT_NAME |
d62a17ae | 11817 | : bgp->name); |
d62a17ae | 11818 | } |
8c1d4cd5 LS |
11819 | if (neighbor) { |
11820 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11821 | use_json); | |
11822 | if (!fpeer) | |
11823 | continue; | |
11824 | } | |
11825 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11826 | as, show_flags); | |
d62a17ae | 11827 | } |
11828 | ||
11829 | if (use_json) | |
11830 | vty_out(vty, "}\n"); | |
9f049418 DS |
11831 | else if (!nbr_output) |
11832 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11833 | } |
11834 | ||
11835 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11836 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11837 | as_t as, uint16_t show_flags) |
d62a17ae | 11838 | { |
11839 | struct bgp *bgp; | |
85eeb029 | 11840 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11841 | struct peer *fpeer = NULL; |
d62a17ae | 11842 | |
11843 | if (name) { | |
11844 | if (strmatch(name, "all")) { | |
85eeb029 | 11845 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11846 | neighbor, as_type, |
11847 | as, show_flags); | |
d62a17ae | 11848 | return CMD_SUCCESS; |
11849 | } else { | |
11850 | bgp = bgp_lookup_by_name(name); | |
11851 | ||
11852 | if (!bgp) { | |
11853 | if (use_json) | |
11854 | vty_out(vty, "{}\n"); | |
11855 | else | |
11856 | vty_out(vty, | |
ca61fd25 | 11857 | "%% BGP instance not found\n"); |
d62a17ae | 11858 | return CMD_WARNING; |
11859 | } | |
11860 | ||
8c1d4cd5 LS |
11861 | if (neighbor) { |
11862 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11863 | use_json); | |
11864 | if (!fpeer) | |
11865 | return CMD_WARNING; | |
11866 | } | |
11867 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11868 | as_type, as, show_flags); | |
d62a17ae | 11869 | return CMD_SUCCESS; |
11870 | } | |
11871 | } | |
11872 | ||
11873 | bgp = bgp_get_default(); | |
11874 | ||
8c1d4cd5 LS |
11875 | if (bgp) { |
11876 | if (neighbor) { | |
11877 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11878 | use_json); | |
11879 | if (!fpeer) | |
11880 | return CMD_WARNING; | |
11881 | } | |
11882 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11883 | as, show_flags); | |
11884 | } else { | |
ca61fd25 DS |
11885 | if (use_json) |
11886 | vty_out(vty, "{}\n"); | |
11887 | else | |
11888 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11889 | return CMD_WARNING; |
11890 | } | |
d62a17ae | 11891 | |
11892 | return CMD_SUCCESS; | |
4fb25c53 DW |
11893 | } |
11894 | ||
716b2d8a | 11895 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11896 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11897 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11898 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11899 | "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <(1-4294967295)|internal|external>>] [terse] [wide] [json$uj]", |
8c1d4cd5 LS |
11900 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11901 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11902 | "Display the entries for all address families\n" | |
11903 | "Summary of BGP neighbor status\n" | |
11904 | "Show only sessions in Established state\n" | |
11905 | "Show only sessions not in Established state\n" | |
11906 | "Show only the specified neighbor session\n" | |
11907 | "Neighbor to display information about\n" | |
11908 | "Neighbor to display information about\n" | |
11909 | "Neighbor on BGP configured interface\n" | |
11910 | "Show only the specified remote AS sessions\n" | |
11911 | "AS number\n" | |
11912 | "Internal (iBGP) AS sessions\n" | |
11913 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11914 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11915 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11916 | { |
d62a17ae | 11917 | char *vrf = NULL; |
11918 | afi_t afi = AFI_MAX; | |
11919 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11920 | as_t as = 0; /* 0 means AS filter not set */ |
11921 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11922 | uint16_t show_flags = 0; |
d62a17ae | 11923 | |
11924 | int idx = 0; | |
11925 | ||
11926 | /* show [ip] bgp */ | |
96f3485c | 11927 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11928 | afi = AFI_IP; |
9a8bdf1c PG |
11929 | /* [<vrf> VIEWVRFNAME] */ |
11930 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11931 | vrf = argv[idx + 1]->arg; | |
11932 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11933 | vrf = NULL; | |
11934 | } else if (argv_find(argv, argc, "view", &idx)) | |
11935 | /* [<view> VIEWVRFNAME] */ | |
11936 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11937 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11938 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11939 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11940 | } | |
11941 | ||
3577f1c5 | 11942 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11943 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11944 | ||
10b49f14 | 11945 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11946 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11947 | ||
8c1d4cd5 LS |
11948 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11949 | if (argv[idx + 1]->arg[0] == 'i') | |
11950 | as_type = AS_INTERNAL; | |
11951 | else if (argv[idx + 1]->arg[0] == 'e') | |
11952 | as_type = AS_EXTERNAL; | |
11953 | else | |
11954 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11955 | } | |
11956 | ||
96c81f66 LS |
11957 | if (argv_find(argv, argc, "terse", &idx)) |
11958 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11959 | ||
85eeb029 DA |
11960 | if (argv_find(argv, argc, "wide", &idx)) |
11961 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11962 | ||
11963 | if (argv_find(argv, argc, "json", &idx)) | |
11964 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11965 | |
8c1d4cd5 LS |
11966 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11967 | show_flags); | |
d62a17ae | 11968 | } |
11969 | ||
5cb5f4d0 | 11970 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11971 | { |
5cb5f4d0 DD |
11972 | if (for_json) |
11973 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11974 | else |
5cb5f4d0 | 11975 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11976 | } |
11977 | ||
d62a17ae | 11978 | |
11979 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11980 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11981 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11982 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11983 | bool use_json, json_object *json_pref) |
d62a17ae | 11984 | { |
11985 | /* Send-Mode */ | |
11986 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11987 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11988 | if (use_json) { | |
11989 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11990 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11991 | json_object_string_add(json_pref, "sendMode", | |
11992 | "advertisedAndReceived"); | |
11993 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11994 | json_object_string_add(json_pref, "sendMode", | |
11995 | "advertised"); | |
11996 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11997 | json_object_string_add(json_pref, "sendMode", | |
11998 | "received"); | |
11999 | } else { | |
12000 | vty_out(vty, " Send-mode: "); | |
12001 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
12002 | vty_out(vty, "advertised"); | |
12003 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
12004 | vty_out(vty, "%sreceived", | |
12005 | CHECK_FLAG(p->af_cap[afi][safi], | |
12006 | adv_smcap) | |
12007 | ? ", " | |
12008 | : ""); | |
12009 | vty_out(vty, "\n"); | |
12010 | } | |
12011 | } | |
12012 | ||
12013 | /* Receive-Mode */ | |
12014 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
12015 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
12016 | if (use_json) { | |
12017 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
12018 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
12019 | json_object_string_add(json_pref, "recvMode", | |
12020 | "advertisedAndReceived"); | |
12021 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
12022 | json_object_string_add(json_pref, "recvMode", | |
12023 | "advertised"); | |
12024 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
12025 | json_object_string_add(json_pref, "recvMode", | |
12026 | "received"); | |
12027 | } else { | |
12028 | vty_out(vty, " Receive-mode: "); | |
12029 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
12030 | vty_out(vty, "advertised"); | |
12031 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
12032 | vty_out(vty, "%sreceived", | |
12033 | CHECK_FLAG(p->af_cap[afi][safi], | |
12034 | adv_rmcap) | |
12035 | ? ", " | |
12036 | : ""); | |
12037 | vty_out(vty, "\n"); | |
12038 | } | |
12039 | } | |
12040 | } | |
12041 | ||
13909c4f DS |
12042 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
12043 | struct peer *p, | |
12044 | bool use_json, | |
12045 | json_object *json) | |
2986cac2 | 12046 | { |
08c2d52a | 12047 | bool rbit_status = false; |
2986cac2 | 12048 | |
12049 | if (!use_json) | |
a53ca37b | 12050 | vty_out(vty, "\n R bit: "); |
2986cac2 | 12051 | |
13909c4f DS |
12052 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
12053 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 12054 | && (peer_established(p))) { |
2986cac2 | 12055 | |
12056 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 12057 | rbit_status = true; |
2986cac2 | 12058 | else |
08c2d52a | 12059 | rbit_status = false; |
2986cac2 | 12060 | } |
12061 | ||
12062 | if (rbit_status) { | |
12063 | if (use_json) | |
13909c4f | 12064 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 12065 | else |
12066 | vty_out(vty, "True\n"); | |
12067 | } else { | |
12068 | if (use_json) | |
13909c4f | 12069 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 12070 | else |
12071 | vty_out(vty, "False\n"); | |
12072 | } | |
12073 | } | |
12074 | ||
13909c4f DS |
12075 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
12076 | struct peer *peer, | |
12077 | bool use_json, | |
12078 | json_object *json) | |
2986cac2 | 12079 | { |
2bb5d39b | 12080 | const char *mode = "NotApplicable"; |
2986cac2 | 12081 | |
12082 | if (!use_json) | |
a53ca37b | 12083 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 12084 | |
13909c4f | 12085 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 12086 | && (peer_established(peer))) { |
2986cac2 | 12087 | |
13909c4f DS |
12088 | if ((peer->nsf_af_count == 0) |
12089 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12090 | |
2986cac2 | 12091 | mode = "Disable"; |
12092 | ||
13909c4f DS |
12093 | } else if (peer->nsf_af_count == 0 |
12094 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12095 | |
2986cac2 | 12096 | mode = "Helper"; |
12097 | ||
13909c4f DS |
12098 | } else if (peer->nsf_af_count != 0 |
12099 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12100 | |
2986cac2 | 12101 | mode = "Restart"; |
2986cac2 | 12102 | } |
12103 | } | |
12104 | ||
12105 | if (use_json) { | |
13909c4f | 12106 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 12107 | } else |
12108 | vty_out(vty, mode, "\n"); | |
12109 | } | |
12110 | ||
13909c4f DS |
12111 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
12112 | struct peer *p, | |
12113 | bool use_json, | |
12114 | json_object *json) | |
2986cac2 | 12115 | { |
12116 | const char *mode = "Invalid"; | |
12117 | ||
12118 | if (!use_json) | |
a53ca37b | 12119 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 12120 | |
12121 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
12122 | mode = "Helper"; | |
12123 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
12124 | mode = "Restart"; | |
12125 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
12126 | mode = "Disable"; | |
2ba1fe69 | 12127 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 12128 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
12129 | mode = "Helper*"; | |
12130 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
12131 | mode = "Restart*"; | |
12132 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
12133 | mode = "Disable*"; | |
12134 | else | |
12135 | mode = "Invalid*"; | |
2ba1fe69 | 12136 | } |
2986cac2 | 12137 | |
12138 | if (use_json) { | |
13909c4f | 12139 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 12140 | } else { |
12141 | vty_out(vty, mode, "\n"); | |
12142 | } | |
12143 | } | |
12144 | ||
13909c4f DS |
12145 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
12146 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 12147 | { |
2ba1fe69 | 12148 | afi_t afi; |
12149 | safi_t safi; | |
2986cac2 | 12150 | json_object *json_afi_safi = NULL; |
12151 | json_object *json_timer = NULL; | |
12152 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 12153 | bool eor_flag = false; |
2986cac2 | 12154 | |
12155 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
12156 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
12157 | if (!peer->afc[afi][safi]) |
12158 | continue; | |
2986cac2 | 12159 | |
13909c4f DS |
12160 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
12161 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
12162 | continue; | |
9e3b51a7 | 12163 | |
13909c4f DS |
12164 | if (use_json) { |
12165 | json_afi_safi = json_object_new_object(); | |
12166 | json_endofrib_status = json_object_new_object(); | |
12167 | json_timer = json_object_new_object(); | |
12168 | } | |
2986cac2 | 12169 | |
13909c4f DS |
12170 | if (peer->eor_stime[afi][safi] |
12171 | >= peer->pkt_stime[afi][safi]) | |
12172 | eor_flag = true; | |
12173 | else | |
12174 | eor_flag = false; | |
2986cac2 | 12175 | |
13909c4f | 12176 | if (!use_json) { |
a53ca37b | 12177 | vty_out(vty, " %s:\n", |
13909c4f | 12178 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 12179 | |
a53ca37b | 12180 | vty_out(vty, " F bit: "); |
698ba8d0 | 12181 | } |
2986cac2 | 12182 | |
13909c4f DS |
12183 | if (peer->nsf[afi][safi] |
12184 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
12185 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 12186 | |
13909c4f DS |
12187 | if (use_json) { |
12188 | json_object_boolean_true_add( | |
2986cac2 | 12189 | json_afi_safi, "fBit"); |
13909c4f DS |
12190 | } else |
12191 | vty_out(vty, "True\n"); | |
12192 | } else { | |
12193 | if (use_json) | |
12194 | json_object_boolean_false_add( | |
12195 | json_afi_safi, "fBit"); | |
12196 | else | |
12197 | vty_out(vty, "False\n"); | |
12198 | } | |
2986cac2 | 12199 | |
13909c4f | 12200 | if (!use_json) |
a53ca37b | 12201 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 12202 | |
13909c4f DS |
12203 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12204 | PEER_STATUS_EOR_SEND)) { | |
12205 | if (use_json) { | |
12206 | json_object_boolean_true_add( | |
2986cac2 | 12207 | json_endofrib_status, |
13909c4f | 12208 | "endOfRibSend"); |
9e3b51a7 | 12209 | |
13909c4f DS |
12210 | PRINT_EOR_JSON(eor_flag); |
12211 | } else { | |
12212 | vty_out(vty, "Yes\n"); | |
12213 | vty_out(vty, | |
a53ca37b | 12214 | " End-of-RIB sent after update: "); |
2986cac2 | 12215 | |
13909c4f DS |
12216 | PRINT_EOR(eor_flag); |
12217 | } | |
12218 | } else { | |
12219 | if (use_json) { | |
12220 | json_object_boolean_false_add( | |
2986cac2 | 12221 | json_endofrib_status, |
13909c4f DS |
12222 | "endOfRibSend"); |
12223 | json_object_boolean_false_add( | |
9e3b51a7 | 12224 | json_endofrib_status, |
13909c4f DS |
12225 | "endOfRibSentAfterUpdate"); |
12226 | } else { | |
12227 | vty_out(vty, "No\n"); | |
12228 | vty_out(vty, | |
a53ca37b | 12229 | " End-of-RIB sent after update: "); |
13909c4f | 12230 | vty_out(vty, "No\n"); |
2986cac2 | 12231 | } |
13909c4f | 12232 | } |
2986cac2 | 12233 | |
a53ca37b DA |
12234 | if (!use_json) |
12235 | vty_out(vty, " End-of-RIB received: "); | |
12236 | ||
12237 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
12238 | PEER_STATUS_EOR_RECEIVED)) { | |
12239 | if (use_json) | |
12240 | json_object_boolean_true_add( | |
12241 | json_endofrib_status, | |
12242 | "endOfRibRecv"); | |
12243 | else | |
12244 | vty_out(vty, "Yes\n"); | |
12245 | } else { | |
12246 | if (use_json) | |
12247 | json_object_boolean_false_add( | |
12248 | json_endofrib_status, | |
12249 | "endOfRibRecv"); | |
12250 | else | |
12251 | vty_out(vty, "No\n"); | |
12252 | } | |
12253 | ||
13909c4f DS |
12254 | if (use_json) { |
12255 | json_object_int_add(json_timer, | |
12256 | "stalePathTimer", | |
12257 | peer->bgp->stalepath_time); | |
2986cac2 | 12258 | |
13909c4f DS |
12259 | if (peer->t_gr_stale != NULL) { |
12260 | json_object_int_add( | |
2986cac2 | 12261 | json_timer, |
12262 | "stalePathTimerRemaining", | |
12263 | thread_timer_remain_second( | |
13909c4f DS |
12264 | peer->t_gr_stale)); |
12265 | } | |
3a75afa4 | 12266 | |
13909c4f DS |
12267 | /* Display Configured Selection |
12268 | * Deferral only when when | |
12269 | * Gr mode is enabled. | |
12270 | */ | |
12271 | if (CHECK_FLAG(peer->flags, | |
12272 | PEER_FLAG_GRACEFUL_RESTART)) { | |
12273 | json_object_int_add( | |
3a75afa4 | 12274 | json_timer, |
2986cac2 | 12275 | "selectionDeferralTimer", |
12276 | peer->bgp->stalepath_time); | |
13909c4f | 12277 | } |
2986cac2 | 12278 | |
13909c4f DS |
12279 | if (peer->bgp->gr_info[afi][safi] |
12280 | .t_select_deferral | |
12281 | != NULL) { | |
2986cac2 | 12282 | |
13909c4f | 12283 | json_object_int_add( |
2986cac2 | 12284 | json_timer, |
12285 | "selectionDeferralTimerRemaining", | |
12286 | thread_timer_remain_second( | |
13909c4f DS |
12287 | peer->bgp |
12288 | ->gr_info[afi] | |
12289 | [safi] | |
12290 | .t_select_deferral)); | |
12291 | } | |
12292 | } else { | |
a53ca37b | 12293 | vty_out(vty, " Timers:\n"); |
13909c4f | 12294 | vty_out(vty, |
a53ca37b DA |
12295 | " Configured Stale Path Time(sec): %u\n", |
12296 | peer->bgp->stalepath_time); | |
2986cac2 | 12297 | |
a53ca37b | 12298 | if (peer->t_gr_stale != NULL) |
2986cac2 | 12299 | vty_out(vty, |
a53ca37b | 12300 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 12301 | thread_timer_remain_second( |
13909c4f | 12302 | peer->t_gr_stale)); |
13909c4f DS |
12303 | /* Display Configured Selection |
12304 | * Deferral only when when | |
12305 | * Gr mode is enabled. | |
12306 | */ | |
12307 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 12308 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 12309 | vty_out(vty, |
a53ca37b | 12310 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 12311 | peer->bgp->select_defer_time); |
2986cac2 | 12312 | |
13909c4f DS |
12313 | if (peer->bgp->gr_info[afi][safi] |
12314 | .t_select_deferral | |
a53ca37b | 12315 | != NULL) |
13909c4f | 12316 | vty_out(vty, |
a53ca37b | 12317 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 12318 | thread_timer_remain_second( |
13909c4f DS |
12319 | peer->bgp |
12320 | ->gr_info[afi] | |
12321 | [safi] | |
12322 | .t_select_deferral)); | |
2986cac2 | 12323 | } |
13909c4f DS |
12324 | if (use_json) { |
12325 | json_object_object_add(json_afi_safi, | |
12326 | "endOfRibStatus", | |
12327 | json_endofrib_status); | |
12328 | json_object_object_add(json_afi_safi, "timers", | |
12329 | json_timer); | |
12330 | json_object_object_add( | |
12331 | json, get_afi_safi_str(afi, safi, true), | |
12332 | json_afi_safi); | |
12333 | } | |
2986cac2 | 12334 | } |
12335 | } | |
12336 | } | |
12337 | ||
36235319 QY |
12338 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
12339 | struct peer *p, | |
12340 | bool use_json, | |
12341 | json_object *json) | |
2986cac2 | 12342 | { |
12343 | if (use_json) { | |
12344 | json_object *json_timer = NULL; | |
12345 | ||
12346 | json_timer = json_object_new_object(); | |
12347 | ||
13909c4f DS |
12348 | json_object_int_add(json_timer, "configuredRestartTimer", |
12349 | p->bgp->restart_time); | |
2986cac2 | 12350 | |
13909c4f DS |
12351 | json_object_int_add(json_timer, "receivedRestartTimer", |
12352 | p->v_gr_restart); | |
2986cac2 | 12353 | |
13909c4f DS |
12354 | if (p->t_gr_restart != NULL) |
12355 | json_object_int_add( | |
12356 | json_timer, "restartTimerRemaining", | |
12357 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 12358 | |
12359 | json_object_object_add(json, "timers", json_timer); | |
12360 | } else { | |
12361 | ||
a53ca37b DA |
12362 | vty_out(vty, " Timers:\n"); |
12363 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 12364 | p->bgp->restart_time); |
2986cac2 | 12365 | |
a53ca37b | 12366 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
12367 | p->v_gr_restart); |
12368 | if (p->t_gr_restart != NULL) | |
a53ca37b | 12369 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 12370 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 12371 | if (p->t_gr_restart != NULL) { |
a53ca37b | 12372 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
12373 | thread_timer_remain_second(p->t_gr_restart)); |
12374 | } | |
2986cac2 | 12375 | } |
12376 | } | |
12377 | ||
12378 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 12379 | bool use_json, json_object *json) |
2986cac2 | 12380 | { |
12381 | char buf[SU_ADDRSTRLEN] = {0}; | |
12382 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
12383 | /* '*' + v6 address of neighbor */ |
12384 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 12385 | |
2986cac2 | 12386 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
12387 | dn_flag[0] = '*'; | |
12388 | ||
12389 | if (p->conf_if) { | |
12390 | if (use_json) | |
13909c4f DS |
12391 | json_object_string_add( |
12392 | json, "neighborAddr", | |
2986cac2 | 12393 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
12394 | ? "none" |
12395 | : sockunion2str(&p->su, buf, | |
12396 | SU_ADDRSTRLEN)); | |
2986cac2 | 12397 | else |
13909c4f | 12398 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 12399 | BGP_PEER_SU_UNSPEC(p) |
12400 | ? "none" | |
12401 | : sockunion2str(&p->su, buf, | |
12402 | SU_ADDRSTRLEN)); | |
12403 | } else { | |
772270f3 QY |
12404 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
12405 | p->host); | |
2986cac2 | 12406 | |
12407 | if (use_json) | |
36235319 QY |
12408 | json_object_string_add(json, "neighborAddr", |
12409 | neighborAddr); | |
2986cac2 | 12410 | else |
36235319 | 12411 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 12412 | } |
12413 | ||
12414 | /* more gr info in new format */ | |
12415 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
12416 | } | |
12417 | ||
d62a17ae | 12418 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 12419 | safi_t safi, bool use_json, |
d62a17ae | 12420 | json_object *json_neigh) |
12421 | { | |
0291c246 MK |
12422 | struct bgp_filter *filter; |
12423 | struct peer_af *paf; | |
12424 | char orf_pfx_name[BUFSIZ]; | |
12425 | int orf_pfx_count; | |
12426 | json_object *json_af = NULL; | |
12427 | json_object *json_prefA = NULL; | |
12428 | json_object *json_prefB = NULL; | |
12429 | json_object *json_addr = NULL; | |
fa36596c | 12430 | json_object *json_advmap = NULL; |
d62a17ae | 12431 | |
12432 | if (use_json) { | |
12433 | json_addr = json_object_new_object(); | |
12434 | json_af = json_object_new_object(); | |
12435 | filter = &p->filter[afi][safi]; | |
12436 | ||
12437 | if (peer_group_active(p)) | |
12438 | json_object_string_add(json_addr, "peerGroupMember", | |
12439 | p->group->name); | |
12440 | ||
12441 | paf = peer_af_find(p, afi, safi); | |
12442 | if (paf && PAF_SUBGRP(paf)) { | |
12443 | json_object_int_add(json_addr, "updateGroupId", | |
12444 | PAF_UPDGRP(paf)->id); | |
12445 | json_object_int_add(json_addr, "subGroupId", | |
12446 | PAF_SUBGRP(paf)->id); | |
12447 | json_object_int_add(json_addr, "packetQueueLength", | |
12448 | bpacket_queue_virtual_length(paf)); | |
12449 | } | |
12450 | ||
12451 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12452 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12453 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12454 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12455 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12456 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12457 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12458 | json_object_int_add(json_af, "orfType", | |
12459 | ORF_TYPE_PREFIX); | |
12460 | json_prefA = json_object_new_object(); | |
12461 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
12462 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
12463 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12464 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12465 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
12466 | use_json, json_prefA); | |
12467 | json_object_object_add(json_af, "orfPrefixList", | |
12468 | json_prefA); | |
12469 | } | |
12470 | ||
12471 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12472 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12473 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12474 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12475 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12476 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12477 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12478 | json_object_int_add(json_af, "orfOldType", | |
12479 | ORF_TYPE_PREFIX_OLD); | |
12480 | json_prefB = json_object_new_object(); | |
12481 | bgp_show_peer_afi_orf_cap( | |
12482 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12483 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12484 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12485 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
12486 | json_prefB); | |
12487 | json_object_object_add(json_af, "orfOldPrefixList", | |
12488 | json_prefB); | |
12489 | } | |
12490 | ||
12491 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12492 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12493 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12494 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12495 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12496 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12497 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12498 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12499 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12500 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12501 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12502 | json_object_object_add(json_addr, "afDependentCap", | |
12503 | json_af); | |
12504 | else | |
12505 | json_object_free(json_af); | |
12506 | ||
772270f3 QY |
12507 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12508 | p->host, afi, safi); | |
d62a17ae | 12509 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12510 | NULL, afi, orf_pfx_name, use_json); | |
12511 | ||
12512 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12513 | PEER_STATUS_ORF_PREFIX_SEND) | |
12514 | || orf_pfx_count) { | |
12515 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12516 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12517 | json_object_boolean_true_add(json_neigh, | |
12518 | "orfSent"); | |
12519 | if (orf_pfx_count) | |
12520 | json_object_int_add(json_addr, "orfRecvCounter", | |
12521 | orf_pfx_count); | |
12522 | } | |
12523 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12524 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12525 | json_object_string_add( | |
12526 | json_addr, "orfFirstUpdate", | |
12527 | "deferredUntilORFOrRouteRefreshRecvd"); | |
12528 | ||
12529 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12530 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12531 | json_object_boolean_true_add(json_addr, | |
12532 | "routeReflectorClient"); | |
12533 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12534 | PEER_FLAG_RSERVER_CLIENT)) | |
12535 | json_object_boolean_true_add(json_addr, | |
12536 | "routeServerClient"); | |
12537 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12538 | json_object_boolean_true_add(json_addr, | |
12539 | "inboundSoftConfigPermit"); | |
12540 | ||
12541 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12542 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12543 | json_object_boolean_true_add( | |
12544 | json_addr, | |
12545 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
12546 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12547 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12548 | json_object_boolean_true_add( | |
12549 | json_addr, | |
12550 | "privateAsNumsReplacedInUpdatesToNbr"); | |
12551 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12552 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12553 | json_object_boolean_true_add( | |
12554 | json_addr, | |
12555 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
12556 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12557 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12558 | json_object_boolean_true_add( | |
12559 | json_addr, | |
12560 | "privateAsNumsRemovedInUpdatesToNbr"); | |
12561 | ||
dcc68b5e MS |
12562 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12563 | json_object_boolean_true_add( | |
12564 | json_addr, | |
12565 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12566 | ->type_json_name); | |
d62a17ae | 12567 | |
12568 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12569 | json_object_string_add(json_addr, | |
12570 | "overrideASNsInOutboundUpdates", | |
12571 | "ifAspathEqualRemoteAs"); | |
12572 | ||
12573 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12574 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12575 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12576 | json_object_boolean_true_add(json_addr, | |
12577 | "routerAlwaysNextHop"); | |
12578 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12579 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12580 | json_object_boolean_true_add( | |
12581 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
12582 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12583 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12584 | json_object_boolean_true_add( | |
12585 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
12586 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12587 | json_object_boolean_true_add( | |
12588 | json_addr, "unchangedMedPropogatedToNbr"); | |
12589 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12590 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12591 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
12592 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12593 | PEER_FLAG_SEND_COMMUNITY) | |
12594 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12595 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12596 | json_object_string_add(json_addr, | |
12597 | "commAttriSentToNbr", | |
12598 | "extendedAndStandard"); | |
12599 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12600 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12601 | json_object_string_add(json_addr, | |
12602 | "commAttriSentToNbr", | |
12603 | "extended"); | |
12604 | else | |
12605 | json_object_string_add(json_addr, | |
12606 | "commAttriSentToNbr", | |
12607 | "standard"); | |
12608 | } | |
12609 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12610 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12611 | if (p->default_rmap[afi][safi].name) | |
12612 | json_object_string_add( | |
12613 | json_addr, "defaultRouteMap", | |
12614 | p->default_rmap[afi][safi].name); | |
12615 | ||
12616 | if (paf && PAF_SUBGRP(paf) | |
12617 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12618 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12619 | json_object_boolean_true_add(json_addr, | |
12620 | "defaultSent"); | |
12621 | else | |
12622 | json_object_boolean_true_add(json_addr, | |
12623 | "defaultNotSent"); | |
12624 | } | |
12625 | ||
dff8f48d | 12626 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 12627 | if (is_evpn_enabled()) |
60466a63 QY |
12628 | json_object_boolean_true_add( |
12629 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
12630 | } |
12631 | ||
d62a17ae | 12632 | if (filter->plist[FILTER_IN].name |
12633 | || filter->dlist[FILTER_IN].name | |
12634 | || filter->aslist[FILTER_IN].name | |
12635 | || filter->map[RMAP_IN].name) | |
12636 | json_object_boolean_true_add(json_addr, | |
12637 | "inboundPathPolicyConfig"); | |
12638 | if (filter->plist[FILTER_OUT].name | |
12639 | || filter->dlist[FILTER_OUT].name | |
12640 | || filter->aslist[FILTER_OUT].name | |
12641 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12642 | json_object_boolean_true_add( | |
12643 | json_addr, "outboundPathPolicyConfig"); | |
12644 | ||
12645 | /* prefix-list */ | |
12646 | if (filter->plist[FILTER_IN].name) | |
12647 | json_object_string_add(json_addr, | |
12648 | "incomingUpdatePrefixFilterList", | |
12649 | filter->plist[FILTER_IN].name); | |
12650 | if (filter->plist[FILTER_OUT].name) | |
12651 | json_object_string_add(json_addr, | |
12652 | "outgoingUpdatePrefixFilterList", | |
12653 | filter->plist[FILTER_OUT].name); | |
12654 | ||
12655 | /* distribute-list */ | |
12656 | if (filter->dlist[FILTER_IN].name) | |
12657 | json_object_string_add( | |
12658 | json_addr, "incomingUpdateNetworkFilterList", | |
12659 | filter->dlist[FILTER_IN].name); | |
12660 | if (filter->dlist[FILTER_OUT].name) | |
12661 | json_object_string_add( | |
12662 | json_addr, "outgoingUpdateNetworkFilterList", | |
12663 | filter->dlist[FILTER_OUT].name); | |
12664 | ||
12665 | /* filter-list. */ | |
12666 | if (filter->aslist[FILTER_IN].name) | |
12667 | json_object_string_add(json_addr, | |
12668 | "incomingUpdateAsPathFilterList", | |
12669 | filter->aslist[FILTER_IN].name); | |
12670 | if (filter->aslist[FILTER_OUT].name) | |
12671 | json_object_string_add(json_addr, | |
12672 | "outgoingUpdateAsPathFilterList", | |
12673 | filter->aslist[FILTER_OUT].name); | |
12674 | ||
12675 | /* route-map. */ | |
12676 | if (filter->map[RMAP_IN].name) | |
12677 | json_object_string_add( | |
12678 | json_addr, "routeMapForIncomingAdvertisements", | |
12679 | filter->map[RMAP_IN].name); | |
12680 | if (filter->map[RMAP_OUT].name) | |
12681 | json_object_string_add( | |
12682 | json_addr, "routeMapForOutgoingAdvertisements", | |
12683 | filter->map[RMAP_OUT].name); | |
12684 | ||
9dac9fc8 | 12685 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12686 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12687 | && !bgp_inbound_policy_exists(p, filter)) |
12688 | json_object_string_add( | |
12689 | json_addr, "inboundEbgpRequiresPolicy", | |
12690 | "Inbound updates discarded due to missing policy"); | |
12691 | ||
12692 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12693 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12694 | && (!bgp_outbound_policy_exists(p, filter))) |
12695 | json_object_string_add( | |
12696 | json_addr, "outboundEbgpRequiresPolicy", | |
12697 | "Outbound updates discarded due to missing policy"); | |
12698 | ||
d62a17ae | 12699 | /* unsuppress-map */ |
12700 | if (filter->usmap.name) | |
12701 | json_object_string_add(json_addr, | |
12702 | "selectiveUnsuppressRouteMap", | |
12703 | filter->usmap.name); | |
12704 | ||
fa36596c MK |
12705 | /* advertise-map */ |
12706 | if (filter->advmap.aname) { | |
12707 | json_advmap = json_object_new_object(); | |
12708 | json_object_string_add(json_advmap, "condition", | |
12709 | filter->advmap.condition | |
12710 | ? "EXIST" | |
12711 | : "NON_EXIST"); | |
12712 | json_object_string_add(json_advmap, "conditionMap", | |
12713 | filter->advmap.cname); | |
12714 | json_object_string_add(json_advmap, "advertiseMap", | |
12715 | filter->advmap.aname); | |
12716 | json_object_string_add(json_advmap, "advertiseStatus", | |
12717 | filter->advmap.update_type | |
12718 | == ADVERTISE | |
12719 | ? "Advertise" | |
12720 | : "Withdraw"); | |
12721 | json_object_object_add(json_addr, "advertiseMap", | |
12722 | json_advmap); | |
12723 | } | |
12724 | ||
d62a17ae | 12725 | /* Receive prefix count */ |
12726 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12727 | p->pcount[afi][safi]); | |
50e05855 AD |
12728 | if (paf && PAF_SUBGRP(paf)) |
12729 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12730 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12731 | |
fde246e8 DA |
12732 | /* Maximum prefix */ |
12733 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12734 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12735 | p->pmax_out[afi][safi]); | |
12736 | ||
d62a17ae | 12737 | /* Maximum prefix */ |
12738 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12739 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12740 | p->pmax[afi][safi]); | |
12741 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12742 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12743 | json_object_boolean_true_add( | |
12744 | json_addr, "prefixAllowedMaxWarning"); | |
12745 | json_object_int_add(json_addr, | |
12746 | "prefixAllowedWarningThresh", | |
12747 | p->pmax_threshold[afi][safi]); | |
12748 | if (p->pmax_restart[afi][safi]) | |
12749 | json_object_int_add( | |
12750 | json_addr, | |
12751 | "prefixAllowedRestartIntervalMsecs", | |
12752 | p->pmax_restart[afi][safi] * 60000); | |
12753 | } | |
2986cac2 | 12754 | json_object_object_add(json_neigh, |
36235319 | 12755 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12756 | json_addr); |
12757 | ||
12758 | } else { | |
12759 | filter = &p->filter[afi][safi]; | |
12760 | ||
12761 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12762 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12763 | |
12764 | if (peer_group_active(p)) | |
12765 | vty_out(vty, " %s peer-group member\n", | |
12766 | p->group->name); | |
12767 | ||
12768 | paf = peer_af_find(p, afi, safi); | |
12769 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12770 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12771 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12772 | vty_out(vty, " Packet Queue length %d\n", | |
12773 | bpacket_queue_virtual_length(paf)); | |
12774 | } else { | |
12775 | vty_out(vty, " Not part of any update group\n"); | |
12776 | } | |
12777 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12778 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12779 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12780 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12781 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12782 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12783 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12784 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12785 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12786 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12787 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12788 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12789 | ||
12790 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12791 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12792 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12793 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12794 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12795 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12796 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12797 | vty_out(vty, | |
12798 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12799 | ORF_TYPE_PREFIX); | |
12800 | bgp_show_peer_afi_orf_cap( | |
12801 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12802 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12803 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12804 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12805 | } | |
12806 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12807 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12808 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12809 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12810 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12811 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12812 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12813 | vty_out(vty, | |
12814 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12815 | ORF_TYPE_PREFIX_OLD); | |
12816 | bgp_show_peer_afi_orf_cap( | |
12817 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12818 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12819 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12820 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12821 | } | |
12822 | ||
772270f3 QY |
12823 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12824 | p->host, afi, safi); | |
d62a17ae | 12825 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12826 | NULL, afi, orf_pfx_name, use_json); | |
12827 | ||
12828 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12829 | PEER_STATUS_ORF_PREFIX_SEND) | |
12830 | || orf_pfx_count) { | |
12831 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12832 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12833 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12834 | vty_out(vty, " sent;"); | |
12835 | if (orf_pfx_count) | |
12836 | vty_out(vty, " received (%d entries)", | |
12837 | orf_pfx_count); | |
12838 | vty_out(vty, "\n"); | |
12839 | } | |
12840 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12841 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12842 | vty_out(vty, | |
12843 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12844 | ||
12845 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12846 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12847 | vty_out(vty, " Route-Reflector Client\n"); | |
12848 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12849 | PEER_FLAG_RSERVER_CLIENT)) | |
12850 | vty_out(vty, " Route-Server Client\n"); | |
12851 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12852 | vty_out(vty, | |
12853 | " Inbound soft reconfiguration allowed\n"); | |
12854 | ||
12855 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12856 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12857 | vty_out(vty, | |
12858 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12859 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12860 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12861 | vty_out(vty, | |
12862 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12863 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12864 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12865 | vty_out(vty, | |
12866 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12867 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12868 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12869 | vty_out(vty, | |
12870 | " Private AS numbers removed in updates to this neighbor\n"); | |
12871 | ||
dcc68b5e MS |
12872 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12873 | vty_out(vty, " %s\n", | |
12874 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12875 | ->human_description); | |
d62a17ae | 12876 | |
12877 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12878 | vty_out(vty, | |
12879 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12880 | ||
12881 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12882 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12883 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12884 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12885 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12886 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12887 | vty_out(vty, | |
12888 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12889 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12890 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12891 | vty_out(vty, | |
12892 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12893 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12894 | vty_out(vty, | |
12895 | " MED is propagated unchanged to this neighbor\n"); | |
12896 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12897 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12898 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12899 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12900 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12901 | vty_out(vty, | |
12902 | " Community attribute sent to this neighbor"); | |
12903 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12904 | PEER_FLAG_SEND_COMMUNITY) | |
12905 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12906 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12907 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12908 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12909 | vty_out(vty, "(all)\n"); | |
12910 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12911 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12912 | vty_out(vty, "(large)\n"); | |
12913 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12914 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12915 | vty_out(vty, "(extended)\n"); | |
12916 | else | |
12917 | vty_out(vty, "(standard)\n"); | |
12918 | } | |
12919 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12920 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12921 | vty_out(vty, " Default information originate,"); | |
12922 | ||
12923 | if (p->default_rmap[afi][safi].name) | |
12924 | vty_out(vty, " default route-map %s%s,", | |
12925 | p->default_rmap[afi][safi].map ? "*" | |
12926 | : "", | |
12927 | p->default_rmap[afi][safi].name); | |
12928 | if (paf && PAF_SUBGRP(paf) | |
12929 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12930 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12931 | vty_out(vty, " default sent\n"); | |
12932 | else | |
12933 | vty_out(vty, " default not sent\n"); | |
12934 | } | |
12935 | ||
dff8f48d MK |
12936 | /* advertise-vni-all */ |
12937 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12938 | if (is_evpn_enabled()) |
dff8f48d MK |
12939 | vty_out(vty, " advertise-all-vni\n"); |
12940 | } | |
12941 | ||
d62a17ae | 12942 | if (filter->plist[FILTER_IN].name |
12943 | || filter->dlist[FILTER_IN].name | |
12944 | || filter->aslist[FILTER_IN].name | |
12945 | || filter->map[RMAP_IN].name) | |
12946 | vty_out(vty, " Inbound path policy configured\n"); | |
12947 | if (filter->plist[FILTER_OUT].name | |
12948 | || filter->dlist[FILTER_OUT].name | |
12949 | || filter->aslist[FILTER_OUT].name | |
12950 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12951 | vty_out(vty, " Outbound path policy configured\n"); | |
12952 | ||
12953 | /* prefix-list */ | |
12954 | if (filter->plist[FILTER_IN].name) | |
12955 | vty_out(vty, | |
12956 | " Incoming update prefix filter list is %s%s\n", | |
12957 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12958 | filter->plist[FILTER_IN].name); | |
12959 | if (filter->plist[FILTER_OUT].name) | |
12960 | vty_out(vty, | |
12961 | " Outgoing update prefix filter list is %s%s\n", | |
12962 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12963 | filter->plist[FILTER_OUT].name); | |
12964 | ||
12965 | /* distribute-list */ | |
12966 | if (filter->dlist[FILTER_IN].name) | |
12967 | vty_out(vty, | |
12968 | " Incoming update network filter list is %s%s\n", | |
12969 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12970 | filter->dlist[FILTER_IN].name); | |
12971 | if (filter->dlist[FILTER_OUT].name) | |
12972 | vty_out(vty, | |
12973 | " Outgoing update network filter list is %s%s\n", | |
12974 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12975 | filter->dlist[FILTER_OUT].name); | |
12976 | ||
12977 | /* filter-list. */ | |
12978 | if (filter->aslist[FILTER_IN].name) | |
12979 | vty_out(vty, | |
12980 | " Incoming update AS path filter list is %s%s\n", | |
12981 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12982 | filter->aslist[FILTER_IN].name); | |
12983 | if (filter->aslist[FILTER_OUT].name) | |
12984 | vty_out(vty, | |
12985 | " Outgoing update AS path filter list is %s%s\n", | |
12986 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12987 | filter->aslist[FILTER_OUT].name); | |
12988 | ||
12989 | /* route-map. */ | |
12990 | if (filter->map[RMAP_IN].name) | |
12991 | vty_out(vty, | |
12992 | " Route map for incoming advertisements is %s%s\n", | |
12993 | filter->map[RMAP_IN].map ? "*" : "", | |
12994 | filter->map[RMAP_IN].name); | |
12995 | if (filter->map[RMAP_OUT].name) | |
12996 | vty_out(vty, | |
12997 | " Route map for outgoing advertisements is %s%s\n", | |
12998 | filter->map[RMAP_OUT].map ? "*" : "", | |
12999 | filter->map[RMAP_OUT].name); | |
13000 | ||
9dac9fc8 | 13001 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 13002 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
13003 | && !bgp_inbound_policy_exists(p, filter)) |
13004 | vty_out(vty, | |
13005 | " Inbound updates discarded due to missing policy\n"); | |
13006 | ||
13007 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 13008 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
13009 | && !bgp_outbound_policy_exists(p, filter)) |
13010 | vty_out(vty, | |
13011 | " Outbound updates discarded due to missing policy\n"); | |
13012 | ||
d62a17ae | 13013 | /* unsuppress-map */ |
13014 | if (filter->usmap.name) | |
13015 | vty_out(vty, | |
13016 | " Route map for selective unsuppress is %s%s\n", | |
13017 | filter->usmap.map ? "*" : "", | |
13018 | filter->usmap.name); | |
13019 | ||
7f7940e6 MK |
13020 | /* advertise-map */ |
13021 | if (filter->advmap.aname && filter->advmap.cname) | |
13022 | vty_out(vty, | |
13023 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
13024 | filter->advmap.condition ? "EXIST" | |
13025 | : "NON_EXIST", | |
13026 | filter->advmap.cmap ? "*" : "", | |
13027 | filter->advmap.cname, | |
13028 | filter->advmap.amap ? "*" : "", | |
13029 | filter->advmap.aname, | |
fa36596c | 13030 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
13031 | ? "Advertise" |
13032 | : "Withdraw"); | |
7f7940e6 | 13033 | |
d62a17ae | 13034 | /* Receive prefix count */ |
6cde4b45 | 13035 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 13036 | p->pcount[afi][safi]); |
d62a17ae | 13037 | |
fde246e8 DA |
13038 | /* maximum-prefix-out */ |
13039 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
13040 | PEER_FLAG_MAX_PREFIX_OUT)) | |
13041 | vty_out(vty, | |
6cde4b45 | 13042 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
13043 | p->pmax_out[afi][safi]); |
13044 | ||
d62a17ae | 13045 | /* Maximum prefix */ |
13046 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 13047 | vty_out(vty, |
6cde4b45 | 13048 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 13049 | p->pmax[afi][safi], |
13050 | CHECK_FLAG(p->af_flags[afi][safi], | |
13051 | PEER_FLAG_MAX_PREFIX_WARNING) | |
13052 | ? " (warning-only)" | |
13053 | : ""); | |
13054 | vty_out(vty, " Threshold for warning message %d%%", | |
13055 | p->pmax_threshold[afi][safi]); | |
13056 | if (p->pmax_restart[afi][safi]) | |
13057 | vty_out(vty, ", restart interval %d min", | |
13058 | p->pmax_restart[afi][safi]); | |
13059 | vty_out(vty, "\n"); | |
13060 | } | |
13061 | ||
13062 | vty_out(vty, "\n"); | |
13063 | } | |
13064 | } | |
13065 | ||
9f049418 | 13066 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 13067 | json_object *json) |
718e3744 | 13068 | { |
d62a17ae | 13069 | struct bgp *bgp; |
13070 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
13071 | char timebuf[BGP_UPTIME_LEN]; | |
13072 | char dn_flag[2]; | |
d62a17ae | 13073 | afi_t afi; |
13074 | safi_t safi; | |
d7c0a89a QY |
13075 | uint16_t i; |
13076 | uint8_t *msg; | |
d62a17ae | 13077 | json_object *json_neigh = NULL; |
13078 | time_t epoch_tbuf; | |
4ab46701 | 13079 | uint32_t sync_tcp_mss; |
718e3744 | 13080 | |
d62a17ae | 13081 | bgp = p->bgp; |
13082 | ||
13083 | if (use_json) | |
13084 | json_neigh = json_object_new_object(); | |
13085 | ||
13086 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
13087 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
13088 | dn_flag[0] = '*'; | |
13089 | ||
13090 | if (!use_json) { | |
13091 | if (p->conf_if) /* Configured interface name. */ | |
13092 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
13093 | BGP_PEER_SU_UNSPEC(p) | |
13094 | ? "None" | |
13095 | : sockunion2str(&p->su, buf, | |
13096 | SU_ADDRSTRLEN)); | |
13097 | else /* Configured IP address. */ | |
13098 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
13099 | p->host); | |
13100 | } | |
13101 | ||
13102 | if (use_json) { | |
13103 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
13104 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
13105 | "none"); | |
13106 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
13107 | json_object_string_add( | |
13108 | json_neigh, "bgpNeighborAddr", | |
13109 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
13110 | ||
13111 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
13112 | ||
13113 | if (p->change_local_as) | |
13114 | json_object_int_add(json_neigh, "localAs", | |
13115 | p->change_local_as); | |
13116 | else | |
13117 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
13118 | ||
13119 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
13120 | json_object_boolean_true_add(json_neigh, | |
13121 | "localAsNoPrepend"); | |
13122 | ||
13123 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
13124 | json_object_boolean_true_add(json_neigh, | |
13125 | "localAsReplaceAs"); | |
13126 | } else { | |
13127 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
13128 | || (p->as_type == AS_INTERNAL)) | |
13129 | vty_out(vty, "remote AS %u, ", p->as); | |
13130 | else | |
13131 | vty_out(vty, "remote AS Unspecified, "); | |
13132 | vty_out(vty, "local AS %u%s%s, ", | |
13133 | p->change_local_as ? p->change_local_as : p->local_as, | |
13134 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
13135 | ? " no-prepend" | |
13136 | : "", | |
13137 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
13138 | ? " replace-as" | |
13139 | : ""); | |
13140 | } | |
faa16034 DS |
13141 | /* peer type internal or confed-internal */ |
13142 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 13143 | if (use_json) { |
13144 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13145 | json_object_boolean_true_add( | |
13146 | json_neigh, "nbrConfedInternalLink"); | |
13147 | else | |
13148 | json_object_boolean_true_add(json_neigh, | |
13149 | "nbrInternalLink"); | |
13150 | } else { | |
13151 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13152 | vty_out(vty, "confed-internal link\n"); | |
13153 | else | |
13154 | vty_out(vty, "internal link\n"); | |
13155 | } | |
faa16034 DS |
13156 | /* peer type external or confed-external */ |
13157 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 13158 | if (use_json) { |
13159 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13160 | json_object_boolean_true_add( | |
13161 | json_neigh, "nbrConfedExternalLink"); | |
13162 | else | |
13163 | json_object_boolean_true_add(json_neigh, | |
13164 | "nbrExternalLink"); | |
13165 | } else { | |
13166 | if (bgp_confederation_peers_check(bgp, p->as)) | |
13167 | vty_out(vty, "confed-external link\n"); | |
13168 | else | |
13169 | vty_out(vty, "external link\n"); | |
13170 | } | |
faa16034 DS |
13171 | } else { |
13172 | if (use_json) | |
13173 | json_object_boolean_true_add(json_neigh, | |
13174 | "nbrUnspecifiedLink"); | |
13175 | else | |
13176 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 13177 | } |
13178 | ||
13179 | /* Description. */ | |
13180 | if (p->desc) { | |
13181 | if (use_json) | |
13182 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
13183 | else | |
13184 | vty_out(vty, " Description: %s\n", p->desc); | |
13185 | } | |
13186 | ||
13187 | if (p->hostname) { | |
13188 | if (use_json) { | |
13189 | if (p->hostname) | |
13190 | json_object_string_add(json_neigh, "hostname", | |
13191 | p->hostname); | |
13192 | ||
13193 | if (p->domainname) | |
13194 | json_object_string_add(json_neigh, "domainname", | |
13195 | p->domainname); | |
13196 | } else { | |
13197 | if (p->domainname && (p->domainname[0] != '\0')) | |
13198 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
13199 | p->domainname); | |
13200 | else | |
13201 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
13202 | } | |
13203 | } | |
13204 | ||
13205 | /* Peer-group */ | |
13206 | if (p->group) { | |
13207 | if (use_json) { | |
13208 | json_object_string_add(json_neigh, "peerGroup", | |
13209 | p->group->name); | |
13210 | ||
13211 | if (dn_flag[0]) { | |
13212 | struct prefix prefix, *range = NULL; | |
13213 | ||
0154d8ce DS |
13214 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13215 | range = peer_group_lookup_dynamic_neighbor_range( | |
13216 | p->group, &prefix); | |
d62a17ae | 13217 | |
13218 | if (range) { | |
13219 | prefix2str(range, buf1, sizeof(buf1)); | |
13220 | json_object_string_add( | |
13221 | json_neigh, | |
13222 | "peerSubnetRangeGroup", buf1); | |
13223 | } | |
13224 | } | |
13225 | } else { | |
13226 | vty_out(vty, | |
13227 | " Member of peer-group %s for session parameters\n", | |
13228 | p->group->name); | |
13229 | ||
13230 | if (dn_flag[0]) { | |
13231 | struct prefix prefix, *range = NULL; | |
13232 | ||
0154d8ce DS |
13233 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13234 | range = peer_group_lookup_dynamic_neighbor_range( | |
13235 | p->group, &prefix); | |
d62a17ae | 13236 | |
13237 | if (range) { | |
d62a17ae | 13238 | vty_out(vty, |
1b78780b DL |
13239 | " Belongs to the subnet range group: %pFX\n", |
13240 | range); | |
d62a17ae | 13241 | } |
13242 | } | |
13243 | } | |
13244 | } | |
13245 | ||
13246 | if (use_json) { | |
13247 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13248 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13249 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13250 | json_object_boolean_true_add(json_neigh, |
13251 | "adminShutDown"); | |
13252 | ||
13253 | /* BGP Version. */ | |
13254 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
13255 | json_object_string_add( | |
13256 | json_neigh, "remoteRouterId", | |
13257 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
13258 | json_object_string_add( |
13259 | json_neigh, "localRouterId", | |
13260 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
13261 | sizeof(buf1))); | |
d62a17ae | 13262 | |
13263 | /* Confederation */ | |
13264 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13265 | && bgp_confederation_peers_check(bgp, p->as)) | |
13266 | json_object_boolean_true_add(json_neigh, | |
13267 | "nbrCommonAdmin"); | |
13268 | ||
13269 | /* Status. */ | |
13270 | json_object_string_add( | |
13271 | json_neigh, "bgpState", | |
13272 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13273 | ||
feb17238 | 13274 | if (peer_established(p)) { |
d62a17ae | 13275 | time_t uptime; |
d62a17ae | 13276 | |
13277 | uptime = bgp_clock(); | |
13278 | uptime -= p->uptime; | |
d62a17ae | 13279 | epoch_tbuf = time(NULL) - uptime; |
13280 | ||
d3c7efed DS |
13281 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
13282 | uptime * 1000); | |
d62a17ae | 13283 | json_object_string_add(json_neigh, "bgpTimerUpString", |
13284 | peer_uptime(p->uptime, timebuf, | |
13285 | BGP_UPTIME_LEN, 0, | |
13286 | NULL)); | |
13287 | json_object_int_add(json_neigh, | |
13288 | "bgpTimerUpEstablishedEpoch", | |
13289 | epoch_tbuf); | |
13290 | } | |
13291 | ||
13292 | else if (p->status == Active) { | |
13293 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13294 | json_object_string_add(json_neigh, "bgpStateIs", | |
13295 | "passive"); | |
13296 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13297 | json_object_string_add(json_neigh, "bgpStateIs", | |
13298 | "passiveNSF"); | |
13299 | } | |
13300 | ||
13301 | /* read timer */ | |
13302 | time_t uptime; | |
a2700b50 | 13303 | struct tm tm; |
d62a17ae | 13304 | |
13305 | uptime = bgp_clock(); | |
13306 | uptime -= p->readtime; | |
a2700b50 MS |
13307 | gmtime_r(&uptime, &tm); |
13308 | ||
d62a17ae | 13309 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
13310 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13311 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13312 | |
13313 | uptime = bgp_clock(); | |
13314 | uptime -= p->last_write; | |
a2700b50 MS |
13315 | gmtime_r(&uptime, &tm); |
13316 | ||
d62a17ae | 13317 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
13318 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13319 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13320 | |
13321 | uptime = bgp_clock(); | |
13322 | uptime -= p->update_time; | |
a2700b50 MS |
13323 | gmtime_r(&uptime, &tm); |
13324 | ||
d62a17ae | 13325 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
13326 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13327 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13328 | |
13329 | /* Configured timer values. */ | |
13330 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
13331 | p->v_holdtime * 1000); | |
13332 | json_object_int_add(json_neigh, | |
13333 | "bgpTimerKeepAliveIntervalMsecs", | |
13334 | p->v_keepalive * 1000); | |
d43114f3 DS |
13335 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
13336 | json_object_int_add(json_neigh, | |
13337 | "bgpTimerDelayOpenTimeMsecs", | |
13338 | p->v_delayopen * 1000); | |
13339 | } | |
13340 | ||
4ab46701 AR |
13341 | /* Configured and Synced tcp-mss value for peer */ |
13342 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13343 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13344 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
13345 | p->tcp_mss); | |
13346 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
13347 | sync_tcp_mss); | |
13348 | } | |
13349 | ||
b90a8e13 | 13350 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 13351 | json_object_int_add(json_neigh, |
13352 | "bgpTimerConfiguredHoldTimeMsecs", | |
13353 | p->holdtime * 1000); | |
13354 | json_object_int_add( | |
13355 | json_neigh, | |
13356 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
13357 | p->keepalive * 1000); | |
5d5393b9 DL |
13358 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
13359 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
13360 | json_object_int_add(json_neigh, |
13361 | "bgpTimerConfiguredHoldTimeMsecs", | |
13362 | bgp->default_holdtime); | |
13363 | json_object_int_add( | |
13364 | json_neigh, | |
13365 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
13366 | bgp->default_keepalive); | |
d62a17ae | 13367 | } |
13368 | } else { | |
13369 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13370 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13371 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13372 | vty_out(vty, " Administratively shut down\n"); |
13373 | ||
13374 | /* BGP Version. */ | |
13375 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 13376 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 13377 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
13378 | vty_out(vty, ", local router ID %s\n", |
13379 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
13380 | sizeof(buf1))); | |
d62a17ae | 13381 | |
13382 | /* Confederation */ | |
13383 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13384 | && bgp_confederation_peers_check(bgp, p->as)) | |
13385 | vty_out(vty, | |
13386 | " Neighbor under common administration\n"); | |
13387 | ||
13388 | /* Status. */ | |
13389 | vty_out(vty, " BGP state = %s", | |
13390 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13391 | ||
feb17238 | 13392 | if (peer_established(p)) |
d62a17ae | 13393 | vty_out(vty, ", up for %8s", |
13394 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
13395 | 0, NULL)); | |
13396 | ||
13397 | else if (p->status == Active) { | |
13398 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13399 | vty_out(vty, " (passive)"); | |
13400 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13401 | vty_out(vty, " (NSF passive)"); | |
13402 | } | |
13403 | vty_out(vty, "\n"); | |
13404 | ||
13405 | /* read timer */ | |
13406 | vty_out(vty, " Last read %s", | |
13407 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
13408 | NULL)); | |
13409 | vty_out(vty, ", Last write %s\n", | |
13410 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
13411 | NULL)); | |
13412 | ||
13413 | /* Configured timer values. */ | |
13414 | vty_out(vty, | |
13415 | " Hold time is %d, keepalive interval is %d seconds\n", | |
13416 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 13417 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 13418 | vty_out(vty, " Configured hold time is %d", |
13419 | p->holdtime); | |
13420 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
13421 | p->keepalive); | |
5d5393b9 DL |
13422 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
13423 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
13424 | vty_out(vty, " Configured hold time is %d", |
13425 | bgp->default_holdtime); | |
13426 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
13427 | bgp->default_keepalive); | |
d62a17ae | 13428 | } |
d43114f3 DS |
13429 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
13430 | vty_out(vty, | |
13431 | " Configured DelayOpenTime is %d seconds\n", | |
13432 | p->delayopen); | |
4ab46701 AR |
13433 | |
13434 | /* Configured and synced tcp-mss value for peer */ | |
13435 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13436 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13437 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
13438 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
13439 | } | |
d62a17ae | 13440 | } |
13441 | /* Capability. */ | |
feb17238 | 13442 | if (peer_established(p)) { |
d62a17ae | 13443 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] |
13444 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
13445 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
13446 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
13447 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
13448 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
13449 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
13450 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
13451 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
13452 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
13453 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
13454 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 13455 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
13456 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 13457 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
13458 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 13459 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
13460 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 13461 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
13462 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
13463 | if (use_json) { | |
13464 | json_object *json_cap = NULL; | |
13465 | ||
13466 | json_cap = json_object_new_object(); | |
13467 | ||
13468 | /* AS4 */ | |
13469 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13470 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13471 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
13472 | && CHECK_FLAG(p->cap, | |
13473 | PEER_CAP_AS4_RCV)) | |
13474 | json_object_string_add( | |
13475 | json_cap, "4byteAs", | |
13476 | "advertisedAndReceived"); | |
13477 | else if (CHECK_FLAG(p->cap, | |
13478 | PEER_CAP_AS4_ADV)) | |
13479 | json_object_string_add( | |
13480 | json_cap, "4byteAs", | |
13481 | "advertised"); | |
13482 | else if (CHECK_FLAG(p->cap, | |
13483 | PEER_CAP_AS4_RCV)) | |
13484 | json_object_string_add( | |
13485 | json_cap, "4byteAs", | |
13486 | "received"); | |
13487 | } | |
13488 | ||
ef56aee4 DA |
13489 | /* Extended Message Support */ |
13490 | if (CHECK_FLAG(p->cap, | |
13491 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13492 | && CHECK_FLAG( | |
13493 | p->cap, | |
13494 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13495 | json_object_string_add( | |
13496 | json_cap, "extendedMessage", | |
13497 | "advertisedAndReceived"); | |
13498 | else if (CHECK_FLAG( | |
13499 | p->cap, | |
13500 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13501 | json_object_string_add( | |
13502 | json_cap, "extendedMessage", | |
13503 | "advertised"); | |
13504 | else if (CHECK_FLAG( | |
13505 | p->cap, | |
13506 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13507 | json_object_string_add( | |
13508 | json_cap, "extendedMessage", | |
13509 | "received"); | |
13510 | ||
d62a17ae | 13511 | /* AddPath */ |
13512 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13513 | || CHECK_FLAG(p->cap, | |
13514 | PEER_CAP_ADDPATH_ADV)) { | |
13515 | json_object *json_add = NULL; | |
13516 | const char *print_store; | |
13517 | ||
13518 | json_add = json_object_new_object(); | |
13519 | ||
05c7a1cc QY |
13520 | FOREACH_AFI_SAFI (afi, safi) { |
13521 | json_object *json_sub = NULL; | |
13522 | json_sub = | |
13523 | json_object_new_object(); | |
5cb5f4d0 DD |
13524 | print_store = get_afi_safi_str( |
13525 | afi, safi, true); | |
d62a17ae | 13526 | |
05c7a1cc QY |
13527 | if (CHECK_FLAG( |
13528 | p->af_cap[afi] | |
13529 | [safi], | |
13530 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13531 | || CHECK_FLAG( | |
13532 | p->af_cap[afi] | |
13533 | [safi], | |
13534 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 13535 | if (CHECK_FLAG( |
13536 | p->af_cap | |
13537 | [afi] | |
13538 | [safi], | |
13539 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 13540 | && CHECK_FLAG( |
d62a17ae | 13541 | p->af_cap |
13542 | [afi] | |
13543 | [safi], | |
05c7a1cc QY |
13544 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
13545 | json_object_boolean_true_add( | |
13546 | json_sub, | |
13547 | "txAdvertisedAndReceived"); | |
13548 | else if ( | |
13549 | CHECK_FLAG( | |
13550 | p->af_cap | |
13551 | [afi] | |
13552 | [safi], | |
13553 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13554 | json_object_boolean_true_add( | |
13555 | json_sub, | |
13556 | "txAdvertised"); | |
13557 | else if ( | |
13558 | CHECK_FLAG( | |
13559 | p->af_cap | |
13560 | [afi] | |
13561 | [safi], | |
13562 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13563 | json_object_boolean_true_add( | |
13564 | json_sub, | |
13565 | "txReceived"); | |
13566 | } | |
d62a17ae | 13567 | |
05c7a1cc QY |
13568 | if (CHECK_FLAG( |
13569 | p->af_cap[afi] | |
13570 | [safi], | |
13571 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13572 | || CHECK_FLAG( | |
13573 | p->af_cap[afi] | |
13574 | [safi], | |
13575 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 13576 | if (CHECK_FLAG( |
13577 | p->af_cap | |
13578 | [afi] | |
13579 | [safi], | |
13580 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 13581 | && CHECK_FLAG( |
d62a17ae | 13582 | p->af_cap |
13583 | [afi] | |
13584 | [safi], | |
13585 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
13586 | json_object_boolean_true_add( |
13587 | json_sub, | |
13588 | "rxAdvertisedAndReceived"); | |
13589 | else if ( | |
13590 | CHECK_FLAG( | |
13591 | p->af_cap | |
13592 | [afi] | |
13593 | [safi], | |
13594 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13595 | json_object_boolean_true_add( | |
13596 | json_sub, | |
13597 | "rxAdvertised"); | |
13598 | else if ( | |
13599 | CHECK_FLAG( | |
13600 | p->af_cap | |
13601 | [afi] | |
13602 | [safi], | |
13603 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13604 | json_object_boolean_true_add( | |
13605 | json_sub, | |
13606 | "rxReceived"); | |
d62a17ae | 13607 | } |
13608 | ||
05c7a1cc QY |
13609 | if (CHECK_FLAG( |
13610 | p->af_cap[afi] | |
13611 | [safi], | |
13612 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13613 | || CHECK_FLAG( | |
13614 | p->af_cap[afi] | |
13615 | [safi], | |
13616 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
13617 | || CHECK_FLAG( | |
13618 | p->af_cap[afi] | |
13619 | [safi], | |
13620 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13621 | || CHECK_FLAG( | |
13622 | p->af_cap[afi] | |
13623 | [safi], | |
13624 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13625 | json_object_object_add( | |
13626 | json_add, | |
13627 | print_store, | |
13628 | json_sub); | |
13629 | else | |
13630 | json_object_free( | |
13631 | json_sub); | |
13632 | } | |
13633 | ||
d62a17ae | 13634 | json_object_object_add( |
13635 | json_cap, "addPath", json_add); | |
13636 | } | |
13637 | ||
13638 | /* Dynamic */ | |
13639 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13640 | || CHECK_FLAG(p->cap, | |
13641 | PEER_CAP_DYNAMIC_ADV)) { | |
13642 | if (CHECK_FLAG(p->cap, | |
13643 | PEER_CAP_DYNAMIC_ADV) | |
13644 | && CHECK_FLAG(p->cap, | |
13645 | PEER_CAP_DYNAMIC_RCV)) | |
13646 | json_object_string_add( | |
13647 | json_cap, "dynamic", | |
13648 | "advertisedAndReceived"); | |
13649 | else if (CHECK_FLAG( | |
13650 | p->cap, | |
13651 | PEER_CAP_DYNAMIC_ADV)) | |
13652 | json_object_string_add( | |
13653 | json_cap, "dynamic", | |
13654 | "advertised"); | |
13655 | else if (CHECK_FLAG( | |
13656 | p->cap, | |
13657 | PEER_CAP_DYNAMIC_RCV)) | |
13658 | json_object_string_add( | |
13659 | json_cap, "dynamic", | |
13660 | "received"); | |
13661 | } | |
13662 | ||
13663 | /* Extended nexthop */ | |
13664 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13665 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13666 | json_object *json_nxt = NULL; | |
13667 | const char *print_store; | |
13668 | ||
13669 | ||
13670 | if (CHECK_FLAG(p->cap, | |
13671 | PEER_CAP_ENHE_ADV) | |
13672 | && CHECK_FLAG(p->cap, | |
13673 | PEER_CAP_ENHE_RCV)) | |
13674 | json_object_string_add( | |
13675 | json_cap, | |
13676 | "extendedNexthop", | |
13677 | "advertisedAndReceived"); | |
13678 | else if (CHECK_FLAG(p->cap, | |
13679 | PEER_CAP_ENHE_ADV)) | |
13680 | json_object_string_add( | |
13681 | json_cap, | |
13682 | "extendedNexthop", | |
13683 | "advertised"); | |
13684 | else if (CHECK_FLAG(p->cap, | |
13685 | PEER_CAP_ENHE_RCV)) | |
13686 | json_object_string_add( | |
13687 | json_cap, | |
13688 | "extendedNexthop", | |
13689 | "received"); | |
13690 | ||
13691 | if (CHECK_FLAG(p->cap, | |
13692 | PEER_CAP_ENHE_RCV)) { | |
13693 | json_nxt = | |
13694 | json_object_new_object(); | |
13695 | ||
13696 | for (safi = SAFI_UNICAST; | |
13697 | safi < SAFI_MAX; safi++) { | |
13698 | if (CHECK_FLAG( | |
13699 | p->af_cap | |
13700 | [AFI_IP] | |
13701 | [safi], | |
13702 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 13703 | print_store = get_afi_safi_str( |
d62a17ae | 13704 | AFI_IP, |
5cb5f4d0 | 13705 | safi, true); |
d62a17ae | 13706 | json_object_string_add( |
13707 | json_nxt, | |
13708 | print_store, | |
54f29523 | 13709 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 13710 | } |
13711 | } | |
13712 | json_object_object_add( | |
13713 | json_cap, | |
13714 | "extendedNexthopFamililesByPeer", | |
13715 | json_nxt); | |
13716 | } | |
13717 | } | |
13718 | ||
13719 | /* Route Refresh */ | |
13720 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13721 | || CHECK_FLAG(p->cap, | |
13722 | PEER_CAP_REFRESH_NEW_RCV) | |
13723 | || CHECK_FLAG(p->cap, | |
13724 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13725 | if (CHECK_FLAG(p->cap, | |
13726 | PEER_CAP_REFRESH_ADV) | |
13727 | && (CHECK_FLAG( | |
13728 | p->cap, | |
13729 | PEER_CAP_REFRESH_NEW_RCV) | |
13730 | || CHECK_FLAG( | |
13731 | p->cap, | |
13732 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13733 | if (CHECK_FLAG( | |
13734 | p->cap, | |
13735 | PEER_CAP_REFRESH_OLD_RCV) | |
13736 | && CHECK_FLAG( | |
13737 | p->cap, | |
13738 | PEER_CAP_REFRESH_NEW_RCV)) | |
13739 | json_object_string_add( | |
13740 | json_cap, | |
13741 | "routeRefresh", | |
13742 | "advertisedAndReceivedOldNew"); | |
13743 | else { | |
13744 | if (CHECK_FLAG( | |
13745 | p->cap, | |
13746 | PEER_CAP_REFRESH_OLD_RCV)) | |
13747 | json_object_string_add( | |
13748 | json_cap, | |
13749 | "routeRefresh", | |
13750 | "advertisedAndReceivedOld"); | |
13751 | else | |
13752 | json_object_string_add( | |
13753 | json_cap, | |
13754 | "routeRefresh", | |
13755 | "advertisedAndReceivedNew"); | |
13756 | } | |
13757 | } else if ( | |
13758 | CHECK_FLAG( | |
13759 | p->cap, | |
13760 | PEER_CAP_REFRESH_ADV)) | |
13761 | json_object_string_add( | |
13762 | json_cap, | |
13763 | "routeRefresh", | |
13764 | "advertised"); | |
13765 | else if ( | |
13766 | CHECK_FLAG( | |
13767 | p->cap, | |
13768 | PEER_CAP_REFRESH_NEW_RCV) | |
13769 | || CHECK_FLAG( | |
13770 | p->cap, | |
13771 | PEER_CAP_REFRESH_OLD_RCV)) | |
13772 | json_object_string_add( | |
13773 | json_cap, | |
13774 | "routeRefresh", | |
13775 | "received"); | |
13776 | } | |
13777 | ||
9af52ccf DA |
13778 | /* Enhanced Route Refresh */ |
13779 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
13780 | || CHECK_FLAG(p->cap, | |
13781 | PEER_CAP_ENHANCED_RR_RCV)) { | |
13782 | if (CHECK_FLAG(p->cap, | |
13783 | PEER_CAP_ENHANCED_RR_ADV) | |
13784 | && CHECK_FLAG( | |
13785 | p->cap, | |
13786 | PEER_CAP_ENHANCED_RR_RCV)) | |
13787 | json_object_string_add( | |
13788 | json_cap, | |
13789 | "enhancedRouteRefresh", | |
13790 | "advertisedAndReceived"); | |
13791 | else if ( | |
13792 | CHECK_FLAG( | |
13793 | p->cap, | |
13794 | PEER_CAP_ENHANCED_RR_ADV)) | |
13795 | json_object_string_add( | |
13796 | json_cap, | |
13797 | "enhancedRouteRefresh", | |
13798 | "advertised"); | |
13799 | else if ( | |
13800 | CHECK_FLAG( | |
13801 | p->cap, | |
13802 | PEER_CAP_ENHANCED_RR_RCV)) | |
13803 | json_object_string_add( | |
13804 | json_cap, | |
13805 | "enhancedRouteRefresh", | |
13806 | "received"); | |
13807 | } | |
13808 | ||
d62a17ae | 13809 | /* Multiprotocol Extensions */ |
13810 | json_object *json_multi = NULL; | |
13811 | json_multi = json_object_new_object(); | |
13812 | ||
05c7a1cc QY |
13813 | FOREACH_AFI_SAFI (afi, safi) { |
13814 | if (p->afc_adv[afi][safi] | |
13815 | || p->afc_recv[afi][safi]) { | |
13816 | json_object *json_exten = NULL; | |
13817 | json_exten = | |
13818 | json_object_new_object(); | |
13819 | ||
d62a17ae | 13820 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
13821 | && p->afc_recv[afi][safi]) |
13822 | json_object_boolean_true_add( | |
13823 | json_exten, | |
13824 | "advertisedAndReceived"); | |
13825 | else if (p->afc_adv[afi][safi]) | |
13826 | json_object_boolean_true_add( | |
13827 | json_exten, | |
13828 | "advertised"); | |
13829 | else if (p->afc_recv[afi][safi]) | |
13830 | json_object_boolean_true_add( | |
13831 | json_exten, | |
13832 | "received"); | |
d62a17ae | 13833 | |
05c7a1cc QY |
13834 | json_object_object_add( |
13835 | json_multi, | |
5cb5f4d0 DD |
13836 | get_afi_safi_str(afi, |
13837 | safi, | |
13838 | true), | |
05c7a1cc | 13839 | json_exten); |
d62a17ae | 13840 | } |
13841 | } | |
13842 | json_object_object_add( | |
13843 | json_cap, "multiprotocolExtensions", | |
13844 | json_multi); | |
13845 | ||
d77114b7 | 13846 | /* Hostname capabilities */ |
60466a63 | 13847 | json_object *json_hname = NULL; |
d77114b7 MK |
13848 | |
13849 | json_hname = json_object_new_object(); | |
13850 | ||
13851 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13852 | json_object_string_add( | |
60466a63 QY |
13853 | json_hname, "advHostName", |
13854 | bgp->peer_self->hostname | |
13855 | ? bgp->peer_self | |
13856 | ->hostname | |
d77114b7 MK |
13857 | : "n/a"); |
13858 | json_object_string_add( | |
60466a63 QY |
13859 | json_hname, "advDomainName", |
13860 | bgp->peer_self->domainname | |
13861 | ? bgp->peer_self | |
13862 | ->domainname | |
d77114b7 MK |
13863 | : "n/a"); |
13864 | } | |
13865 | ||
13866 | ||
13867 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13868 | json_object_string_add( | |
60466a63 QY |
13869 | json_hname, "rcvHostName", |
13870 | p->hostname ? p->hostname | |
13871 | : "n/a"); | |
d77114b7 | 13872 | json_object_string_add( |
60466a63 QY |
13873 | json_hname, "rcvDomainName", |
13874 | p->domainname ? p->domainname | |
13875 | : "n/a"); | |
d77114b7 MK |
13876 | } |
13877 | ||
60466a63 | 13878 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13879 | json_hname); |
13880 | ||
d62a17ae | 13881 | /* Gracefull Restart */ |
13882 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13883 | || CHECK_FLAG(p->cap, | |
13884 | PEER_CAP_RESTART_ADV)) { | |
13885 | if (CHECK_FLAG(p->cap, | |
13886 | PEER_CAP_RESTART_ADV) | |
13887 | && CHECK_FLAG(p->cap, | |
13888 | PEER_CAP_RESTART_RCV)) | |
13889 | json_object_string_add( | |
13890 | json_cap, | |
13891 | "gracefulRestart", | |
13892 | "advertisedAndReceived"); | |
13893 | else if (CHECK_FLAG( | |
13894 | p->cap, | |
13895 | PEER_CAP_RESTART_ADV)) | |
13896 | json_object_string_add( | |
13897 | json_cap, | |
13898 | "gracefulRestartCapability", | |
13899 | "advertised"); | |
13900 | else if (CHECK_FLAG( | |
13901 | p->cap, | |
13902 | PEER_CAP_RESTART_RCV)) | |
13903 | json_object_string_add( | |
13904 | json_cap, | |
13905 | "gracefulRestartCapability", | |
13906 | "received"); | |
13907 | ||
13908 | if (CHECK_FLAG(p->cap, | |
13909 | PEER_CAP_RESTART_RCV)) { | |
13910 | int restart_af_count = 0; | |
13911 | json_object *json_restart = | |
13912 | NULL; | |
13913 | json_restart = | |
13914 | json_object_new_object(); | |
13915 | ||
13916 | json_object_int_add( | |
13917 | json_cap, | |
13918 | "gracefulRestartRemoteTimerMsecs", | |
13919 | p->v_gr_restart * 1000); | |
13920 | ||
05c7a1cc QY |
13921 | FOREACH_AFI_SAFI (afi, safi) { |
13922 | if (CHECK_FLAG( | |
13923 | p->af_cap | |
13924 | [afi] | |
13925 | [safi], | |
13926 | PEER_CAP_RESTART_AF_RCV)) { | |
13927 | json_object * | |
13928 | json_sub = | |
13929 | NULL; | |
13930 | json_sub = | |
13931 | json_object_new_object(); | |
13932 | ||
d62a17ae | 13933 | if (CHECK_FLAG( |
13934 | p->af_cap | |
13935 | [afi] | |
13936 | [safi], | |
05c7a1cc QY |
13937 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13938 | json_object_boolean_true_add( | |
13939 | json_sub, | |
13940 | "preserved"); | |
13941 | restart_af_count++; | |
13942 | json_object_object_add( | |
13943 | json_restart, | |
5cb5f4d0 | 13944 | get_afi_safi_str( |
05c7a1cc | 13945 | afi, |
5cb5f4d0 DD |
13946 | safi, |
13947 | true), | |
05c7a1cc | 13948 | json_sub); |
d62a17ae | 13949 | } |
13950 | } | |
13951 | if (!restart_af_count) { | |
13952 | json_object_string_add( | |
13953 | json_cap, | |
13954 | "addressFamiliesByPeer", | |
13955 | "none"); | |
13956 | json_object_free( | |
13957 | json_restart); | |
13958 | } else | |
13959 | json_object_object_add( | |
13960 | json_cap, | |
13961 | "addressFamiliesByPeer", | |
13962 | json_restart); | |
13963 | } | |
13964 | } | |
13965 | json_object_object_add(json_neigh, | |
13966 | "neighborCapabilities", | |
13967 | json_cap); | |
13968 | } else { | |
13969 | vty_out(vty, " Neighbor capabilities:\n"); | |
13970 | ||
13971 | /* AS4 */ | |
13972 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13973 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13974 | vty_out(vty, " 4 Byte AS:"); | |
13975 | if (CHECK_FLAG(p->cap, | |
13976 | PEER_CAP_AS4_ADV)) | |
13977 | vty_out(vty, " advertised"); | |
13978 | if (CHECK_FLAG(p->cap, | |
13979 | PEER_CAP_AS4_RCV)) | |
13980 | vty_out(vty, " %sreceived", | |
13981 | CHECK_FLAG( | |
13982 | p->cap, | |
13983 | PEER_CAP_AS4_ADV) | |
13984 | ? "and " | |
13985 | : ""); | |
13986 | vty_out(vty, "\n"); | |
13987 | } | |
13988 | ||
ef56aee4 DA |
13989 | /* Extended Message Support */ |
13990 | if (CHECK_FLAG(p->cap, | |
13991 | PEER_CAP_EXTENDED_MESSAGE_RCV) | |
13992 | || CHECK_FLAG( | |
13993 | p->cap, | |
13994 | PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13995 | vty_out(vty, " Extended Message:"); | |
13996 | if (CHECK_FLAG( | |
13997 | p->cap, | |
13998 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13999 | vty_out(vty, " advertised"); | |
14000 | if (CHECK_FLAG( | |
14001 | p->cap, | |
14002 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
14003 | vty_out(vty, " %sreceived", | |
14004 | CHECK_FLAG( | |
14005 | p->cap, | |
14006 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
14007 | ? "and " | |
14008 | : ""); | |
14009 | vty_out(vty, "\n"); | |
14010 | } | |
14011 | ||
d62a17ae | 14012 | /* AddPath */ |
14013 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
14014 | || CHECK_FLAG(p->cap, | |
14015 | PEER_CAP_ADDPATH_ADV)) { | |
14016 | vty_out(vty, " AddPath:\n"); | |
14017 | ||
05c7a1cc QY |
14018 | FOREACH_AFI_SAFI (afi, safi) { |
14019 | if (CHECK_FLAG( | |
14020 | p->af_cap[afi] | |
14021 | [safi], | |
14022 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
14023 | || CHECK_FLAG( | |
14024 | p->af_cap[afi] | |
14025 | [safi], | |
14026 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
14027 | vty_out(vty, | |
14028 | " %s: TX ", | |
5cb5f4d0 | 14029 | get_afi_safi_str( |
05c7a1cc | 14030 | afi, |
5cb5f4d0 DD |
14031 | safi, |
14032 | false)); | |
05c7a1cc | 14033 | |
d62a17ae | 14034 | if (CHECK_FLAG( |
14035 | p->af_cap | |
14036 | [afi] | |
14037 | [safi], | |
05c7a1cc | 14038 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 14039 | vty_out(vty, |
05c7a1cc | 14040 | "advertised %s", |
5cb5f4d0 | 14041 | get_afi_safi_str( |
d62a17ae | 14042 | afi, |
5cb5f4d0 DD |
14043 | safi, |
14044 | false)); | |
d62a17ae | 14045 | |
05c7a1cc QY |
14046 | if (CHECK_FLAG( |
14047 | p->af_cap | |
14048 | [afi] | |
14049 | [safi], | |
14050 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
14051 | vty_out(vty, | |
14052 | "%sreceived", | |
14053 | CHECK_FLAG( | |
14054 | p->af_cap | |
14055 | [afi] | |
14056 | [safi], | |
14057 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
14058 | ? " and " | |
14059 | : ""); | |
d62a17ae | 14060 | |
05c7a1cc QY |
14061 | vty_out(vty, "\n"); |
14062 | } | |
d62a17ae | 14063 | |
05c7a1cc QY |
14064 | if (CHECK_FLAG( |
14065 | p->af_cap[afi] | |
14066 | [safi], | |
14067 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
14068 | || CHECK_FLAG( | |
14069 | p->af_cap[afi] | |
14070 | [safi], | |
14071 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
14072 | vty_out(vty, | |
14073 | " %s: RX ", | |
5cb5f4d0 | 14074 | get_afi_safi_str( |
05c7a1cc | 14075 | afi, |
5cb5f4d0 DD |
14076 | safi, |
14077 | false)); | |
d62a17ae | 14078 | |
14079 | if (CHECK_FLAG( | |
14080 | p->af_cap | |
14081 | [afi] | |
14082 | [safi], | |
05c7a1cc | 14083 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 14084 | vty_out(vty, |
05c7a1cc | 14085 | "advertised %s", |
5cb5f4d0 | 14086 | get_afi_safi_str( |
d62a17ae | 14087 | afi, |
5cb5f4d0 DD |
14088 | safi, |
14089 | false)); | |
d62a17ae | 14090 | |
05c7a1cc QY |
14091 | if (CHECK_FLAG( |
14092 | p->af_cap | |
14093 | [afi] | |
14094 | [safi], | |
14095 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 14096 | vty_out(vty, |
05c7a1cc QY |
14097 | "%sreceived", |
14098 | CHECK_FLAG( | |
14099 | p->af_cap | |
14100 | [afi] | |
14101 | [safi], | |
14102 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
14103 | ? " and " | |
14104 | : ""); | |
14105 | ||
14106 | vty_out(vty, "\n"); | |
d62a17ae | 14107 | } |
05c7a1cc | 14108 | } |
d62a17ae | 14109 | } |
14110 | ||
14111 | /* Dynamic */ | |
14112 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
14113 | || CHECK_FLAG(p->cap, | |
14114 | PEER_CAP_DYNAMIC_ADV)) { | |
14115 | vty_out(vty, " Dynamic:"); | |
14116 | if (CHECK_FLAG(p->cap, | |
14117 | PEER_CAP_DYNAMIC_ADV)) | |
14118 | vty_out(vty, " advertised"); | |
14119 | if (CHECK_FLAG(p->cap, | |
14120 | PEER_CAP_DYNAMIC_RCV)) | |
14121 | vty_out(vty, " %sreceived", | |
14122 | CHECK_FLAG( | |
14123 | p->cap, | |
14124 | PEER_CAP_DYNAMIC_ADV) | |
14125 | ? "and " | |
14126 | : ""); | |
14127 | vty_out(vty, "\n"); | |
14128 | } | |
14129 | ||
14130 | /* Extended nexthop */ | |
14131 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
14132 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
14133 | vty_out(vty, " Extended nexthop:"); | |
14134 | if (CHECK_FLAG(p->cap, | |
14135 | PEER_CAP_ENHE_ADV)) | |
14136 | vty_out(vty, " advertised"); | |
14137 | if (CHECK_FLAG(p->cap, | |
14138 | PEER_CAP_ENHE_RCV)) | |
14139 | vty_out(vty, " %sreceived", | |
14140 | CHECK_FLAG( | |
14141 | p->cap, | |
14142 | PEER_CAP_ENHE_ADV) | |
14143 | ? "and " | |
14144 | : ""); | |
14145 | vty_out(vty, "\n"); | |
14146 | ||
14147 | if (CHECK_FLAG(p->cap, | |
14148 | PEER_CAP_ENHE_RCV)) { | |
14149 | vty_out(vty, | |
14150 | " Address families by peer:\n "); | |
14151 | for (safi = SAFI_UNICAST; | |
14152 | safi < SAFI_MAX; safi++) | |
14153 | if (CHECK_FLAG( | |
14154 | p->af_cap | |
14155 | [AFI_IP] | |
14156 | [safi], | |
14157 | PEER_CAP_ENHE_AF_RCV)) | |
14158 | vty_out(vty, | |
14159 | " %s\n", | |
5cb5f4d0 | 14160 | get_afi_safi_str( |
d62a17ae | 14161 | AFI_IP, |
5cb5f4d0 DD |
14162 | safi, |
14163 | false)); | |
d62a17ae | 14164 | } |
14165 | } | |
14166 | ||
14167 | /* Route Refresh */ | |
14168 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
14169 | || CHECK_FLAG(p->cap, | |
14170 | PEER_CAP_REFRESH_NEW_RCV) | |
14171 | || CHECK_FLAG(p->cap, | |
14172 | PEER_CAP_REFRESH_OLD_RCV)) { | |
14173 | vty_out(vty, " Route refresh:"); | |
14174 | if (CHECK_FLAG(p->cap, | |
14175 | PEER_CAP_REFRESH_ADV)) | |
14176 | vty_out(vty, " advertised"); | |
14177 | if (CHECK_FLAG(p->cap, | |
14178 | PEER_CAP_REFRESH_NEW_RCV) | |
14179 | || CHECK_FLAG( | |
14180 | p->cap, | |
14181 | PEER_CAP_REFRESH_OLD_RCV)) | |
14182 | vty_out(vty, " %sreceived(%s)", | |
14183 | CHECK_FLAG( | |
14184 | p->cap, | |
14185 | PEER_CAP_REFRESH_ADV) | |
14186 | ? "and " | |
14187 | : "", | |
14188 | (CHECK_FLAG( | |
14189 | p->cap, | |
14190 | PEER_CAP_REFRESH_OLD_RCV) | |
14191 | && CHECK_FLAG( | |
14192 | p->cap, | |
14193 | PEER_CAP_REFRESH_NEW_RCV)) | |
14194 | ? "old & new" | |
14195 | : CHECK_FLAG( | |
14196 | p->cap, | |
14197 | PEER_CAP_REFRESH_OLD_RCV) | |
14198 | ? "old" | |
14199 | : "new"); | |
14200 | ||
14201 | vty_out(vty, "\n"); | |
14202 | } | |
14203 | ||
9af52ccf DA |
14204 | /* Enhanced Route Refresh */ |
14205 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
14206 | || CHECK_FLAG(p->cap, | |
14207 | PEER_CAP_ENHANCED_RR_RCV)) { | |
14208 | vty_out(vty, | |
14209 | " Enhanced Route Refresh:"); | |
14210 | if (CHECK_FLAG( | |
14211 | p->cap, | |
14212 | PEER_CAP_ENHANCED_RR_ADV)) | |
14213 | vty_out(vty, " advertised"); | |
14214 | if (CHECK_FLAG( | |
14215 | p->cap, | |
14216 | PEER_CAP_ENHANCED_RR_RCV)) | |
14217 | vty_out(vty, " %sreceived", | |
14218 | CHECK_FLAG( | |
14219 | p->cap, | |
14220 | PEER_CAP_REFRESH_ADV) | |
14221 | ? "and " | |
14222 | : ""); | |
14223 | vty_out(vty, "\n"); | |
14224 | } | |
14225 | ||
d62a17ae | 14226 | /* Multiprotocol Extensions */ |
05c7a1cc QY |
14227 | FOREACH_AFI_SAFI (afi, safi) |
14228 | if (p->afc_adv[afi][safi] | |
14229 | || p->afc_recv[afi][safi]) { | |
14230 | vty_out(vty, | |
14231 | " Address Family %s:", | |
5cb5f4d0 DD |
14232 | get_afi_safi_str( |
14233 | afi, | |
14234 | safi, | |
14235 | false)); | |
05c7a1cc | 14236 | if (p->afc_adv[afi][safi]) |
d62a17ae | 14237 | vty_out(vty, |
05c7a1cc QY |
14238 | " advertised"); |
14239 | if (p->afc_recv[afi][safi]) | |
14240 | vty_out(vty, | |
14241 | " %sreceived", | |
14242 | p->afc_adv[afi] | |
14243 | [safi] | |
14244 | ? "and " | |
14245 | : ""); | |
14246 | vty_out(vty, "\n"); | |
14247 | } | |
d62a17ae | 14248 | |
14249 | /* Hostname capability */ | |
60466a63 | 14250 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
14251 | |
14252 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
14253 | vty_out(vty, |
14254 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
14255 | bgp->peer_self->hostname |
14256 | ? bgp->peer_self | |
14257 | ->hostname | |
d77114b7 | 14258 | : "n/a", |
60466a63 QY |
14259 | bgp->peer_self->domainname |
14260 | ? bgp->peer_self | |
14261 | ->domainname | |
d77114b7 MK |
14262 | : "n/a"); |
14263 | } else { | |
14264 | vty_out(vty, " not advertised"); | |
d62a17ae | 14265 | } |
14266 | ||
d77114b7 | 14267 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
14268 | vty_out(vty, |
14269 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
14270 | p->hostname ? p->hostname |
14271 | : "n/a", | |
14272 | p->domainname ? p->domainname | |
14273 | : "n/a"); | |
d77114b7 MK |
14274 | } else { |
14275 | vty_out(vty, " not received"); | |
14276 | } | |
14277 | ||
14278 | vty_out(vty, "\n"); | |
14279 | ||
61bfbd51 | 14280 | /* Graceful Restart */ |
d62a17ae | 14281 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
14282 | || CHECK_FLAG(p->cap, | |
14283 | PEER_CAP_RESTART_ADV)) { | |
14284 | vty_out(vty, | |
61bfbd51 | 14285 | " Graceful Restart Capability:"); |
d62a17ae | 14286 | if (CHECK_FLAG(p->cap, |
14287 | PEER_CAP_RESTART_ADV)) | |
14288 | vty_out(vty, " advertised"); | |
14289 | if (CHECK_FLAG(p->cap, | |
14290 | PEER_CAP_RESTART_RCV)) | |
14291 | vty_out(vty, " %sreceived", | |
14292 | CHECK_FLAG( | |
14293 | p->cap, | |
14294 | PEER_CAP_RESTART_ADV) | |
14295 | ? "and " | |
14296 | : ""); | |
14297 | vty_out(vty, "\n"); | |
14298 | ||
14299 | if (CHECK_FLAG(p->cap, | |
14300 | PEER_CAP_RESTART_RCV)) { | |
14301 | int restart_af_count = 0; | |
14302 | ||
14303 | vty_out(vty, | |
14304 | " Remote Restart timer is %d seconds\n", | |
14305 | p->v_gr_restart); | |
14306 | vty_out(vty, | |
14307 | " Address families by peer:\n "); | |
14308 | ||
05c7a1cc QY |
14309 | FOREACH_AFI_SAFI (afi, safi) |
14310 | if (CHECK_FLAG( | |
14311 | p->af_cap | |
14312 | [afi] | |
14313 | [safi], | |
14314 | PEER_CAP_RESTART_AF_RCV)) { | |
14315 | vty_out(vty, | |
14316 | "%s%s(%s)", | |
14317 | restart_af_count | |
14318 | ? ", " | |
14319 | : "", | |
5cb5f4d0 | 14320 | get_afi_safi_str( |
05c7a1cc | 14321 | afi, |
5cb5f4d0 DD |
14322 | safi, |
14323 | false), | |
05c7a1cc QY |
14324 | CHECK_FLAG( |
14325 | p->af_cap | |
14326 | [afi] | |
14327 | [safi], | |
14328 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
14329 | ? "preserved" | |
14330 | : "not preserved"); | |
14331 | restart_af_count++; | |
14332 | } | |
d62a17ae | 14333 | if (!restart_af_count) |
14334 | vty_out(vty, "none"); | |
14335 | vty_out(vty, "\n"); | |
14336 | } | |
2986cac2 | 14337 | } /* Gracefull Restart */ |
d62a17ae | 14338 | } |
14339 | } | |
14340 | } | |
14341 | ||
14342 | /* graceful restart information */ | |
d62a17ae | 14343 | json_object *json_grace = NULL; |
14344 | json_object *json_grace_send = NULL; | |
14345 | json_object *json_grace_recv = NULL; | |
14346 | int eor_send_af_count = 0; | |
14347 | int eor_receive_af_count = 0; | |
14348 | ||
14349 | if (use_json) { | |
14350 | json_grace = json_object_new_object(); | |
14351 | json_grace_send = json_object_new_object(); | |
14352 | json_grace_recv = json_object_new_object(); | |
14353 | ||
feb17238 | 14354 | if ((peer_established(p)) |
36235319 | 14355 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
05c7a1cc QY |
14356 | FOREACH_AFI_SAFI (afi, safi) { |
14357 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 14358 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
14359 | json_object_boolean_true_add( |
14360 | json_grace_send, | |
5cb5f4d0 DD |
14361 | get_afi_safi_str(afi, |
14362 | safi, | |
14363 | true)); | |
05c7a1cc | 14364 | eor_send_af_count++; |
d62a17ae | 14365 | } |
14366 | } | |
05c7a1cc QY |
14367 | FOREACH_AFI_SAFI (afi, safi) { |
14368 | if (CHECK_FLAG( | |
36235319 QY |
14369 | p->af_sflags[afi][safi], |
14370 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
14371 | json_object_boolean_true_add( |
14372 | json_grace_recv, | |
5cb5f4d0 DD |
14373 | get_afi_safi_str(afi, |
14374 | safi, | |
14375 | true)); | |
05c7a1cc | 14376 | eor_receive_af_count++; |
d62a17ae | 14377 | } |
14378 | } | |
14379 | } | |
36235319 QY |
14380 | json_object_object_add(json_grace, "endOfRibSend", |
14381 | json_grace_send); | |
14382 | json_object_object_add(json_grace, "endOfRibRecv", | |
14383 | json_grace_recv); | |
d62a17ae | 14384 | |
d62a17ae | 14385 | |
14386 | if (p->t_gr_restart) | |
14387 | json_object_int_add(json_grace, | |
14388 | "gracefulRestartTimerMsecs", | |
14389 | thread_timer_remain_second( | |
14390 | p->t_gr_restart) | |
14391 | * 1000); | |
14392 | ||
14393 | if (p->t_gr_stale) | |
14394 | json_object_int_add( | |
14395 | json_grace, | |
14396 | "gracefulStalepathTimerMsecs", | |
14397 | thread_timer_remain_second( | |
14398 | p->t_gr_stale) | |
14399 | * 1000); | |
2986cac2 | 14400 | /* more gr info in new format */ |
14401 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 14402 | json_grace); |
d62a17ae | 14403 | json_object_object_add( |
14404 | json_neigh, "gracefulRestartInfo", json_grace); | |
14405 | } else { | |
2089dd80 | 14406 | vty_out(vty, " Graceful restart information:\n"); |
feb17238 | 14407 | if ((peer_established(p)) |
36235319 | 14408 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
2986cac2 | 14409 | |
d62a17ae | 14410 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
14411 | FOREACH_AFI_SAFI (afi, safi) { |
14412 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14413 | PEER_STATUS_EOR_SEND)) { | |
14414 | vty_out(vty, "%s%s", | |
14415 | eor_send_af_count ? ", " | |
14416 | : "", | |
36235319 QY |
14417 | get_afi_safi_str( |
14418 | afi, safi, | |
14419 | false)); | |
05c7a1cc | 14420 | eor_send_af_count++; |
d62a17ae | 14421 | } |
14422 | } | |
14423 | vty_out(vty, "\n"); | |
14424 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
14425 | FOREACH_AFI_SAFI (afi, safi) { |
14426 | if (CHECK_FLAG( | |
14427 | p->af_sflags[afi][safi], | |
14428 | PEER_STATUS_EOR_RECEIVED)) { | |
14429 | vty_out(vty, "%s%s", | |
14430 | eor_receive_af_count | |
14431 | ? ", " | |
14432 | : "", | |
5cb5f4d0 DD |
14433 | get_afi_safi_str(afi, |
14434 | safi, | |
14435 | false)); | |
05c7a1cc | 14436 | eor_receive_af_count++; |
d62a17ae | 14437 | } |
14438 | } | |
14439 | vty_out(vty, "\n"); | |
14440 | } | |
14441 | ||
14442 | if (p->t_gr_restart) | |
14443 | vty_out(vty, | |
14444 | " The remaining time of restart timer is %ld\n", | |
14445 | thread_timer_remain_second( | |
14446 | p->t_gr_restart)); | |
14447 | ||
14448 | if (p->t_gr_stale) | |
14449 | vty_out(vty, | |
14450 | " The remaining time of stalepath timer is %ld\n", | |
14451 | thread_timer_remain_second( | |
14452 | p->t_gr_stale)); | |
2986cac2 | 14453 | |
14454 | /* more gr info in new format */ | |
14455 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 14456 | } |
2986cac2 | 14457 | |
d62a17ae | 14458 | if (use_json) { |
14459 | json_object *json_stat = NULL; | |
14460 | json_stat = json_object_new_object(); | |
14461 | /* Packet counts. */ | |
43aa5965 QY |
14462 | |
14463 | atomic_size_t outq_count, inq_count; | |
14464 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14465 | memory_order_relaxed); | |
14466 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14467 | memory_order_relaxed); | |
14468 | ||
14469 | json_object_int_add(json_stat, "depthInq", | |
14470 | (unsigned long)inq_count); | |
d62a17ae | 14471 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 14472 | (unsigned long)outq_count); |
0112e9e0 QY |
14473 | json_object_int_add(json_stat, "opensSent", |
14474 | atomic_load_explicit(&p->open_out, | |
14475 | memory_order_relaxed)); | |
14476 | json_object_int_add(json_stat, "opensRecv", | |
14477 | atomic_load_explicit(&p->open_in, | |
14478 | memory_order_relaxed)); | |
d62a17ae | 14479 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
14480 | atomic_load_explicit(&p->notify_out, |
14481 | memory_order_relaxed)); | |
d62a17ae | 14482 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
14483 | atomic_load_explicit(&p->notify_in, |
14484 | memory_order_relaxed)); | |
14485 | json_object_int_add(json_stat, "updatesSent", | |
14486 | atomic_load_explicit(&p->update_out, | |
14487 | memory_order_relaxed)); | |
14488 | json_object_int_add(json_stat, "updatesRecv", | |
14489 | atomic_load_explicit(&p->update_in, | |
14490 | memory_order_relaxed)); | |
d62a17ae | 14491 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
14492 | atomic_load_explicit(&p->keepalive_out, |
14493 | memory_order_relaxed)); | |
d62a17ae | 14494 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
14495 | atomic_load_explicit(&p->keepalive_in, |
14496 | memory_order_relaxed)); | |
d62a17ae | 14497 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
14498 | atomic_load_explicit(&p->refresh_out, |
14499 | memory_order_relaxed)); | |
d62a17ae | 14500 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
14501 | atomic_load_explicit(&p->refresh_in, |
14502 | memory_order_relaxed)); | |
d62a17ae | 14503 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
14504 | atomic_load_explicit(&p->dynamic_cap_out, |
14505 | memory_order_relaxed)); | |
d62a17ae | 14506 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
14507 | atomic_load_explicit(&p->dynamic_cap_in, |
14508 | memory_order_relaxed)); | |
14509 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
14510 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 14511 | json_object_object_add(json_neigh, "messageStats", json_stat); |
14512 | } else { | |
43aa5965 QY |
14513 | atomic_size_t outq_count, inq_count; |
14514 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14515 | memory_order_relaxed); | |
14516 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14517 | memory_order_relaxed); | |
14518 | ||
d62a17ae | 14519 | /* Packet counts. */ |
14520 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
14521 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
14522 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 14523 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
14524 | vty_out(vty, " Opens: %10d %10d\n", |
14525 | atomic_load_explicit(&p->open_out, | |
14526 | memory_order_relaxed), | |
14527 | atomic_load_explicit(&p->open_in, | |
14528 | memory_order_relaxed)); | |
14529 | vty_out(vty, " Notifications: %10d %10d\n", | |
14530 | atomic_load_explicit(&p->notify_out, | |
14531 | memory_order_relaxed), | |
14532 | atomic_load_explicit(&p->notify_in, | |
14533 | memory_order_relaxed)); | |
14534 | vty_out(vty, " Updates: %10d %10d\n", | |
14535 | atomic_load_explicit(&p->update_out, | |
14536 | memory_order_relaxed), | |
14537 | atomic_load_explicit(&p->update_in, | |
14538 | memory_order_relaxed)); | |
14539 | vty_out(vty, " Keepalives: %10d %10d\n", | |
14540 | atomic_load_explicit(&p->keepalive_out, | |
14541 | memory_order_relaxed), | |
14542 | atomic_load_explicit(&p->keepalive_in, | |
14543 | memory_order_relaxed)); | |
14544 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
14545 | atomic_load_explicit(&p->refresh_out, | |
14546 | memory_order_relaxed), | |
14547 | atomic_load_explicit(&p->refresh_in, | |
14548 | memory_order_relaxed)); | |
d62a17ae | 14549 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
14550 | atomic_load_explicit(&p->dynamic_cap_out, |
14551 | memory_order_relaxed), | |
14552 | atomic_load_explicit(&p->dynamic_cap_in, | |
14553 | memory_order_relaxed)); | |
14554 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
14555 | PEER_TOTAL_RX(p)); | |
d62a17ae | 14556 | } |
14557 | ||
14558 | if (use_json) { | |
14559 | /* advertisement-interval */ | |
14560 | json_object_int_add(json_neigh, | |
14561 | "minBtwnAdvertisementRunsTimerMsecs", | |
14562 | p->v_routeadv * 1000); | |
14563 | ||
14564 | /* Update-source. */ | |
14565 | if (p->update_if || p->update_source) { | |
14566 | if (p->update_if) | |
14567 | json_object_string_add(json_neigh, | |
14568 | "updateSource", | |
14569 | p->update_if); | |
14570 | else if (p->update_source) | |
14571 | json_object_string_add( | |
14572 | json_neigh, "updateSource", | |
14573 | sockunion2str(p->update_source, buf1, | |
14574 | SU_ADDRSTRLEN)); | |
14575 | } | |
14576 | } else { | |
14577 | /* advertisement-interval */ | |
14578 | vty_out(vty, | |
14579 | " Minimum time between advertisement runs is %d seconds\n", | |
14580 | p->v_routeadv); | |
14581 | ||
14582 | /* Update-source. */ | |
14583 | if (p->update_if || p->update_source) { | |
14584 | vty_out(vty, " Update source is "); | |
14585 | if (p->update_if) | |
14586 | vty_out(vty, "%s", p->update_if); | |
14587 | else if (p->update_source) | |
14588 | vty_out(vty, "%s", | |
14589 | sockunion2str(p->update_source, buf1, | |
14590 | SU_ADDRSTRLEN)); | |
14591 | vty_out(vty, "\n"); | |
14592 | } | |
14593 | ||
14594 | vty_out(vty, "\n"); | |
14595 | } | |
14596 | ||
14597 | /* Address Family Information */ | |
14598 | json_object *json_hold = NULL; | |
14599 | ||
14600 | if (use_json) | |
14601 | json_hold = json_object_new_object(); | |
14602 | ||
05c7a1cc QY |
14603 | FOREACH_AFI_SAFI (afi, safi) |
14604 | if (p->afc[afi][safi]) | |
14605 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
14606 | json_hold); | |
d62a17ae | 14607 | |
14608 | if (use_json) { | |
14609 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
14610 | json_hold); | |
14611 | json_object_int_add(json_neigh, "connectionsEstablished", | |
14612 | p->established); | |
14613 | json_object_int_add(json_neigh, "connectionsDropped", | |
14614 | p->dropped); | |
14615 | } else | |
14616 | vty_out(vty, " Connections established %d; dropped %d\n", | |
14617 | p->established, p->dropped); | |
14618 | ||
14619 | if (!p->last_reset) { | |
14620 | if (use_json) | |
14621 | json_object_string_add(json_neigh, "lastReset", | |
14622 | "never"); | |
14623 | else | |
14624 | vty_out(vty, " Last reset never\n"); | |
14625 | } else { | |
14626 | if (use_json) { | |
14627 | time_t uptime; | |
a2700b50 | 14628 | struct tm tm; |
d62a17ae | 14629 | |
14630 | uptime = bgp_clock(); | |
14631 | uptime -= p->resettime; | |
a2700b50 MS |
14632 | gmtime_r(&uptime, &tm); |
14633 | ||
d62a17ae | 14634 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
14635 | (tm.tm_sec * 1000) |
14636 | + (tm.tm_min * 60000) | |
14637 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 14638 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 14639 | } else { |
14640 | vty_out(vty, " Last reset %s, ", | |
14641 | peer_uptime(p->resettime, timebuf, | |
14642 | BGP_UPTIME_LEN, 0, NULL)); | |
14643 | ||
3577f1c5 | 14644 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 14645 | if (p->last_reset_cause_size) { |
14646 | msg = p->last_reset_cause; | |
14647 | vty_out(vty, | |
14648 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
14649 | for (i = 1; i <= p->last_reset_cause_size; | |
14650 | i++) { | |
14651 | vty_out(vty, "%02X", *msg++); | |
14652 | ||
14653 | if (i != p->last_reset_cause_size) { | |
14654 | if (i % 16 == 0) { | |
14655 | vty_out(vty, "\n "); | |
14656 | } else if (i % 4 == 0) { | |
14657 | vty_out(vty, " "); | |
14658 | } | |
14659 | } | |
14660 | } | |
14661 | vty_out(vty, "\n"); | |
14662 | } | |
14663 | } | |
14664 | } | |
14665 | ||
14666 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
14667 | if (use_json) | |
14668 | json_object_boolean_true_add(json_neigh, | |
14669 | "prefixesConfigExceedMax"); | |
14670 | else | |
14671 | vty_out(vty, | |
14672 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
14673 | ||
14674 | if (p->t_pmax_restart) { | |
14675 | if (use_json) { | |
14676 | json_object_boolean_true_add( | |
14677 | json_neigh, "reducePrefixNumFrom"); | |
14678 | json_object_int_add(json_neigh, | |
14679 | "restartInTimerMsec", | |
14680 | thread_timer_remain_second( | |
14681 | p->t_pmax_restart) | |
14682 | * 1000); | |
14683 | } else | |
14684 | vty_out(vty, | |
14685 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
14686 | p->host, thread_timer_remain_second( |
14687 | p->t_pmax_restart)); | |
d62a17ae | 14688 | } else { |
14689 | if (use_json) | |
14690 | json_object_boolean_true_add( | |
14691 | json_neigh, | |
14692 | "reducePrefixNumAndClearIpBgp"); | |
14693 | else | |
14694 | vty_out(vty, | |
14695 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
14696 | p->host); | |
14697 | } | |
14698 | } | |
14699 | ||
14700 | /* EBGP Multihop and GTSM */ | |
14701 | if (p->sort != BGP_PEER_IBGP) { | |
14702 | if (use_json) { | |
e2521429 | 14703 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14704 | json_object_int_add(json_neigh, |
14705 | "externalBgpNbrMaxHopsAway", | |
14706 | p->gtsm_hops); | |
c8d6f0d6 | 14707 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 14708 | json_object_int_add(json_neigh, |
14709 | "externalBgpNbrMaxHopsAway", | |
14710 | p->ttl); | |
14711 | } else { | |
e2521429 | 14712 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14713 | vty_out(vty, |
14714 | " External BGP neighbor may be up to %d hops away.\n", | |
14715 | p->gtsm_hops); | |
c8d6f0d6 | 14716 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 14717 | vty_out(vty, |
14718 | " External BGP neighbor may be up to %d hops away.\n", | |
14719 | p->ttl); | |
14720 | } | |
14721 | } else { | |
e2521429 | 14722 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 14723 | if (use_json) |
14724 | json_object_int_add(json_neigh, | |
14725 | "internalBgpNbrMaxHopsAway", | |
14726 | p->gtsm_hops); | |
14727 | else | |
14728 | vty_out(vty, | |
14729 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14730 | p->gtsm_hops); | |
14731 | } | |
14732 | } | |
14733 | ||
14734 | /* Local address. */ | |
14735 | if (p->su_local) { | |
14736 | if (use_json) { | |
14737 | json_object_string_add(json_neigh, "hostLocal", | |
14738 | sockunion2str(p->su_local, buf1, | |
14739 | SU_ADDRSTRLEN)); | |
14740 | json_object_int_add(json_neigh, "portLocal", | |
14741 | ntohs(p->su_local->sin.sin_port)); | |
14742 | } else | |
14743 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
14744 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
14745 | ntohs(p->su_local->sin.sin_port)); | |
14746 | } | |
14747 | ||
14748 | /* Remote address. */ | |
14749 | if (p->su_remote) { | |
14750 | if (use_json) { | |
14751 | json_object_string_add(json_neigh, "hostForeign", | |
14752 | sockunion2str(p->su_remote, buf1, | |
14753 | SU_ADDRSTRLEN)); | |
14754 | json_object_int_add(json_neigh, "portForeign", | |
14755 | ntohs(p->su_remote->sin.sin_port)); | |
14756 | } else | |
14757 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
14758 | sockunion2str(p->su_remote, buf1, | |
14759 | SU_ADDRSTRLEN), | |
14760 | ntohs(p->su_remote->sin.sin_port)); | |
14761 | } | |
14762 | ||
14763 | /* Nexthop display. */ | |
14764 | if (p->su_local) { | |
14765 | if (use_json) { | |
14766 | json_object_string_add(json_neigh, "nexthop", | |
14767 | inet_ntop(AF_INET, | |
14768 | &p->nexthop.v4, buf1, | |
14769 | sizeof(buf1))); | |
14770 | json_object_string_add(json_neigh, "nexthopGlobal", | |
14771 | inet_ntop(AF_INET6, | |
14772 | &p->nexthop.v6_global, | |
14773 | buf1, sizeof(buf1))); | |
14774 | json_object_string_add(json_neigh, "nexthopLocal", | |
14775 | inet_ntop(AF_INET6, | |
14776 | &p->nexthop.v6_local, | |
14777 | buf1, sizeof(buf1))); | |
14778 | if (p->shared_network) | |
14779 | json_object_string_add(json_neigh, | |
14780 | "bgpConnection", | |
14781 | "sharedNetwork"); | |
14782 | else | |
14783 | json_object_string_add(json_neigh, | |
14784 | "bgpConnection", | |
14785 | "nonSharedNetwork"); | |
14786 | } else { | |
14787 | vty_out(vty, "Nexthop: %s\n", | |
14788 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
14789 | sizeof(buf1))); | |
14790 | vty_out(vty, "Nexthop global: %s\n", | |
14791 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
14792 | sizeof(buf1))); | |
14793 | vty_out(vty, "Nexthop local: %s\n", | |
14794 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
14795 | sizeof(buf1))); | |
14796 | vty_out(vty, "BGP connection: %s\n", | |
14797 | p->shared_network ? "shared network" | |
14798 | : "non shared network"); | |
14799 | } | |
14800 | } | |
14801 | ||
14802 | /* Timer information. */ | |
14803 | if (use_json) { | |
14804 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14805 | p->v_connect); | |
feb17238 | 14806 | if (peer_established(p) && p->rtt) |
d62a17ae | 14807 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14808 | p->rtt); | |
14809 | if (p->t_start) | |
14810 | json_object_int_add( | |
14811 | json_neigh, "nextStartTimerDueInMsecs", | |
14812 | thread_timer_remain_second(p->t_start) * 1000); | |
14813 | if (p->t_connect) | |
14814 | json_object_int_add( | |
14815 | json_neigh, "nextConnectTimerDueInMsecs", | |
14816 | thread_timer_remain_second(p->t_connect) | |
14817 | * 1000); | |
14818 | if (p->t_routeadv) { | |
14819 | json_object_int_add(json_neigh, "mraiInterval", | |
14820 | p->v_routeadv); | |
14821 | json_object_int_add( | |
14822 | json_neigh, "mraiTimerExpireInMsecs", | |
14823 | thread_timer_remain_second(p->t_routeadv) | |
14824 | * 1000); | |
14825 | } | |
14826 | if (p->password) | |
14827 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14828 | 1); | |
14829 | ||
14830 | if (p->t_read) | |
14831 | json_object_string_add(json_neigh, "readThread", "on"); | |
14832 | else | |
14833 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14834 | |
14835 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14836 | json_object_string_add(json_neigh, "writeThread", "on"); |
14837 | else | |
14838 | json_object_string_add(json_neigh, "writeThread", | |
14839 | "off"); | |
14840 | } else { | |
14841 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14842 | p->v_connect); | |
feb17238 | 14843 | if (peer_established(p) && p->rtt) |
d62a17ae | 14844 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14845 | p->rtt); | |
14846 | if (p->t_start) | |
14847 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14848 | thread_timer_remain_second(p->t_start)); | |
14849 | if (p->t_connect) | |
14850 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14851 | thread_timer_remain_second(p->t_connect)); | |
14852 | if (p->t_routeadv) | |
14853 | vty_out(vty, | |
14854 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14855 | p->v_routeadv, | |
14856 | thread_timer_remain_second(p->t_routeadv)); | |
14857 | if (p->password) | |
14858 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14859 | ||
cac9e917 | 14860 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14861 | p->t_read ? "on" : "off", |
14862 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14863 | ? "on" | |
cac9e917 | 14864 | : "off", p->fd); |
d62a17ae | 14865 | } |
14866 | ||
14867 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14868 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14869 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14870 | ||
14871 | if (!use_json) | |
14872 | vty_out(vty, "\n"); | |
14873 | ||
14874 | /* BFD information. */ | |
21bfce98 RZ |
14875 | if (p->bfd_config) |
14876 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14877 | |
14878 | if (use_json) { | |
14879 | if (p->conf_if) /* Configured interface name. */ | |
14880 | json_object_object_add(json, p->conf_if, json_neigh); | |
14881 | else /* Configured IP address. */ | |
14882 | json_object_object_add(json, p->host, json_neigh); | |
14883 | } | |
14884 | } | |
14885 | ||
36235319 QY |
14886 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14887 | enum show_type type, | |
14888 | union sockunion *su, | |
14889 | const char *conf_if, afi_t afi, | |
74a630b6 | 14890 | bool use_json) |
2986cac2 | 14891 | { |
14892 | struct listnode *node, *nnode; | |
14893 | struct peer *peer; | |
14894 | int find = 0; | |
14895 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14896 | json_object *json = NULL; |
2986cac2 | 14897 | json_object *json_neighbor = NULL; |
14898 | ||
74a630b6 NT |
14899 | if (use_json) { |
14900 | json = json_object_new_object(); | |
14901 | json_neighbor = json_object_new_object(); | |
14902 | } | |
14903 | ||
2986cac2 | 14904 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14905 | ||
14906 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14907 | continue; | |
14908 | ||
14909 | if ((peer->afc[afi][safi]) == 0) | |
14910 | continue; | |
14911 | ||
2ba1fe69 | 14912 | if (type == show_all) { |
2986cac2 | 14913 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14914 | json_neighbor); |
2986cac2 | 14915 | |
74a630b6 | 14916 | if (use_json) { |
13909c4f DS |
14917 | json_object_object_add(json, peer->host, |
14918 | json_neighbor); | |
74a630b6 NT |
14919 | json_neighbor = NULL; |
14920 | } | |
2986cac2 | 14921 | |
2ba1fe69 | 14922 | } else if (type == show_peer) { |
2986cac2 | 14923 | if (conf_if) { |
14924 | if ((peer->conf_if | |
13909c4f DS |
14925 | && !strcmp(peer->conf_if, conf_if)) |
14926 | || (peer->hostname | |
2986cac2 | 14927 | && !strcmp(peer->hostname, conf_if))) { |
14928 | find = 1; | |
13909c4f DS |
14929 | bgp_show_peer_gr_status(vty, peer, |
14930 | use_json, | |
14931 | json_neighbor); | |
2986cac2 | 14932 | } |
14933 | } else { | |
14934 | if (sockunion_same(&peer->su, su)) { | |
14935 | find = 1; | |
13909c4f DS |
14936 | bgp_show_peer_gr_status(vty, peer, |
14937 | use_json, | |
14938 | json_neighbor); | |
2986cac2 | 14939 | } |
14940 | } | |
13909c4f DS |
14941 | if (use_json && find) |
14942 | json_object_object_add(json, peer->host, | |
14943 | json_neighbor); | |
2986cac2 | 14944 | } |
14945 | ||
74a630b6 NT |
14946 | if (find) { |
14947 | json_neighbor = NULL; | |
2986cac2 | 14948 | break; |
74a630b6 | 14949 | } |
2986cac2 | 14950 | } |
14951 | ||
14952 | if (type == show_peer && !find) { | |
14953 | if (use_json) | |
13909c4f | 14954 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14955 | else |
14956 | vty_out(vty, "%% No such neighbor\n"); | |
14957 | } | |
14958 | if (use_json) { | |
13909c4f DS |
14959 | vty_out(vty, "%s\n", |
14960 | json_object_to_json_string_ext( | |
14961 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14962 | |
14963 | if (json_neighbor) | |
14964 | json_object_free(json_neighbor); | |
14965 | json_object_free(json); | |
2986cac2 | 14966 | } else { |
14967 | vty_out(vty, "\n"); | |
14968 | } | |
14969 | ||
14970 | return CMD_SUCCESS; | |
14971 | } | |
14972 | ||
d62a17ae | 14973 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14974 | enum show_type type, union sockunion *su, | |
9f049418 | 14975 | const char *conf_if, bool use_json, |
d62a17ae | 14976 | json_object *json) |
14977 | { | |
14978 | struct listnode *node, *nnode; | |
14979 | struct peer *peer; | |
14980 | int find = 0; | |
9f049418 | 14981 | bool nbr_output = false; |
d1927ebe AS |
14982 | afi_t afi = AFI_MAX; |
14983 | safi_t safi = SAFI_MAX; | |
14984 | ||
14985 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14986 | afi = AFI_IP; | |
14987 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14988 | afi = AFI_IP6; | |
14989 | } | |
d62a17ae | 14990 | |
14991 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14992 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14993 | continue; | |
14994 | ||
14995 | switch (type) { | |
14996 | case show_all: | |
14997 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14998 | nbr_output = true; |
d62a17ae | 14999 | break; |
15000 | case show_peer: | |
15001 | if (conf_if) { | |
15002 | if ((peer->conf_if | |
15003 | && !strcmp(peer->conf_if, conf_if)) | |
15004 | || (peer->hostname | |
15005 | && !strcmp(peer->hostname, conf_if))) { | |
15006 | find = 1; | |
15007 | bgp_show_peer(vty, peer, use_json, | |
15008 | json); | |
15009 | } | |
15010 | } else { | |
15011 | if (sockunion_same(&peer->su, su)) { | |
15012 | find = 1; | |
15013 | bgp_show_peer(vty, peer, use_json, | |
15014 | json); | |
15015 | } | |
15016 | } | |
15017 | break; | |
d1927ebe AS |
15018 | case show_ipv4_peer: |
15019 | case show_ipv6_peer: | |
15020 | FOREACH_SAFI (safi) { | |
15021 | if (peer->afc[afi][safi]) { | |
15022 | if (conf_if) { | |
15023 | if ((peer->conf_if | |
15024 | && !strcmp(peer->conf_if, conf_if)) | |
15025 | || (peer->hostname | |
15026 | && !strcmp(peer->hostname, conf_if))) { | |
15027 | find = 1; | |
15028 | bgp_show_peer(vty, peer, use_json, | |
15029 | json); | |
15030 | break; | |
15031 | } | |
15032 | } else { | |
15033 | if (sockunion_same(&peer->su, su)) { | |
15034 | find = 1; | |
15035 | bgp_show_peer(vty, peer, use_json, | |
15036 | json); | |
15037 | break; | |
15038 | } | |
15039 | } | |
15040 | } | |
15041 | } | |
15042 | break; | |
15043 | case show_ipv4_all: | |
15044 | case show_ipv6_all: | |
15045 | FOREACH_SAFI (safi) { | |
15046 | if (peer->afc[afi][safi]) { | |
15047 | bgp_show_peer(vty, peer, use_json, json); | |
15048 | nbr_output = true; | |
15049 | break; | |
15050 | } | |
15051 | } | |
15052 | break; | |
d62a17ae | 15053 | } |
15054 | } | |
15055 | ||
d1927ebe AS |
15056 | if ((type == show_peer || type == show_ipv4_peer || |
15057 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 15058 | if (use_json) |
15059 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
15060 | else | |
88b7d255 | 15061 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 15062 | } |
15063 | ||
d1927ebe AS |
15064 | if (type != show_peer && type != show_ipv4_peer && |
15065 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 15066 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 15067 | |
d62a17ae | 15068 | if (use_json) { |
996c9314 LB |
15069 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
15070 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 15071 | } else { |
15072 | vty_out(vty, "\n"); | |
15073 | } | |
15074 | ||
15075 | return CMD_SUCCESS; | |
15076 | } | |
15077 | ||
36235319 QY |
15078 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
15079 | enum show_type type, | |
15080 | const char *ip_str, | |
15081 | afi_t afi, bool use_json) | |
2986cac2 | 15082 | { |
15083 | ||
15084 | int ret; | |
15085 | struct bgp *bgp; | |
15086 | union sockunion su; | |
2986cac2 | 15087 | |
15088 | bgp = bgp_get_default(); | |
15089 | ||
13909c4f DS |
15090 | if (!bgp) |
15091 | return; | |
2986cac2 | 15092 | |
13909c4f DS |
15093 | if (!use_json) |
15094 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
15095 | NULL); | |
2986cac2 | 15096 | |
13909c4f DS |
15097 | if (ip_str) { |
15098 | ret = str2sockunion(ip_str, &su); | |
15099 | if (ret < 0) | |
13909c4f | 15100 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
15101 | vty, bgp, type, NULL, ip_str, afi, use_json); |
15102 | else | |
15103 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
15104 | NULL, afi, use_json); | |
13909c4f DS |
15105 | } else |
15106 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 15107 | afi, use_json); |
2986cac2 | 15108 | } |
15109 | ||
d62a17ae | 15110 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
15111 | enum show_type type, |
15112 | const char *ip_str, | |
9f049418 | 15113 | bool use_json) |
d62a17ae | 15114 | { |
0291c246 MK |
15115 | struct listnode *node, *nnode; |
15116 | struct bgp *bgp; | |
71aedaa3 | 15117 | union sockunion su; |
0291c246 | 15118 | json_object *json = NULL; |
71aedaa3 | 15119 | int ret, is_first = 1; |
9f049418 | 15120 | bool nbr_output = false; |
d62a17ae | 15121 | |
15122 | if (use_json) | |
15123 | vty_out(vty, "{\n"); | |
15124 | ||
15125 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 15126 | nbr_output = true; |
d62a17ae | 15127 | if (use_json) { |
15128 | if (!(json = json_object_new_object())) { | |
af4c2728 | 15129 | flog_err( |
e50f7cfd | 15130 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 15131 | "Unable to allocate memory for JSON object"); |
15132 | vty_out(vty, | |
15133 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
15134 | return; | |
15135 | } | |
15136 | ||
15137 | json_object_int_add(json, "vrfId", | |
15138 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
15139 | ? -1 |
15140 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 15141 | json_object_string_add( |
15142 | json, "vrfName", | |
15143 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15144 | ? VRF_DEFAULT_NAME |
d62a17ae | 15145 | : bgp->name); |
15146 | ||
15147 | if (!is_first) | |
15148 | vty_out(vty, ",\n"); | |
15149 | else | |
15150 | is_first = 0; | |
15151 | ||
15152 | vty_out(vty, "\"%s\":", | |
15153 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15154 | ? VRF_DEFAULT_NAME |
d62a17ae | 15155 | : bgp->name); |
15156 | } else { | |
15157 | vty_out(vty, "\nInstance %s:\n", | |
15158 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15159 | ? VRF_DEFAULT_NAME |
d62a17ae | 15160 | : bgp->name); |
15161 | } | |
71aedaa3 | 15162 | |
d1927ebe AS |
15163 | if (type == show_peer || type == show_ipv4_peer || |
15164 | type == show_ipv6_peer) { | |
71aedaa3 DS |
15165 | ret = str2sockunion(ip_str, &su); |
15166 | if (ret < 0) | |
15167 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15168 | use_json, json); | |
15169 | else | |
15170 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15171 | use_json, json); | |
15172 | } else { | |
d1927ebe | 15173 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
15174 | use_json, json); |
15175 | } | |
b77004d6 | 15176 | json_object_free(json); |
121067e9 | 15177 | json = NULL; |
d62a17ae | 15178 | } |
15179 | ||
3e78a6ce | 15180 | if (use_json) |
d62a17ae | 15181 | vty_out(vty, "}\n"); |
9f049418 DS |
15182 | else if (!nbr_output) |
15183 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15184 | } |
15185 | ||
15186 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
15187 | enum show_type type, const char *ip_str, | |
9f049418 | 15188 | bool use_json) |
d62a17ae | 15189 | { |
15190 | int ret; | |
15191 | struct bgp *bgp; | |
15192 | union sockunion su; | |
15193 | json_object *json = NULL; | |
15194 | ||
15195 | if (name) { | |
15196 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
15197 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
15198 | use_json); | |
d62a17ae | 15199 | return CMD_SUCCESS; |
15200 | } else { | |
15201 | bgp = bgp_lookup_by_name(name); | |
15202 | if (!bgp) { | |
15203 | if (use_json) { | |
15204 | json = json_object_new_object(); | |
d62a17ae | 15205 | vty_out(vty, "%s\n", |
15206 | json_object_to_json_string_ext( | |
15207 | json, | |
15208 | JSON_C_TO_STRING_PRETTY)); | |
15209 | json_object_free(json); | |
15210 | } else | |
15211 | vty_out(vty, | |
9f049418 | 15212 | "%% BGP instance not found\n"); |
d62a17ae | 15213 | |
15214 | return CMD_WARNING; | |
15215 | } | |
15216 | } | |
15217 | } else { | |
15218 | bgp = bgp_get_default(); | |
15219 | } | |
15220 | ||
15221 | if (bgp) { | |
15222 | json = json_object_new_object(); | |
15223 | if (ip_str) { | |
15224 | ret = str2sockunion(ip_str, &su); | |
15225 | if (ret < 0) | |
15226 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15227 | use_json, json); | |
15228 | else | |
15229 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15230 | use_json, json); | |
15231 | } else { | |
15232 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
15233 | json); | |
15234 | } | |
15235 | json_object_free(json); | |
ca61fd25 DS |
15236 | } else { |
15237 | if (use_json) | |
15238 | vty_out(vty, "{}\n"); | |
15239 | else | |
15240 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15241 | } |
15242 | ||
15243 | return CMD_SUCCESS; | |
4fb25c53 DW |
15244 | } |
15245 | ||
2986cac2 | 15246 | |
15247 | ||
15248 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
15249 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
15250 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
15251 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
15252 | SHOW_STR | |
15253 | BGP_STR | |
15254 | IP_STR | |
15255 | IPV6_STR | |
15256 | NEIGHBOR_STR | |
15257 | "Neighbor to display information about\n" | |
15258 | "Neighbor to display information about\n" | |
15259 | "Neighbor on BGP configured interface\n" | |
15260 | GR_SHOW | |
15261 | JSON_STR) | |
15262 | { | |
15263 | char *sh_arg = NULL; | |
15264 | enum show_type sh_type; | |
15265 | int idx = 0; | |
15266 | afi_t afi = AFI_MAX; | |
2986cac2 | 15267 | bool uj = use_json(argc, argv); |
15268 | ||
36235319 | 15269 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 15270 | afi = AFI_MAX; |
15271 | ||
15272 | idx++; | |
15273 | ||
15274 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
15275 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15276 | || argv_find(argv, argc, "WORD", &idx)) { | |
15277 | sh_type = show_peer; | |
15278 | sh_arg = argv[idx]->arg; | |
15279 | } else | |
15280 | sh_type = show_all; | |
15281 | ||
15282 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
15283 | return CMD_SUCCESS; | |
15284 | ||
15285 | ||
36235319 QY |
15286 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
15287 | afi, uj); | |
2986cac2 | 15288 | } |
15289 | ||
716b2d8a | 15290 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 15291 | DEFUN (show_ip_bgp_neighbors, |
15292 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 15293 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 15294 | SHOW_STR |
15295 | IP_STR | |
15296 | BGP_STR | |
f2a8972b | 15297 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
15298 | "Address Family\n" |
15299 | "Address Family\n" | |
718e3744 | 15300 | "Detailed information on TCP and BGP neighbor connections\n" |
15301 | "Neighbor to display information about\n" | |
a80beece | 15302 | "Neighbor to display information about\n" |
91d37724 | 15303 | "Neighbor on BGP configured interface\n" |
9973d184 | 15304 | JSON_STR) |
718e3744 | 15305 | { |
d62a17ae | 15306 | char *vrf = NULL; |
15307 | char *sh_arg = NULL; | |
15308 | enum show_type sh_type; | |
d1927ebe | 15309 | afi_t afi = AFI_MAX; |
718e3744 | 15310 | |
9f049418 | 15311 | bool uj = use_json(argc, argv); |
718e3744 | 15312 | |
d62a17ae | 15313 | int idx = 0; |
718e3744 | 15314 | |
9a8bdf1c PG |
15315 | /* [<vrf> VIEWVRFNAME] */ |
15316 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15317 | vrf = argv[idx + 1]->arg; | |
15318 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15319 | vrf = NULL; | |
15320 | } else if (argv_find(argv, argc, "view", &idx)) | |
15321 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 15322 | vrf = argv[idx + 1]->arg; |
718e3744 | 15323 | |
d62a17ae | 15324 | idx++; |
d1927ebe AS |
15325 | |
15326 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
15327 | sh_type = show_ipv4_all; | |
15328 | afi = AFI_IP; | |
15329 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
15330 | sh_type = show_ipv6_all; | |
15331 | afi = AFI_IP6; | |
15332 | } else { | |
15333 | sh_type = show_all; | |
15334 | } | |
15335 | ||
d62a17ae | 15336 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
15337 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15338 | || argv_find(argv, argc, "WORD", &idx)) { | |
15339 | sh_type = show_peer; | |
15340 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
15341 | } |
15342 | ||
15343 | if (sh_type == show_peer && afi == AFI_IP) { | |
15344 | sh_type = show_ipv4_peer; | |
15345 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
15346 | sh_type = show_ipv6_peer; | |
15347 | } | |
856ca177 | 15348 | |
d62a17ae | 15349 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 15350 | } |
15351 | ||
716b2d8a | 15352 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 15353 | paths' and `show ip mbgp paths'. Those functions results are the |
15354 | same.*/ | |
f412b39a | 15355 | DEFUN (show_ip_bgp_paths, |
718e3744 | 15356 | show_ip_bgp_paths_cmd, |
46f296b4 | 15357 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 15358 | SHOW_STR |
15359 | IP_STR | |
15360 | BGP_STR | |
46f296b4 | 15361 | BGP_SAFI_HELP_STR |
718e3744 | 15362 | "Path information\n") |
15363 | { | |
d62a17ae | 15364 | vty_out(vty, "Address Refcnt Path\n"); |
15365 | aspath_print_all_vty(vty); | |
15366 | return CMD_SUCCESS; | |
718e3744 | 15367 | } |
15368 | ||
718e3744 | 15369 | #include "hash.h" |
15370 | ||
e3b78da8 | 15371 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15372 | struct vty *vty) |
718e3744 | 15373 | { |
d62a17ae | 15374 | struct community *com; |
718e3744 | 15375 | |
e3b78da8 | 15376 | com = (struct community *)bucket->data; |
3f65c5b1 | 15377 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 15378 | community_str(com, false)); |
718e3744 | 15379 | } |
15380 | ||
15381 | /* Show BGP's community internal data. */ | |
f412b39a | 15382 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 15383 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 15384 | "show [ip] bgp community-info", |
718e3744 | 15385 | SHOW_STR |
15386 | IP_STR | |
15387 | BGP_STR | |
15388 | "List all bgp community information\n") | |
15389 | { | |
d62a17ae | 15390 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 15391 | |
d62a17ae | 15392 | hash_iterate(community_hash(), |
e3b78da8 | 15393 | (void (*)(struct hash_bucket *, |
d62a17ae | 15394 | void *))community_show_all_iterator, |
15395 | vty); | |
718e3744 | 15396 | |
d62a17ae | 15397 | return CMD_SUCCESS; |
718e3744 | 15398 | } |
15399 | ||
e3b78da8 | 15400 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15401 | struct vty *vty) |
57d187bc | 15402 | { |
d62a17ae | 15403 | struct lcommunity *lcom; |
57d187bc | 15404 | |
e3b78da8 | 15405 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 15406 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 15407 | lcommunity_str(lcom, false)); |
57d187bc JS |
15408 | } |
15409 | ||
15410 | /* Show BGP's community internal data. */ | |
15411 | DEFUN (show_ip_bgp_lcommunity_info, | |
15412 | show_ip_bgp_lcommunity_info_cmd, | |
15413 | "show ip bgp large-community-info", | |
15414 | SHOW_STR | |
15415 | IP_STR | |
15416 | BGP_STR | |
15417 | "List all bgp large-community information\n") | |
15418 | { | |
d62a17ae | 15419 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 15420 | |
d62a17ae | 15421 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 15422 | (void (*)(struct hash_bucket *, |
d62a17ae | 15423 | void *))lcommunity_show_all_iterator, |
15424 | vty); | |
57d187bc | 15425 | |
d62a17ae | 15426 | return CMD_SUCCESS; |
57d187bc | 15427 | } |
2986cac2 | 15428 | /* Graceful Restart */ |
15429 | ||
15430 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
15431 | struct bgp *bgp, |
15432 | bool use_json, | |
15433 | json_object *json) | |
2986cac2 | 15434 | { |
57d187bc JS |
15435 | |
15436 | ||
2986cac2 | 15437 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
15438 | ||
7318ae88 | 15439 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 15440 | |
15441 | switch (bgp_global_gr_mode) { | |
15442 | ||
15443 | case GLOBAL_HELPER: | |
13909c4f | 15444 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 15445 | break; |
15446 | ||
15447 | case GLOBAL_GR: | |
13909c4f | 15448 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 15449 | break; |
15450 | ||
15451 | case GLOBAL_DISABLE: | |
13909c4f | 15452 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 15453 | break; |
15454 | ||
15455 | case GLOBAL_INVALID: | |
2986cac2 | 15456 | vty_out(vty, |
2ba1fe69 | 15457 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 15458 | break; |
15459 | } | |
15460 | vty_out(vty, "\n"); | |
15461 | } | |
15462 | ||
36235319 QY |
15463 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
15464 | enum show_type type, | |
15465 | const char *ip_str, | |
15466 | afi_t afi, bool use_json) | |
2986cac2 | 15467 | { |
15468 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
15469 | afi = AFI_IP; | |
15470 | ||
15471 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
15472 | ||
36235319 QY |
15473 | bgp_show_neighbor_graceful_restart_vty( |
15474 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 15475 | afi++; |
15476 | } | |
15477 | } else if (afi != AFI_MAX) { | |
36235319 QY |
15478 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
15479 | use_json); | |
2986cac2 | 15480 | } else { |
15481 | return CMD_ERR_INCOMPLETE; | |
15482 | } | |
15483 | ||
15484 | return CMD_SUCCESS; | |
15485 | } | |
15486 | /* Graceful Restart */ | |
15487 | ||
f412b39a | 15488 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 15489 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 15490 | "show [ip] bgp attribute-info", |
718e3744 | 15491 | SHOW_STR |
15492 | IP_STR | |
15493 | BGP_STR | |
15494 | "List all bgp attribute information\n") | |
15495 | { | |
d62a17ae | 15496 | attr_show_all(vty); |
15497 | return CMD_SUCCESS; | |
718e3744 | 15498 | } |
6b0655a2 | 15499 | |
03915806 CS |
15500 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
15501 | afi_t afi, safi_t safi, | |
15502 | bool use_json, json_object *json) | |
53089bec | 15503 | { |
15504 | struct bgp *bgp; | |
15505 | struct listnode *node; | |
15506 | char *vname; | |
15507 | char buf1[INET6_ADDRSTRLEN]; | |
15508 | char *ecom_str; | |
15509 | vpn_policy_direction_t dir; | |
15510 | ||
03915806 | 15511 | if (json) { |
b46dfd20 DS |
15512 | json_object *json_import_vrfs = NULL; |
15513 | json_object *json_export_vrfs = NULL; | |
15514 | ||
b46dfd20 DS |
15515 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15516 | ||
53089bec | 15517 | if (!bgp) { |
b46dfd20 DS |
15518 | vty_out(vty, "%s\n", |
15519 | json_object_to_json_string_ext( | |
15520 | json, | |
15521 | JSON_C_TO_STRING_PRETTY)); | |
15522 | json_object_free(json); | |
15523 | ||
53089bec | 15524 | return CMD_WARNING; |
15525 | } | |
b46dfd20 | 15526 | |
94d4c685 DS |
15527 | /* Provide context for the block */ |
15528 | json_object_string_add(json, "vrf", name ? name : "default"); | |
15529 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 15530 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 15531 | |
b46dfd20 DS |
15532 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15533 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15534 | json_object_string_add(json, "importFromVrfs", "none"); | |
15535 | json_object_string_add(json, "importRts", "none"); | |
15536 | } else { | |
6ce24e52 DS |
15537 | json_import_vrfs = json_object_new_array(); |
15538 | ||
b46dfd20 DS |
15539 | for (ALL_LIST_ELEMENTS_RO( |
15540 | bgp->vpn_policy[afi].import_vrf, | |
15541 | node, vname)) | |
15542 | json_object_array_add(json_import_vrfs, | |
15543 | json_object_new_string(vname)); | |
15544 | ||
b20875ea CS |
15545 | json_object_object_add(json, "importFromVrfs", |
15546 | json_import_vrfs); | |
b46dfd20 | 15547 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
15548 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15549 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15550 | bgp->vpn_policy[afi].rtlist[dir], |
15551 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15552 | json_object_string_add(json, "importRts", |
15553 | ecom_str); | |
15554 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15555 | } else | |
15556 | json_object_string_add(json, "importRts", | |
15557 | "none"); | |
b46dfd20 DS |
15558 | } |
15559 | ||
15560 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
15561 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
15562 | json_object_string_add(json, "exportToVrfs", "none"); | |
15563 | json_object_string_add(json, "routeDistinguisher", | |
15564 | "none"); | |
15565 | json_object_string_add(json, "exportRts", "none"); | |
15566 | } else { | |
6ce24e52 DS |
15567 | json_export_vrfs = json_object_new_array(); |
15568 | ||
b46dfd20 DS |
15569 | for (ALL_LIST_ELEMENTS_RO( |
15570 | bgp->vpn_policy[afi].export_vrf, | |
15571 | node, vname)) | |
15572 | json_object_array_add(json_export_vrfs, | |
15573 | json_object_new_string(vname)); | |
15574 | json_object_object_add(json, "exportToVrfs", | |
15575 | json_export_vrfs); | |
15576 | json_object_string_add(json, "routeDistinguisher", | |
15577 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
15578 | buf1, RD_ADDRSTRLEN)); | |
15579 | ||
15580 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15581 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15582 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15583 | bgp->vpn_policy[afi].rtlist[dir], |
15584 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15585 | json_object_string_add(json, "exportRts", |
15586 | ecom_str); | |
15587 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15588 | } else | |
15589 | json_object_string_add(json, "exportRts", | |
15590 | "none"); | |
b46dfd20 DS |
15591 | } |
15592 | ||
03915806 CS |
15593 | if (use_json) { |
15594 | vty_out(vty, "%s\n", | |
15595 | json_object_to_json_string_ext(json, | |
b46dfd20 | 15596 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
15597 | json_object_free(json); |
15598 | } | |
53089bec | 15599 | } else { |
b46dfd20 DS |
15600 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15601 | ||
53089bec | 15602 | if (!bgp) { |
b46dfd20 | 15603 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 15604 | return CMD_WARNING; |
15605 | } | |
53089bec | 15606 | |
b46dfd20 DS |
15607 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15608 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
15609 | vty_out(vty, | |
15610 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 15611 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15612 | else { |
15613 | vty_out(vty, | |
15614 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 15615 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15616 | |
15617 | for (ALL_LIST_ELEMENTS_RO( | |
15618 | bgp->vpn_policy[afi].import_vrf, | |
15619 | node, vname)) | |
15620 | vty_out(vty, " %s\n", vname); | |
15621 | ||
15622 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
15623 | ecom_str = NULL; |
15624 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
15625 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15626 | bgp->vpn_policy[afi].rtlist[dir], |
15627 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 15628 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 15629 | |
b20875ea CS |
15630 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
15631 | } else | |
15632 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15633 | } |
53089bec | 15634 | |
b46dfd20 DS |
15635 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15636 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15637 | vty_out(vty, | |
15638 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 15639 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15640 | else { |
15641 | vty_out(vty, | |
04c9077f | 15642 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 15643 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15644 | |
15645 | for (ALL_LIST_ELEMENTS_RO( | |
15646 | bgp->vpn_policy[afi].export_vrf, | |
15647 | node, vname)) | |
15648 | vty_out(vty, " %s\n", vname); | |
15649 | ||
15650 | vty_out(vty, "RD: %s\n", | |
15651 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
15652 | buf1, RD_ADDRSTRLEN)); | |
15653 | ||
15654 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15655 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15656 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15657 | bgp->vpn_policy[afi].rtlist[dir], |
15658 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15659 | vty_out(vty, "Export RT: %s\n", ecom_str); |
15660 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15661 | } else | |
15662 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15663 | } |
53089bec | 15664 | } |
15665 | ||
15666 | return CMD_SUCCESS; | |
15667 | } | |
15668 | ||
03915806 CS |
15669 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
15670 | safi_t safi, bool use_json) | |
15671 | { | |
15672 | struct listnode *node, *nnode; | |
15673 | struct bgp *bgp; | |
15674 | char *vrf_name = NULL; | |
15675 | json_object *json = NULL; | |
15676 | json_object *json_vrf = NULL; | |
15677 | json_object *json_vrfs = NULL; | |
15678 | ||
15679 | if (use_json) { | |
15680 | json = json_object_new_object(); | |
15681 | json_vrfs = json_object_new_object(); | |
15682 | } | |
15683 | ||
15684 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
15685 | ||
15686 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
15687 | vrf_name = bgp->name; | |
15688 | ||
15689 | if (use_json) { | |
15690 | json_vrf = json_object_new_object(); | |
15691 | } else { | |
15692 | vty_out(vty, "\nInstance %s:\n", | |
15693 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15694 | ? VRF_DEFAULT_NAME : bgp->name); | |
15695 | } | |
15696 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
15697 | if (use_json) { | |
15698 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15699 | json_object_object_add(json_vrfs, | |
15700 | VRF_DEFAULT_NAME, json_vrf); | |
15701 | else | |
15702 | json_object_object_add(json_vrfs, vrf_name, | |
15703 | json_vrf); | |
15704 | } | |
15705 | } | |
15706 | ||
15707 | if (use_json) { | |
15708 | json_object_object_add(json, "vrfs", json_vrfs); | |
15709 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
15710 | JSON_C_TO_STRING_PRETTY)); | |
15711 | json_object_free(json); | |
15712 | } | |
15713 | ||
15714 | return CMD_SUCCESS; | |
15715 | } | |
15716 | ||
53089bec | 15717 | /* "show [ip] bgp route-leak" command. */ |
15718 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
15719 | show_ip_bgp_route_leak_cmd, |
15720 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
15721 | SHOW_STR |
15722 | IP_STR | |
15723 | BGP_STR | |
15724 | BGP_INSTANCE_HELP_STR | |
15725 | BGP_AFI_HELP_STR | |
15726 | BGP_SAFI_HELP_STR | |
15727 | "Route leaking information\n" | |
15728 | JSON_STR) | |
53089bec | 15729 | { |
15730 | char *vrf = NULL; | |
15731 | afi_t afi = AFI_MAX; | |
15732 | safi_t safi = SAFI_MAX; | |
15733 | ||
9f049418 | 15734 | bool uj = use_json(argc, argv); |
53089bec | 15735 | int idx = 0; |
03915806 | 15736 | json_object *json = NULL; |
53089bec | 15737 | |
15738 | /* show [ip] bgp */ | |
15739 | if (argv_find(argv, argc, "ip", &idx)) { | |
15740 | afi = AFI_IP; | |
15741 | safi = SAFI_UNICAST; | |
15742 | } | |
15743 | /* [vrf VIEWVRFNAME] */ | |
15744 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
15745 | vty_out(vty, |
15746 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 15747 | return CMD_WARNING; |
15748 | } | |
15749 | ||
9a8bdf1c PG |
15750 | if (argv_find(argv, argc, "vrf", &idx)) { |
15751 | vrf = argv[idx + 1]->arg; | |
15752 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15753 | vrf = NULL; | |
15754 | } | |
53089bec | 15755 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15756 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15757 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15758 | } | |
15759 | ||
15760 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
15761 | vty_out(vty, |
15762 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 15763 | return CMD_WARNING; |
15764 | } | |
15765 | ||
03915806 CS |
15766 | if (vrf && strmatch(vrf, "all")) |
15767 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
15768 | ||
15769 | if (uj) | |
15770 | json = json_object_new_object(); | |
15771 | ||
15772 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15773 | } |
15774 | ||
d62a17ae | 15775 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
15776 | safi_t safi) | |
f186de26 | 15777 | { |
d62a17ae | 15778 | struct listnode *node, *nnode; |
15779 | struct bgp *bgp; | |
f186de26 | 15780 | |
d62a17ae | 15781 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
15782 | vty_out(vty, "\nInstance %s:\n", | |
15783 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15784 | ? VRF_DEFAULT_NAME |
d62a17ae | 15785 | : bgp->name); |
15786 | update_group_show(bgp, afi, safi, vty, 0); | |
15787 | } | |
f186de26 | 15788 | } |
15789 | ||
d62a17ae | 15790 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
15791 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 15792 | { |
d62a17ae | 15793 | struct bgp *bgp; |
4fb25c53 | 15794 | |
d62a17ae | 15795 | if (name) { |
15796 | if (strmatch(name, "all")) { | |
15797 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
15798 | return CMD_SUCCESS; | |
15799 | } else { | |
15800 | bgp = bgp_lookup_by_name(name); | |
15801 | } | |
15802 | } else { | |
15803 | bgp = bgp_get_default(); | |
15804 | } | |
4fb25c53 | 15805 | |
d62a17ae | 15806 | if (bgp) |
15807 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
15808 | return CMD_SUCCESS; | |
4fb25c53 DW |
15809 | } |
15810 | ||
8fe8a7f6 DS |
15811 | DEFUN (show_ip_bgp_updgrps, |
15812 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 15813 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 15814 | SHOW_STR |
15815 | IP_STR | |
15816 | BGP_STR | |
15817 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15818 | BGP_AFI_HELP_STR |
9bedbb1e | 15819 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
15820 | "Detailed info about dynamic update groups\n" |
15821 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 15822 | { |
d62a17ae | 15823 | char *vrf = NULL; |
15824 | afi_t afi = AFI_IP6; | |
15825 | safi_t safi = SAFI_UNICAST; | |
15826 | uint64_t subgrp_id = 0; | |
15827 | ||
15828 | int idx = 0; | |
15829 | ||
15830 | /* show [ip] bgp */ | |
15831 | if (argv_find(argv, argc, "ip", &idx)) | |
15832 | afi = AFI_IP; | |
9a8bdf1c PG |
15833 | /* [<vrf> VIEWVRFNAME] */ |
15834 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15835 | vrf = argv[idx + 1]->arg; | |
15836 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15837 | vrf = NULL; | |
15838 | } else if (argv_find(argv, argc, "view", &idx)) | |
15839 | /* [<view> VIEWVRFNAME] */ | |
15840 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15841 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15842 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15843 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15844 | } | |
5bf15956 | 15845 | |
d62a17ae | 15846 | /* get subgroup id, if provided */ |
15847 | idx = argc - 1; | |
15848 | if (argv[idx]->type == VARIABLE_TKN) | |
15849 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15850 | |
d62a17ae | 15851 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
15852 | } |
15853 | ||
f186de26 | 15854 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15855 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 15856 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 15857 | SHOW_STR |
716b2d8a | 15858 | IP_STR |
f186de26 | 15859 | BGP_STR |
15860 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15861 | "Detailed info about dynamic update groups\n") |
f186de26 | 15862 | { |
d62a17ae | 15863 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15864 | return CMD_SUCCESS; | |
f186de26 | 15865 | } |
15866 | ||
43d3f4fc DS |
15867 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15868 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15869 | "show [ip] bgp l2vpn evpn update-groups", | |
15870 | SHOW_STR | |
15871 | IP_STR | |
15872 | BGP_STR | |
15873 | "l2vpn address family\n" | |
15874 | "evpn sub-address family\n" | |
15875 | "Detailed info about dynamic update groups\n") | |
15876 | { | |
15877 | char *vrf = NULL; | |
15878 | uint64_t subgrp_id = 0; | |
15879 | ||
15880 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15881 | return CMD_SUCCESS; | |
15882 | } | |
15883 | ||
5bf15956 DW |
15884 | DEFUN (show_bgp_updgrps_stats, |
15885 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15886 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15887 | SHOW_STR |
716b2d8a | 15888 | IP_STR |
3f9c7369 | 15889 | BGP_STR |
0c7b1b01 | 15890 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15891 | "Statistics\n") |
15892 | { | |
d62a17ae | 15893 | struct bgp *bgp; |
3f9c7369 | 15894 | |
d62a17ae | 15895 | bgp = bgp_get_default(); |
15896 | if (bgp) | |
15897 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15898 | |
d62a17ae | 15899 | return CMD_SUCCESS; |
3f9c7369 DS |
15900 | } |
15901 | ||
8386ac43 | 15902 | DEFUN (show_bgp_instance_updgrps_stats, |
15903 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15904 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15905 | SHOW_STR |
716b2d8a | 15906 | IP_STR |
8386ac43 | 15907 | BGP_STR |
15908 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15909 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15910 | "Statistics\n") |
15911 | { | |
d62a17ae | 15912 | int idx_word = 3; |
15913 | struct bgp *bgp; | |
8386ac43 | 15914 | |
d62a17ae | 15915 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15916 | if (bgp) | |
15917 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15918 | |
d62a17ae | 15919 | return CMD_SUCCESS; |
8386ac43 | 15920 | } |
15921 | ||
d62a17ae | 15922 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15923 | afi_t afi, safi_t safi, | |
15924 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15925 | { |
d62a17ae | 15926 | struct bgp *bgp; |
8386ac43 | 15927 | |
d62a17ae | 15928 | if (name) |
15929 | bgp = bgp_lookup_by_name(name); | |
15930 | else | |
15931 | bgp = bgp_get_default(); | |
8386ac43 | 15932 | |
d62a17ae | 15933 | if (bgp) { |
15934 | if (!strcmp(what, "advertise-queue")) | |
15935 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15936 | subgrp_id); | |
15937 | else if (!strcmp(what, "advertised-routes")) | |
15938 | update_group_show_advertised(bgp, afi, safi, vty, | |
15939 | subgrp_id); | |
15940 | else if (!strcmp(what, "packet-queue")) | |
15941 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15942 | subgrp_id); | |
15943 | } | |
3f9c7369 DS |
15944 | } |
15945 | ||
dc64bdec QY |
15946 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15947 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15948 | "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", | |
15949 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15950 | BGP_SAFI_HELP_STR | |
15951 | "Detailed info about dynamic update groups\n" | |
15952 | "Specific subgroup to display info for\n" | |
15953 | "Advertisement queue\n" | |
15954 | "Announced routes\n" | |
15955 | "Packet queue\n") | |
3f9c7369 | 15956 | { |
dc64bdec QY |
15957 | uint64_t subgrp_id = 0; |
15958 | afi_t afiz; | |
15959 | safi_t safiz; | |
15960 | if (sgid) | |
15961 | subgrp_id = strtoull(sgid, NULL, 10); | |
15962 | ||
15963 | if (!ip && !afi) | |
15964 | afiz = AFI_IP6; | |
15965 | if (!ip && afi) | |
15966 | afiz = bgp_vty_afi_from_str(afi); | |
15967 | if (ip && !afi) | |
15968 | afiz = AFI_IP; | |
15969 | if (ip && afi) { | |
15970 | afiz = bgp_vty_afi_from_str(afi); | |
15971 | if (afiz != AFI_IP) | |
15972 | vty_out(vty, | |
15973 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15974 | return CMD_WARNING; | |
15975 | } | |
d62a17ae | 15976 | |
dc64bdec | 15977 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15978 | |
dc64bdec | 15979 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15980 | return CMD_SUCCESS; |
15981 | } | |
15982 | ||
6f4eacf3 DA |
15983 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15984 | json_object *json) | |
d62a17ae | 15985 | { |
15986 | struct listnode *node, *nnode; | |
15987 | struct prefix *range; | |
15988 | struct peer *conf; | |
15989 | struct peer *peer; | |
d62a17ae | 15990 | afi_t afi; |
15991 | safi_t safi; | |
15992 | const char *peer_status; | |
d62a17ae | 15993 | int lr_count; |
15994 | int dynamic; | |
6f4eacf3 DA |
15995 | bool af_cfgd; |
15996 | json_object *json_peer_group = NULL; | |
15997 | json_object *json_peer_group_afc = NULL; | |
15998 | json_object *json_peer_group_members = NULL; | |
15999 | json_object *json_peer_group_dynamic = NULL; | |
16000 | json_object *json_peer_group_dynamic_af = NULL; | |
16001 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 16002 | |
16003 | conf = group->conf; | |
16004 | ||
6f4eacf3 DA |
16005 | if (json) { |
16006 | json_peer_group = json_object_new_object(); | |
16007 | json_peer_group_afc = json_object_new_array(); | |
16008 | } | |
16009 | ||
d62a17ae | 16010 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
16011 | if (json) |
16012 | json_object_int_add(json_peer_group, "remoteAs", | |
16013 | conf->as); | |
16014 | else | |
16015 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
16016 | group->name, conf->as); | |
d62a17ae | 16017 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
16018 | if (json) |
16019 | json_object_int_add(json_peer_group, "remoteAs", | |
16020 | group->bgp->as); | |
16021 | else | |
16022 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
16023 | group->name, group->bgp->as); | |
d62a17ae | 16024 | } else { |
6f4eacf3 DA |
16025 | if (!json) |
16026 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 16027 | } |
f14e6fdb | 16028 | |
6f4eacf3 DA |
16029 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
16030 | if (json) | |
16031 | json_object_string_add(json_peer_group, "type", | |
16032 | "internal"); | |
16033 | else | |
16034 | vty_out(vty, " Peer-group type is internal\n"); | |
16035 | } else { | |
16036 | if (json) | |
16037 | json_object_string_add(json_peer_group, "type", | |
16038 | "external"); | |
16039 | else | |
16040 | vty_out(vty, " Peer-group type is external\n"); | |
16041 | } | |
d62a17ae | 16042 | |
16043 | /* Display AFs configured. */ | |
6f4eacf3 DA |
16044 | if (!json) |
16045 | vty_out(vty, " Configured address-families:"); | |
16046 | ||
05c7a1cc QY |
16047 | FOREACH_AFI_SAFI (afi, safi) { |
16048 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
16049 | af_cfgd = true; |
16050 | if (json) | |
16051 | json_object_array_add( | |
16052 | json_peer_group_afc, | |
16053 | json_object_new_string(get_afi_safi_str( | |
16054 | afi, safi, false))); | |
16055 | else | |
16056 | vty_out(vty, " %s;", | |
16057 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 16058 | } |
05c7a1cc | 16059 | } |
6f4eacf3 DA |
16060 | |
16061 | if (json) { | |
16062 | json_object_object_add(json_peer_group, | |
16063 | "addressFamiliesConfigured", | |
16064 | json_peer_group_afc); | |
16065 | } else { | |
16066 | if (!af_cfgd) | |
16067 | vty_out(vty, " none\n"); | |
16068 | else | |
16069 | vty_out(vty, "\n"); | |
16070 | } | |
d62a17ae | 16071 | |
16072 | /* Display listen ranges (for dynamic neighbors), if any */ | |
16073 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 16074 | lr_count = listcount(group->listen_range[afi]); |
16075 | if (lr_count) { | |
6f4eacf3 DA |
16076 | if (json) { |
16077 | if (!json_peer_group_dynamic) | |
16078 | json_peer_group_dynamic = | |
16079 | json_object_new_object(); | |
16080 | ||
16081 | json_peer_group_dynamic_af = | |
16082 | json_object_new_object(); | |
16083 | json_peer_group_ranges = | |
16084 | json_object_new_array(); | |
16085 | json_object_int_add(json_peer_group_dynamic_af, | |
16086 | "count", lr_count); | |
16087 | } else { | |
16088 | vty_out(vty, " %d %s listen range(s)\n", | |
16089 | lr_count, afi2str(afi)); | |
16090 | } | |
d62a17ae | 16091 | |
16092 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
16093 | nnode, range)) { |
16094 | if (json) { | |
16095 | char buf[BUFSIZ]; | |
16096 | ||
16097 | snprintfrr(buf, sizeof(buf), "%pFX", | |
16098 | range); | |
16099 | ||
16100 | json_object_array_add( | |
16101 | json_peer_group_ranges, | |
16102 | json_object_new_string(buf)); | |
16103 | } else { | |
16104 | vty_out(vty, " %pFX\n", range); | |
16105 | } | |
16106 | } | |
16107 | ||
16108 | if (json) { | |
16109 | json_object_object_add( | |
16110 | json_peer_group_dynamic_af, "ranges", | |
16111 | json_peer_group_ranges); | |
16112 | ||
16113 | json_object_object_add( | |
16114 | json_peer_group_dynamic, afi2str(afi), | |
16115 | json_peer_group_dynamic_af); | |
16116 | } | |
d62a17ae | 16117 | } |
16118 | } | |
f14e6fdb | 16119 | |
6f4eacf3 DA |
16120 | if (json_peer_group_dynamic) |
16121 | json_object_object_add(json_peer_group, "dynamicRanges", | |
16122 | json_peer_group_dynamic); | |
16123 | ||
d62a17ae | 16124 | /* Display group members and their status */ |
16125 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
16126 | if (json) |
16127 | json_peer_group_members = json_object_new_object(); | |
16128 | else | |
16129 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 16130 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
16131 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
16132 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 16133 | peer_status = "Idle (Admin)"; |
16134 | else if (CHECK_FLAG(peer->sflags, | |
16135 | PEER_STATUS_PREFIX_OVERFLOW)) | |
16136 | peer_status = "Idle (PfxCt)"; | |
16137 | else | |
16138 | peer_status = lookup_msg(bgp_status_msg, | |
16139 | peer->status, NULL); | |
16140 | ||
16141 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
16142 | |
16143 | if (json) { | |
16144 | json_object *json_peer_group_member = | |
16145 | json_object_new_object(); | |
16146 | ||
16147 | json_object_string_add(json_peer_group_member, | |
16148 | "status", peer_status); | |
16149 | ||
16150 | if (dynamic) | |
16151 | json_object_boolean_true_add( | |
16152 | json_peer_group_member, | |
16153 | "dynamic"); | |
16154 | ||
16155 | json_object_object_add(json_peer_group_members, | |
16156 | peer->host, | |
16157 | json_peer_group_member); | |
16158 | } else { | |
16159 | vty_out(vty, " %s %s %s \n", peer->host, | |
16160 | dynamic ? "(dynamic)" : "", | |
16161 | peer_status); | |
16162 | } | |
d62a17ae | 16163 | } |
6f4eacf3 DA |
16164 | if (json) |
16165 | json_object_object_add(json_peer_group, "members", | |
16166 | json_peer_group_members); | |
d62a17ae | 16167 | } |
f14e6fdb | 16168 | |
6f4eacf3 DA |
16169 | if (json) |
16170 | json_object_object_add(json, group->name, json_peer_group); | |
16171 | ||
d62a17ae | 16172 | return CMD_SUCCESS; |
16173 | } | |
16174 | ||
ff9959b0 | 16175 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 16176 | const char *group_name, bool uj) |
d62a17ae | 16177 | { |
ff9959b0 | 16178 | struct bgp *bgp; |
d62a17ae | 16179 | struct listnode *node, *nnode; |
16180 | struct peer_group *group; | |
ff9959b0 | 16181 | bool found = false; |
6f4eacf3 DA |
16182 | json_object *json = NULL; |
16183 | ||
16184 | if (uj) | |
16185 | json = json_object_new_object(); | |
ff9959b0 QY |
16186 | |
16187 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
16188 | ||
16189 | if (!bgp) { | |
6f4eacf3 DA |
16190 | if (uj) { |
16191 | vty_out(vty, "%s\n", | |
16192 | json_object_to_json_string_ext( | |
16193 | json, JSON_C_TO_STRING_PRETTY)); | |
16194 | json_object_free(json); | |
16195 | } else { | |
16196 | vty_out(vty, "%% BGP instance not found\n"); | |
16197 | } | |
16198 | ||
ff9959b0 QY |
16199 | return CMD_WARNING; |
16200 | } | |
d62a17ae | 16201 | |
16202 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
16203 | if (group_name) { |
16204 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 16205 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
16206 | found = true; |
16207 | break; | |
d62a17ae | 16208 | } |
ff9959b0 | 16209 | } else { |
6f4eacf3 | 16210 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 16211 | } |
f14e6fdb | 16212 | } |
f14e6fdb | 16213 | |
6f4eacf3 | 16214 | if (group_name && !found && !uj) |
d62a17ae | 16215 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 16216 | |
6f4eacf3 DA |
16217 | if (uj) { |
16218 | vty_out(vty, "%s\n", | |
16219 | json_object_to_json_string_ext( | |
16220 | json, JSON_C_TO_STRING_PRETTY)); | |
16221 | json_object_free(json); | |
16222 | } | |
16223 | ||
d62a17ae | 16224 | return CMD_SUCCESS; |
f14e6fdb DS |
16225 | } |
16226 | ||
6f4eacf3 DA |
16227 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
16228 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
16229 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
16230 | "Detailed information on BGP peer groups\n" | |
16231 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 16232 | { |
d62a17ae | 16233 | char *vrf, *pg; |
d62a17ae | 16234 | int idx = 0; |
6f4eacf3 | 16235 | bool uj = use_json(argc, argv); |
f14e6fdb | 16236 | |
a4d82a8a PZ |
16237 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
16238 | : NULL; | |
d62a17ae | 16239 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 16240 | |
6f4eacf3 | 16241 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 16242 | } |
3f9c7369 | 16243 | |
d6e3c605 | 16244 | |
718e3744 | 16245 | /* Redistribute VTY commands. */ |
16246 | ||
37a87b8f CS |
16247 | DEFUN_YANG (bgp_redistribute_ipv4, |
16248 | bgp_redistribute_ipv4_cmd, | |
16249 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16250 | "Redistribute information from another routing protocol\n" | |
16251 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 16252 | { |
d62a17ae | 16253 | int idx_protocol = 1; |
37a87b8f | 16254 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 16255 | |
37a87b8f CS |
16256 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16257 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16258 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16259 | argv[idx_protocol]->text, "0"); | |
16260 | ||
16261 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
7f323236 | 16262 | |
37a87b8f | 16263 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 16264 | } |
16265 | ||
d62a17ae | 16266 | ALIAS_HIDDEN( |
16267 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
16268 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16269 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 16270 | |
37a87b8f CS |
16271 | DEFUN_YANG (bgp_redistribute_ipv4_rmap, |
16272 | bgp_redistribute_ipv4_rmap_cmd, | |
16273 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
16274 | "Redistribute information from another routing protocol\n" | |
16275 | FRR_IP_REDIST_HELP_STR_BGPD | |
16276 | "Route map reference\n" | |
16277 | "Pointer to route-map entries\n") | |
718e3744 | 16278 | { |
d62a17ae | 16279 | int idx_protocol = 1; |
16280 | int idx_word = 3; | |
37a87b8f CS |
16281 | char base_xpath[XPATH_MAXLEN]; |
16282 | ||
16283 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16284 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16285 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16286 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16287 | |
37a87b8f CS |
16288 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16289 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16290 | argv[idx_word]->arg); | |
16291 | ||
16292 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16293 | } |
16294 | ||
d62a17ae | 16295 | ALIAS_HIDDEN( |
16296 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
16297 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
16298 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16299 | "Route map reference\n" | |
16300 | "Pointer to route-map entries\n") | |
596c17ba | 16301 | |
37a87b8f CS |
16302 | DEFUN_YANG (bgp_redistribute_ipv4_metric, |
16303 | bgp_redistribute_ipv4_metric_cmd, | |
16304 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16305 | "Redistribute information from another routing protocol\n" | |
16306 | FRR_IP_REDIST_HELP_STR_BGPD | |
16307 | "Metric for redistributed routes\n" | |
16308 | "Default metric\n") | |
718e3744 | 16309 | { |
d62a17ae | 16310 | int idx_protocol = 1; |
16311 | int idx_number = 3; | |
37a87b8f CS |
16312 | char base_xpath[XPATH_MAXLEN]; |
16313 | ||
16314 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16315 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16316 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16317 | argv[idx_protocol]->text, "0"); | |
d62a17ae | 16318 | |
37a87b8f CS |
16319 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16320 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16321 | argv[idx_number]->arg); | |
16322 | ||
16323 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 16324 | } |
16325 | ||
16326 | ALIAS_HIDDEN( | |
16327 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
16328 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16329 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16330 | "Metric for redistributed routes\n" | |
16331 | "Default metric\n") | |
596c17ba | 16332 | |
37a87b8f CS |
16333 | DEFUN_YANG( |
16334 | bgp_redistribute_ipv4_rmap_metric, | |
16335 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
16336 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
16337 | " route-map WORD metric (0-4294967295)", | |
16338 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16339 | "Route map reference\n" | |
16340 | "Pointer to route-map entries\n" | |
16341 | "Metric for redistributed routes\n" | |
16342 | "Default metric\n") | |
718e3744 | 16343 | { |
d62a17ae | 16344 | int idx_protocol = 1; |
16345 | int idx_word = 3; | |
16346 | int idx_number = 5; | |
37a87b8f CS |
16347 | char base_xpath[XPATH_MAXLEN]; |
16348 | ||
16349 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16350 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16351 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16352 | argv[idx_protocol]->text, "0"); | |
16353 | ||
16354 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
16355 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16356 | argv[idx_word]->arg); | |
16357 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16358 | argv[idx_number]->arg); | |
d62a17ae | 16359 | |
37a87b8f | 16360 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16361 | } |
16362 | ||
16363 | ALIAS_HIDDEN( | |
16364 | bgp_redistribute_ipv4_rmap_metric, | |
16365 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
16366 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
16367 | " route-map WORD metric (0-4294967295)", | |
16368 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16369 | "Route map reference\n" | |
16370 | "Pointer to route-map entries\n" | |
16371 | "Metric for redistributed routes\n" | |
16372 | "Default metric\n") | |
596c17ba | 16373 | |
37a87b8f CS |
16374 | DEFUN_YANG( |
16375 | bgp_redistribute_ipv4_metric_rmap, | |
16376 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
16377 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
16378 | " metric (0-4294967295) route-map WORD", | |
16379 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16380 | "Metric for redistributed routes\n" | |
16381 | "Default metric\n" | |
16382 | "Route map reference\n" | |
16383 | "Pointer to route-map entries\n") | |
718e3744 | 16384 | { |
d62a17ae | 16385 | int idx_protocol = 1; |
d62a17ae | 16386 | int idx_word = 5; |
37a87b8f CS |
16387 | int idx_number = 3; |
16388 | char base_xpath[XPATH_MAXLEN]; | |
16389 | ||
16390 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16391 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16392 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16393 | argv[idx_protocol]->text, "0"); | |
16394 | ||
16395 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
16396 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16397 | argv[idx_number]->arg); | |
16398 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16399 | argv[idx_word]->arg); | |
d62a17ae | 16400 | |
37a87b8f | 16401 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16402 | } |
16403 | ||
16404 | ALIAS_HIDDEN( | |
16405 | bgp_redistribute_ipv4_metric_rmap, | |
16406 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
16407 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
16408 | " metric (0-4294967295) route-map WORD", | |
16409 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16410 | "Metric for redistributed routes\n" | |
16411 | "Default metric\n" | |
16412 | "Route map reference\n" | |
16413 | "Pointer to route-map entries\n") | |
596c17ba | 16414 | |
37a87b8f CS |
16415 | DEFUN_YANG (bgp_redistribute_ipv4_ospf, |
16416 | bgp_redistribute_ipv4_ospf_cmd, | |
16417 | "redistribute <ospf|table> (1-65535)", | |
16418 | "Redistribute information from another routing protocol\n" | |
16419 | "Open Shortest Path First (OSPFv2)\n" | |
16420 | "Non-main Kernel Routing Table\n" | |
16421 | "Instance ID/Table ID\n") | |
7c8ff89e | 16422 | { |
37a87b8f | 16423 | int idx_protocol = 1; |
d62a17ae | 16424 | int idx_number = 2; |
37a87b8f | 16425 | char base_xpath[XPATH_MAXLEN]; |
7c8ff89e | 16426 | |
37a87b8f CS |
16427 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16428 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16429 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16430 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
7a4bb9c5 | 16431 | |
37a87b8f | 16432 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
7a4bb9c5 | 16433 | |
37a87b8f | 16434 | return nb_cli_apply_changes(vty, base_xpath); |
7c8ff89e DS |
16435 | } |
16436 | ||
d62a17ae | 16437 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
16438 | "redistribute <ospf|table> (1-65535)", | |
16439 | "Redistribute information from another routing protocol\n" | |
16440 | "Open Shortest Path First (OSPFv2)\n" | |
16441 | "Non-main Kernel Routing Table\n" | |
16442 | "Instance ID/Table ID\n") | |
596c17ba | 16443 | |
37a87b8f CS |
16444 | DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap, |
16445 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
16446 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
16447 | "Redistribute information from another routing protocol\n" | |
16448 | "Open Shortest Path First (OSPFv2)\n" | |
16449 | "Non-main Kernel Routing Table\n" | |
16450 | "Instance ID/Table ID\n" | |
16451 | "Route map reference\n" | |
16452 | "Pointer to route-map entries\n") | |
7c8ff89e | 16453 | { |
37a87b8f | 16454 | int idx_protocol = 1; |
d62a17ae | 16455 | int idx_number = 2; |
16456 | int idx_word = 4; | |
37a87b8f CS |
16457 | char base_xpath[XPATH_MAXLEN]; |
16458 | ||
16459 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16460 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16461 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16462 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
16463 | ||
16464 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
16465 | ||
16466 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16467 | argv[idx_word]->arg); | |
d62a17ae | 16468 | |
37a87b8f | 16469 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16470 | } |
16471 | ||
16472 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
16473 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
16474 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
16475 | "Redistribute information from another routing protocol\n" | |
16476 | "Open Shortest Path First (OSPFv2)\n" | |
16477 | "Non-main Kernel Routing Table\n" | |
16478 | "Instance ID/Table ID\n" | |
16479 | "Route map reference\n" | |
16480 | "Pointer to route-map entries\n") | |
596c17ba | 16481 | |
37a87b8f CS |
16482 | DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric, |
16483 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
16484 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16485 | "Redistribute information from another routing protocol\n" | |
16486 | "Open Shortest Path First (OSPFv2)\n" | |
16487 | "Non-main Kernel Routing Table\n" | |
16488 | "Instance ID/Table ID\n" | |
16489 | "Metric for redistributed routes\n" | |
16490 | "Default metric\n") | |
7c8ff89e | 16491 | { |
37a87b8f | 16492 | int idx_protocol = 1; |
d62a17ae | 16493 | int idx_number = 2; |
16494 | int idx_number_2 = 4; | |
37a87b8f CS |
16495 | char base_xpath[XPATH_MAXLEN]; |
16496 | ||
16497 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16498 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16499 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16500 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
16501 | ||
16502 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 16503 | |
37a87b8f CS |
16504 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
16505 | argv[idx_number_2]->arg); | |
d62a17ae | 16506 | |
37a87b8f | 16507 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16508 | } |
16509 | ||
16510 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
16511 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
16512 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16513 | "Redistribute information from another routing protocol\n" | |
16514 | "Open Shortest Path First (OSPFv2)\n" | |
16515 | "Non-main Kernel Routing Table\n" | |
16516 | "Instance ID/Table ID\n" | |
16517 | "Metric for redistributed routes\n" | |
16518 | "Default metric\n") | |
596c17ba | 16519 | |
37a87b8f CS |
16520 | DEFUN_YANG( |
16521 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
16522 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
16523 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
16524 | "Redistribute information from another routing protocol\n" | |
16525 | "Open Shortest Path First (OSPFv2)\n" | |
16526 | "Non-main Kernel Routing Table\n" | |
16527 | "Instance ID/Table ID\n" | |
16528 | "Route map reference\n" | |
16529 | "Pointer to route-map entries\n" | |
16530 | "Metric for redistributed routes\n" | |
16531 | "Default metric\n") | |
7c8ff89e | 16532 | { |
37a87b8f | 16533 | int idx_protocol = 1; |
d62a17ae | 16534 | int idx_number = 2; |
16535 | int idx_word = 4; | |
16536 | int idx_number_2 = 6; | |
37a87b8f CS |
16537 | char base_xpath[XPATH_MAXLEN]; |
16538 | ||
16539 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16540 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16541 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16542 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
16543 | ||
16544 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 16545 | |
37a87b8f CS |
16546 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, |
16547 | argv[idx_word]->arg); | |
16548 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16549 | argv[idx_number_2]->arg); | |
d62a17ae | 16550 | |
37a87b8f | 16551 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16552 | } |
16553 | ||
16554 | ALIAS_HIDDEN( | |
16555 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
16556 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
16557 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
16558 | "Redistribute information from another routing protocol\n" | |
16559 | "Open Shortest Path First (OSPFv2)\n" | |
16560 | "Non-main Kernel Routing Table\n" | |
16561 | "Instance ID/Table ID\n" | |
16562 | "Route map reference\n" | |
16563 | "Pointer to route-map entries\n" | |
16564 | "Metric for redistributed routes\n" | |
16565 | "Default metric\n") | |
596c17ba | 16566 | |
37a87b8f CS |
16567 | DEFUN_YANG( |
16568 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
16569 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
16570 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
16571 | "Redistribute information from another routing protocol\n" | |
16572 | "Open Shortest Path First (OSPFv2)\n" | |
16573 | "Non-main Kernel Routing Table\n" | |
16574 | "Instance ID/Table ID\n" | |
16575 | "Metric for redistributed routes\n" | |
16576 | "Default metric\n" | |
16577 | "Route map reference\n" | |
16578 | "Pointer to route-map entries\n") | |
7c8ff89e | 16579 | { |
37a87b8f | 16580 | int idx_protocol = 1; |
d62a17ae | 16581 | int idx_number = 2; |
16582 | int idx_number_2 = 4; | |
16583 | int idx_word = 6; | |
37a87b8f CS |
16584 | char base_xpath[XPATH_MAXLEN]; |
16585 | ||
16586 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16587 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16588 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16589 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
16590 | ||
16591 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
d62a17ae | 16592 | |
37a87b8f CS |
16593 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, |
16594 | argv[idx_number_2]->arg); | |
16595 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16596 | argv[idx_word]->arg); | |
d62a17ae | 16597 | |
37a87b8f | 16598 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16599 | } |
16600 | ||
16601 | ALIAS_HIDDEN( | |
16602 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
16603 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
16604 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
16605 | "Redistribute information from another routing protocol\n" | |
16606 | "Open Shortest Path First (OSPFv2)\n" | |
16607 | "Non-main Kernel Routing Table\n" | |
16608 | "Instance ID/Table ID\n" | |
16609 | "Metric for redistributed routes\n" | |
16610 | "Default metric\n" | |
16611 | "Route map reference\n" | |
16612 | "Pointer to route-map entries\n") | |
596c17ba | 16613 | |
37a87b8f CS |
16614 | DEFUN_YANG (no_bgp_redistribute_ipv4_ospf, |
16615 | no_bgp_redistribute_ipv4_ospf_cmd, | |
16616 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
16617 | NO_STR | |
16618 | "Redistribute information from another routing protocol\n" | |
16619 | "Open Shortest Path First (OSPFv2)\n" | |
16620 | "Non-main Kernel Routing Table\n" | |
16621 | "Instance ID/Table ID\n" | |
16622 | "Metric for redistributed routes\n" | |
16623 | "Default metric\n" | |
16624 | "Route map reference\n" | |
16625 | "Pointer to route-map entries\n") | |
7c8ff89e | 16626 | { |
37a87b8f | 16627 | int idx_protocol = 2; |
d62a17ae | 16628 | int idx_number = 3; |
37a87b8f | 16629 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 16630 | |
37a87b8f CS |
16631 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16632 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16633 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16634 | argv[idx_protocol]->text, argv[idx_number]->arg); | |
16635 | ||
16636 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
d62a17ae | 16637 | |
37a87b8f | 16638 | return nb_cli_apply_changes(vty, base_xpath); |
d62a17ae | 16639 | } |
16640 | ||
16641 | ALIAS_HIDDEN( | |
16642 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 16643 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 16644 | NO_STR |
16645 | "Redistribute information from another routing protocol\n" | |
16646 | "Open Shortest Path First (OSPFv2)\n" | |
16647 | "Non-main Kernel Routing Table\n" | |
16648 | "Instance ID/Table ID\n" | |
16649 | "Metric for redistributed routes\n" | |
16650 | "Default metric\n" | |
16651 | "Route map reference\n" | |
16652 | "Pointer to route-map entries\n") | |
596c17ba | 16653 | |
37a87b8f CS |
16654 | DEFUN_YANG (no_bgp_redistribute_ipv4, |
16655 | no_bgp_redistribute_ipv4_cmd, | |
16656 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
16657 | NO_STR | |
16658 | "Redistribute information from another routing protocol\n" | |
16659 | FRR_IP_REDIST_HELP_STR_BGPD | |
16660 | "Metric for redistributed routes\n" | |
16661 | "Default metric\n" | |
16662 | "Route map reference\n" | |
16663 | "Pointer to route-map entries\n") | |
718e3744 | 16664 | { |
d62a17ae | 16665 | int idx_protocol = 2; |
37a87b8f | 16666 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 16667 | |
37a87b8f CS |
16668 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16669 | yang_afi_safi_value2identity(AFI_IP, SAFI_UNICAST), | |
16670 | bgp_afi_safi_get_container_str(AFI_IP, SAFI_UNICAST), | |
16671 | argv[idx_protocol]->text, "0"); | |
16672 | ||
16673 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
16674 | ||
16675 | return nb_cli_apply_changes(vty, base_xpath); | |
d62a17ae | 16676 | } |
16677 | ||
16678 | ALIAS_HIDDEN( | |
16679 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
16680 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 16681 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 16682 | NO_STR |
16683 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16684 | "Metric for redistributed routes\n" | |
16685 | "Default metric\n" | |
16686 | "Route map reference\n" | |
16687 | "Pointer to route-map entries\n") | |
596c17ba | 16688 | |
37a87b8f CS |
16689 | DEFUN_YANG (bgp_redistribute_ipv6, |
16690 | bgp_redistribute_ipv6_cmd, | |
16691 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
16692 | "Redistribute information from another routing protocol\n" | |
16693 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 16694 | { |
d62a17ae | 16695 | int idx_protocol = 1; |
37a87b8f | 16696 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 16697 | |
37a87b8f CS |
16698 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16699 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16700 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16701 | argv[idx_protocol]->text, "0"); | |
16702 | ||
16703 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
718e3744 | 16704 | |
37a87b8f | 16705 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 16706 | } |
16707 | ||
37a87b8f CS |
16708 | DEFUN_YANG (bgp_redistribute_ipv6_rmap, |
16709 | bgp_redistribute_ipv6_rmap_cmd, | |
16710 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
16711 | "Redistribute information from another routing protocol\n" | |
16712 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16713 | "Route map reference\n" | |
16714 | "Pointer to route-map entries\n") | |
718e3744 | 16715 | { |
d62a17ae | 16716 | int idx_protocol = 1; |
16717 | int idx_word = 3; | |
37a87b8f CS |
16718 | char base_xpath[XPATH_MAXLEN]; |
16719 | ||
16720 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16721 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16722 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16723 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16724 | |
37a87b8f CS |
16725 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16726 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16727 | argv[idx_word]->arg); | |
16728 | ||
16729 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16730 | } |
16731 | ||
37a87b8f | 16732 | DEFUN_YANG (bgp_redistribute_ipv6_metric, |
718e3744 | 16733 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16734 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16735 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16736 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16737 | "Metric for redistributed routes\n" |
16738 | "Default metric\n") | |
16739 | { | |
d62a17ae | 16740 | int idx_protocol = 1; |
16741 | int idx_number = 3; | |
37a87b8f CS |
16742 | char base_xpath[XPATH_MAXLEN]; |
16743 | ||
16744 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16745 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16746 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16747 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16748 | |
37a87b8f CS |
16749 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16750 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16751 | argv[idx_number]->arg); | |
16752 | ||
16753 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16754 | } |
16755 | ||
37a87b8f CS |
16756 | DEFUN_YANG( |
16757 | bgp_redistribute_ipv6_rmap_metric, | |
16758 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
16759 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
16760 | " route-map WORD metric (0-4294967295)", | |
16761 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
16762 | "Route map reference\n" | |
16763 | "Pointer to route-map entries\n" | |
16764 | "Metric for redistributed routes\n" | |
16765 | "Default metric\n") | |
718e3744 | 16766 | { |
d62a17ae | 16767 | int idx_protocol = 1; |
16768 | int idx_word = 3; | |
16769 | int idx_number = 5; | |
37a87b8f CS |
16770 | char base_xpath[XPATH_MAXLEN]; |
16771 | ||
16772 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16773 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16774 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16775 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16776 | |
37a87b8f CS |
16777 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16778 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16779 | argv[idx_word]->arg); | |
16780 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16781 | argv[idx_number]->arg); | |
16782 | ||
16783 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16784 | } |
16785 | ||
37a87b8f CS |
16786 | DEFUN_YANG( |
16787 | bgp_redistribute_ipv6_metric_rmap, | |
16788 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
16789 | "redistribute " FRR_IP6_REDIST_STR_BGPD | |
16790 | " metric (0-4294967295) route-map WORD", | |
16791 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
16792 | "Metric for redistributed routes\n" | |
16793 | "Default metric\n" | |
16794 | "Route map reference\n" | |
16795 | "Pointer to route-map entries\n") | |
718e3744 | 16796 | { |
d62a17ae | 16797 | int idx_protocol = 1; |
d62a17ae | 16798 | int idx_word = 5; |
37a87b8f CS |
16799 | int idx_number = 3; |
16800 | char base_xpath[XPATH_MAXLEN]; | |
16801 | ||
16802 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, | |
16803 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16804 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16805 | argv[idx_protocol]->text, "0"); | |
718e3744 | 16806 | |
37a87b8f CS |
16807 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); |
16808 | nb_cli_enqueue_change(vty, "./metric", NB_OP_CREATE, | |
16809 | argv[idx_number]->arg); | |
16810 | nb_cli_enqueue_change(vty, "./rmap-policy-import", NB_OP_CREATE, | |
16811 | argv[idx_word]->arg); | |
16812 | ||
16813 | return nb_cli_apply_changes(vty, base_xpath); | |
718e3744 | 16814 | } |
16815 | ||
37a87b8f CS |
16816 | DEFUN_YANG( |
16817 | no_bgp_redistribute_ipv6, | |
16818 | no_bgp_redistribute_ipv6_cmd, | |
16819 | "no redistribute " FRR_IP6_REDIST_STR_BGPD | |
16820 | " [{metric (0-4294967295)|route-map WORD}]", | |
16821 | NO_STR | |
16822 | "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD | |
16823 | "Metric for redistributed routes\n" | |
16824 | "Default metric\n" | |
16825 | "Route map reference\n" | |
16826 | "Pointer to route-map entries\n") | |
718e3744 | 16827 | { |
d62a17ae | 16828 | int idx_protocol = 2; |
37a87b8f | 16829 | char base_xpath[XPATH_MAXLEN]; |
718e3744 | 16830 | |
37a87b8f CS |
16831 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_AFI_SAFI_REDIST_XPATH, |
16832 | yang_afi_safi_value2identity(AFI_IP6, SAFI_UNICAST), | |
16833 | bgp_afi_safi_get_container_str(AFI_IP6, SAFI_UNICAST), | |
16834 | argv[idx_protocol]->text, "0"); | |
16835 | ||
16836 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); | |
16837 | ||
16838 | return nb_cli_apply_changes(vty, base_xpath); | |
16839 | } | |
718e3744 | 16840 | |
37a87b8f CS |
16841 | void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list( |
16842 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
16843 | { | |
16844 | uint32_t instance = 0; | |
16845 | ||
16846 | vty_out(vty, " redistribute %s", | |
16847 | yang_dnode_get_string(dnode, "./route-type")); | |
16848 | if ((instance = yang_dnode_get_uint16(dnode, "./route-instance"))) | |
16849 | vty_out(vty, " %d", instance); | |
16850 | if (yang_dnode_exists(dnode, "./metric")) | |
16851 | vty_out(vty, " metric %u", | |
16852 | yang_dnode_get_uint32(dnode, "./metric")); | |
16853 | if (yang_dnode_exists(dnode, "./rmap-policy-import")) | |
16854 | vty_out(vty, " route-map %s", | |
16855 | yang_dnode_get_string(dnode, "./rmap-policy-import")); | |
16856 | vty_out(vty, "\n"); | |
d62a17ae | 16857 | } |
16858 | ||
4ab46701 AR |
16859 | /* Neighbor update tcp-mss. */ |
16860 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16861 | const char *tcp_mss_str) | |
16862 | { | |
16863 | struct peer *peer; | |
16864 | uint32_t tcp_mss_val = 0; | |
16865 | ||
16866 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16867 | if (!peer) | |
16868 | return CMD_WARNING_CONFIG_FAILED; | |
16869 | ||
16870 | if (tcp_mss_str) { | |
16871 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16872 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16873 | } else { | |
16874 | peer_tcp_mss_unset(peer); | |
16875 | } | |
16876 | ||
16877 | return CMD_SUCCESS; | |
16878 | } | |
16879 | ||
16880 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16881 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16882 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16883 | "TCP max segment size\n" | |
16884 | "TCP MSS value\n") | |
16885 | { | |
16886 | int peer_index = 1; | |
16887 | int mss_index = 3; | |
16888 | ||
16889 | vty_out(vty, | |
16890 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16891 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16892 | argv[mss_index]->arg); | |
16893 | } | |
16894 | ||
16895 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16896 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16897 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16898 | "TCP max segment size\n" | |
16899 | "TCP MSS value\n") | |
16900 | { | |
16901 | int peer_index = 2; | |
16902 | ||
16903 | vty_out(vty, | |
16904 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16905 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16906 | } | |
16907 | ||
dd65f45e DL |
16908 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16909 | afi_t afi, safi_t safi) | |
d62a17ae | 16910 | { |
16911 | int i; | |
16912 | ||
16913 | /* Unicast redistribution only. */ | |
16914 | if (safi != SAFI_UNICAST) | |
2b791107 | 16915 | return; |
d62a17ae | 16916 | |
16917 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16918 | /* Redistribute BGP does not make sense. */ | |
16919 | if (i != ZEBRA_ROUTE_BGP) { | |
16920 | struct list *red_list; | |
16921 | struct listnode *node; | |
16922 | struct bgp_redist *red; | |
16923 | ||
16924 | red_list = bgp->redist[afi][i]; | |
16925 | if (!red_list) | |
16926 | continue; | |
16927 | ||
16928 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16929 | /* "redistribute" configuration. */ |
16930 | vty_out(vty, " redistribute %s", | |
16931 | zebra_route_string(i)); | |
16932 | if (red->instance) | |
16933 | vty_out(vty, " %d", red->instance); | |
16934 | if (red->redist_metric_flag) | |
16935 | vty_out(vty, " metric %u", | |
16936 | red->redist_metric); | |
16937 | if (red->rmap.name) | |
16938 | vty_out(vty, " route-map %s", | |
16939 | red->rmap.name); | |
16940 | vty_out(vty, "\n"); | |
16941 | } | |
16942 | } | |
16943 | } | |
718e3744 | 16944 | } |
6b0655a2 | 16945 | |
dd65f45e DL |
16946 | /* peer-group helpers for config-write */ |
16947 | ||
16948 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16949 | { | |
16950 | if (!peer_group_active(peer)) { | |
16951 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16952 | return !CHECK_FLAG(peer->flags, flag); | |
16953 | else | |
16954 | return !!CHECK_FLAG(peer->flags, flag); | |
16955 | } | |
16956 | ||
16957 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16958 | } | |
16959 | ||
16960 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16961 | uint32_t flag) | |
16962 | { | |
16963 | if (!peer_group_active(peer)) { | |
16964 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16965 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16966 | else | |
16967 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16968 | } | |
16969 | ||
16970 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16971 | } | |
16972 | ||
16973 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16974 | uint8_t type, int direct) | |
16975 | { | |
16976 | struct bgp_filter *filter; | |
16977 | ||
16978 | if (peer_group_active(peer)) | |
16979 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16980 | type); | |
16981 | ||
16982 | filter = &peer->filter[afi][safi]; | |
16983 | switch (type) { | |
16984 | case PEER_FT_DISTRIBUTE_LIST: | |
16985 | return !!(filter->dlist[direct].name); | |
16986 | case PEER_FT_FILTER_LIST: | |
16987 | return !!(filter->aslist[direct].name); | |
16988 | case PEER_FT_PREFIX_LIST: | |
16989 | return !!(filter->plist[direct].name); | |
16990 | case PEER_FT_ROUTE_MAP: | |
16991 | return !!(filter->map[direct].name); | |
16992 | case PEER_FT_UNSUPPRESS_MAP: | |
16993 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16994 | case PEER_FT_ADVERTISE_MAP: |
16995 | return !!(filter->advmap.aname | |
16996 | && ((filter->advmap.condition == direct) | |
16997 | && filter->advmap.cname)); | |
dd65f45e DL |
16998 | default: |
16999 | return false; | |
17000 | } | |
17001 | } | |
17002 | ||
17003 | /* Return true if the addpath type is set for peer and different from | |
17004 | * peer-group. | |
17005 | */ | |
3dc339cd DA |
17006 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
17007 | safi_t safi) | |
dd65f45e DL |
17008 | { |
17009 | enum bgp_addpath_strat type, g_type; | |
17010 | ||
17011 | type = peer->addpath_type[afi][safi]; | |
17012 | ||
17013 | if (type != BGP_ADDPATH_NONE) { | |
17014 | if (peer_group_active(peer)) { | |
17015 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
17016 | ||
17017 | if (type != g_type) | |
3dc339cd | 17018 | return true; |
dd65f45e | 17019 | else |
3dc339cd | 17020 | return false; |
dd65f45e DL |
17021 | } |
17022 | ||
3dc339cd | 17023 | return true; |
dd65f45e DL |
17024 | } |
17025 | ||
3dc339cd | 17026 | return false; |
dd65f45e DL |
17027 | } |
17028 | ||
b9c7bc5a | 17029 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 17030 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
17031 | afi_t afi) |
17032 | { | |
b9c7bc5a | 17033 | int indent = 2; |
ddb5b488 | 17034 | |
8a066a70 | 17035 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
17036 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
17037 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
17038 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
17039 | bgp->vpn_policy[afi] | |
bb4f6190 | 17040 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
17041 | else |
17042 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
17043 | bgp->vpn_policy[afi] | |
17044 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
17045 | } | |
12a844a5 DS |
17046 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
17047 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
17048 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
17049 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
17050 | return; | |
17051 | ||
e70e9f8e PZ |
17052 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
17053 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
17054 | ||
17055 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
17056 | ||
17057 | } else { | |
17058 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
17059 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
17060 | bgp->vpn_policy[afi].tovpn_label); | |
17061 | } | |
ddb5b488 PZ |
17062 | } |
17063 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
17064 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
17065 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 17066 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
17067 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
17068 | sizeof(buf))); | |
17069 | } | |
17070 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
17071 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
17072 | ||
17073 | char buf[PREFIX_STRLEN]; | |
17074 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
17075 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
17076 | sizeof(buf))) { | |
17077 | ||
b9c7bc5a PZ |
17078 | vty_out(vty, "%*snexthop vpn export %s\n", |
17079 | indent, "", buf); | |
ddb5b488 PZ |
17080 | } |
17081 | } | |
17082 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
17083 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
17084 | && ecommunity_cmp( | |
17085 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
17086 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
17087 | ||
17088 | char *b = ecommunity_ecom2str( | |
17089 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
17090 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17091 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
17092 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17093 | } else { | |
17094 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
17095 | char *b = ecommunity_ecom2str( | |
17096 | bgp->vpn_policy[afi] | |
17097 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
17098 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17099 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17100 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
17101 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17102 | } | |
17103 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
17104 | char *b = ecommunity_ecom2str( | |
17105 | bgp->vpn_policy[afi] | |
17106 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
17107 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17108 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17109 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
17110 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17111 | } | |
17112 | } | |
bb4f6190 DS |
17113 | |
17114 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 17115 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
17116 | bgp->vpn_policy[afi] |
17117 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 17118 | |
301ad80a PG |
17119 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
17120 | char *b = ecommunity_ecom2str( | |
17121 | bgp->vpn_policy[afi] | |
17122 | .import_redirect_rtlist, | |
17123 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17124 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 17125 | |
9a659715 PG |
17126 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
17127 | != ECOMMUNITY_SIZE) | |
c6423c31 | 17128 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
17129 | indent, "", b); |
17130 | else | |
17131 | vty_out(vty, "%*srt redirect import %s\n", | |
17132 | indent, "", b); | |
301ad80a PG |
17133 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17134 | } | |
ddb5b488 PZ |
17135 | } |
17136 | ||
dd65f45e DL |
17137 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
17138 | afi_t afi, safi_t safi) | |
17139 | { | |
17140 | struct bgp_filter *filter; | |
17141 | char *addr; | |
17142 | ||
17143 | addr = peer->host; | |
17144 | filter = &peer->filter[afi][safi]; | |
17145 | ||
17146 | /* distribute-list. */ | |
17147 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17148 | FILTER_IN)) | |
17149 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
17150 | filter->dlist[FILTER_IN].name); | |
17151 | ||
17152 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17153 | FILTER_OUT)) | |
17154 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
17155 | filter->dlist[FILTER_OUT].name); | |
17156 | ||
17157 | /* prefix-list. */ | |
17158 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17159 | FILTER_IN)) | |
17160 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
17161 | filter->plist[FILTER_IN].name); | |
17162 | ||
17163 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17164 | FILTER_OUT)) | |
17165 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
17166 | filter->plist[FILTER_OUT].name); | |
17167 | ||
17168 | /* route-map. */ | |
17169 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
17170 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
17171 | filter->map[RMAP_IN].name); | |
17172 | ||
17173 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
17174 | RMAP_OUT)) | |
17175 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
17176 | filter->map[RMAP_OUT].name); | |
17177 | ||
17178 | /* unsuppress-map */ | |
17179 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
17180 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
17181 | filter->usmap.name); | |
17182 | ||
7f7940e6 MK |
17183 | /* advertise-map : always applied in OUT direction*/ |
17184 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17185 | CONDITION_NON_EXIST)) | |
17186 | vty_out(vty, | |
17187 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
17188 | addr, filter->advmap.aname, filter->advmap.cname); | |
17189 | ||
17190 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17191 | CONDITION_EXIST)) | |
17192 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
17193 | addr, filter->advmap.aname, filter->advmap.cname); | |
17194 | ||
dd65f45e DL |
17195 | /* filter-list. */ |
17196 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17197 | FILTER_IN)) | |
17198 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
17199 | filter->aslist[FILTER_IN].name); | |
17200 | ||
17201 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17202 | FILTER_OUT)) | |
17203 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
17204 | filter->aslist[FILTER_OUT].name); | |
17205 | } | |
17206 | ||
17207 | /* BGP peer configuration display function. */ | |
17208 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
17209 | struct peer *peer) | |
17210 | { | |
17211 | struct peer *g_peer = NULL; | |
17212 | char buf[SU_ADDRSTRLEN]; | |
17213 | char *addr; | |
17214 | int if_pg_printed = false; | |
17215 | int if_ras_printed = false; | |
17216 | ||
17217 | /* Skip dynamic neighbors. */ | |
17218 | if (peer_dynamic_neighbor(peer)) | |
17219 | return; | |
17220 | ||
17221 | if (peer->conf_if) | |
17222 | addr = peer->conf_if; | |
17223 | else | |
17224 | addr = peer->host; | |
17225 | ||
17226 | /************************************ | |
17227 | ****** Global to the neighbor ****** | |
17228 | ************************************/ | |
17229 | if (peer->conf_if) { | |
17230 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
17231 | vty_out(vty, " neighbor %s interface v6only", addr); | |
17232 | else | |
17233 | vty_out(vty, " neighbor %s interface", addr); | |
17234 | ||
17235 | if (peer_group_active(peer)) { | |
17236 | vty_out(vty, " peer-group %s", peer->group->name); | |
17237 | if_pg_printed = true; | |
17238 | } else if (peer->as_type == AS_SPECIFIED) { | |
17239 | vty_out(vty, " remote-as %u", peer->as); | |
17240 | if_ras_printed = true; | |
17241 | } else if (peer->as_type == AS_INTERNAL) { | |
17242 | vty_out(vty, " remote-as internal"); | |
17243 | if_ras_printed = true; | |
17244 | } else if (peer->as_type == AS_EXTERNAL) { | |
17245 | vty_out(vty, " remote-as external"); | |
17246 | if_ras_printed = true; | |
17247 | } | |
17248 | ||
17249 | vty_out(vty, "\n"); | |
17250 | } | |
17251 | ||
17252 | /* remote-as and peer-group */ | |
17253 | /* peer is a member of a peer-group */ | |
17254 | if (peer_group_active(peer)) { | |
17255 | g_peer = peer->group->conf; | |
17256 | ||
17257 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
17258 | if (peer->as_type == AS_SPECIFIED) { | |
17259 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17260 | addr, peer->as); | |
17261 | } else if (peer->as_type == AS_INTERNAL) { | |
17262 | vty_out(vty, | |
17263 | " neighbor %s remote-as internal\n", | |
17264 | addr); | |
17265 | } else if (peer->as_type == AS_EXTERNAL) { | |
17266 | vty_out(vty, | |
17267 | " neighbor %s remote-as external\n", | |
17268 | addr); | |
17269 | } | |
17270 | } | |
17271 | ||
17272 | /* For swpX peers we displayed the peer-group | |
17273 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
17274 | if (!if_pg_printed) | |
17275 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
17276 | peer->group->name); | |
17277 | } | |
17278 | ||
17279 | /* peer is NOT a member of a peer-group */ | |
17280 | else { | |
17281 | /* peer is a peer-group, declare the peer-group */ | |
17282 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
17283 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
17284 | } | |
17285 | ||
17286 | if (!if_ras_printed) { | |
17287 | if (peer->as_type == AS_SPECIFIED) { | |
17288 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17289 | addr, peer->as); | |
17290 | } else if (peer->as_type == AS_INTERNAL) { | |
17291 | vty_out(vty, | |
17292 | " neighbor %s remote-as internal\n", | |
17293 | addr); | |
17294 | } else if (peer->as_type == AS_EXTERNAL) { | |
17295 | vty_out(vty, | |
17296 | " neighbor %s remote-as external\n", | |
17297 | addr); | |
17298 | } | |
17299 | } | |
17300 | } | |
17301 | ||
17302 | /* local-as */ | |
17303 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
17304 | vty_out(vty, " neighbor %s local-as %u", addr, | |
17305 | peer->change_local_as); | |
17306 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
17307 | vty_out(vty, " no-prepend"); | |
17308 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
17309 | vty_out(vty, " replace-as"); | |
17310 | vty_out(vty, "\n"); | |
17311 | } | |
17312 | ||
17313 | /* description */ | |
17314 | if (peer->desc) { | |
17315 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
17316 | } | |
17317 | ||
17318 | /* shutdown */ | |
17319 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
17320 | if (peer->tx_shutdown_message) | |
17321 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
17322 | peer->tx_shutdown_message); | |
17323 | else | |
17324 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
17325 | } | |
17326 | ||
8336c896 DA |
17327 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
17328 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
17329 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
17330 | ||
dd65f45e | 17331 | /* bfd */ |
21bfce98 RZ |
17332 | if (peer->bfd_config) |
17333 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
17334 | |
17335 | /* password */ | |
17336 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
17337 | vty_out(vty, " neighbor %s password %s\n", addr, | |
17338 | peer->password); | |
17339 | ||
17340 | /* neighbor solo */ | |
17341 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
17342 | if (!peer_group_active(peer)) { | |
17343 | vty_out(vty, " neighbor %s solo\n", addr); | |
17344 | } | |
17345 | } | |
17346 | ||
17347 | /* BGP port */ | |
17348 | if (peer->port != BGP_PORT_DEFAULT) { | |
17349 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
17350 | } | |
17351 | ||
17352 | /* Local interface name */ | |
17353 | if (peer->ifname) { | |
17354 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
17355 | } | |
17356 | ||
4ab46701 AR |
17357 | /* TCP max segment size */ |
17358 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
17359 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
17360 | ||
dd65f45e DL |
17361 | /* passive */ |
17362 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
17363 | vty_out(vty, " neighbor %s passive\n", addr); | |
17364 | ||
17365 | /* ebgp-multihop */ | |
17366 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
17367 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
17368 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
17369 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
17370 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
17371 | peer->ttl); | |
17372 | } | |
17373 | } | |
17374 | ||
17375 | /* ttl-security hops */ | |
e2521429 | 17376 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
17377 | if (!peer_group_active(peer) |
17378 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
17379 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
17380 | addr, peer->gtsm_hops); | |
17381 | } | |
17382 | } | |
17383 | ||
17384 | /* disable-connected-check */ | |
17385 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
17386 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
17387 | ||
17388 | /* enforce-first-as */ | |
17389 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
17390 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
17391 | ||
17392 | /* update-source */ | |
17393 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
17394 | if (peer->update_source) | |
17395 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
17396 | sockunion2str(peer->update_source, buf, | |
17397 | SU_ADDRSTRLEN)); | |
17398 | else if (peer->update_if) | |
17399 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
17400 | peer->update_if); | |
17401 | } | |
17402 | ||
17403 | /* advertisement-interval */ | |
17404 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
17405 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
17406 | peer->routeadv); | |
17407 | ||
17408 | /* timers */ | |
17409 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
17410 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
17411 | peer->keepalive, peer->holdtime); | |
17412 | ||
17413 | /* timers connect */ | |
17414 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
17415 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17416 | peer->connect); | |
5d5393b9 DL |
17417 | /* need special-case handling for changed default values due to |
17418 | * config profile / version (because there is no "timers bgp connect" | |
17419 | * command, we need to save this per-peer :/) | |
17420 | */ | |
17421 | else if (!peer_group_active(peer) && !peer->connect && | |
17422 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
17423 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17424 | peer->bgp->default_connect_retry); | |
dd65f45e | 17425 | |
d43114f3 DS |
17426 | /* timers delayopen */ |
17427 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
17428 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17429 | peer->delayopen); | |
17430 | /* Save config even though flag is not set if default values have been | |
17431 | * changed | |
17432 | */ | |
17433 | else if (!peer_group_active(peer) && !peer->delayopen | |
17434 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
17435 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17436 | peer->bgp->default_delayopen); | |
17437 | ||
dd65f45e DL |
17438 | /* capability dynamic */ |
17439 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
17440 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
17441 | ||
17442 | /* capability extended-nexthop */ | |
17443 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
17444 | if (!peer->conf_if) { | |
17445 | if (CHECK_FLAG(peer->flags_invert, | |
17446 | PEER_FLAG_CAPABILITY_ENHE)) | |
17447 | vty_out(vty, | |
17448 | " no neighbor %s capability extended-nexthop\n", | |
17449 | addr); | |
17450 | else | |
17451 | vty_out(vty, | |
17452 | " neighbor %s capability extended-nexthop\n", | |
17453 | addr); | |
17454 | } | |
17455 | } | |
17456 | ||
17457 | /* dont-capability-negotiation */ | |
17458 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
17459 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
17460 | ||
17461 | /* override-capability */ | |
17462 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
17463 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
17464 | ||
17465 | /* strict-capability-match */ | |
17466 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
17467 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
17468 | ||
17469 | /* Sender side AS path loop detection. */ | |
17470 | if (peer->as_path_loop_detection) | |
17471 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
17472 | addr); | |
cfd47646 | 17473 | |
17474 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17475 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 17476 | |
17477 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17478 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 17479 | vty_out(vty, |
17480 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
17481 | } else if (CHECK_FLAG( |
17482 | peer->peer_gr_new_status_flag, | |
17483 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 17484 | vty_out(vty, |
17485 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
17486 | } else if ( |
17487 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
17488 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
17489 | && !(CHECK_FLAG( | |
17490 | peer->peer_gr_new_status_flag, | |
17491 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
17492 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
17493 | addr); | |
cfd47646 | 17494 | } |
17495 | } | |
dd65f45e DL |
17496 | } |
17497 | ||
17498 | /* BGP peer configuration display function. */ | |
17499 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
17500 | struct peer *peer, afi_t afi, safi_t safi) | |
17501 | { | |
17502 | struct peer *g_peer = NULL; | |
17503 | char *addr; | |
17504 | bool flag_scomm, flag_secomm, flag_slcomm; | |
17505 | ||
17506 | /* Skip dynamic neighbors. */ | |
17507 | if (peer_dynamic_neighbor(peer)) | |
17508 | return; | |
17509 | ||
17510 | if (peer->conf_if) | |
17511 | addr = peer->conf_if; | |
17512 | else | |
17513 | addr = peer->host; | |
17514 | ||
17515 | /************************************ | |
17516 | ****** Per AF to the neighbor ****** | |
17517 | ************************************/ | |
17518 | if (peer_group_active(peer)) { | |
17519 | g_peer = peer->group->conf; | |
17520 | ||
17521 | /* If the peer-group is active but peer is not, print a 'no | |
17522 | * activate' */ | |
17523 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
17524 | vty_out(vty, " no neighbor %s activate\n", addr); | |
17525 | } | |
17526 | ||
17527 | /* If the peer-group is not active but peer is, print an | |
17528 | 'activate' */ | |
17529 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
17530 | vty_out(vty, " neighbor %s activate\n", addr); | |
17531 | } | |
17532 | } else { | |
17533 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
17534 | if (safi == SAFI_ENCAP) |
17535 | vty_out(vty, " neighbor %s activate\n", addr); | |
17536 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
17537 | vty_out(vty, " neighbor %s activate\n", addr); |
17538 | } else { | |
38d11af5 TA |
17539 | if (bgp->default_af[afi][safi]) |
17540 | vty_out(vty, " no neighbor %s activate\n", | |
17541 | addr); | |
dd65f45e DL |
17542 | } |
17543 | } | |
17544 | ||
17545 | /* addpath TX knobs */ | |
17546 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
17547 | switch (peer->addpath_type[afi][safi]) { | |
17548 | case BGP_ADDPATH_ALL: | |
17549 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
17550 | addr); | |
17551 | break; | |
17552 | case BGP_ADDPATH_BEST_PER_AS: | |
17553 | vty_out(vty, | |
17554 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
17555 | addr); | |
17556 | break; | |
17557 | case BGP_ADDPATH_MAX: | |
17558 | case BGP_ADDPATH_NONE: | |
17559 | break; | |
17560 | } | |
17561 | } | |
17562 | ||
17563 | /* ORF capability. */ | |
17564 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
17565 | || peergroup_af_flag_check(peer, afi, safi, | |
17566 | PEER_FLAG_ORF_PREFIX_RM)) { | |
17567 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
17568 | ||
17569 | if (peergroup_af_flag_check(peer, afi, safi, | |
17570 | PEER_FLAG_ORF_PREFIX_SM) | |
17571 | && peergroup_af_flag_check(peer, afi, safi, | |
17572 | PEER_FLAG_ORF_PREFIX_RM)) | |
17573 | vty_out(vty, " both"); | |
17574 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17575 | PEER_FLAG_ORF_PREFIX_SM)) | |
17576 | vty_out(vty, " send"); | |
17577 | else | |
17578 | vty_out(vty, " receive"); | |
17579 | vty_out(vty, "\n"); | |
17580 | } | |
17581 | ||
dd65f45e DL |
17582 | /* Route reflector client. */ |
17583 | if (peergroup_af_flag_check(peer, afi, safi, | |
17584 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
17585 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
17586 | } | |
17587 | ||
17588 | /* next-hop-self force */ | |
17589 | if (peergroup_af_flag_check(peer, afi, safi, | |
17590 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
17591 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
17592 | } | |
17593 | ||
17594 | /* next-hop-self */ | |
17595 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
17596 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
17597 | } | |
17598 | ||
17599 | /* remove-private-AS */ | |
17600 | if (peergroup_af_flag_check(peer, afi, safi, | |
17601 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
17602 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
17603 | addr); | |
17604 | } | |
17605 | ||
17606 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17607 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
17608 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
17609 | addr); | |
17610 | } | |
17611 | ||
17612 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17613 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
17614 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
17615 | } | |
17616 | ||
17617 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17618 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
17619 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
17620 | } | |
17621 | ||
17622 | /* as-override */ | |
17623 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
17624 | vty_out(vty, " neighbor %s as-override\n", addr); | |
17625 | } | |
17626 | ||
17627 | /* send-community print. */ | |
17628 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
17629 | PEER_FLAG_SEND_COMMUNITY); | |
17630 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
17631 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
17632 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
17633 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
17634 | ||
17635 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
17636 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
17637 | } else { | |
17638 | if (flag_scomm) | |
17639 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
17640 | if (flag_secomm) | |
17641 | vty_out(vty, | |
17642 | " no neighbor %s send-community extended\n", | |
17643 | addr); | |
17644 | ||
17645 | if (flag_slcomm) | |
17646 | vty_out(vty, " no neighbor %s send-community large\n", | |
17647 | addr); | |
17648 | } | |
17649 | ||
17650 | /* Default information */ | |
17651 | if (peergroup_af_flag_check(peer, afi, safi, | |
17652 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
17653 | vty_out(vty, " neighbor %s default-originate", addr); | |
17654 | ||
17655 | if (peer->default_rmap[afi][safi].name) | |
17656 | vty_out(vty, " route-map %s", | |
17657 | peer->default_rmap[afi][safi].name); | |
17658 | ||
17659 | vty_out(vty, "\n"); | |
17660 | } | |
17661 | ||
17662 | /* Soft reconfiguration inbound. */ | |
17663 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
17664 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
17665 | addr); | |
17666 | } | |
17667 | ||
17668 | /* maximum-prefix. */ | |
17669 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 17670 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
17671 | peer->pmax[afi][safi]); |
17672 | ||
17673 | if (peer->pmax_threshold[afi][safi] | |
17674 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
17675 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
17676 | if (peer_af_flag_check(peer, afi, safi, | |
17677 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
17678 | vty_out(vty, " warning-only"); | |
17679 | if (peer->pmax_restart[afi][safi]) | |
17680 | vty_out(vty, " restart %u", | |
17681 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
17682 | if (peer_af_flag_check(peer, afi, safi, |
17683 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
17684 | vty_out(vty, " force"); | |
dd65f45e DL |
17685 | |
17686 | vty_out(vty, "\n"); | |
17687 | } | |
17688 | ||
fde246e8 DA |
17689 | /* maximum-prefix-out */ |
17690 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 17691 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
17692 | addr, peer->pmax_out[afi][safi]); |
17693 | ||
dd65f45e DL |
17694 | /* Route server client. */ |
17695 | if (peergroup_af_flag_check(peer, afi, safi, | |
17696 | PEER_FLAG_RSERVER_CLIENT)) { | |
17697 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
17698 | } | |
17699 | ||
17700 | /* Nexthop-local unchanged. */ | |
17701 | if (peergroup_af_flag_check(peer, afi, safi, | |
17702 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
17703 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17704 | } | |
17705 | ||
17706 | /* allowas-in <1-10> */ | |
17707 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17708 | if (peer_af_flag_check(peer, afi, safi, | |
17709 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17710 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17711 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17712 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17713 | } else { | |
17714 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17715 | peer->allowas_in[afi][safi]); | |
17716 | } | |
17717 | } | |
17718 | ||
17719 | /* weight */ | |
17720 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17721 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17722 | peer->weight[afi][safi]); | |
17723 | ||
17724 | /* Filter. */ | |
17725 | bgp_config_write_filter(vty, peer, afi, safi); | |
17726 | ||
17727 | /* atribute-unchanged. */ | |
17728 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17729 | || (safi != SAFI_EVPN | |
17730 | && peer_af_flag_check(peer, afi, safi, | |
17731 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17732 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17733 | ||
17734 | if (!peer_group_active(peer) | |
17735 | || peergroup_af_flag_check(peer, afi, safi, | |
17736 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17737 | || peergroup_af_flag_check(peer, afi, safi, | |
17738 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17739 | || peergroup_af_flag_check(peer, afi, safi, | |
17740 | PEER_FLAG_MED_UNCHANGED)) { | |
17741 | ||
17742 | vty_out(vty, | |
17743 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17744 | addr, | |
17745 | peer_af_flag_check(peer, afi, safi, | |
17746 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17747 | ? " as-path" | |
17748 | : "", | |
17749 | peer_af_flag_check(peer, afi, safi, | |
17750 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17751 | ? " next-hop" | |
17752 | : "", | |
17753 | peer_af_flag_check(peer, afi, safi, | |
17754 | PEER_FLAG_MED_UNCHANGED) | |
17755 | ? " med" | |
17756 | : ""); | |
17757 | } | |
17758 | } | |
39d8dd2d DS |
17759 | |
17760 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_CONFIG_DAMPENING)) | |
17761 | bgp_config_write_peer_damp(vty, peer, afi, safi); | |
dd65f45e DL |
17762 | } |
17763 | ||
17764 | /* Address family based peer configuration display. */ | |
17765 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17766 | safi_t safi) | |
17767 | { | |
17768 | struct peer *peer; | |
17769 | struct peer_group *group; | |
17770 | struct listnode *node, *nnode; | |
17771 | ||
17772 | ||
17773 | vty_frame(vty, " !\n address-family "); | |
17774 | if (afi == AFI_IP) { | |
17775 | if (safi == SAFI_UNICAST) | |
17776 | vty_frame(vty, "ipv4 unicast"); | |
17777 | else if (safi == SAFI_LABELED_UNICAST) | |
17778 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17779 | else if (safi == SAFI_MULTICAST) | |
17780 | vty_frame(vty, "ipv4 multicast"); | |
17781 | else if (safi == SAFI_MPLS_VPN) | |
17782 | vty_frame(vty, "ipv4 vpn"); | |
17783 | else if (safi == SAFI_ENCAP) | |
17784 | vty_frame(vty, "ipv4 encap"); | |
17785 | else if (safi == SAFI_FLOWSPEC) | |
17786 | vty_frame(vty, "ipv4 flowspec"); | |
17787 | } else if (afi == AFI_IP6) { | |
17788 | if (safi == SAFI_UNICAST) | |
17789 | vty_frame(vty, "ipv6 unicast"); | |
17790 | else if (safi == SAFI_LABELED_UNICAST) | |
17791 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17792 | else if (safi == SAFI_MULTICAST) | |
17793 | vty_frame(vty, "ipv6 multicast"); | |
17794 | else if (safi == SAFI_MPLS_VPN) | |
17795 | vty_frame(vty, "ipv6 vpn"); | |
17796 | else if (safi == SAFI_ENCAP) | |
17797 | vty_frame(vty, "ipv6 encap"); | |
17798 | else if (safi == SAFI_FLOWSPEC) | |
17799 | vty_frame(vty, "ipv6 flowspec"); | |
17800 | } else if (afi == AFI_L2VPN) { | |
17801 | if (safi == SAFI_EVPN) | |
17802 | vty_frame(vty, "l2vpn evpn"); | |
17803 | } | |
17804 | vty_frame(vty, "\n"); | |
17805 | ||
17806 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17807 | ||
17808 | bgp_config_write_network(vty, bgp, afi, safi); | |
17809 | ||
17810 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17811 | ||
8a4e7fe6 DA |
17812 | /* BGP flag dampening. */ |
17813 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
0221327c | 17814 | bgp_config_write_damp(vty, bgp, afi, safi); |
8a4e7fe6 | 17815 | |
dd65f45e DL |
17816 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17817 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17818 | ||
17819 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17820 | /* Do not display doppelganger peers */ |
17821 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17822 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17823 | } | |
17824 | ||
17825 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17826 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17827 | ||
17828 | if (safi == SAFI_EVPN) | |
17829 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17830 | ||
17831 | if (safi == SAFI_FLOWSPEC) | |
17832 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17833 | ||
17834 | if (safi == SAFI_UNICAST) { | |
17835 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17836 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17837 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17838 | ||
17839 | vty_out(vty, " export vpn\n"); | |
17840 | } | |
17841 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17842 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17843 | ||
17844 | vty_out(vty, " import vpn\n"); | |
17845 | } | |
17846 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17847 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17848 | char *name; | |
17849 | ||
17850 | for (ALL_LIST_ELEMENTS_RO( | |
17851 | bgp->vpn_policy[afi].import_vrf, node, | |
17852 | name)) | |
17853 | vty_out(vty, " import vrf %s\n", name); | |
17854 | } | |
17855 | } | |
17856 | ||
17857 | vty_endframe(vty, " exit-address-family\n"); | |
17858 | } | |
17859 | ||
17860 | int bgp_config_write(struct vty *vty) | |
17861 | { | |
17862 | struct bgp *bgp; | |
17863 | struct peer_group *group; | |
17864 | struct peer *peer; | |
17865 | struct listnode *node, *nnode; | |
17866 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17867 | afi_t afi; |
17868 | safi_t safi; | |
dd65f45e DL |
17869 | |
17870 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17871 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17872 | bm->rmap_update_timer); | |
17873 | ||
d70583f7 D |
17874 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17875 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17876 | if (bm->v_update_delay != bm->v_establish_wait) | |
17877 | vty_out(vty, " %d", bm->v_establish_wait); | |
17878 | vty_out(vty, "\n"); | |
17879 | } | |
17880 | ||
9acb67cb DS |
17881 | if (bm->wait_for_fib) |
17882 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17883 | ||
05bd726c | 17884 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17885 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17886 | ||
c163f297 DS |
17887 | /* No-RIB (Zebra) option flag configuration */ |
17888 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17889 | vty_out(vty, "bgp no-rib\n"); | |
17890 | ||
ec0acb80 | 17891 | if (!CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
e46723a5 DS |
17892 | vty_out(vty, "no bgp send-extra-data zebra\n"); |
17893 | ||
dd65f45e DL |
17894 | /* BGP configuration. */ |
17895 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17896 | ||
17897 | /* skip all auto created vrf as they dont have user config */ | |
17898 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17899 | continue; | |
17900 | ||
17901 | /* Router bgp ASN */ | |
17902 | vty_out(vty, "router bgp %u", bgp->as); | |
17903 | ||
17904 | if (bgp->name) | |
17905 | vty_out(vty, " %s %s", | |
17906 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17907 | ? "view" : "vrf", bgp->name); | |
17908 | vty_out(vty, "\n"); | |
17909 | ||
17910 | /* BGP fast-external-failover. */ | |
17911 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17912 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17913 | ||
17914 | /* BGP router ID. */ | |
3a6290bd | 17915 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17916 | vty_out(vty, " bgp router-id %pI4\n", |
17917 | &bgp->router_id_static); | |
dd65f45e | 17918 | |
c208c586 S |
17919 | /* Suppress fib pending */ |
17920 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17921 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17922 | ||
dd65f45e | 17923 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17924 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17925 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17926 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17927 | CHECK_FLAG(bgp->flags, |
17928 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17929 | ? "" |
17930 | : "no "); | |
17931 | ||
17932 | /* BGP configuration. */ | |
892fedb6 | 17933 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17934 | vty_out(vty, " bgp always-compare-med\n"); |
17935 | ||
17936 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17937 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17938 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17939 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17940 | CHECK_FLAG(bgp->flags, | |
17941 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17942 | ? "" | |
17943 | : "no "); | |
dd65f45e DL |
17944 | |
17945 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17946 | if (bgp->reject_as_sets) |
dd65f45e DL |
17947 | vty_out(vty, " bgp reject-as-sets\n"); |
17948 | ||
2adac256 DA |
17949 | /* Suppress duplicate updates if the route actually not changed |
17950 | */ | |
17951 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17952 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17953 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17954 | CHECK_FLAG(bgp->flags, | |
17955 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17956 | ? "" | |
17957 | : "no "); | |
17958 | ||
b16bcbba TA |
17959 | /* BGP default <afi>-<safi> */ |
17960 | FOREACH_AFI_SAFI (afi, safi) { | |
17961 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17962 | if (!bgp->default_af[afi][safi]) | |
17963 | vty_out(vty, " no bgp default %s\n", | |
17964 | get_bgp_default_af_flag(afi, | |
17965 | safi)); | |
17966 | } else if (bgp->default_af[afi][safi]) | |
17967 | vty_out(vty, " bgp default %s\n", | |
17968 | get_bgp_default_af_flag(afi, safi)); | |
17969 | } | |
e84c59af | 17970 | |
dd65f45e DL |
17971 | /* BGP default local-preference. */ |
17972 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17973 | vty_out(vty, " bgp default local-preference %u\n", | |
17974 | bgp->default_local_pref); | |
17975 | ||
17976 | /* BGP default show-hostname */ | |
892fedb6 | 17977 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17978 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17979 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17980 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17981 | ? "" |
17982 | : "no "); | |
17983 | ||
aef999a2 DA |
17984 | /* BGP default show-nexthop-hostname */ |
17985 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17986 | != SAVE_BGP_SHOW_HOSTNAME) | |
17987 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17988 | CHECK_FLAG(bgp->flags, | |
17989 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17990 | ? "" | |
17991 | : "no "); | |
17992 | ||
dd65f45e DL |
17993 | /* BGP default subgroup-pkt-queue-max. */ |
17994 | if (bgp->default_subgroup_pkt_queue_max | |
17995 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17996 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17997 | bgp->default_subgroup_pkt_queue_max); | |
17998 | ||
17999 | /* BGP client-to-client reflection. */ | |
892fedb6 | 18000 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
18001 | vty_out(vty, " no bgp client-to-client reflection\n"); |
18002 | ||
18003 | /* BGP cluster ID. */ | |
18004 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
18005 | vty_out(vty, " bgp cluster-id %pI4\n", |
18006 | &bgp->cluster_id); | |
dd65f45e DL |
18007 | |
18008 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 18009 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
18010 | vty_out(vty, |
18011 | " bgp disable-ebgp-connected-route-check\n"); | |
18012 | ||
18013 | /* Confederation identifier*/ | |
18014 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
18015 | vty_out(vty, " bgp confederation identifier %u\n", | |
18016 | bgp->confed_id); | |
18017 | ||
18018 | /* Confederation peer */ | |
18019 | if (bgp->confed_peers_cnt > 0) { | |
18020 | int i; | |
18021 | ||
18022 | vty_out(vty, " bgp confederation peers"); | |
18023 | ||
18024 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
18025 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
18026 | ||
18027 | vty_out(vty, "\n"); | |
18028 | } | |
18029 | ||
18030 | /* BGP deterministic-med. */ | |
892fedb6 | 18031 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 18032 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 18033 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
18034 | CHECK_FLAG(bgp->flags, |
18035 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
18036 | ? "" |
18037 | : "no "); | |
18038 | ||
18039 | /* BGP update-delay. */ | |
18040 | bgp_config_write_update_delay(vty, bgp); | |
18041 | ||
18042 | if (bgp->v_maxmed_onstartup | |
18043 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
18044 | vty_out(vty, " bgp max-med on-startup %u", | |
18045 | bgp->v_maxmed_onstartup); | |
18046 | if (bgp->maxmed_onstartup_value | |
18047 | != BGP_MAXMED_VALUE_DEFAULT) | |
18048 | vty_out(vty, " %u", | |
18049 | bgp->maxmed_onstartup_value); | |
18050 | vty_out(vty, "\n"); | |
18051 | } | |
18052 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
18053 | vty_out(vty, " bgp max-med administrative"); | |
18054 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
18055 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
18056 | vty_out(vty, "\n"); | |
18057 | } | |
18058 | ||
18059 | /* write quanta */ | |
18060 | bgp_config_write_wpkt_quanta(vty, bgp); | |
18061 | /* read quanta */ | |
18062 | bgp_config_write_rpkt_quanta(vty, bgp); | |
18063 | ||
18064 | /* coalesce time */ | |
18065 | bgp_config_write_coalesce_time(vty, bgp); | |
18066 | ||
05bd726c | 18067 | /* BGP per-instance graceful-shutdown */ |
18068 | /* BGP-wide settings and per-instance settings are mutually | |
18069 | * exclusive. | |
18070 | */ | |
18071 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
18072 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
18073 | vty_out(vty, " bgp graceful-shutdown\n"); | |
18074 | ||
dd65f45e DL |
18075 | /* BGP graceful-restart. */ |
18076 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
18077 | vty_out(vty, | |
18078 | " bgp graceful-restart stalepath-time %u\n", | |
18079 | bgp->stalepath_time); | |
cfd47646 | 18080 | |
dd65f45e DL |
18081 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
18082 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
18083 | bgp->restart_time); | |
cfd47646 | 18084 | |
18085 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
18086 | vty_out(vty, | |
18087 | " bgp graceful-restart select-defer-time %u\n", | |
18088 | bgp->select_defer_time); | |
18089 | ||
18090 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
18091 | vty_out(vty, " bgp graceful-restart\n"); |
18092 | ||
cfd47646 | 18093 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
18094 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
18095 | ||
dd65f45e | 18096 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 18097 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
18098 | vty_out(vty, |
18099 | " bgp graceful-restart preserve-fw-state\n"); | |
18100 | ||
dc95985f | 18101 | /* Stale timer for RIB */ |
18102 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
18103 | vty_out(vty, | |
18104 | " bgp graceful-restart rib-stale-time %u\n", | |
18105 | bgp->rib_stale_time); | |
18106 | ||
dd65f45e | 18107 | /* BGP bestpath method. */ |
892fedb6 | 18108 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 18109 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 18110 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
18111 | vty_out(vty, " bgp bestpath as-path confed\n"); |
18112 | ||
892fedb6 DA |
18113 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
18114 | if (CHECK_FLAG(bgp->flags, | |
18115 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
18116 | vty_out(vty, |
18117 | " bgp bestpath as-path multipath-relax as-set\n"); | |
18118 | } else { | |
18119 | vty_out(vty, | |
18120 | " bgp bestpath as-path multipath-relax\n"); | |
18121 | } | |
18122 | } | |
18123 | ||
892fedb6 | 18124 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
18125 | vty_out(vty, |
18126 | " bgp route-reflector allow-outbound-policy\n"); | |
18127 | } | |
892fedb6 | 18128 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 18129 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
18130 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
18131 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 18132 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 18133 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 18134 | vty_out(vty, " confed"); |
892fedb6 DA |
18135 | if (CHECK_FLAG(bgp->flags, |
18136 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
18137 | vty_out(vty, " missing-as-worst"); |
18138 | vty_out(vty, "\n"); | |
18139 | } | |
18140 | ||
ee88563a JM |
18141 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
18142 | vty_out(vty, | |
18143 | " bgp bestpath peer-type multipath-relax\n"); | |
18144 | ||
f7e1c681 | 18145 | /* Link bandwidth handling. */ |
18146 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
18147 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
18148 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
18149 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
18150 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
18151 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
18152 | ||
dd65f45e | 18153 | /* BGP network import check. */ |
892fedb6 | 18154 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 18155 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 18156 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 18157 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
18158 | ? "" |
18159 | : "no "); | |
18160 | ||
18161 | /* BGP timers configuration. */ | |
5d5393b9 | 18162 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 18163 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
18164 | vty_out(vty, " timers bgp %u %u\n", |
18165 | bgp->default_keepalive, bgp->default_holdtime); | |
18166 | ||
389e4f92 QY |
18167 | /* Conditional advertisement timer configuration */ |
18168 | if (bgp->condition_check_period | |
18169 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
18170 | vty_out(vty, | |
18171 | " bgp conditional-advertisement timer %u\n", | |
18172 | bgp->condition_check_period); | |
18173 | ||
dd65f45e DL |
18174 | /* peer-group */ |
18175 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
18176 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
18177 | } | |
18178 | ||
18179 | /* Normal neighbor configuration. */ | |
18180 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
18181 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
18182 | bgp_config_write_peer_global(vty, bgp, peer); | |
18183 | } | |
18184 | ||
18185 | /* listen range and limit for dynamic BGP neighbors */ | |
18186 | bgp_config_write_listen(vty, bgp); | |
18187 | ||
18188 | /* | |
18189 | * BGP default autoshutdown neighbors | |
18190 | * | |
18191 | * This must be placed after any peer and peer-group | |
18192 | * configuration, to avoid setting all peers to shutdown after | |
18193 | * a daemon restart, which is undesired behavior. (see #2286) | |
18194 | */ | |
18195 | if (bgp->autoshutdown) | |
18196 | vty_out(vty, " bgp default shutdown\n"); | |
18197 | ||
9cf59432 DS |
18198 | /* BGP instance administrative shutdown */ |
18199 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
18200 | vty_out(vty, " bgp shutdown\n"); | |
18201 | ||
a0281b2e HS |
18202 | if (bgp->srv6_enabled) { |
18203 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 18204 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
18205 | vty_out(vty, " locator %s\n", |
18206 | bgp->srv6_locator_name); | |
18207 | } | |
18208 | ||
18209 | ||
dd65f45e DL |
18210 | /* IPv4 unicast configuration. */ |
18211 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
18212 | ||
18213 | /* IPv4 multicast configuration. */ | |
18214 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
18215 | ||
18216 | /* IPv4 labeled-unicast configuration. */ | |
18217 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
18218 | ||
18219 | /* IPv4 VPN configuration. */ | |
18220 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
18221 | ||
18222 | /* ENCAPv4 configuration. */ | |
18223 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
18224 | ||
18225 | /* FLOWSPEC v4 configuration. */ | |
18226 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
18227 | ||
18228 | /* IPv6 unicast configuration. */ | |
18229 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
18230 | ||
18231 | /* IPv6 multicast configuration. */ | |
18232 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
18233 | ||
18234 | /* IPv6 labeled-unicast configuration. */ | |
18235 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
18236 | SAFI_LABELED_UNICAST); | |
18237 | ||
18238 | /* IPv6 VPN configuration. */ | |
18239 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
18240 | ||
18241 | /* ENCAPv6 configuration. */ | |
18242 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
18243 | ||
18244 | /* FLOWSPEC v6 configuration. */ | |
18245 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
18246 | ||
18247 | /* EVPN configuration. */ | |
18248 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
18249 | ||
18250 | hook_call(bgp_inst_config_write, bgp, vty); | |
18251 | ||
49e5a4a0 | 18252 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
18253 | bgp_rfapi_cfg_write(vty, bgp); |
18254 | #endif | |
18255 | ||
18256 | vty_out(vty, "!\n"); | |
18257 | } | |
18258 | return 0; | |
18259 | } | |
18260 | ||
ddb5b488 | 18261 | |
718e3744 | 18262 | /* BGP node structure. */ |
d62a17ae | 18263 | static struct cmd_node bgp_node = { |
f4b8291f | 18264 | .name = "bgp", |
62b346ee | 18265 | .node = BGP_NODE, |
24389580 | 18266 | .parent_node = CONFIG_NODE, |
62b346ee | 18267 | .prompt = "%s(config-router)# ", |
612c2c15 | 18268 | .config_write = bgp_config_write, |
718e3744 | 18269 | }; |
18270 | ||
d62a17ae | 18271 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 18272 | .name = "bgp ipv4 unicast", |
62b346ee | 18273 | .node = BGP_IPV4_NODE, |
24389580 | 18274 | .parent_node = BGP_NODE, |
62b346ee | 18275 | .prompt = "%s(config-router-af)# ", |
718e3744 | 18276 | }; |
18277 | ||
d62a17ae | 18278 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 18279 | .name = "bgp ipv4 multicast", |
62b346ee | 18280 | .node = BGP_IPV4M_NODE, |
24389580 | 18281 | .parent_node = BGP_NODE, |
62b346ee | 18282 | .prompt = "%s(config-router-af)# ", |
718e3744 | 18283 | }; |
18284 | ||
d62a17ae | 18285 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 18286 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 18287 | .node = BGP_IPV4L_NODE, |
24389580 | 18288 | .parent_node = BGP_NODE, |
62b346ee | 18289 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
18290 | }; |
18291 | ||
d62a17ae | 18292 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 18293 | .name = "bgp ipv6", |
62b346ee | 18294 | .node = BGP_IPV6_NODE, |
24389580 | 18295 | .parent_node = BGP_NODE, |
62b346ee | 18296 | .prompt = "%s(config-router-af)# ", |
718e3744 | 18297 | }; |
18298 | ||
d62a17ae | 18299 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 18300 | .name = "bgp ipv6 multicast", |
62b346ee | 18301 | .node = BGP_IPV6M_NODE, |
24389580 | 18302 | .parent_node = BGP_NODE, |
62b346ee | 18303 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 18304 | }; |
18305 | ||
d62a17ae | 18306 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 18307 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 18308 | .node = BGP_IPV6L_NODE, |
24389580 | 18309 | .parent_node = BGP_NODE, |
62b346ee | 18310 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
18311 | }; |
18312 | ||
62b346ee | 18313 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 18314 | .name = "bgp vpnv4", |
62b346ee | 18315 | .node = BGP_VPNV4_NODE, |
24389580 | 18316 | .parent_node = BGP_NODE, |
62b346ee | 18317 | .prompt = "%s(config-router-af)# ", |
62b346ee | 18318 | }; |
6b0655a2 | 18319 | |
62b346ee | 18320 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 18321 | .name = "bgp vpnv6", |
62b346ee | 18322 | .node = BGP_VPNV6_NODE, |
24389580 | 18323 | .parent_node = BGP_NODE, |
62b346ee | 18324 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 18325 | }; |
8ecd3266 | 18326 | |
62b346ee | 18327 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 18328 | .name = "bgp evpn", |
62b346ee | 18329 | .node = BGP_EVPN_NODE, |
24389580 | 18330 | .parent_node = BGP_NODE, |
62b346ee | 18331 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 18332 | }; |
4e0b7b6d | 18333 | |
62b346ee | 18334 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 18335 | .name = "bgp evpn vni", |
62b346ee | 18336 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 18337 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 18338 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 18339 | }; |
90e60aa7 | 18340 | |
62b346ee | 18341 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 18342 | .name = "bgp ipv4 flowspec", |
62b346ee | 18343 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 18344 | .parent_node = BGP_NODE, |
62b346ee | 18345 | .prompt = "%s(config-router-af)# ", |
62b346ee | 18346 | }; |
7c40bf39 | 18347 | |
62b346ee | 18348 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 18349 | .name = "bgp ipv6 flowspec", |
62b346ee | 18350 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 18351 | .parent_node = BGP_NODE, |
62b346ee | 18352 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 18353 | }; |
7c40bf39 | 18354 | |
bfaab44d HS |
18355 | static struct cmd_node bgp_srv6_node = { |
18356 | .name = "bgp srv6", | |
18357 | .node = BGP_SRV6_NODE, | |
18358 | .parent_node = BGP_NODE, | |
18359 | .prompt = "%s(config-router-srv6)# ", | |
18360 | }; | |
18361 | ||
d62a17ae | 18362 | static void community_list_vty(void); |
1f8ae70b | 18363 | |
d62a17ae | 18364 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 18365 | { |
d62a17ae | 18366 | struct bgp *bgp; |
18367 | struct peer *peer; | |
d62a17ae | 18368 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 18369 | |
d62a17ae | 18370 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
18371 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
18372 | /* only provide suggestions on the appropriate input | |
18373 | * token type, | |
18374 | * they'll otherwise show up multiple times */ | |
18375 | enum cmd_token_type match_type; | |
18376 | char *name = peer->host; | |
d48ed3e0 | 18377 | |
d62a17ae | 18378 | if (peer->conf_if) { |
18379 | match_type = VARIABLE_TKN; | |
18380 | name = peer->conf_if; | |
18381 | } else if (strchr(peer->host, ':')) | |
18382 | match_type = IPV6_TKN; | |
18383 | else | |
18384 | match_type = IPV4_TKN; | |
d48ed3e0 | 18385 | |
d62a17ae | 18386 | if (token->type != match_type) |
18387 | continue; | |
d48ed3e0 | 18388 | |
d62a17ae | 18389 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
18390 | } | |
d62a17ae | 18391 | } |
b8a815e5 DL |
18392 | } |
18393 | ||
18394 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 18395 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
18396 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 18397 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 18398 | {.completions = NULL}}; |
18399 | ||
47a306a0 DS |
18400 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
18401 | { | |
18402 | struct bgp *bgp; | |
18403 | struct peer_group *group; | |
18404 | struct listnode *lnbgp, *lnpeer; | |
18405 | ||
18406 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
18407 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
18408 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
18409 | group->name)); | |
18410 | } | |
18411 | } | |
18412 | ||
18413 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
18414 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
18415 | {.completions = NULL} }; | |
18416 | ||
d62a17ae | 18417 | void bgp_vty_init(void) |
18418 | { | |
18419 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 18420 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 18421 | |
18422 | /* Install bgp top node. */ | |
612c2c15 DL |
18423 | install_node(&bgp_node); |
18424 | install_node(&bgp_ipv4_unicast_node); | |
18425 | install_node(&bgp_ipv4_multicast_node); | |
18426 | install_node(&bgp_ipv4_labeled_unicast_node); | |
18427 | install_node(&bgp_ipv6_unicast_node); | |
18428 | install_node(&bgp_ipv6_multicast_node); | |
18429 | install_node(&bgp_ipv6_labeled_unicast_node); | |
18430 | install_node(&bgp_vpnv4_node); | |
18431 | install_node(&bgp_vpnv6_node); | |
18432 | install_node(&bgp_evpn_node); | |
18433 | install_node(&bgp_evpn_vni_node); | |
18434 | install_node(&bgp_flowspecv4_node); | |
18435 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 18436 | install_node(&bgp_srv6_node); |
d62a17ae | 18437 | |
18438 | /* Install default VTY commands to new nodes. */ | |
18439 | install_default(BGP_NODE); | |
18440 | install_default(BGP_IPV4_NODE); | |
18441 | install_default(BGP_IPV4M_NODE); | |
18442 | install_default(BGP_IPV4L_NODE); | |
18443 | install_default(BGP_IPV6_NODE); | |
18444 | install_default(BGP_IPV6M_NODE); | |
18445 | install_default(BGP_IPV6L_NODE); | |
18446 | install_default(BGP_VPNV4_NODE); | |
18447 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 18448 | install_default(BGP_FLOWSPECV4_NODE); |
18449 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 18450 | install_default(BGP_EVPN_NODE); |
18451 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 18452 | install_default(BGP_SRV6_NODE); |
d62a17ae | 18453 | |
8029b216 AK |
18454 | /* "bgp local-mac" hidden commands. */ |
18455 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
18456 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
18457 | ||
9acb67cb DS |
18458 | /* "bgp suppress-fib-pending" global */ |
18459 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
18460 | ||
d62a17ae | 18461 | /* bgp route-map delay-timer commands. */ |
18462 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18463 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18464 | ||
d70583f7 D |
18465 | /* global bgp update-delay command */ |
18466 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
18467 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
18468 | ||
05bd726c | 18469 | /* global bgp graceful-shutdown command */ |
18470 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
18471 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
18472 | ||
d62a17ae | 18473 | /* Dummy commands (Currently not supported) */ |
18474 | install_element(BGP_NODE, &no_synchronization_cmd); | |
18475 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
18476 | ||
18477 | /* "router bgp" commands. */ | |
18478 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
18479 | ||
18480 | /* "no router bgp" commands. */ | |
18481 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
18482 | ||
18483 | /* "bgp router-id" commands. */ | |
18484 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
18485 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
18486 | ||
c208c586 S |
18487 | /* "bgp suppress-fib-pending" command */ |
18488 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
18489 | ||
d62a17ae | 18490 | /* "bgp cluster-id" commands. */ |
18491 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
18492 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
18493 | ||
c163f297 DS |
18494 | /* "bgp no-rib" commands. */ |
18495 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
18496 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
18497 | ||
e46723a5 DS |
18498 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
18499 | ||
d62a17ae | 18500 | /* "bgp confederation" commands. */ |
18501 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
18502 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
18503 | ||
18504 | /* "bgp confederation peers" commands. */ | |
18505 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
18506 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
18507 | ||
18508 | /* bgp max-med command */ | |
18509 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
18510 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
18511 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
18512 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
18513 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
18514 | ||
18515 | /* bgp disable-ebgp-connected-nh-check */ | |
18516 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
18517 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
18518 | ||
18519 | /* bgp update-delay command */ | |
18520 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
18521 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 18522 | |
18523 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 18524 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 18525 | |
18526 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
18527 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
18528 | ||
18529 | /* "maximum-paths" commands. */ | |
18530 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
18531 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
18532 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
18533 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
18534 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
18535 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
18536 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
18537 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
18538 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
18539 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
18540 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18541 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18542 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
18543 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18544 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18545 | ||
39edabac PG |
18546 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
18547 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
18548 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18549 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18550 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 18551 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
18552 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
18553 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18554 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18555 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18556 | ||
18557 | /* "timers bgp" commands. */ | |
18558 | install_element(BGP_NODE, &bgp_timers_cmd); | |
18559 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
18560 | ||
18561 | /* route-map delay-timer commands - per instance for backwards compat. | |
18562 | */ | |
18563 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18564 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18565 | ||
18566 | /* "bgp client-to-client reflection" commands */ | |
18567 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
18568 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
18569 | ||
18570 | /* "bgp always-compare-med" commands */ | |
18571 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
18572 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
18573 | ||
9dac9fc8 DA |
18574 | /* bgp ebgp-requires-policy */ |
18575 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
18576 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
18577 | ||
2adac256 DA |
18578 | /* bgp suppress-duplicates */ |
18579 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
18580 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
18581 | ||
fb29348a DA |
18582 | /* bgp reject-as-sets */ |
18583 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
18584 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
18585 | ||
d62a17ae | 18586 | /* "bgp deterministic-med" commands */ |
18587 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
18588 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
18589 | ||
055679e9 | 18590 | /* "bgp graceful-restart" command */ |
36235319 QY |
18591 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
18592 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 18593 | |
18594 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
18595 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
18596 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 18597 | |
18598 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
18599 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
18600 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 18601 | |
18602 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
18603 | install_element(BGP_NODE, | |
18604 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
18605 | install_element(BGP_NODE, | |
18606 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
18607 | ||
18608 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
18609 | install_element(BGP_NODE, | |
18610 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
18611 | install_element(BGP_NODE, | |
18612 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
18613 | ||
d62a17ae | 18614 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
18615 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
18616 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
18617 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 18618 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 18619 | install_element(BGP_NODE, |
18620 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 18621 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
18622 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
18623 | ||
d6e3c15b | 18624 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
18625 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 18626 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
18627 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 18628 | |
7f323236 DW |
18629 | /* "bgp graceful-shutdown" commands */ |
18630 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
18631 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
18632 | ||
d62a17ae | 18633 | /* "bgp fast-external-failover" commands */ |
18634 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
18635 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
18636 | ||
d62a17ae | 18637 | /* "bgp bestpath compare-routerid" commands */ |
18638 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
18639 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
18640 | ||
18641 | /* "bgp bestpath as-path ignore" commands */ | |
18642 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
18643 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
18644 | ||
18645 | /* "bgp bestpath as-path confed" commands */ | |
18646 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
18647 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
18648 | ||
18649 | /* "bgp bestpath as-path multipath-relax" commands */ | |
18650 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
18651 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
18652 | ||
ee88563a JM |
18653 | /* "bgp bestpath peer-type multipath-relax" commands */ |
18654 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
18655 | install_element(BGP_NODE, | |
18656 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
18657 | ||
d62a17ae | 18658 | /* "bgp log-neighbor-changes" commands */ |
18659 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
18660 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
18661 | ||
18662 | /* "bgp bestpath med" commands */ | |
18663 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
18664 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
18665 | ||
f7e1c681 | 18666 | /* "bgp bestpath bandwidth" commands */ |
18667 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 18668 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 18669 | |
b16bcbba TA |
18670 | /* "no bgp default <afi>-<safi>" commands. */ |
18671 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 18672 | |
d62a17ae | 18673 | /* "bgp network import-check" commands. */ |
18674 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
18675 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
18676 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
18677 | ||
18678 | /* "bgp default local-preference" commands. */ | |
18679 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
18680 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
18681 | ||
18682 | /* bgp default show-hostname */ | |
18683 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
18684 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
18685 | ||
aef999a2 DA |
18686 | /* bgp default show-nexthop-hostname */ |
18687 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
18688 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
18689 | ||
d62a17ae | 18690 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
18691 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
18692 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
18693 | ||
18694 | /* bgp ibgp-allow-policy-mods command */ | |
18695 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
18696 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
18697 | ||
18698 | /* "bgp listen limit" commands. */ | |
18699 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
18700 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
18701 | ||
18702 | /* "bgp listen range" commands. */ | |
18703 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
18704 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
18705 | ||
8175f54a | 18706 | /* "bgp default shutdown" command */ |
f26845f9 | 18707 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
18708 | |
18709 | /* "bgp shutdown" commands */ | |
18710 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 18711 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 18712 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 18713 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 18714 | |
d62a17ae | 18715 | /* "neighbor remote-as" commands. */ |
18716 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
18717 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
18718 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
18719 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
18720 | install_element(BGP_NODE, | |
18721 | &neighbor_interface_v6only_config_remote_as_cmd); | |
18722 | install_element(BGP_NODE, &no_neighbor_cmd); | |
18723 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
18724 | ||
18725 | /* "neighbor peer-group" commands. */ | |
18726 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
18727 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
18728 | install_element(BGP_NODE, | |
18729 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
18730 | ||
18731 | /* "neighbor local-as" commands. */ | |
18732 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
18733 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
18734 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
18735 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
18736 | ||
18737 | /* "neighbor solo" commands. */ | |
18738 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
18739 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
18740 | ||
18741 | /* "neighbor password" commands. */ | |
18742 | install_element(BGP_NODE, &neighbor_password_cmd); | |
18743 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
18744 | ||
18745 | /* "neighbor activate" commands. */ | |
18746 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
18747 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
18748 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
18749 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
18750 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
18751 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
18752 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
18753 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
18754 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 18755 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
18756 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 18757 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
18758 | ||
18759 | /* "no neighbor activate" commands. */ | |
18760 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
18761 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
18762 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
18763 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
18764 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
18765 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
18766 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
18767 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
18768 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 18769 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
18770 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 18771 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
18772 | ||
18773 | /* "neighbor peer-group" set commands. */ | |
18774 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
18775 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18776 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18777 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18778 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18779 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18780 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18781 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18782 | install_element(BGP_FLOWSPECV4_NODE, |
18783 | &neighbor_set_peer_group_hidden_cmd); | |
18784 | install_element(BGP_FLOWSPECV6_NODE, | |
18785 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18786 | |
18787 | /* "no neighbor peer-group unset" commands. */ | |
18788 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
18789 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18790 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18791 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18792 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18793 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18794 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18795 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18796 | install_element(BGP_FLOWSPECV4_NODE, |
18797 | &no_neighbor_set_peer_group_hidden_cmd); | |
18798 | install_element(BGP_FLOWSPECV6_NODE, | |
18799 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18800 | |
18801 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18802 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18803 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18804 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18805 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18806 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18807 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18808 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18809 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18810 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18811 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18812 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18813 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18814 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18815 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18816 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18817 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18818 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18819 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 18820 | install_element(BGP_FLOWSPECV4_NODE, |
18821 | &neighbor_soft_reconfiguration_cmd); | |
18822 | install_element(BGP_FLOWSPECV4_NODE, | |
18823 | &no_neighbor_soft_reconfiguration_cmd); | |
18824 | install_element(BGP_FLOWSPECV6_NODE, | |
18825 | &neighbor_soft_reconfiguration_cmd); | |
18826 | install_element(BGP_FLOWSPECV6_NODE, | |
18827 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
18828 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
18829 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 18830 | |
18831 | /* "neighbor attribute-unchanged" commands. */ | |
18832 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18833 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18834 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18835 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18836 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18837 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18838 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18839 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18840 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18841 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18842 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18843 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18844 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18845 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18846 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18847 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18848 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18849 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18850 | ||
18851 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18852 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18853 | ||
b8ad84d2 PG |
18854 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
18855 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18856 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18857 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18858 | ||
d62a17ae | 18859 | /* "nexthop-local unchanged" commands */ |
18860 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18861 | install_element(BGP_IPV6_NODE, | |
18862 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18863 | ||
18864 | /* "neighbor next-hop-self" commands. */ | |
18865 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18866 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18867 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18868 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18869 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18870 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18871 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18872 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18873 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18874 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18875 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18876 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18877 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18878 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18879 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18880 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18881 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18882 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
18883 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
18884 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 18885 | |
18886 | /* "neighbor next-hop-self force" commands. */ | |
18887 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18888 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
18889 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18890 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18891 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
18892 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18893 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18894 | install_element(BGP_IPV4_NODE, | |
18895 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18896 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18897 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18898 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18899 | install_element(BGP_IPV4M_NODE, | |
18900 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18901 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18902 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18903 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18904 | install_element(BGP_IPV4L_NODE, | |
18905 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18906 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18907 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18908 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18909 | install_element(BGP_IPV6_NODE, | |
18910 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18911 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18912 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18913 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18914 | install_element(BGP_IPV6M_NODE, | |
18915 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18916 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18917 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18918 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18919 | install_element(BGP_IPV6L_NODE, | |
18920 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18921 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18922 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18923 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18924 | install_element(BGP_VPNV4_NODE, | |
18925 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18926 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18927 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18928 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18929 | install_element(BGP_VPNV6_NODE, | |
18930 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18931 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18932 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18933 | |
18934 | /* "neighbor as-override" commands. */ | |
18935 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18936 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18937 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18938 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18939 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18940 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18941 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18942 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18943 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18944 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18945 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18946 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18947 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18948 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18949 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18950 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18951 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18952 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18953 | ||
18954 | /* "neighbor remove-private-AS" commands. */ | |
18955 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18956 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18957 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18958 | install_element(BGP_NODE, | |
18959 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18960 | install_element(BGP_NODE, | |
18961 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18962 | install_element(BGP_NODE, | |
18963 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18964 | install_element(BGP_NODE, | |
18965 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18966 | install_element( | |
18967 | BGP_NODE, | |
18968 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18969 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18970 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18971 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18972 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18973 | install_element(BGP_IPV4_NODE, | |
18974 | &neighbor_remove_private_as_replace_as_cmd); | |
18975 | install_element(BGP_IPV4_NODE, | |
18976 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18977 | install_element(BGP_IPV4_NODE, | |
18978 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18979 | install_element(BGP_IPV4_NODE, | |
18980 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18981 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18982 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18983 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18984 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18985 | install_element(BGP_IPV4M_NODE, | |
18986 | &neighbor_remove_private_as_replace_as_cmd); | |
18987 | install_element(BGP_IPV4M_NODE, | |
18988 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18989 | install_element(BGP_IPV4M_NODE, | |
18990 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18991 | install_element(BGP_IPV4M_NODE, | |
18992 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18993 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18994 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18995 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18996 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18997 | install_element(BGP_IPV4L_NODE, | |
18998 | &neighbor_remove_private_as_replace_as_cmd); | |
18999 | install_element(BGP_IPV4L_NODE, | |
19000 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19001 | install_element(BGP_IPV4L_NODE, | |
19002 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19003 | install_element(BGP_IPV4L_NODE, | |
19004 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19005 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
19006 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19007 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19008 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19009 | install_element(BGP_IPV6_NODE, | |
19010 | &neighbor_remove_private_as_replace_as_cmd); | |
19011 | install_element(BGP_IPV6_NODE, | |
19012 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19013 | install_element(BGP_IPV6_NODE, | |
19014 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19015 | install_element(BGP_IPV6_NODE, | |
19016 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19017 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
19018 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
19019 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
19020 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19021 | install_element(BGP_IPV6M_NODE, | |
19022 | &neighbor_remove_private_as_replace_as_cmd); | |
19023 | install_element(BGP_IPV6M_NODE, | |
19024 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19025 | install_element(BGP_IPV6M_NODE, | |
19026 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19027 | install_element(BGP_IPV6M_NODE, | |
19028 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19029 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
19030 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
19031 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
19032 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19033 | install_element(BGP_IPV6L_NODE, | |
19034 | &neighbor_remove_private_as_replace_as_cmd); | |
19035 | install_element(BGP_IPV6L_NODE, | |
19036 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19037 | install_element(BGP_IPV6L_NODE, | |
19038 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19039 | install_element(BGP_IPV6L_NODE, | |
19040 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19041 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
19042 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19043 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19044 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19045 | install_element(BGP_VPNV4_NODE, | |
19046 | &neighbor_remove_private_as_replace_as_cmd); | |
19047 | install_element(BGP_VPNV4_NODE, | |
19048 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19049 | install_element(BGP_VPNV4_NODE, | |
19050 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19051 | install_element(BGP_VPNV4_NODE, | |
19052 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19053 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
19054 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19055 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19056 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19057 | install_element(BGP_VPNV6_NODE, | |
19058 | &neighbor_remove_private_as_replace_as_cmd); | |
19059 | install_element(BGP_VPNV6_NODE, | |
19060 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19061 | install_element(BGP_VPNV6_NODE, | |
19062 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19063 | install_element(BGP_VPNV6_NODE, | |
19064 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19065 | ||
19066 | /* "neighbor send-community" commands.*/ | |
19067 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
19068 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
19069 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
19070 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
19071 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
19072 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
19073 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
19074 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
19075 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
19076 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
19077 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
19078 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
19079 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
19080 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
19081 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
19082 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
19083 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
19084 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
19085 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
19086 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
19087 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
19088 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
19089 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
19090 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
19091 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
19092 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
19093 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
19094 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
19095 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
19096 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
19097 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
19098 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
19099 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
19100 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
19101 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
19102 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
19103 | ||
19104 | /* "neighbor route-reflector" commands.*/ | |
19105 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
19106 | install_element(BGP_NODE, | |
19107 | &no_neighbor_route_reflector_client_hidden_cmd); | |
19108 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
19109 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
19110 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
19111 | install_element(BGP_IPV4M_NODE, | |
19112 | &no_neighbor_route_reflector_client_cmd); | |
19113 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
19114 | install_element(BGP_IPV4L_NODE, | |
19115 | &no_neighbor_route_reflector_client_cmd); | |
19116 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
19117 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
19118 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
19119 | install_element(BGP_IPV6M_NODE, | |
19120 | &no_neighbor_route_reflector_client_cmd); | |
19121 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
19122 | install_element(BGP_IPV6L_NODE, | |
19123 | &no_neighbor_route_reflector_client_cmd); | |
19124 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
19125 | install_element(BGP_VPNV4_NODE, | |
19126 | &no_neighbor_route_reflector_client_cmd); | |
19127 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
19128 | install_element(BGP_VPNV6_NODE, | |
19129 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 19130 | install_element(BGP_FLOWSPECV4_NODE, |
19131 | &neighbor_route_reflector_client_cmd); | |
19132 | install_element(BGP_FLOWSPECV4_NODE, | |
19133 | &no_neighbor_route_reflector_client_cmd); | |
19134 | install_element(BGP_FLOWSPECV6_NODE, | |
19135 | &neighbor_route_reflector_client_cmd); | |
19136 | install_element(BGP_FLOWSPECV6_NODE, | |
19137 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 19138 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
19139 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
19140 | ||
19141 | /* "neighbor route-server" commands.*/ | |
19142 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
19143 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
19144 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
19145 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
19146 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
19147 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
19148 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
19149 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
19150 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
19151 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
19152 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
19153 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
19154 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
19155 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
19156 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
19157 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
19158 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
19159 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
19160 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
19161 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 19162 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
19163 | install_element(BGP_FLOWSPECV4_NODE, | |
19164 | &no_neighbor_route_server_client_cmd); | |
19165 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
19166 | install_element(BGP_FLOWSPECV6_NODE, | |
19167 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 19168 | |
19169 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
19170 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
19171 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
19172 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19173 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19174 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19175 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19176 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19177 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19178 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19179 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19180 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19181 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19182 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19183 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19184 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19185 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19186 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19187 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19188 | ||
19189 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
19190 | install_element(BGP_NODE, | |
19191 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19192 | install_element(BGP_NODE, | |
19193 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19194 | install_element(BGP_IPV4_NODE, | |
19195 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19196 | install_element(BGP_IPV4_NODE, | |
19197 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19198 | install_element(BGP_IPV4M_NODE, | |
19199 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19200 | install_element(BGP_IPV4M_NODE, | |
19201 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19202 | install_element(BGP_IPV4L_NODE, | |
19203 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19204 | install_element(BGP_IPV4L_NODE, | |
19205 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19206 | install_element(BGP_IPV6_NODE, | |
19207 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19208 | install_element(BGP_IPV6_NODE, | |
19209 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19210 | install_element(BGP_IPV6M_NODE, | |
19211 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19212 | install_element(BGP_IPV6M_NODE, | |
19213 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19214 | install_element(BGP_IPV6L_NODE, | |
19215 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19216 | install_element(BGP_IPV6L_NODE, | |
19217 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19218 | install_element(BGP_VPNV4_NODE, | |
19219 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19220 | install_element(BGP_VPNV4_NODE, | |
19221 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19222 | install_element(BGP_VPNV6_NODE, | |
19223 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19224 | install_element(BGP_VPNV6_NODE, | |
19225 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19226 | ||
2b31007c RZ |
19227 | /* "neighbor sender-as-path-loop-detection" commands. */ |
19228 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
19229 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
19230 | ||
d62a17ae | 19231 | /* "neighbor passive" commands. */ |
19232 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
19233 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
19234 | ||
19235 | ||
19236 | /* "neighbor shutdown" commands. */ | |
19237 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
19238 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
19239 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
19240 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
19241 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
19242 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 19243 | |
19244 | /* "neighbor capability extended-nexthop" commands.*/ | |
19245 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
19246 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
19247 | ||
19248 | /* "neighbor capability orf prefix-list" commands.*/ | |
19249 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
19250 | install_element(BGP_NODE, | |
19251 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
19252 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
19253 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19254 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19255 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19256 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19257 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19258 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
19259 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19260 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19261 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19262 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19263 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19264 | ||
19265 | /* "neighbor capability dynamic" commands.*/ | |
19266 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
19267 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
19268 | ||
19269 | /* "neighbor dont-capability-negotiate" commands. */ | |
19270 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
19271 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
19272 | ||
19273 | /* "neighbor ebgp-multihop" commands. */ | |
19274 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
19275 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
19276 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
19277 | ||
19278 | /* "neighbor disable-connected-check" commands. */ | |
19279 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
19280 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
19281 | ||
47cbc09b PM |
19282 | /* "neighbor enforce-first-as" commands. */ |
19283 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
19284 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
19285 | ||
d62a17ae | 19286 | /* "neighbor description" commands. */ |
19287 | install_element(BGP_NODE, &neighbor_description_cmd); | |
19288 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 19289 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 19290 | |
19291 | /* "neighbor update-source" commands. "*/ | |
19292 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
19293 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
19294 | ||
19295 | /* "neighbor default-originate" commands. */ | |
19296 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
19297 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
19298 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
19299 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
19300 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
19301 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
19302 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
19303 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
19304 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
19305 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
19306 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
19307 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
19308 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
19309 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
19310 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
19311 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
19312 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
19313 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
19314 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
19315 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
19316 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
19317 | ||
19318 | /* "neighbor port" commands. */ | |
19319 | install_element(BGP_NODE, &neighbor_port_cmd); | |
19320 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
19321 | ||
19322 | /* "neighbor weight" commands. */ | |
19323 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
19324 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
19325 | ||
19326 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
19327 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
19328 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
19329 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
19330 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
19331 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
19332 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
19333 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
19334 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
19335 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
19336 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
19337 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
19338 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
19339 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
19340 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
19341 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
19342 | ||
19343 | /* "neighbor override-capability" commands. */ | |
19344 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
19345 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
19346 | ||
19347 | /* "neighbor strict-capability-match" commands. */ | |
19348 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
19349 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
19350 | ||
19351 | /* "neighbor timers" commands. */ | |
19352 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
19353 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
19354 | ||
19355 | /* "neighbor timers connect" commands. */ | |
19356 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
19357 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
19358 | ||
d43114f3 DS |
19359 | /* "neighbor timers delayopen" commands. */ |
19360 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
19361 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
19362 | ||
d62a17ae | 19363 | /* "neighbor advertisement-interval" commands. */ |
19364 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
19365 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
19366 | ||
19367 | /* "neighbor interface" commands. */ | |
19368 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
19369 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
19370 | ||
19371 | /* "neighbor distribute" commands. */ | |
19372 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
19373 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
19374 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
19375 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
19376 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
19377 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
19378 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
19379 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
19380 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
19381 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
19382 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
19383 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
19384 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
19385 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
19386 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
19387 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
19388 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
19389 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
19390 | ||
19391 | /* "neighbor prefix-list" commands. */ | |
19392 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
d62a17ae | 19393 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19394 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19395 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19396 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19397 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19398 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19399 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19400 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
7c40bf39 | 19401 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
7c40bf39 | 19402 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
d62a17ae | 19403 | |
19404 | /* "neighbor filter-list" commands. */ | |
19405 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
19406 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
19407 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
19408 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
19409 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
19410 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
19411 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
19412 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
19413 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
19414 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
19415 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
19416 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
19417 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
19418 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
19419 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
19420 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
19421 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
19422 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 19423 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
19424 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
19425 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
19426 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 19427 | |
19428 | /* "neighbor route-map" commands. */ | |
d62a17ae | 19429 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19430 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19431 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19432 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19433 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19434 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19435 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19436 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
7c40bf39 | 19437 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
7c40bf39 | 19438 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
d37ba549 | 19439 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
d62a17ae | 19440 | |
19441 | /* "neighbor unsuppress-map" commands. */ | |
19442 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
19443 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
19444 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
19445 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19446 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
19447 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19448 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
19449 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19450 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
19451 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19452 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
19453 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19454 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
19455 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19456 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
19457 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19458 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
19459 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19460 | ||
7f7940e6 | 19461 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 19462 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 19463 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 19464 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19465 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19466 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19467 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19468 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19469 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19470 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19471 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19472 | |
fde246e8 DA |
19473 | /* neighbor maximum-prefix-out commands. */ |
19474 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
19475 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19476 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19477 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19478 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19479 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19480 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19481 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19482 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19483 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19484 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19485 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19486 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19487 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19488 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19489 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19490 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19491 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19492 | ||
d62a17ae | 19493 | /* "neighbor maximum-prefix" commands. */ |
19494 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
19495 | install_element(BGP_NODE, | |
19496 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
19497 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
19498 | install_element(BGP_NODE, | |
19499 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
19500 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
19501 | install_element(BGP_NODE, | |
19502 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
19503 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
19504 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
19505 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19506 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19507 | install_element(BGP_IPV4_NODE, | |
19508 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19509 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19510 | install_element(BGP_IPV4_NODE, | |
19511 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19512 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19513 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
19514 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19515 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19516 | install_element(BGP_IPV4M_NODE, | |
19517 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19518 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19519 | install_element(BGP_IPV4M_NODE, | |
19520 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19521 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19522 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
19523 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19524 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19525 | install_element(BGP_IPV4L_NODE, | |
19526 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19527 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19528 | install_element(BGP_IPV4L_NODE, | |
19529 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19530 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19531 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
19532 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19533 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19534 | install_element(BGP_IPV6_NODE, | |
19535 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19536 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19537 | install_element(BGP_IPV6_NODE, | |
19538 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19539 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19540 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
19541 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19542 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19543 | install_element(BGP_IPV6M_NODE, | |
19544 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19545 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19546 | install_element(BGP_IPV6M_NODE, | |
19547 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19548 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19549 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
19550 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19551 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19552 | install_element(BGP_IPV6L_NODE, | |
19553 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19554 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19555 | install_element(BGP_IPV6L_NODE, | |
19556 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19557 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19558 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
19559 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19560 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19561 | install_element(BGP_VPNV4_NODE, | |
19562 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19563 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19564 | install_element(BGP_VPNV4_NODE, | |
19565 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19566 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19567 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
19568 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19569 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19570 | install_element(BGP_VPNV6_NODE, | |
19571 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19572 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19573 | install_element(BGP_VPNV6_NODE, | |
19574 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19575 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19576 | ||
19577 | /* "neighbor allowas-in" */ | |
19578 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
19579 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
19580 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
19581 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
19582 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
19583 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
19584 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
19585 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
19586 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
19587 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
19588 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
19589 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
19590 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
19591 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
19592 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
19593 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
19594 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
19595 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
19596 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
19597 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
19598 | ||
0221327c DS |
19599 | /* "neighbor dampening" commands. */ |
19600 | install_element(BGP_NODE, &neighbor_damp_cmd); | |
19601 | install_element(BGP_NODE, &no_neighbor_damp_cmd); | |
19602 | install_element(BGP_IPV4_NODE, &neighbor_damp_cmd); | |
19603 | install_element(BGP_IPV4_NODE, &no_neighbor_damp_cmd); | |
19604 | install_element(BGP_IPV4M_NODE, &neighbor_damp_cmd); | |
19605 | install_element(BGP_IPV4M_NODE, &no_neighbor_damp_cmd); | |
19606 | install_element(BGP_IPV4L_NODE, &neighbor_damp_cmd); | |
19607 | install_element(BGP_IPV4L_NODE, &no_neighbor_damp_cmd); | |
19608 | install_element(BGP_IPV6_NODE, &neighbor_damp_cmd); | |
19609 | install_element(BGP_IPV6_NODE, &no_neighbor_damp_cmd); | |
19610 | install_element(BGP_IPV6M_NODE, &neighbor_damp_cmd); | |
19611 | install_element(BGP_IPV6M_NODE, &no_neighbor_damp_cmd); | |
19612 | install_element(BGP_IPV6L_NODE, &neighbor_damp_cmd); | |
19613 | install_element(BGP_IPV6L_NODE, &no_neighbor_damp_cmd); | |
19614 | install_element(VIEW_NODE, &show_ip_bgp_neighbor_damp_param_cmd); | |
19615 | ||
d62a17ae | 19616 | /* address-family commands. */ |
19617 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
19618 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 19619 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 19620 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
19621 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 19622 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 19623 | |
d62a17ae | 19624 | install_element(BGP_NODE, &address_family_evpn_cmd); |
19625 | ||
19626 | /* "exit-address-family" command. */ | |
19627 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
19628 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
19629 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
19630 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
19631 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
19632 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
19633 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
19634 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 19635 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
19636 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 19637 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
19638 | ||
19639 | /* "clear ip bgp commands" */ | |
19640 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
19641 | ||
19642 | /* clear ip bgp prefix */ | |
19643 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
19644 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
19645 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
19646 | ||
19647 | /* "show [ip] bgp summary" commands. */ | |
19648 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 19649 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 19650 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 19651 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 19652 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
19653 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 19654 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
19655 | ||
19656 | /* "show [ip] bgp neighbors" commands. */ | |
19657 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
19658 | ||
36235319 | 19659 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 19660 | |
d62a17ae | 19661 | /* "show [ip] bgp peer-group" commands. */ |
19662 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
19663 | ||
19664 | /* "show [ip] bgp paths" commands. */ | |
19665 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
19666 | ||
19667 | /* "show [ip] bgp community" commands. */ | |
19668 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
19669 | ||
19670 | /* "show ip bgp large-community" commands. */ | |
19671 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
19672 | /* "show [ip] bgp attribute-info" commands. */ | |
19673 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 19674 | /* "show [ip] bgp route-leak" command */ |
19675 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 19676 | |
19677 | /* "redistribute" commands. */ | |
19678 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
19679 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
19680 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
19681 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
19682 | install_element(BGP_NODE, | |
19683 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
19684 | install_element(BGP_NODE, | |
19685 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
19686 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19687 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19688 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
19689 | install_element(BGP_NODE, | |
19690 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
19691 | install_element(BGP_NODE, | |
19692 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
19693 | install_element(BGP_NODE, | |
19694 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
19695 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
19696 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
19697 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
19698 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
19699 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
19700 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
19701 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
19702 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
19703 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
19704 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
19705 | install_element(BGP_IPV4_NODE, | |
19706 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
19707 | install_element(BGP_IPV4_NODE, | |
19708 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
19709 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
19710 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
19711 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
19712 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
19713 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
19714 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
19715 | ||
b9c7bc5a PZ |
19716 | /* import|export vpn [route-map WORD] */ |
19717 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
19718 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 19719 | |
12a844a5 DS |
19720 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
19721 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
19722 | ||
d62a17ae | 19723 | /* ttl_security commands */ |
19724 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
19725 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
19726 | ||
19727 | /* "show [ip] bgp memory" commands. */ | |
19728 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
19729 | ||
acf71666 MK |
19730 | /* "show bgp martian next-hop" */ |
19731 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
19732 | ||
48ecf8f5 DS |
19733 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
19734 | ||
d62a17ae | 19735 | /* "show [ip] bgp views" commands. */ |
19736 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
19737 | ||
19738 | /* "show [ip] bgp vrfs" commands. */ | |
19739 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
19740 | ||
19741 | /* Community-list. */ | |
19742 | community_list_vty(); | |
ddb5b488 | 19743 | |
ed0e57e3 DA |
19744 | community_alias_vty(); |
19745 | ||
ddb5b488 | 19746 | /* vpn-policy commands */ |
b9c7bc5a PZ |
19747 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
19748 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
19749 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
19750 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
19751 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
19752 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
19753 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
19754 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
19755 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
19756 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19757 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
19758 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 19759 | |
301ad80a PG |
19760 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
19761 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
19762 | ||
b9c7bc5a PZ |
19763 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
19764 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
19765 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
19766 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
19767 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
19768 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
19769 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
19770 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19771 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
19772 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
19773 | |
19774 | /* tcp-mss command */ | |
19775 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
19776 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
19777 | |
19778 | /* srv6 commands */ | |
ea372e81 | 19779 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 19780 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
a0281b2e | 19781 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
b72c9e14 HS |
19782 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
19783 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
718e3744 | 19784 | } |
6b0655a2 | 19785 | |
718e3744 | 19786 | #include "memory.h" |
19787 | #include "bgp_regex.h" | |
19788 | #include "bgp_clist.h" | |
19789 | #include "bgp_ecommunity.h" | |
19790 | ||
19791 | /* VTY functions. */ | |
19792 | ||
19793 | /* Direction value to string conversion. */ | |
d62a17ae | 19794 | static const char *community_direct_str(int direct) |
19795 | { | |
19796 | switch (direct) { | |
19797 | case COMMUNITY_DENY: | |
19798 | return "deny"; | |
19799 | case COMMUNITY_PERMIT: | |
19800 | return "permit"; | |
19801 | default: | |
19802 | return "unknown"; | |
19803 | } | |
718e3744 | 19804 | } |
19805 | ||
19806 | /* Display error string. */ | |
d62a17ae | 19807 | static void community_list_perror(struct vty *vty, int ret) |
19808 | { | |
19809 | switch (ret) { | |
19810 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19811 | vty_out(vty, "%% Can't find community-list\n"); | |
19812 | break; | |
19813 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19814 | vty_out(vty, "%% Malformed community-list value\n"); | |
19815 | break; | |
19816 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19817 | vty_out(vty, | |
19818 | "%% Community name conflict, previously defined as standard community\n"); | |
19819 | break; | |
19820 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19821 | vty_out(vty, | |
19822 | "%% Community name conflict, previously defined as expanded community\n"); | |
19823 | break; | |
19824 | } | |
718e3744 | 19825 | } |
19826 | ||
5bf15956 DW |
19827 | /* "community-list" keyword help string. */ |
19828 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19829 | ||
7336e101 SP |
19830 | /*community-list standard */ |
19831 | DEFUN (community_list_standard, | |
19832 | bgp_community_list_standard_cmd, | |
a08032fe | 19833 | "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19834 | BGP_STR |
718e3744 | 19835 | COMMUNITY_LIST_STR |
19836 | "Community list number (standard)\n" | |
5bf15956 | 19837 | "Add an standard community-list entry\n" |
718e3744 | 19838 | "Community list name\n" |
2f8cc0e5 DA |
19839 | "Sequence number of an entry\n" |
19840 | "Sequence number\n" | |
718e3744 | 19841 | "Specify community to reject\n" |
19842 | "Specify community to accept\n" | |
19843 | COMMUNITY_VAL_STR) | |
19844 | { | |
d62a17ae | 19845 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19846 | char *seq = NULL; |
d62a17ae | 19847 | int direct = 0; |
19848 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 19849 | int idx = 0; |
7336e101 | 19850 | |
a08032fe | 19851 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19852 | if (idx) |
19853 | seq = argv[idx]->arg; | |
19854 | ||
19855 | idx = 0; | |
d62a17ae | 19856 | argv_find(argv, argc, "(1-99)", &idx); |
19857 | argv_find(argv, argc, "WORD", &idx); | |
19858 | cl_name_or_number = argv[idx]->arg; | |
19859 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19860 | : COMMUNITY_DENY; | |
19861 | argv_find(argv, argc, "AA:NN", &idx); | |
19862 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19863 | |
2f8cc0e5 DA |
19864 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19865 | direct, style); | |
42f914d4 | 19866 | |
d62a17ae | 19867 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19868 | |
d62a17ae | 19869 | if (ret < 0) { |
19870 | /* Display error string. */ | |
19871 | community_list_perror(vty, ret); | |
19872 | return CMD_WARNING_CONFIG_FAILED; | |
19873 | } | |
42f914d4 | 19874 | |
d62a17ae | 19875 | return CMD_SUCCESS; |
718e3744 | 19876 | } |
19877 | ||
7336e101 SP |
19878 | DEFUN (no_community_list_standard_all, |
19879 | no_bgp_community_list_standard_all_cmd, | |
a08032fe | 19880 | "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19881 | NO_STR |
19882 | BGP_STR | |
19883 | COMMUNITY_LIST_STR | |
19884 | "Community list number (standard)\n" | |
19885 | "Add an standard community-list entry\n" | |
19886 | "Community list name\n" | |
2f8cc0e5 DA |
19887 | "Sequence number of an entry\n" |
19888 | "Sequence number\n" | |
7336e101 SP |
19889 | "Specify community to reject\n" |
19890 | "Specify community to accept\n" | |
19891 | COMMUNITY_VAL_STR) | |
718e3744 | 19892 | { |
d62a17ae | 19893 | char *cl_name_or_number = NULL; |
174b5cb9 | 19894 | char *str = NULL; |
d62a17ae | 19895 | int direct = 0; |
19896 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19897 | char *seq = NULL; |
d62a17ae | 19898 | int idx = 0; |
7336e101 | 19899 | |
a08032fe | 19900 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19901 | if (idx) |
19902 | seq = argv[idx]->arg; | |
19903 | ||
19904 | idx = 0; | |
174b5cb9 DA |
19905 | argv_find(argv, argc, "permit", &idx); |
19906 | argv_find(argv, argc, "deny", &idx); | |
19907 | ||
19908 | if (idx) { | |
19909 | direct = argv_find(argv, argc, "permit", &idx) | |
19910 | ? COMMUNITY_PERMIT | |
19911 | : COMMUNITY_DENY; | |
19912 | ||
19913 | idx = 0; | |
19914 | argv_find(argv, argc, "AA:NN", &idx); | |
19915 | str = argv_concat(argv, argc, idx); | |
19916 | } | |
19917 | ||
19918 | idx = 0; | |
d62a17ae | 19919 | argv_find(argv, argc, "(1-99)", &idx); |
19920 | argv_find(argv, argc, "WORD", &idx); | |
19921 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19922 | |
2f8cc0e5 | 19923 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19924 | direct, style); |
42f914d4 | 19925 | |
d62a17ae | 19926 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19927 | |
d62a17ae | 19928 | if (ret < 0) { |
19929 | community_list_perror(vty, ret); | |
19930 | return CMD_WARNING_CONFIG_FAILED; | |
19931 | } | |
42f914d4 | 19932 | |
d62a17ae | 19933 | return CMD_SUCCESS; |
718e3744 | 19934 | } |
7336e101 | 19935 | |
174b5cb9 DA |
19936 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
19937 | "no bgp community-list <(1-99)|standard WORD>", | |
19938 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
19939 | "Community list number (standard)\n" | |
19940 | "Add an standard community-list entry\n" | |
19941 | "Community list name\n") | |
19942 | ||
7336e101 SP |
19943 | /*community-list expanded */ |
19944 | DEFUN (community_list_expanded_all, | |
19945 | bgp_community_list_expanded_all_cmd, | |
a08032fe | 19946 | "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19947 | BGP_STR |
19948 | COMMUNITY_LIST_STR | |
718e3744 | 19949 | "Community list number (expanded)\n" |
5bf15956 | 19950 | "Add an expanded community-list entry\n" |
718e3744 | 19951 | "Community list name\n" |
2f8cc0e5 DA |
19952 | "Sequence number of an entry\n" |
19953 | "Sequence number\n" | |
718e3744 | 19954 | "Specify community to reject\n" |
19955 | "Specify community to accept\n" | |
19956 | COMMUNITY_VAL_STR) | |
19957 | { | |
d62a17ae | 19958 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19959 | char *seq = NULL; |
d62a17ae | 19960 | int direct = 0; |
19961 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19962 | int idx = 0; |
7b9a4750 | 19963 | |
a08032fe | 19964 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19965 | if (idx) |
19966 | seq = argv[idx]->arg; | |
19967 | ||
19968 | idx = 0; | |
19969 | ||
d62a17ae | 19970 | argv_find(argv, argc, "(100-500)", &idx); |
19971 | argv_find(argv, argc, "WORD", &idx); | |
19972 | cl_name_or_number = argv[idx]->arg; | |
19973 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19974 | : COMMUNITY_DENY; | |
19975 | argv_find(argv, argc, "AA:NN", &idx); | |
19976 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19977 | |
2f8cc0e5 DA |
19978 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19979 | direct, style); | |
42f914d4 | 19980 | |
d62a17ae | 19981 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19982 | |
d62a17ae | 19983 | if (ret < 0) { |
19984 | /* Display error string. */ | |
19985 | community_list_perror(vty, ret); | |
19986 | return CMD_WARNING_CONFIG_FAILED; | |
19987 | } | |
42f914d4 | 19988 | |
d62a17ae | 19989 | return CMD_SUCCESS; |
718e3744 | 19990 | } |
19991 | ||
7336e101 SP |
19992 | DEFUN (no_community_list_expanded_all, |
19993 | no_bgp_community_list_expanded_all_cmd, | |
a08032fe | 19994 | "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19995 | NO_STR |
19996 | BGP_STR | |
19997 | COMMUNITY_LIST_STR | |
19998 | "Community list number (expanded)\n" | |
19999 | "Add an expanded community-list entry\n" | |
20000 | "Community list name\n" | |
2f8cc0e5 DA |
20001 | "Sequence number of an entry\n" |
20002 | "Sequence number\n" | |
7336e101 SP |
20003 | "Specify community to reject\n" |
20004 | "Specify community to accept\n" | |
20005 | COMMUNITY_VAL_STR) | |
718e3744 | 20006 | { |
d62a17ae | 20007 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20008 | char *seq = NULL; |
174b5cb9 | 20009 | char *str = NULL; |
d62a17ae | 20010 | int direct = 0; |
20011 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20012 | int idx = 0; |
174b5cb9 | 20013 | |
a08032fe | 20014 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
20015 | if (idx) |
20016 | seq = argv[idx]->arg; | |
20017 | ||
20018 | idx = 0; | |
174b5cb9 DA |
20019 | argv_find(argv, argc, "permit", &idx); |
20020 | argv_find(argv, argc, "deny", &idx); | |
20021 | ||
20022 | if (idx) { | |
20023 | direct = argv_find(argv, argc, "permit", &idx) | |
20024 | ? COMMUNITY_PERMIT | |
20025 | : COMMUNITY_DENY; | |
20026 | ||
20027 | idx = 0; | |
20028 | argv_find(argv, argc, "AA:NN", &idx); | |
20029 | str = argv_concat(argv, argc, idx); | |
7336e101 | 20030 | } |
174b5cb9 DA |
20031 | |
20032 | idx = 0; | |
d62a17ae | 20033 | argv_find(argv, argc, "(100-500)", &idx); |
20034 | argv_find(argv, argc, "WORD", &idx); | |
20035 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 20036 | |
2f8cc0e5 | 20037 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20038 | direct, style); |
42f914d4 | 20039 | |
d62a17ae | 20040 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20041 | |
d62a17ae | 20042 | if (ret < 0) { |
20043 | community_list_perror(vty, ret); | |
20044 | return CMD_WARNING_CONFIG_FAILED; | |
20045 | } | |
42f914d4 | 20046 | |
d62a17ae | 20047 | return CMD_SUCCESS; |
718e3744 | 20048 | } |
20049 | ||
36d4bb44 EB |
20050 | ALIAS(no_community_list_expanded_all, |
20051 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 20052 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 20053 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
20054 | "Community list number (expanded)\n" |
20055 | "Add an expanded community-list entry\n" | |
20056 | "Community list name\n") | |
20057 | ||
8d9b8ed9 PM |
20058 | /* Return configuration string of community-list entry. */ |
20059 | static const char *community_list_config_str(struct community_entry *entry) | |
20060 | { | |
20061 | const char *str; | |
20062 | ||
20063 | if (entry->any) | |
20064 | str = ""; | |
20065 | else { | |
20066 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
20067 | str = community_str(entry->u.com, false); | |
20068 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
20069 | str = lcommunity_str(entry->u.lcom, false); | |
20070 | else | |
20071 | str = entry->config; | |
20072 | } | |
20073 | return str; | |
20074 | } | |
20075 | ||
d62a17ae | 20076 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20077 | { |
d62a17ae | 20078 | struct community_entry *entry; |
718e3744 | 20079 | |
d62a17ae | 20080 | for (entry = list->head; entry; entry = entry->next) { |
20081 | if (entry == list->head) { | |
20082 | if (all_digit(list->name)) | |
20083 | vty_out(vty, "Community %s list %s\n", | |
20084 | entry->style == COMMUNITY_LIST_STANDARD | |
20085 | ? "standard" | |
20086 | : "(expanded) access", | |
20087 | list->name); | |
20088 | else | |
20089 | vty_out(vty, "Named Community %s list %s\n", | |
20090 | entry->style == COMMUNITY_LIST_STANDARD | |
20091 | ? "standard" | |
20092 | : "expanded", | |
20093 | list->name); | |
20094 | } | |
20095 | if (entry->any) | |
20096 | vty_out(vty, " %s\n", | |
20097 | community_direct_str(entry->direct)); | |
20098 | else | |
20099 | vty_out(vty, " %s %s\n", | |
20100 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20101 | community_list_config_str(entry)); |
d62a17ae | 20102 | } |
718e3744 | 20103 | } |
20104 | ||
7336e101 SP |
20105 | DEFUN (show_community_list, |
20106 | show_bgp_community_list_cmd, | |
20107 | "show bgp community-list", | |
718e3744 | 20108 | SHOW_STR |
7336e101 | 20109 | BGP_STR |
718e3744 | 20110 | "List community-list\n") |
20111 | { | |
d62a17ae | 20112 | struct community_list *list; |
20113 | struct community_list_master *cm; | |
718e3744 | 20114 | |
d62a17ae | 20115 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
20116 | if (!cm) | |
20117 | return CMD_SUCCESS; | |
718e3744 | 20118 | |
d62a17ae | 20119 | for (list = cm->num.head; list; list = list->next) |
20120 | community_list_show(vty, list); | |
718e3744 | 20121 | |
d62a17ae | 20122 | for (list = cm->str.head; list; list = list->next) |
20123 | community_list_show(vty, list); | |
718e3744 | 20124 | |
d62a17ae | 20125 | return CMD_SUCCESS; |
718e3744 | 20126 | } |
20127 | ||
7336e101 SP |
20128 | DEFUN (show_community_list_arg, |
20129 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 20130 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
20131 | SHOW_STR |
20132 | BGP_STR | |
718e3744 | 20133 | "List community-list\n" |
20134 | "Community-list number\n" | |
960b69b9 | 20135 | "Community-list name\n" |
20136 | "Detailed information on community-list\n") | |
718e3744 | 20137 | { |
d62a17ae | 20138 | int idx_comm_list = 3; |
20139 | struct community_list *list; | |
718e3744 | 20140 | |
e237b0d2 | 20141 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20142 | COMMUNITY_LIST_MASTER); |
20143 | if (!list) { | |
20144 | vty_out(vty, "%% Can't find community-list\n"); | |
20145 | return CMD_WARNING; | |
20146 | } | |
718e3744 | 20147 | |
d62a17ae | 20148 | community_list_show(vty, list); |
718e3744 | 20149 | |
d62a17ae | 20150 | return CMD_SUCCESS; |
718e3744 | 20151 | } |
6b0655a2 | 20152 | |
57d187bc JS |
20153 | /* |
20154 | * Large Community code. | |
20155 | */ | |
d62a17ae | 20156 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
20157 | struct cmd_token **argv, int style, | |
20158 | int reject_all_digit_name) | |
20159 | { | |
20160 | int ret; | |
20161 | int direct; | |
20162 | char *str; | |
20163 | int idx = 0; | |
20164 | char *cl_name; | |
2f8cc0e5 DA |
20165 | char *seq = NULL; |
20166 | ||
a08032fe | 20167 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20168 | seq = argv[idx]->arg; |
d62a17ae | 20169 | |
2f8cc0e5 | 20170 | idx = 0; |
d62a17ae | 20171 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20172 | : COMMUNITY_DENY; | |
20173 | ||
20174 | /* All digit name check. */ | |
20175 | idx = 0; | |
20176 | argv_find(argv, argc, "WORD", &idx); | |
20177 | argv_find(argv, argc, "(1-99)", &idx); | |
20178 | argv_find(argv, argc, "(100-500)", &idx); | |
20179 | cl_name = argv[idx]->arg; | |
20180 | if (reject_all_digit_name && all_digit(cl_name)) { | |
20181 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
20182 | return CMD_WARNING_CONFIG_FAILED; | |
20183 | } | |
20184 | ||
20185 | idx = 0; | |
20186 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
20187 | argv_find(argv, argc, "LINE", &idx); | |
20188 | /* Concat community string argument. */ | |
20189 | if (idx) | |
20190 | str = argv_concat(argv, argc, idx); | |
20191 | else | |
20192 | str = NULL; | |
20193 | ||
2f8cc0e5 | 20194 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 20195 | |
20196 | /* Free temporary community list string allocated by | |
20197 | argv_concat(). */ | |
0a22ddfb | 20198 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20199 | |
20200 | if (ret < 0) { | |
20201 | community_list_perror(vty, ret); | |
20202 | return CMD_WARNING_CONFIG_FAILED; | |
20203 | } | |
20204 | return CMD_SUCCESS; | |
20205 | } | |
20206 | ||
20207 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
20208 | struct cmd_token **argv, int style) | |
20209 | { | |
20210 | int ret; | |
20211 | int direct = 0; | |
20212 | char *str = NULL; | |
20213 | int idx = 0; | |
2f8cc0e5 | 20214 | char *seq = NULL; |
d62a17ae | 20215 | |
a08032fe | 20216 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20217 | seq = argv[idx]->arg; |
d62a17ae | 20218 | |
2f8cc0e5 | 20219 | idx = 0; |
d62a17ae | 20220 | argv_find(argv, argc, "permit", &idx); |
20221 | argv_find(argv, argc, "deny", &idx); | |
20222 | ||
20223 | if (idx) { | |
20224 | /* Check the list direct. */ | |
20225 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
20226 | direct = COMMUNITY_PERMIT; | |
20227 | else | |
20228 | direct = COMMUNITY_DENY; | |
20229 | ||
20230 | idx = 0; | |
20231 | argv_find(argv, argc, "LINE", &idx); | |
20232 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
20233 | /* Concat community string argument. */ | |
20234 | str = argv_concat(argv, argc, idx); | |
20235 | } | |
20236 | ||
20237 | idx = 0; | |
20238 | argv_find(argv, argc, "(1-99)", &idx); | |
20239 | argv_find(argv, argc, "(100-500)", &idx); | |
20240 | argv_find(argv, argc, "WORD", &idx); | |
20241 | ||
20242 | /* Unset community list. */ | |
2f8cc0e5 | 20243 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 20244 | style); |
20245 | ||
20246 | /* Free temporary community list string allocated by | |
20247 | argv_concat(). */ | |
0a22ddfb | 20248 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20249 | |
20250 | if (ret < 0) { | |
20251 | community_list_perror(vty, ret); | |
20252 | return CMD_WARNING_CONFIG_FAILED; | |
20253 | } | |
20254 | ||
20255 | return CMD_SUCCESS; | |
57d187bc JS |
20256 | } |
20257 | ||
20258 | /* "large-community-list" keyword help string. */ | |
20259 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
20260 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
20261 | ||
7336e101 SP |
20262 | DEFUN (lcommunity_list_standard, |
20263 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20264 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20265 | BGP_STR |
20266 | LCOMMUNITY_LIST_STR | |
20267 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20268 | "Sequence number of an entry\n" |
20269 | "Sequence number\n" | |
7336e101 SP |
20270 | "Specify large community to reject\n" |
20271 | "Specify large community to accept\n" | |
20272 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20273 | { |
d62a17ae | 20274 | return lcommunity_list_set_vty(vty, argc, argv, |
20275 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
20276 | } |
20277 | ||
7336e101 SP |
20278 | DEFUN (lcommunity_list_expanded, |
20279 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20280 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20281 | BGP_STR |
20282 | LCOMMUNITY_LIST_STR | |
20283 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20284 | "Sequence number of an entry\n" |
20285 | "Sequence number\n" | |
7336e101 SP |
20286 | "Specify large community to reject\n" |
20287 | "Specify large community to accept\n" | |
20288 | "An ordered list as a regular-expression\n") | |
57d187bc | 20289 | { |
d62a17ae | 20290 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20291 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
20292 | } |
20293 | ||
7336e101 SP |
20294 | DEFUN (lcommunity_list_name_standard, |
20295 | bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 20296 | "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20297 | BGP_STR |
20298 | LCOMMUNITY_LIST_STR | |
20299 | "Specify standard large-community-list\n" | |
20300 | "Large Community list name\n" | |
2f8cc0e5 DA |
20301 | "Sequence number of an entry\n" |
20302 | "Sequence number\n" | |
7336e101 SP |
20303 | "Specify large community to reject\n" |
20304 | "Specify large community to accept\n" | |
20305 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20306 | { |
d62a17ae | 20307 | return lcommunity_list_set_vty(vty, argc, argv, |
20308 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
20309 | } |
20310 | ||
7336e101 SP |
20311 | DEFUN (lcommunity_list_name_expanded, |
20312 | bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 20313 | "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20314 | BGP_STR |
20315 | LCOMMUNITY_LIST_STR | |
20316 | "Specify expanded large-community-list\n" | |
20317 | "Large Community list name\n" | |
2f8cc0e5 DA |
20318 | "Sequence number of an entry\n" |
20319 | "Sequence number\n" | |
7336e101 SP |
20320 | "Specify large community to reject\n" |
20321 | "Specify large community to accept\n" | |
20322 | "An ordered list as a regular-expression\n") | |
57d187bc | 20323 | { |
d62a17ae | 20324 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20325 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
20326 | } |
20327 | ||
4378f57c DA |
20328 | DEFUN (no_lcommunity_list_all, |
20329 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
20330 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
20331 | NO_STR | |
20332 | BGP_STR | |
20333 | LCOMMUNITY_LIST_STR | |
20334 | "Large Community list number (standard)\n" | |
20335 | "Large Community list number (expanded)\n" | |
20336 | "Large Community list name\n") | |
57d187bc | 20337 | { |
7336e101 SP |
20338 | return lcommunity_list_unset_vty(vty, argc, argv, |
20339 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
20340 | } |
20341 | ||
4378f57c DA |
20342 | DEFUN (no_lcommunity_list_name_standard_all, |
20343 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
20344 | "no bgp large-community-list standard WORD", | |
20345 | NO_STR | |
20346 | BGP_STR | |
20347 | LCOMMUNITY_LIST_STR | |
20348 | "Specify standard large-community-list\n" | |
20349 | "Large Community list name\n") | |
20350 | { | |
20351 | return lcommunity_list_unset_vty(vty, argc, argv, | |
20352 | LARGE_COMMUNITY_LIST_STANDARD); | |
20353 | } | |
20354 | ||
7336e101 SP |
20355 | DEFUN (no_lcommunity_list_name_expanded_all, |
20356 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
20357 | "no bgp large-community-list expanded WORD", | |
20358 | NO_STR | |
20359 | BGP_STR | |
20360 | LCOMMUNITY_LIST_STR | |
20361 | "Specify expanded large-community-list\n" | |
20362 | "Large Community list name\n") | |
57d187bc | 20363 | { |
d62a17ae | 20364 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20365 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20366 | } |
20367 | ||
7336e101 SP |
20368 | DEFUN (no_lcommunity_list_standard, |
20369 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20370 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20371 | NO_STR |
20372 | BGP_STR | |
20373 | LCOMMUNITY_LIST_STR | |
20374 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20375 | "Sequence number of an entry\n" |
20376 | "Sequence number\n" | |
7336e101 SP |
20377 | "Specify large community to reject\n" |
20378 | "Specify large community to accept\n" | |
20379 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20380 | { |
d62a17ae | 20381 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20382 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20383 | } |
20384 | ||
7336e101 SP |
20385 | DEFUN (no_lcommunity_list_expanded, |
20386 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20387 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20388 | NO_STR |
20389 | BGP_STR | |
20390 | LCOMMUNITY_LIST_STR | |
20391 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20392 | "Sequence number of an entry\n" |
20393 | "Sequence number\n" | |
7336e101 SP |
20394 | "Specify large community to reject\n" |
20395 | "Specify large community to accept\n" | |
20396 | "An ordered list as a regular-expression\n") | |
57d187bc | 20397 | { |
d62a17ae | 20398 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20399 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20400 | } |
20401 | ||
7336e101 SP |
20402 | DEFUN (no_lcommunity_list_name_standard, |
20403 | no_bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 20404 | "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20405 | NO_STR |
20406 | BGP_STR | |
20407 | LCOMMUNITY_LIST_STR | |
20408 | "Specify standard large-community-list\n" | |
20409 | "Large Community list name\n" | |
2f8cc0e5 DA |
20410 | "Sequence number of an entry\n" |
20411 | "Sequence number\n" | |
7336e101 SP |
20412 | "Specify large community to reject\n" |
20413 | "Specify large community to accept\n" | |
20414 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20415 | { |
d62a17ae | 20416 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20417 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20418 | } |
20419 | ||
7336e101 SP |
20420 | DEFUN (no_lcommunity_list_name_expanded, |
20421 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 20422 | "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20423 | NO_STR |
20424 | BGP_STR | |
20425 | LCOMMUNITY_LIST_STR | |
20426 | "Specify expanded large-community-list\n" | |
20427 | "Large community list name\n" | |
2f8cc0e5 DA |
20428 | "Sequence number of an entry\n" |
20429 | "Sequence number\n" | |
7336e101 SP |
20430 | "Specify large community to reject\n" |
20431 | "Specify large community to accept\n" | |
20432 | "An ordered list as a regular-expression\n") | |
57d187bc | 20433 | { |
d62a17ae | 20434 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20435 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20436 | } |
20437 | ||
d62a17ae | 20438 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
20439 | { | |
20440 | struct community_entry *entry; | |
20441 | ||
20442 | for (entry = list->head; entry; entry = entry->next) { | |
20443 | if (entry == list->head) { | |
20444 | if (all_digit(list->name)) | |
20445 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 20446 | entry->style == |
20447 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20448 | ? "standard" |
20449 | : "(expanded) access", | |
20450 | list->name); | |
20451 | else | |
20452 | vty_out(vty, | |
20453 | "Named large community %s list %s\n", | |
169b72c8 | 20454 | entry->style == |
20455 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20456 | ? "standard" |
20457 | : "expanded", | |
20458 | list->name); | |
20459 | } | |
20460 | if (entry->any) | |
20461 | vty_out(vty, " %s\n", | |
20462 | community_direct_str(entry->direct)); | |
20463 | else | |
20464 | vty_out(vty, " %s %s\n", | |
20465 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20466 | community_list_config_str(entry)); |
d62a17ae | 20467 | } |
57d187bc JS |
20468 | } |
20469 | ||
7336e101 SP |
20470 | DEFUN (show_lcommunity_list, |
20471 | show_bgp_lcommunity_list_cmd, | |
20472 | "show bgp large-community-list", | |
57d187bc | 20473 | SHOW_STR |
7336e101 | 20474 | BGP_STR |
57d187bc JS |
20475 | "List large-community list\n") |
20476 | { | |
d62a17ae | 20477 | struct community_list *list; |
20478 | struct community_list_master *cm; | |
57d187bc | 20479 | |
d62a17ae | 20480 | cm = community_list_master_lookup(bgp_clist, |
20481 | LARGE_COMMUNITY_LIST_MASTER); | |
20482 | if (!cm) | |
20483 | return CMD_SUCCESS; | |
57d187bc | 20484 | |
d62a17ae | 20485 | for (list = cm->num.head; list; list = list->next) |
20486 | lcommunity_list_show(vty, list); | |
57d187bc | 20487 | |
d62a17ae | 20488 | for (list = cm->str.head; list; list = list->next) |
20489 | lcommunity_list_show(vty, list); | |
57d187bc | 20490 | |
d62a17ae | 20491 | return CMD_SUCCESS; |
57d187bc JS |
20492 | } |
20493 | ||
7336e101 SP |
20494 | DEFUN (show_lcommunity_list_arg, |
20495 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 20496 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
20497 | SHOW_STR |
20498 | BGP_STR | |
57d187bc | 20499 | "List large-community list\n" |
960b69b9 | 20500 | "Large-community-list number\n" |
20501 | "Large-community-list name\n" | |
20502 | "Detailed information on large-community-list\n") | |
57d187bc | 20503 | { |
d62a17ae | 20504 | struct community_list *list; |
57d187bc | 20505 | |
e237b0d2 | 20506 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 20507 | LARGE_COMMUNITY_LIST_MASTER); |
20508 | if (!list) { | |
960b69b9 | 20509 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 20510 | return CMD_WARNING; |
20511 | } | |
57d187bc | 20512 | |
d62a17ae | 20513 | lcommunity_list_show(vty, list); |
57d187bc | 20514 | |
d62a17ae | 20515 | return CMD_SUCCESS; |
57d187bc JS |
20516 | } |
20517 | ||
718e3744 | 20518 | /* "extcommunity-list" keyword help string. */ |
20519 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
20520 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
20521 | ||
7336e101 SP |
20522 | DEFUN (extcommunity_list_standard, |
20523 | bgp_extcommunity_list_standard_cmd, | |
a08032fe | 20524 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20525 | BGP_STR |
718e3744 | 20526 | EXTCOMMUNITY_LIST_STR |
20527 | "Extended Community list number (standard)\n" | |
718e3744 | 20528 | "Specify standard extcommunity-list\n" |
5bf15956 | 20529 | "Community list name\n" |
2f8cc0e5 DA |
20530 | "Sequence number of an entry\n" |
20531 | "Sequence number\n" | |
718e3744 | 20532 | "Specify community to reject\n" |
20533 | "Specify community to accept\n" | |
20534 | EXTCOMMUNITY_VAL_STR) | |
20535 | { | |
d62a17ae | 20536 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20537 | int direct = 0; | |
20538 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20539 | char *seq = NULL; |
42f914d4 | 20540 | |
d62a17ae | 20541 | int idx = 0; |
7b9a4750 | 20542 | |
d62a17ae | 20543 | argv_find(argv, argc, "(1-99)", &idx); |
20544 | argv_find(argv, argc, "WORD", &idx); | |
20545 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 20546 | |
a08032fe | 20547 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20548 | seq = argv[idx]->arg; |
20549 | ||
d62a17ae | 20550 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20551 | : COMMUNITY_DENY; | |
20552 | argv_find(argv, argc, "AA:NN", &idx); | |
20553 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20554 | |
2f8cc0e5 | 20555 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20556 | direct, style); |
42f914d4 | 20557 | |
d62a17ae | 20558 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20559 | |
d62a17ae | 20560 | if (ret < 0) { |
20561 | community_list_perror(vty, ret); | |
20562 | return CMD_WARNING_CONFIG_FAILED; | |
20563 | } | |
42f914d4 | 20564 | |
d62a17ae | 20565 | return CMD_SUCCESS; |
718e3744 | 20566 | } |
20567 | ||
7336e101 SP |
20568 | DEFUN (extcommunity_list_name_expanded, |
20569 | bgp_extcommunity_list_name_expanded_cmd, | |
a08032fe | 20570 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20571 | BGP_STR |
20572 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 20573 | "Extended Community list number (expanded)\n" |
718e3744 | 20574 | "Specify expanded extcommunity-list\n" |
20575 | "Extended Community list name\n" | |
2f8cc0e5 DA |
20576 | "Sequence number of an entry\n" |
20577 | "Sequence number\n" | |
718e3744 | 20578 | "Specify community to reject\n" |
20579 | "Specify community to accept\n" | |
20580 | "An ordered list as a regular-expression\n") | |
20581 | { | |
d62a17ae | 20582 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20583 | int direct = 0; | |
20584 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20585 | char *seq = NULL; |
d62a17ae | 20586 | int idx = 0; |
7336e101 | 20587 | |
d62a17ae | 20588 | argv_find(argv, argc, "(100-500)", &idx); |
20589 | argv_find(argv, argc, "WORD", &idx); | |
20590 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 20591 | |
a08032fe | 20592 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20593 | seq = argv[idx]->arg; |
20594 | ||
d62a17ae | 20595 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20596 | : COMMUNITY_DENY; | |
20597 | argv_find(argv, argc, "LINE", &idx); | |
20598 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20599 | |
2f8cc0e5 | 20600 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20601 | direct, style); |
42f914d4 | 20602 | |
d62a17ae | 20603 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20604 | |
d62a17ae | 20605 | if (ret < 0) { |
20606 | community_list_perror(vty, ret); | |
20607 | return CMD_WARNING_CONFIG_FAILED; | |
20608 | } | |
42f914d4 | 20609 | |
d62a17ae | 20610 | return CMD_SUCCESS; |
718e3744 | 20611 | } |
20612 | ||
7336e101 SP |
20613 | DEFUN (no_extcommunity_list_standard_all, |
20614 | no_bgp_extcommunity_list_standard_all_cmd, | |
a08032fe | 20615 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20616 | NO_STR |
20617 | BGP_STR | |
20618 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 20619 | "Extended Community list number (standard)\n" |
718e3744 | 20620 | "Specify standard extcommunity-list\n" |
5bf15956 | 20621 | "Community list name\n" |
2f8cc0e5 DA |
20622 | "Sequence number of an entry\n" |
20623 | "Sequence number\n" | |
718e3744 | 20624 | "Specify community to reject\n" |
20625 | "Specify community to accept\n" | |
20626 | EXTCOMMUNITY_VAL_STR) | |
20627 | { | |
d62a17ae | 20628 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20629 | int direct = 0; | |
20630 | char *cl_number_or_name = NULL; | |
d4455c89 | 20631 | char *str = NULL; |
2f8cc0e5 | 20632 | char *seq = NULL; |
d62a17ae | 20633 | int idx = 0; |
d4455c89 | 20634 | |
a08032fe | 20635 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20636 | seq = argv[idx]->arg; |
20637 | ||
20638 | idx = 0; | |
d4455c89 DA |
20639 | argv_find(argv, argc, "permit", &idx); |
20640 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
20641 | if (idx) { |
20642 | direct = argv_find(argv, argc, "permit", &idx) | |
20643 | ? COMMUNITY_PERMIT | |
20644 | : COMMUNITY_DENY; | |
20645 | ||
20646 | idx = 0; | |
20647 | argv_find(argv, argc, "AA:NN", &idx); | |
20648 | str = argv_concat(argv, argc, idx); | |
20649 | } | |
20650 | ||
20651 | idx = 0; | |
d62a17ae | 20652 | argv_find(argv, argc, "(1-99)", &idx); |
20653 | argv_find(argv, argc, "WORD", &idx); | |
20654 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 20655 | |
d62a17ae | 20656 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20657 | seq, direct, style); |
42f914d4 | 20658 | |
d62a17ae | 20659 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20660 | |
d62a17ae | 20661 | if (ret < 0) { |
20662 | community_list_perror(vty, ret); | |
20663 | return CMD_WARNING_CONFIG_FAILED; | |
20664 | } | |
42f914d4 | 20665 | |
d62a17ae | 20666 | return CMD_SUCCESS; |
718e3744 | 20667 | } |
20668 | ||
d4455c89 DA |
20669 | ALIAS(no_extcommunity_list_standard_all, |
20670 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
20671 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 20672 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20673 | "Extended Community list number (standard)\n" |
20674 | "Specify standard extcommunity-list\n" | |
20675 | "Community list name\n") | |
20676 | ||
7336e101 SP |
20677 | DEFUN (no_extcommunity_list_expanded_all, |
20678 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a08032fe | 20679 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20680 | NO_STR |
20681 | BGP_STR | |
20682 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 20683 | "Extended Community list number (expanded)\n" |
718e3744 | 20684 | "Specify expanded extcommunity-list\n" |
5bf15956 | 20685 | "Extended Community list name\n" |
2f8cc0e5 DA |
20686 | "Sequence number of an entry\n" |
20687 | "Sequence number\n" | |
718e3744 | 20688 | "Specify community to reject\n" |
20689 | "Specify community to accept\n" | |
20690 | "An ordered list as a regular-expression\n") | |
20691 | { | |
d62a17ae | 20692 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20693 | int direct = 0; | |
20694 | char *cl_number_or_name = NULL; | |
d4455c89 | 20695 | char *str = NULL; |
2f8cc0e5 | 20696 | char *seq = NULL; |
d62a17ae | 20697 | int idx = 0; |
d4455c89 | 20698 | |
a08032fe | 20699 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20700 | seq = argv[idx]->arg; |
20701 | ||
20702 | idx = 0; | |
d4455c89 DA |
20703 | argv_find(argv, argc, "permit", &idx); |
20704 | argv_find(argv, argc, "deny", &idx); | |
20705 | ||
20706 | if (idx) { | |
20707 | direct = argv_find(argv, argc, "permit", &idx) | |
20708 | ? COMMUNITY_PERMIT | |
20709 | : COMMUNITY_DENY; | |
20710 | ||
20711 | idx = 0; | |
20712 | argv_find(argv, argc, "LINE", &idx); | |
20713 | str = argv_concat(argv, argc, idx); | |
20714 | } | |
20715 | ||
20716 | idx = 0; | |
d62a17ae | 20717 | argv_find(argv, argc, "(100-500)", &idx); |
20718 | argv_find(argv, argc, "WORD", &idx); | |
20719 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 20720 | |
d62a17ae | 20721 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20722 | seq, direct, style); |
42f914d4 | 20723 | |
d62a17ae | 20724 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20725 | |
d62a17ae | 20726 | if (ret < 0) { |
20727 | community_list_perror(vty, ret); | |
20728 | return CMD_WARNING_CONFIG_FAILED; | |
20729 | } | |
42f914d4 | 20730 | |
d62a17ae | 20731 | return CMD_SUCCESS; |
718e3744 | 20732 | } |
20733 | ||
d4455c89 DA |
20734 | ALIAS(no_extcommunity_list_expanded_all, |
20735 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
20736 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 20737 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20738 | "Extended Community list number (expanded)\n" |
20739 | "Specify expanded extcommunity-list\n" | |
20740 | "Extended Community list name\n") | |
20741 | ||
d62a17ae | 20742 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20743 | { |
d62a17ae | 20744 | struct community_entry *entry; |
718e3744 | 20745 | |
d62a17ae | 20746 | for (entry = list->head; entry; entry = entry->next) { |
20747 | if (entry == list->head) { | |
20748 | if (all_digit(list->name)) | |
20749 | vty_out(vty, "Extended community %s list %s\n", | |
20750 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20751 | ? "standard" | |
20752 | : "(expanded) access", | |
20753 | list->name); | |
20754 | else | |
20755 | vty_out(vty, | |
20756 | "Named extended community %s list %s\n", | |
20757 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20758 | ? "standard" | |
20759 | : "expanded", | |
20760 | list->name); | |
20761 | } | |
20762 | if (entry->any) | |
20763 | vty_out(vty, " %s\n", | |
20764 | community_direct_str(entry->direct)); | |
20765 | else | |
20766 | vty_out(vty, " %s %s\n", | |
20767 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20768 | community_list_config_str(entry)); |
d62a17ae | 20769 | } |
718e3744 | 20770 | } |
20771 | ||
7336e101 SP |
20772 | DEFUN (show_extcommunity_list, |
20773 | show_bgp_extcommunity_list_cmd, | |
20774 | "show bgp extcommunity-list", | |
718e3744 | 20775 | SHOW_STR |
7336e101 | 20776 | BGP_STR |
718e3744 | 20777 | "List extended-community list\n") |
20778 | { | |
d62a17ae | 20779 | struct community_list *list; |
20780 | struct community_list_master *cm; | |
718e3744 | 20781 | |
d62a17ae | 20782 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
20783 | if (!cm) | |
20784 | return CMD_SUCCESS; | |
718e3744 | 20785 | |
d62a17ae | 20786 | for (list = cm->num.head; list; list = list->next) |
20787 | extcommunity_list_show(vty, list); | |
718e3744 | 20788 | |
d62a17ae | 20789 | for (list = cm->str.head; list; list = list->next) |
20790 | extcommunity_list_show(vty, list); | |
718e3744 | 20791 | |
d62a17ae | 20792 | return CMD_SUCCESS; |
718e3744 | 20793 | } |
20794 | ||
7336e101 SP |
20795 | DEFUN (show_extcommunity_list_arg, |
20796 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 20797 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
20798 | SHOW_STR |
20799 | BGP_STR | |
718e3744 | 20800 | "List extended-community list\n" |
20801 | "Extcommunity-list number\n" | |
960b69b9 | 20802 | "Extcommunity-list name\n" |
20803 | "Detailed information on extcommunity-list\n") | |
718e3744 | 20804 | { |
d62a17ae | 20805 | int idx_comm_list = 3; |
20806 | struct community_list *list; | |
718e3744 | 20807 | |
e237b0d2 | 20808 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20809 | EXTCOMMUNITY_LIST_MASTER); |
20810 | if (!list) { | |
20811 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20812 | return CMD_WARNING; | |
20813 | } | |
718e3744 | 20814 | |
d62a17ae | 20815 | extcommunity_list_show(vty, list); |
718e3744 | 20816 | |
d62a17ae | 20817 | return CMD_SUCCESS; |
718e3744 | 20818 | } |
6b0655a2 | 20819 | |
718e3744 | 20820 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 20821 | static int community_list_config_write(struct vty *vty) |
20822 | { | |
20823 | struct community_list *list; | |
20824 | struct community_entry *entry; | |
20825 | struct community_list_master *cm; | |
20826 | int write = 0; | |
20827 | ||
20828 | /* Community-list. */ | |
20829 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20830 | ||
20831 | for (list = cm->num.head; list; list = list->next) | |
20832 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20833 | vty_out(vty, |
20834 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20835 | list->name, entry->seq, | |
d62a17ae | 20836 | community_direct_str(entry->direct), |
20837 | community_list_config_str(entry)); | |
20838 | write++; | |
20839 | } | |
20840 | for (list = cm->str.head; list; list = list->next) | |
20841 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20842 | vty_out(vty, |
20843 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 20844 | entry->style == COMMUNITY_LIST_STANDARD |
20845 | ? "standard" | |
20846 | : "expanded", | |
2f8cc0e5 DA |
20847 | list->name, entry->seq, |
20848 | community_direct_str(entry->direct), | |
d62a17ae | 20849 | community_list_config_str(entry)); |
20850 | write++; | |
20851 | } | |
20852 | ||
20853 | /* Extcommunity-list. */ | |
20854 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20855 | ||
20856 | for (list = cm->num.head; list; list = list->next) | |
20857 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20858 | vty_out(vty, |
20859 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20860 | list->name, entry->seq, | |
20861 | community_direct_str(entry->direct), | |
d62a17ae | 20862 | community_list_config_str(entry)); |
20863 | write++; | |
20864 | } | |
20865 | for (list = cm->str.head; list; list = list->next) | |
20866 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20867 | vty_out(vty, |
6cde4b45 | 20868 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20869 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20870 | ? "standard" | |
20871 | : "expanded", | |
2f8cc0e5 DA |
20872 | list->name, entry->seq, |
20873 | community_direct_str(entry->direct), | |
d62a17ae | 20874 | community_list_config_str(entry)); |
20875 | write++; | |
20876 | } | |
20877 | ||
20878 | ||
20879 | /* lcommunity-list. */ | |
20880 | cm = community_list_master_lookup(bgp_clist, | |
20881 | LARGE_COMMUNITY_LIST_MASTER); | |
20882 | ||
20883 | for (list = cm->num.head; list; list = list->next) | |
20884 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20885 | vty_out(vty, |
6cde4b45 | 20886 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20887 | list->name, entry->seq, |
20888 | community_direct_str(entry->direct), | |
d62a17ae | 20889 | community_list_config_str(entry)); |
20890 | write++; | |
20891 | } | |
20892 | for (list = cm->str.head; list; list = list->next) | |
20893 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20894 | vty_out(vty, |
6cde4b45 | 20895 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20896 | |
d62a17ae | 20897 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20898 | ? "standard" | |
20899 | : "expanded", | |
2f8cc0e5 | 20900 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20901 | community_list_config_str(entry)); |
20902 | write++; | |
20903 | } | |
20904 | ||
20905 | return write; | |
20906 | } | |
20907 | ||
612c2c15 | 20908 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20909 | static struct cmd_node community_list_node = { |
f4b8291f | 20910 | .name = "community list", |
62b346ee DL |
20911 | .node = COMMUNITY_LIST_NODE, |
20912 | .prompt = "", | |
612c2c15 | 20913 | .config_write = community_list_config_write, |
718e3744 | 20914 | }; |
20915 | ||
d62a17ae | 20916 | static void community_list_vty(void) |
20917 | { | |
612c2c15 | 20918 | install_node(&community_list_node); |
d62a17ae | 20919 | |
20920 | /* Community-list. */ | |
7336e101 SP |
20921 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20922 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20923 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20924 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20925 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20926 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20927 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20928 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20929 | |
20930 | /* Extcommunity-list. */ | |
7336e101 SP |
20931 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20932 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20933 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20934 | install_element(CONFIG_NODE, |
20935 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20936 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20937 | install_element(CONFIG_NODE, |
20938 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20939 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20940 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20941 | |
20942 | /* Large Community List */ | |
7336e101 | 20943 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20944 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20945 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20946 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20947 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20948 | install_element(CONFIG_NODE, | |
20949 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20950 | install_element(CONFIG_NODE, |
20951 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20952 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20953 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20954 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20955 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20956 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20957 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 20958 | } |
ed0e57e3 DA |
20959 | |
20960 | static struct cmd_node community_alias_node = { | |
20961 | .name = "community alias", | |
20962 | .node = COMMUNITY_ALIAS_NODE, | |
20963 | .prompt = "", | |
20964 | .config_write = bgp_community_alias_write, | |
20965 | }; | |
20966 | ||
20967 | void community_alias_vty(void) | |
20968 | { | |
20969 | install_node(&community_alias_node); | |
20970 | ||
20971 | /* Community-list. */ | |
20972 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
20973 | } |