]>
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 | ||
5d5393b9 | 80 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
81 | { |
82 | .val_bool = false, | |
83 | .match_profile = "traditional", | |
84 | .match_version = "< 7.4", | |
85 | }, | |
86 | { .val_bool = true }, | |
67b0f40c | 87 | ); |
5d5393b9 | 88 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
89 | { .val_bool = true, .match_profile = "datacenter", }, |
90 | { .val_bool = false }, | |
67b0f40c | 91 | ); |
aef999a2 DA |
92 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
93 | { .val_bool = true, .match_profile = "datacenter", }, | |
94 | { .val_bool = false }, | |
67b0f40c | 95 | ); |
5d5393b9 | 96 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
97 | { .val_bool = true, .match_profile = "datacenter", }, |
98 | { .val_bool = false }, | |
67b0f40c | 99 | ); |
5d5393b9 | 100 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
101 | { .val_bool = true, .match_profile = "datacenter", }, |
102 | { .val_bool = false }, | |
67b0f40c | 103 | ); |
5d5393b9 DL |
104 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
105 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
106 | { .val_ulong = 120 }, | |
67b0f40c | 107 | ); |
5d5393b9 DL |
108 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
109 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
110 | { .val_ulong = 180 }, | |
67b0f40c | 111 | ); |
5d5393b9 DL |
112 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
113 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
114 | { .val_ulong = 60 }, | |
67b0f40c | 115 | ); |
1d3fdccf DA |
116 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
117 | { .val_bool = false, .match_profile = "datacenter", }, | |
118 | { .val_bool = false, .match_version = "< 7.4", }, | |
119 | { .val_bool = true }, | |
67b0f40c | 120 | ); |
2adac256 DA |
121 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
122 | { .val_bool = false, .match_version = "< 7.6", }, | |
123 | { .val_bool = true }, | |
67b0f40c | 124 | ); |
5d5393b9 | 125 | |
dd65f45e DL |
126 | DEFINE_HOOK(bgp_inst_config_write, |
127 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
128 | (bgp, vty)); |
129 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 130 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 131 | |
d62a17ae | 132 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
133 | struct prefix *range, int exact); | |
134 | ||
055679e9 | 135 | /* Show BGP peer's information. */ |
136 | enum show_type { | |
137 | show_all, | |
138 | show_peer, | |
139 | show_ipv4_all, | |
140 | show_ipv6_all, | |
141 | show_ipv4_peer, | |
142 | show_ipv6_peer | |
143 | }; | |
144 | ||
36235319 QY |
145 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
146 | struct prefix *range, int exact); | |
2986cac2 | 147 | |
36235319 QY |
148 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
149 | struct bgp *bgp, | |
150 | bool use_json, | |
151 | json_object *json); | |
2986cac2 | 152 | |
36235319 QY |
153 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
154 | enum show_type type, | |
155 | const char *ip_str, | |
156 | afi_t afi, bool use_json); | |
2986cac2 | 157 | |
d62a17ae | 158 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
159 | { | |
160 | switch (afi) { | |
161 | case AFI_IP: | |
162 | switch (safi) { | |
163 | case SAFI_UNICAST: | |
164 | return BGP_IPV4_NODE; | |
d62a17ae | 165 | case SAFI_MULTICAST: |
166 | return BGP_IPV4M_NODE; | |
d62a17ae | 167 | case SAFI_LABELED_UNICAST: |
168 | return BGP_IPV4L_NODE; | |
d62a17ae | 169 | case SAFI_MPLS_VPN: |
170 | return BGP_VPNV4_NODE; | |
7c40bf39 | 171 | case SAFI_FLOWSPEC: |
172 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
173 | default: |
174 | /* not expected */ | |
175 | return BGP_IPV4_NODE; | |
d62a17ae | 176 | } |
177 | break; | |
178 | case AFI_IP6: | |
179 | switch (safi) { | |
180 | case SAFI_UNICAST: | |
181 | return BGP_IPV6_NODE; | |
d62a17ae | 182 | case SAFI_MULTICAST: |
183 | return BGP_IPV6M_NODE; | |
d62a17ae | 184 | case SAFI_LABELED_UNICAST: |
185 | return BGP_IPV6L_NODE; | |
d62a17ae | 186 | case SAFI_MPLS_VPN: |
187 | return BGP_VPNV6_NODE; | |
7c40bf39 | 188 | case SAFI_FLOWSPEC: |
189 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
190 | default: |
191 | /* not expected */ | |
192 | return BGP_IPV4_NODE; | |
d62a17ae | 193 | } |
194 | break; | |
195 | case AFI_L2VPN: | |
196 | return BGP_EVPN_NODE; | |
b26f891d | 197 | case AFI_UNSPEC: |
d62a17ae | 198 | case AFI_MAX: |
199 | // We should never be here but to clarify the switch statement.. | |
200 | return BGP_IPV4_NODE; | |
d62a17ae | 201 | } |
202 | ||
203 | // Impossible to happen | |
204 | return BGP_IPV4_NODE; | |
f51bae9c | 205 | } |
20eb8864 | 206 | |
5cb5f4d0 DD |
207 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
208 | { | |
7d0d37de DS |
209 | if (afi == AFI_IP) { |
210 | if (safi == SAFI_UNICAST) | |
211 | return "IPv4 Unicast"; | |
212 | if (safi == SAFI_MULTICAST) | |
213 | return "IPv4 Multicast"; | |
214 | if (safi == SAFI_LABELED_UNICAST) | |
215 | return "IPv4 Labeled Unicast"; | |
216 | if (safi == SAFI_MPLS_VPN) | |
217 | return "IPv4 VPN"; | |
218 | if (safi == SAFI_ENCAP) | |
219 | return "IPv4 Encap"; | |
220 | if (safi == SAFI_FLOWSPEC) | |
221 | return "IPv4 Flowspec"; | |
222 | } else if (afi == AFI_IP6) { | |
223 | if (safi == SAFI_UNICAST) | |
224 | return "IPv6 Unicast"; | |
225 | if (safi == SAFI_MULTICAST) | |
226 | return "IPv6 Multicast"; | |
227 | if (safi == SAFI_LABELED_UNICAST) | |
228 | return "IPv6 Labeled Unicast"; | |
229 | if (safi == SAFI_MPLS_VPN) | |
230 | return "IPv6 VPN"; | |
231 | if (safi == SAFI_ENCAP) | |
232 | return "IPv6 Encap"; | |
233 | if (safi == SAFI_FLOWSPEC) | |
234 | return "IPv6 Flowspec"; | |
235 | } else if (afi == AFI_L2VPN) { | |
236 | if (safi == SAFI_EVPN) | |
237 | return "L2VPN EVPN"; | |
238 | } | |
239 | ||
240 | return "Unknown"; | |
5cb5f4d0 DD |
241 | } |
242 | ||
243 | /* | |
244 | * Please note that we have intentionally camelCased | |
245 | * the return strings here. So if you want | |
246 | * to use this function, please ensure you | |
247 | * are doing this within json output | |
248 | */ | |
249 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
250 | { | |
7d0d37de DS |
251 | if (afi == AFI_IP) { |
252 | if (safi == SAFI_UNICAST) | |
253 | return "ipv4Unicast"; | |
254 | if (safi == SAFI_MULTICAST) | |
255 | return "ipv4Multicast"; | |
256 | if (safi == SAFI_LABELED_UNICAST) | |
257 | return "ipv4LabeledUnicast"; | |
258 | if (safi == SAFI_MPLS_VPN) | |
259 | return "ipv4Vpn"; | |
260 | if (safi == SAFI_ENCAP) | |
261 | return "ipv4Encap"; | |
262 | if (safi == SAFI_FLOWSPEC) | |
263 | return "ipv4Flowspec"; | |
264 | } else if (afi == AFI_IP6) { | |
265 | if (safi == SAFI_UNICAST) | |
266 | return "ipv6Unicast"; | |
267 | if (safi == SAFI_MULTICAST) | |
268 | return "ipv6Multicast"; | |
269 | if (safi == SAFI_LABELED_UNICAST) | |
270 | return "ipv6LabeledUnicast"; | |
271 | if (safi == SAFI_MPLS_VPN) | |
272 | return "ipv6Vpn"; | |
273 | if (safi == SAFI_ENCAP) | |
274 | return "ipv6Encap"; | |
275 | if (safi == SAFI_FLOWSPEC) | |
276 | return "ipv6Flowspec"; | |
277 | } else if (afi == AFI_L2VPN) { | |
278 | if (safi == SAFI_EVPN) | |
279 | return "l2VpnEvpn"; | |
280 | } | |
281 | ||
282 | return "Unknown"; | |
5cb5f4d0 DD |
283 | } |
284 | ||
0249b8b6 HS |
285 | /* unset srv6 locator */ |
286 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
287 | { | |
288 | int ret; | |
289 | struct listnode *node, *nnode; | |
290 | struct prefix_ipv6 *chunk; | |
291 | struct bgp_srv6_function *func; | |
292 | struct bgp *bgp_vrf; | |
293 | struct in6_addr *tovpn_sid; | |
294 | ||
295 | /* release chunk notification via ZAPI */ | |
296 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
297 | bgp->srv6_locator_name); | |
298 | if (ret < 0) | |
299 | return -1; | |
300 | ||
301 | /* refresh chunks */ | |
302 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) | |
303 | listnode_delete(bgp->srv6_locator_chunks, chunk); | |
304 | ||
305 | /* refresh functions */ | |
306 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) | |
307 | listnode_delete(bgp->srv6_functions, func); | |
308 | ||
309 | /* refresh tovpn_sid */ | |
310 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
311 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
312 | continue; | |
313 | ||
314 | /* refresh vpnv4 tovpn_sid */ | |
315 | tovpn_sid = bgp_vrf->vpn_policy[AFI_IP].tovpn_sid; | |
316 | if (tovpn_sid) | |
317 | XFREE(MTYPE_BGP_SRV6_SID, | |
318 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
319 | ||
320 | /* refresh vpnv6 tovpn_sid */ | |
321 | tovpn_sid = bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid; | |
322 | if (tovpn_sid) | |
323 | XFREE(MTYPE_BGP_SRV6_SID, | |
324 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
325 | } | |
326 | ||
327 | /* update vpn bgp processes */ | |
328 | vpn_leak_postchange_all(); | |
329 | ||
330 | /* clear locator name */ | |
331 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
332 | ||
333 | return 0; | |
334 | } | |
335 | ||
718e3744 | 336 | /* Utility function to get address family from current node. */ |
d62a17ae | 337 | afi_t bgp_node_afi(struct vty *vty) |
338 | { | |
339 | afi_t afi; | |
340 | switch (vty->node) { | |
341 | case BGP_IPV6_NODE: | |
342 | case BGP_IPV6M_NODE: | |
343 | case BGP_IPV6L_NODE: | |
344 | case BGP_VPNV6_NODE: | |
7c40bf39 | 345 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 346 | afi = AFI_IP6; |
347 | break; | |
348 | case BGP_EVPN_NODE: | |
349 | afi = AFI_L2VPN; | |
350 | break; | |
351 | default: | |
352 | afi = AFI_IP; | |
353 | break; | |
354 | } | |
355 | return afi; | |
718e3744 | 356 | } |
357 | ||
358 | /* Utility function to get subsequent address family from current | |
359 | node. */ | |
d62a17ae | 360 | safi_t bgp_node_safi(struct vty *vty) |
361 | { | |
362 | safi_t safi; | |
363 | switch (vty->node) { | |
364 | case BGP_VPNV4_NODE: | |
365 | case BGP_VPNV6_NODE: | |
366 | safi = SAFI_MPLS_VPN; | |
367 | break; | |
368 | case BGP_IPV4M_NODE: | |
369 | case BGP_IPV6M_NODE: | |
370 | safi = SAFI_MULTICAST; | |
371 | break; | |
372 | case BGP_EVPN_NODE: | |
373 | safi = SAFI_EVPN; | |
374 | break; | |
375 | case BGP_IPV4L_NODE: | |
376 | case BGP_IPV6L_NODE: | |
377 | safi = SAFI_LABELED_UNICAST; | |
378 | break; | |
7c40bf39 | 379 | case BGP_FLOWSPECV4_NODE: |
380 | case BGP_FLOWSPECV6_NODE: | |
381 | safi = SAFI_FLOWSPEC; | |
382 | break; | |
d62a17ae | 383 | default: |
384 | safi = SAFI_UNICAST; | |
385 | break; | |
386 | } | |
387 | return safi; | |
718e3744 | 388 | } |
389 | ||
55f91488 QY |
390 | /** |
391 | * Converts an AFI in string form to afi_t | |
392 | * | |
393 | * @param afi string, one of | |
394 | * - "ipv4" | |
395 | * - "ipv6" | |
81cf0de5 | 396 | * - "l2vpn" |
55f91488 QY |
397 | * @return the corresponding afi_t |
398 | */ | |
d62a17ae | 399 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
400 | { | |
401 | afi_t afi = AFI_MAX; /* unknown */ | |
402 | if (strmatch(afi_str, "ipv4")) | |
403 | afi = AFI_IP; | |
404 | else if (strmatch(afi_str, "ipv6")) | |
405 | afi = AFI_IP6; | |
81cf0de5 CS |
406 | else if (strmatch(afi_str, "l2vpn")) |
407 | afi = AFI_L2VPN; | |
d62a17ae | 408 | return afi; |
409 | } | |
410 | ||
411 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
412 | afi_t *afi) | |
413 | { | |
414 | int ret = 0; | |
415 | if (argv_find(argv, argc, "ipv4", index)) { | |
416 | ret = 1; | |
417 | if (afi) | |
418 | *afi = AFI_IP; | |
419 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
420 | ret = 1; | |
421 | if (afi) | |
422 | *afi = AFI_IP6; | |
8688b3e7 DS |
423 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
424 | ret = 1; | |
425 | if (afi) | |
426 | *afi = AFI_L2VPN; | |
d62a17ae | 427 | } |
428 | return ret; | |
46f296b4 LB |
429 | } |
430 | ||
375a2e67 | 431 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 432 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
433 | { | |
434 | safi_t safi = SAFI_MAX; /* unknown */ | |
435 | if (strmatch(safi_str, "multicast")) | |
436 | safi = SAFI_MULTICAST; | |
437 | else if (strmatch(safi_str, "unicast")) | |
438 | safi = SAFI_UNICAST; | |
439 | else if (strmatch(safi_str, "vpn")) | |
440 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
441 | else if (strmatch(safi_str, "evpn")) |
442 | safi = SAFI_EVPN; | |
d62a17ae | 443 | else if (strmatch(safi_str, "labeled-unicast")) |
444 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 445 | else if (strmatch(safi_str, "flowspec")) |
446 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 447 | return safi; |
448 | } | |
449 | ||
450 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
451 | safi_t *safi) | |
452 | { | |
453 | int ret = 0; | |
454 | if (argv_find(argv, argc, "unicast", index)) { | |
455 | ret = 1; | |
456 | if (safi) | |
457 | *safi = SAFI_UNICAST; | |
458 | } else if (argv_find(argv, argc, "multicast", index)) { | |
459 | ret = 1; | |
460 | if (safi) | |
461 | *safi = SAFI_MULTICAST; | |
462 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
463 | ret = 1; | |
464 | if (safi) | |
465 | *safi = SAFI_LABELED_UNICAST; | |
466 | } else if (argv_find(argv, argc, "vpn", index)) { | |
467 | ret = 1; | |
468 | if (safi) | |
469 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
470 | } else if (argv_find(argv, argc, "evpn", index)) { |
471 | ret = 1; | |
472 | if (safi) | |
473 | *safi = SAFI_EVPN; | |
7c40bf39 | 474 | } else if (argv_find(argv, argc, "flowspec", index)) { |
475 | ret = 1; | |
476 | if (safi) | |
477 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 478 | } |
479 | return ret; | |
46f296b4 LB |
480 | } |
481 | ||
b16bcbba TA |
482 | /* |
483 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
484 | * | |
485 | * afi | |
486 | * address-family identifier | |
487 | * | |
488 | * safi | |
489 | * subsequent address-family identifier | |
490 | * | |
491 | * Returns: | |
492 | * default_af string corresponding to the supplied afi/safi pair. | |
493 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
494 | * return -1. | |
495 | */ | |
496 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
497 | { | |
498 | switch (afi) { | |
499 | case AFI_IP: | |
500 | switch (safi) { | |
501 | case SAFI_UNICAST: | |
502 | return "ipv4-unicast"; | |
503 | case SAFI_MULTICAST: | |
504 | return "ipv4-multicast"; | |
505 | case SAFI_MPLS_VPN: | |
506 | return "ipv4-vpn"; | |
507 | case SAFI_ENCAP: | |
508 | return "ipv4-encap"; | |
509 | case SAFI_LABELED_UNICAST: | |
510 | return "ipv4-labeled-unicast"; | |
511 | case SAFI_FLOWSPEC: | |
512 | return "ipv4-flowspec"; | |
513 | default: | |
514 | return "unknown-afi/safi"; | |
515 | } | |
516 | break; | |
517 | case AFI_IP6: | |
518 | switch (safi) { | |
519 | case SAFI_UNICAST: | |
520 | return "ipv6-unicast"; | |
521 | case SAFI_MULTICAST: | |
522 | return "ipv6-multicast"; | |
523 | case SAFI_MPLS_VPN: | |
524 | return "ipv6-vpn"; | |
525 | case SAFI_ENCAP: | |
526 | return "ipv6-encap"; | |
527 | case SAFI_LABELED_UNICAST: | |
528 | return "ipv6-labeled-unicast"; | |
529 | case SAFI_FLOWSPEC: | |
530 | return "ipv6-flowspec"; | |
531 | default: | |
532 | return "unknown-afi/safi"; | |
533 | } | |
534 | break; | |
535 | case AFI_L2VPN: | |
536 | switch (safi) { | |
537 | case SAFI_EVPN: | |
538 | return "l2vpn-evpn"; | |
539 | default: | |
540 | return "unknown-afi/safi"; | |
541 | } | |
542 | case AFI_UNSPEC: | |
543 | case AFI_MAX: | |
544 | return "unknown-afi/safi"; | |
545 | } | |
546 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
547 | return "unknown-afi/safi"; | |
548 | } | |
549 | ||
5d5393b9 DL |
550 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
551 | enum bgp_instance_type inst_type) | |
552 | { | |
553 | int ret = bgp_get(bgp, as, name, inst_type); | |
554 | ||
555 | if (ret == BGP_CREATED) { | |
556 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 557 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
558 | |
559 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 560 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 561 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 562 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
563 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
564 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 565 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 566 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 567 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 568 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
569 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
570 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
571 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
572 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
5d5393b9 DL |
573 | |
574 | ret = BGP_SUCCESS; | |
575 | } | |
576 | return ret; | |
577 | } | |
578 | ||
7eeee51e | 579 | /* |
f212a857 | 580 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 581 | * |
f212a857 DS |
582 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
583 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
584 | * to appropriate values for the calling function. This is to allow the |
585 | * calling function to make decisions appropriate for the show command | |
586 | * that is being parsed. | |
587 | * | |
588 | * The show commands are generally of the form: | |
d62a17ae | 589 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
590 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
591 | * |
592 | * Since we use argv_find if the show command in particular doesn't have: | |
593 | * [ip] | |
18c57037 | 594 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 595 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
596 | * The command parsing should still be ok. |
597 | * | |
598 | * vty -> The vty for the command so we can output some useful data in | |
599 | * the event of a parse error in the vrf. | |
600 | * argv -> The command tokens | |
601 | * argc -> How many command tokens we have | |
d62a17ae | 602 | * idx -> The current place in the command, generally should be 0 for this |
603 | * function | |
7eeee51e DS |
604 | * afi -> The parsed afi if it was included in the show command, returned here |
605 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 606 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 607 | * use_json -> json is configured or not |
7eeee51e DS |
608 | * |
609 | * The function returns the correct location in the parse tree for the | |
610 | * last token found. | |
0e37c258 DS |
611 | * |
612 | * Returns 0 for failure to parse correctly, else the idx position of where | |
613 | * it found the last token. | |
7eeee51e | 614 | */ |
d62a17ae | 615 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
616 | struct cmd_token **argv, int argc, | |
617 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 618 | struct bgp **bgp, bool use_json) |
d62a17ae | 619 | { |
620 | char *vrf_name = NULL; | |
621 | ||
622 | assert(afi); | |
623 | assert(safi); | |
624 | assert(bgp); | |
625 | ||
626 | if (argv_find(argv, argc, "ip", idx)) | |
627 | *afi = AFI_IP; | |
628 | ||
9a8bdf1c | 629 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 630 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
631 | else if (argv_find(argv, argc, "vrf", idx)) { |
632 | vrf_name = argv[*idx + 1]->arg; | |
633 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
634 | vrf_name = NULL; | |
635 | } | |
636 | if (vrf_name) { | |
d62a17ae | 637 | if (strmatch(vrf_name, "all")) |
638 | *bgp = NULL; | |
639 | else { | |
640 | *bgp = bgp_lookup_by_name(vrf_name); | |
641 | if (!*bgp) { | |
52e5b8c4 SP |
642 | if (use_json) { |
643 | json_object *json = NULL; | |
644 | json = json_object_new_object(); | |
645 | json_object_string_add( | |
646 | json, "warning", | |
647 | "View/Vrf is unknown"); | |
75eeda93 | 648 | vty_json(vty, json); |
52e5b8c4 | 649 | } |
ca61fd25 DS |
650 | else |
651 | vty_out(vty, "View/Vrf %s is unknown\n", | |
652 | vrf_name); | |
d62a17ae | 653 | *idx = 0; |
654 | return 0; | |
655 | } | |
656 | } | |
657 | } else { | |
658 | *bgp = bgp_get_default(); | |
659 | if (!*bgp) { | |
52e5b8c4 SP |
660 | if (use_json) { |
661 | json_object *json = NULL; | |
662 | json = json_object_new_object(); | |
663 | json_object_string_add( | |
664 | json, "warning", | |
665 | "Default BGP instance not found"); | |
75eeda93 | 666 | vty_json(vty, json); |
52e5b8c4 | 667 | } |
ca61fd25 DS |
668 | else |
669 | vty_out(vty, | |
670 | "Default BGP instance not found\n"); | |
d62a17ae | 671 | *idx = 0; |
672 | return 0; | |
673 | } | |
674 | } | |
675 | ||
676 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
677 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
678 | ||
679 | *idx += 1; | |
680 | return *idx; | |
681 | } | |
682 | ||
28c6e247 | 683 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 684 | { |
685 | struct interface *ifp = NULL; | |
686 | ||
687 | if (su->sa.sa_family == AF_INET) | |
688 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
689 | else if (su->sa.sa_family == AF_INET6) | |
690 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
691 | su->sin6.sin6_scope_id, | |
692 | bgp->vrf_id); | |
693 | ||
694 | if (ifp) | |
3dc339cd | 695 | return true; |
d62a17ae | 696 | |
3dc339cd | 697 | return false; |
718e3744 | 698 | } |
699 | ||
28c6e247 IR |
700 | /* Utility function for looking up peer from VTY. */ |
701 | /* This is used only for configuration, so disallow if attempted on | |
702 | * a dynamic neighbor. | |
703 | */ | |
704 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
705 | { | |
706 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
707 | int ret; | |
708 | union sockunion su; | |
709 | struct peer *peer; | |
710 | ||
711 | if (!bgp) { | |
712 | return NULL; | |
713 | } | |
714 | ||
715 | ret = str2sockunion(ip_str, &su); | |
716 | if (ret < 0) { | |
717 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
718 | if (!peer) { | |
719 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
720 | == NULL) { | |
721 | vty_out(vty, | |
722 | "%% Malformed address or name: %s\n", | |
723 | ip_str); | |
724 | return NULL; | |
725 | } | |
726 | } | |
727 | } else { | |
728 | peer = peer_lookup(bgp, &su); | |
729 | if (!peer) { | |
730 | vty_out(vty, | |
731 | "%% Specify remote-as or peer-group commands first\n"); | |
732 | return NULL; | |
733 | } | |
734 | if (peer_dynamic_neighbor(peer)) { | |
735 | vty_out(vty, | |
736 | "%% Operation not allowed on a dynamic neighbor\n"); | |
737 | return NULL; | |
738 | } | |
739 | } | |
740 | return peer; | |
741 | } | |
742 | ||
718e3744 | 743 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
744 | /* This is used only for configuration, so disallow if attempted on |
745 | * a dynamic neighbor. | |
746 | */ | |
d62a17ae | 747 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
748 | { | |
749 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
750 | int ret; | |
751 | union sockunion su; | |
752 | struct peer *peer = NULL; | |
753 | struct peer_group *group = NULL; | |
754 | ||
755 | if (!bgp) { | |
756 | return NULL; | |
757 | } | |
758 | ||
759 | ret = str2sockunion(peer_str, &su); | |
760 | if (ret == 0) { | |
761 | /* IP address, locate peer. */ | |
762 | peer = peer_lookup(bgp, &su); | |
763 | } else { | |
764 | /* Not IP, could match either peer configured on interface or a | |
765 | * group. */ | |
766 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
767 | if (!peer) | |
768 | group = peer_group_lookup(bgp, peer_str); | |
769 | } | |
770 | ||
771 | if (peer) { | |
772 | if (peer_dynamic_neighbor(peer)) { | |
773 | vty_out(vty, | |
774 | "%% Operation not allowed on a dynamic neighbor\n"); | |
775 | return NULL; | |
776 | } | |
777 | ||
778 | return peer; | |
779 | } | |
780 | ||
781 | if (group) | |
782 | return group->conf; | |
783 | ||
784 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
785 | ||
786 | return NULL; | |
787 | } | |
788 | ||
789 | int bgp_vty_return(struct vty *vty, int ret) | |
790 | { | |
791 | const char *str = NULL; | |
792 | ||
793 | switch (ret) { | |
794 | case BGP_ERR_INVALID_VALUE: | |
795 | str = "Invalid value"; | |
796 | break; | |
797 | case BGP_ERR_INVALID_FLAG: | |
798 | str = "Invalid flag"; | |
799 | break; | |
800 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
801 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
802 | break; | |
803 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
804 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
805 | break; | |
806 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
807 | str = "Specify remote-as or peer-group remote AS first"; | |
808 | break; | |
809 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
810 | str = "Cannot change the peer-group. Deconfigure first"; | |
811 | break; | |
812 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
813 | str = "Peer is not a member of this peer-group"; | |
814 | break; | |
815 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
816 | str = "Prefix/distribute list can not co-exist"; | |
817 | break; | |
818 | case BGP_ERR_NOT_INTERNAL_PEER: | |
819 | str = "Invalid command. Not an internal neighbor"; | |
820 | break; | |
821 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
822 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
823 | break; | |
824 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
825 | str = "Local-AS allowed only for EBGP peers"; | |
826 | break; | |
827 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
828 | str = "Cannot have local-as same as BGP AS number"; | |
829 | break; | |
830 | case BGP_ERR_TCPSIG_FAILED: | |
831 | str = "Error while applying TCP-Sig to session(s)"; | |
832 | break; | |
833 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
834 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
835 | break; | |
836 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
837 | str = "ttl-security only allowed for EBGP peers"; | |
838 | break; | |
839 | case BGP_ERR_AS_OVERRIDE: | |
840 | str = "as-override cannot be configured for IBGP peers"; | |
841 | break; | |
842 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
843 | str = "Invalid limit for number of dynamic neighbors"; | |
844 | break; | |
845 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
846 | str = "Dynamic neighbor listen range already exists"; | |
847 | break; | |
848 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
849 | str = "Operation not allowed on a dynamic neighbor"; | |
850 | break; | |
851 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
852 | str = "Operation not allowed on a directly connected neighbor"; | |
853 | break; | |
854 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 855 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 856 | break; |
857 | case BGP_ERR_GR_INVALID_CMD: | |
858 | str = "The Graceful Restart command used is not valid at this moment."; | |
859 | break; | |
860 | case BGP_ERR_GR_OPERATION_FAILED: | |
861 | str = "The Graceful Restart Operation failed due to an err."; | |
862 | break; | |
d62a17ae | 863 | } |
864 | if (str) { | |
865 | vty_out(vty, "%% %s\n", str); | |
866 | return CMD_WARNING_CONFIG_FAILED; | |
867 | } | |
868 | return CMD_SUCCESS; | |
718e3744 | 869 | } |
870 | ||
7aafcaca | 871 | /* BGP clear sort. */ |
d62a17ae | 872 | enum clear_sort { |
873 | clear_all, | |
874 | clear_peer, | |
875 | clear_group, | |
876 | clear_external, | |
877 | clear_as | |
7aafcaca DS |
878 | }; |
879 | ||
1ca2fd11 IR |
880 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
881 | safi_t safi, int error) | |
d62a17ae | 882 | { |
883 | switch (error) { | |
884 | case BGP_ERR_AF_UNCONFIGURED: | |
1ca2fd11 IR |
885 | vty_out(vty, |
886 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
887 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 888 | break; |
889 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
1ca2fd11 IR |
890 | vty_out(vty, |
891 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
d62a17ae | 892 | peer->host); |
893 | break; | |
894 | default: | |
895 | break; | |
896 | } | |
7aafcaca DS |
897 | } |
898 | ||
dc912615 | 899 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 900 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
901 | { |
902 | int ret = 0; | |
2adac256 | 903 | struct peer_af *paf; |
dc912615 DS |
904 | |
905 | /* if afi/.safi not specified, spin thru all of them */ | |
906 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
907 | afi_t tmp_afi; | |
908 | safi_t tmp_safi; | |
0e5cdd59 DS |
909 | enum bgp_af_index index; |
910 | ||
911 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
912 | paf = peer->peer_af_array[index]; | |
913 | if (!paf) | |
914 | continue; | |
dc912615 | 915 | |
2adac256 DA |
916 | if (paf && paf->subgroup) |
917 | SET_FLAG(paf->subgroup->sflags, | |
918 | SUBGRP_STATUS_FORCE_UPDATES); | |
919 | ||
0e5cdd59 DS |
920 | tmp_afi = paf->afi; |
921 | tmp_safi = paf->safi; | |
dc912615 DS |
922 | if (!peer->afc[tmp_afi][tmp_safi]) |
923 | continue; | |
924 | ||
925 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 926 | ret = peer_clear(peer, nnode); |
dc912615 DS |
927 | else |
928 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
929 | stype); | |
930 | } | |
931 | /* if afi specified and safi not, spin thru safis on this afi */ | |
932 | } else if (safi == SAFI_UNSPEC) { | |
933 | safi_t tmp_safi; | |
934 | ||
935 | for (tmp_safi = SAFI_UNICAST; | |
936 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
937 | if (!peer->afc[afi][tmp_safi]) | |
938 | continue; | |
939 | ||
2adac256 DA |
940 | paf = peer_af_find(peer, afi, tmp_safi); |
941 | if (paf && paf->subgroup) | |
942 | SET_FLAG(paf->subgroup->sflags, | |
943 | SUBGRP_STATUS_FORCE_UPDATES); | |
944 | ||
dc912615 | 945 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 946 | ret = peer_clear(peer, nnode); |
dc912615 DS |
947 | else |
948 | ret = peer_clear_soft(peer, afi, | |
949 | tmp_safi, stype); | |
950 | } | |
951 | /* both afi/safi specified, let the caller know if not defined */ | |
952 | } else { | |
953 | if (!peer->afc[afi][safi]) | |
954 | return 1; | |
955 | ||
2adac256 DA |
956 | paf = peer_af_find(peer, afi, safi); |
957 | if (paf && paf->subgroup) | |
958 | SET_FLAG(paf->subgroup->sflags, | |
959 | SUBGRP_STATUS_FORCE_UPDATES); | |
960 | ||
dc912615 | 961 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 962 | ret = peer_clear(peer, nnode); |
dc912615 DS |
963 | else |
964 | ret = peer_clear_soft(peer, afi, safi, stype); | |
965 | } | |
966 | ||
967 | return ret; | |
968 | } | |
969 | ||
7aafcaca | 970 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 971 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 972 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 973 | const char *arg) |
d62a17ae | 974 | { |
dc912615 | 975 | int ret = 0; |
3ae8bfa5 | 976 | bool found = false; |
d62a17ae | 977 | struct peer *peer; |
dc95985f | 978 | |
979 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 980 | |
981 | /* Clear all neighbors. */ | |
982 | /* | |
983 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
984 | * nodes on the BGP instance as that may get freed if it is a |
985 | * doppelganger | |
d62a17ae | 986 | */ |
987 | if (sort == clear_all) { | |
988 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 989 | |
990 | bgp_peer_gr_flags_update(peer); | |
991 | ||
36235319 | 992 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 993 | gr_router_detected = true; |
994 | ||
c368171c | 995 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 996 | stype); |
d62a17ae | 997 | |
998 | if (ret < 0) | |
1ca2fd11 | 999 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 1000 | } |
1001 | ||
36235319 QY |
1002 | if (gr_router_detected |
1003 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1004 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1005 | } else if (!gr_router_detected |
1006 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1007 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1008 | } |
d62a17ae | 1009 | |
1010 | /* This is to apply read-only mode on this clear. */ | |
1011 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1012 | bgp->update_delay_over = 0; | |
1013 | ||
1014 | return CMD_SUCCESS; | |
7aafcaca DS |
1015 | } |
1016 | ||
3ae8bfa5 | 1017 | /* Clear specified neighbor. */ |
d62a17ae | 1018 | if (sort == clear_peer) { |
1019 | union sockunion su; | |
d62a17ae | 1020 | |
1021 | /* Make sockunion for lookup. */ | |
1022 | ret = str2sockunion(arg, &su); | |
1023 | if (ret < 0) { | |
1024 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1025 | if (!peer) { | |
1026 | peer = peer_lookup_by_hostname(bgp, arg); | |
1027 | if (!peer) { | |
1ca2fd11 IR |
1028 | vty_out(vty, |
1029 | "Malformed address or name: %s\n", | |
d62a17ae | 1030 | arg); |
1031 | return CMD_WARNING; | |
1032 | } | |
1033 | } | |
1034 | } else { | |
1035 | peer = peer_lookup(bgp, &su); | |
1036 | if (!peer) { | |
1ca2fd11 IR |
1037 | vty_out(vty, |
1038 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
1039 | arg); | |
d62a17ae | 1040 | return CMD_WARNING; |
1041 | } | |
1042 | } | |
7aafcaca | 1043 | |
dc95985f | 1044 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1045 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1046 | ||
dc912615 DS |
1047 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1048 | ||
1049 | /* if afi/safi not defined for this peer, let caller know */ | |
1050 | if (ret == 1) | |
3ae8bfa5 | 1051 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1052 | |
d62a17ae | 1053 | if (ret < 0) |
1ca2fd11 | 1054 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1055 | |
d62a17ae | 1056 | return CMD_SUCCESS; |
7aafcaca | 1057 | } |
7aafcaca | 1058 | |
3ae8bfa5 | 1059 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1060 | if (sort == clear_group) { |
1061 | struct peer_group *group; | |
7aafcaca | 1062 | |
d62a17ae | 1063 | group = peer_group_lookup(bgp, arg); |
1064 | if (!group) { | |
1ca2fd11 | 1065 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); |
d62a17ae | 1066 | return CMD_WARNING; |
1067 | } | |
1068 | ||
1069 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1070 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1071 | |
d62a17ae | 1072 | if (ret < 0) |
1ca2fd11 | 1073 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1074 | else |
1075 | found = true; | |
d62a17ae | 1076 | } |
3ae8bfa5 PM |
1077 | |
1078 | if (!found) | |
1ca2fd11 IR |
1079 | vty_out(vty, |
1080 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 1081 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1082 | |
d62a17ae | 1083 | return CMD_SUCCESS; |
7aafcaca | 1084 | } |
7aafcaca | 1085 | |
3ae8bfa5 | 1086 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1087 | if (sort == clear_external) { |
1088 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1089 | if (peer->sort == BGP_PEER_IBGP) | |
1090 | continue; | |
7aafcaca | 1091 | |
dc95985f | 1092 | bgp_peer_gr_flags_update(peer); |
1093 | ||
36235319 | 1094 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1095 | gr_router_detected = true; |
dc95985f | 1096 | |
c368171c | 1097 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1098 | |
d62a17ae | 1099 | if (ret < 0) |
1ca2fd11 | 1100 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1101 | else |
1102 | found = true; | |
d62a17ae | 1103 | } |
3ae8bfa5 | 1104 | |
36235319 QY |
1105 | if (gr_router_detected |
1106 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1107 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1108 | } else if (!gr_router_detected |
1109 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1110 | bgp_zebra_send_capabilities(bgp, true); |
1111 | } | |
1112 | ||
3ae8bfa5 | 1113 | if (!found) |
1ca2fd11 IR |
1114 | vty_out(vty, |
1115 | "%%BGP: No external %s peer is configured\n", | |
1116 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 1117 | |
d62a17ae | 1118 | return CMD_SUCCESS; |
1119 | } | |
1120 | ||
3ae8bfa5 | 1121 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1122 | if (sort == clear_as) { |
3ae8bfa5 | 1123 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1124 | |
1125 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1126 | if (peer->as != as) | |
1127 | continue; | |
1128 | ||
dc95985f | 1129 | bgp_peer_gr_flags_update(peer); |
1130 | ||
36235319 | 1131 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1132 | gr_router_detected = true; |
dc95985f | 1133 | |
c368171c | 1134 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1135 | |
1136 | if (ret < 0) | |
1ca2fd11 | 1137 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1138 | else |
1139 | found = true; | |
d62a17ae | 1140 | } |
3ae8bfa5 | 1141 | |
36235319 QY |
1142 | if (gr_router_detected |
1143 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1144 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1145 | } else if (!gr_router_detected |
1146 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1147 | bgp_zebra_send_capabilities(bgp, true); |
1148 | } | |
1149 | ||
3ae8bfa5 | 1150 | if (!found) |
1ca2fd11 IR |
1151 | vty_out(vty, |
1152 | "%%BGP: No %s peer is configured with AS %s\n", | |
1153 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1154 | |
d62a17ae | 1155 | return CMD_SUCCESS; |
1156 | } | |
1157 | ||
1158 | return CMD_SUCCESS; | |
1159 | } | |
1160 | ||
1ca2fd11 IR |
1161 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1162 | safi_t safi, enum clear_sort sort, | |
1163 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1164 | { |
1165 | struct bgp *bgp; | |
1166 | ||
1167 | /* BGP structure lookup. */ | |
1168 | if (name) { | |
1169 | bgp = bgp_lookup_by_name(name); | |
1170 | if (bgp == NULL) { | |
1ca2fd11 | 1171 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1172 | return CMD_WARNING; |
1173 | } | |
1174 | } else { | |
1175 | bgp = bgp_get_default(); | |
1176 | if (bgp == NULL) { | |
1ca2fd11 | 1177 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1178 | return CMD_WARNING; |
1179 | } | |
1180 | } | |
1181 | ||
1ca2fd11 | 1182 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1183 | } |
1184 | ||
1185 | /* clear soft inbound */ | |
1ca2fd11 | 1186 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1187 | { |
99b3ebd3 NS |
1188 | afi_t afi; |
1189 | safi_t safi; | |
1190 | ||
1ca2fd11 IR |
1191 | FOREACH_AFI_SAFI (afi, safi) |
1192 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1193 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1194 | } |
1195 | ||
1196 | /* clear soft outbound */ | |
1ca2fd11 | 1197 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1198 | { |
99b3ebd3 NS |
1199 | afi_t afi; |
1200 | safi_t safi; | |
1201 | ||
1ca2fd11 IR |
1202 | FOREACH_AFI_SAFI (afi, safi) |
1203 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1204 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1205 | } |
1206 | ||
1207 | ||
f787d7a0 | 1208 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1209 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1210 | #endif |
1211 | ||
8029b216 AK |
1212 | DEFUN_HIDDEN (bgp_local_mac, |
1213 | bgp_local_mac_cmd, | |
093e3f23 | 1214 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1215 | BGP_STR |
1216 | "Local MAC config\n" | |
1217 | "VxLAN Network Identifier\n" | |
1218 | "VNI number\n" | |
1219 | "local mac\n" | |
1220 | "mac address\n" | |
1221 | "mac-mobility sequence\n" | |
1222 | "seq number\n") | |
1223 | { | |
1224 | int rv; | |
1225 | vni_t vni; | |
1226 | struct ethaddr mac; | |
1227 | struct ipaddr ip; | |
1228 | uint32_t seq; | |
1229 | struct bgp *bgp; | |
1230 | ||
1231 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1232 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1233 | vty_out(vty, "%% Malformed MAC address\n"); | |
1234 | return CMD_WARNING; | |
1235 | } | |
1236 | memset(&ip, 0, sizeof(ip)); | |
1237 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1238 | ||
1239 | bgp = bgp_get_default(); | |
1240 | if (!bgp) { | |
1241 | vty_out(vty, "Default BGP instance is not there\n"); | |
1242 | return CMD_WARNING; | |
1243 | } | |
1244 | ||
b5e140c8 AK |
1245 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1246 | zero_esi); | |
8029b216 AK |
1247 | if (rv < 0) { |
1248 | vty_out(vty, "Internal error\n"); | |
1249 | return CMD_WARNING; | |
1250 | } | |
1251 | ||
1252 | return CMD_SUCCESS; | |
1253 | } | |
1254 | ||
1255 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1256 | no_bgp_local_mac_cmd, | |
093e3f23 | 1257 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1258 | NO_STR |
1259 | BGP_STR | |
1260 | "Local MAC config\n" | |
1261 | "VxLAN Network Identifier\n" | |
1262 | "VNI number\n" | |
1263 | "local mac\n" | |
1264 | "mac address\n") | |
1265 | { | |
1266 | int rv; | |
1267 | vni_t vni; | |
1268 | struct ethaddr mac; | |
1269 | struct ipaddr ip; | |
1270 | struct bgp *bgp; | |
1271 | ||
1272 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1273 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1274 | vty_out(vty, "%% Malformed MAC address\n"); | |
1275 | return CMD_WARNING; | |
1276 | } | |
1277 | memset(&ip, 0, sizeof(ip)); | |
1278 | ||
1279 | bgp = bgp_get_default(); | |
1280 | if (!bgp) { | |
1281 | vty_out(vty, "Default BGP instance is not there\n"); | |
1282 | return CMD_WARNING; | |
1283 | } | |
1284 | ||
ec0ab544 | 1285 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1286 | if (rv < 0) { |
1287 | vty_out(vty, "Internal error\n"); | |
1288 | return CMD_WARNING; | |
1289 | } | |
1290 | ||
1291 | return CMD_SUCCESS; | |
1292 | } | |
1293 | ||
718e3744 | 1294 | DEFUN (no_synchronization, |
1295 | no_synchronization_cmd, | |
1296 | "no synchronization", | |
1297 | NO_STR | |
1298 | "Perform IGP synchronization\n") | |
1299 | { | |
d62a17ae | 1300 | return CMD_SUCCESS; |
718e3744 | 1301 | } |
1302 | ||
1303 | DEFUN (no_auto_summary, | |
1304 | no_auto_summary_cmd, | |
1305 | "no auto-summary", | |
1306 | NO_STR | |
1307 | "Enable automatic network number summarization\n") | |
1308 | { | |
d62a17ae | 1309 | return CMD_SUCCESS; |
718e3744 | 1310 | } |
3d515fd9 | 1311 | |
718e3744 | 1312 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1313 | DEFUN_NOSH (router_bgp, |
1314 | router_bgp_cmd, | |
1315 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1316 | ROUTER_STR | |
1317 | BGP_STR | |
1318 | AS_STR | |
1319 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1320 | { |
d62a17ae | 1321 | int idx_asn = 2; |
1322 | int idx_view_vrf = 3; | |
1323 | int idx_vrf = 4; | |
1ca2fd11 IR |
1324 | int is_new_bgp = 0; |
1325 | int ret; | |
d62a17ae | 1326 | as_t as; |
1327 | struct bgp *bgp; | |
1328 | const char *name = NULL; | |
1329 | enum bgp_instance_type inst_type; | |
1330 | ||
1331 | // "router bgp" without an ASN | |
1332 | if (argc == 2) { | |
1333 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1334 | bgp = bgp_get_default(); |
d62a17ae | 1335 | |
1abef40f | 1336 | if (bgp == NULL) { |
d62a17ae | 1337 | vty_out(vty, "%% No BGP process is configured\n"); |
1338 | return CMD_WARNING_CONFIG_FAILED; | |
1339 | } | |
1340 | ||
1341 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1342 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1343 | return CMD_WARNING_CONFIG_FAILED; |
1344 | } | |
1345 | } | |
1346 | ||
1347 | // "router bgp X" | |
1348 | else { | |
ff8a8a7a | 1349 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1ca2fd11 | 1350 | |
cc413e2a DA |
1351 | if (as == BGP_PRIVATE_AS_MAX || as == BGP_AS4_MAX) |
1352 | vty_out(vty, "Reserved AS used (%u|%u); AS is %u\n", | |
1353 | BGP_PRIVATE_AS_MAX, BGP_AS4_MAX, as); | |
1354 | ||
d62a17ae | 1355 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1356 | if (argc > 3) { | |
1357 | name = argv[idx_vrf]->arg; | |
1358 | ||
9a8bdf1c PG |
1359 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1360 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1361 | name = NULL; | |
1362 | else | |
1363 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1ca2fd11 | 1364 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
d62a17ae | 1365 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
d62a17ae | 1366 | } |
1367 | ||
1ca2fd11 IR |
1368 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1369 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1370 | |
1ca2fd11 IR |
1371 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
1372 | switch (ret) { | |
1373 | case BGP_ERR_AS_MISMATCH: | |
1374 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1375 | return CMD_WARNING_CONFIG_FAILED; | |
1376 | case BGP_ERR_INSTANCE_MISMATCH: | |
1377 | vty_out(vty, | |
1378 | "BGP instance name and AS number mismatch\n"); | |
1379 | vty_out(vty, | |
1380 | "BGP instance is already running; AS is %u\n", | |
1381 | as); | |
1382 | return CMD_WARNING_CONFIG_FAILED; | |
ff8a8a7a | 1383 | } |
1ca2fd11 IR |
1384 | |
1385 | /* | |
1386 | * If we just instantiated the default instance, complete | |
1387 | * any pending VRF-VPN leaking that was configured via | |
1388 | * earlier "router bgp X vrf FOO" blocks. | |
1389 | */ | |
1390 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1391 | vpn_leak_postchange_all(); | |
1392 | ||
1393 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1394 | bgp_vpn_leak_export(bgp); | |
1395 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1396 | */ | |
d62a17ae | 1397 | } |
1398 | ||
1ca2fd11 IR |
1399 | /* unset the auto created flag as the user config is now present */ |
1400 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1401 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1402 | ||
1403 | return CMD_SUCCESS; | |
718e3744 | 1404 | } |
1405 | ||
718e3744 | 1406 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1407 | DEFUN (no_router_bgp, |
1408 | no_router_bgp_cmd, | |
1409 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1410 | NO_STR | |
1411 | ROUTER_STR | |
1412 | BGP_STR | |
1413 | AS_STR | |
1414 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1415 | { |
4fd9919e | 1416 | int idx_asn = 3; |
d62a17ae | 1417 | int idx_vrf = 5; |
1ca2fd11 | 1418 | as_t as; |
4fd9919e | 1419 | struct bgp *bgp; |
d62a17ae | 1420 | const char *name = NULL; |
718e3744 | 1421 | |
d62a17ae | 1422 | // "no router bgp" without an ASN |
1423 | if (argc == 3) { | |
1424 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1425 | bgp = bgp_get_default(); |
718e3744 | 1426 | |
8382083a | 1427 | if (bgp == NULL) { |
d62a17ae | 1428 | vty_out(vty, "%% No BGP process is configured\n"); |
1429 | return CMD_WARNING_CONFIG_FAILED; | |
1430 | } | |
7fb21a9f | 1431 | |
d62a17ae | 1432 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1433 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1434 | return CMD_WARNING_CONFIG_FAILED; |
1435 | } | |
4fd9919e | 1436 | |
4fd9919e IR |
1437 | if (bgp->l3vni) { |
1438 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1439 | bgp->l3vni); | |
1440 | return CMD_WARNING_CONFIG_FAILED; | |
1441 | } | |
d62a17ae | 1442 | } else { |
4fd9919e IR |
1443 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1444 | ||
1ca42c8d | 1445 | if (argc > 4) { |
d62a17ae | 1446 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1447 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1448 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1449 | name = NULL; | |
1450 | } | |
7fb21a9f | 1451 | |
4fd9919e IR |
1452 | /* Lookup bgp structure. */ |
1453 | bgp = bgp_lookup(as, name); | |
1454 | if (!bgp) { | |
1455 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1456 | return CMD_WARNING_CONFIG_FAILED; | |
1457 | } | |
1458 | ||
1459 | if (bgp->l3vni) { | |
1460 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1461 | bgp->l3vni); | |
1462 | return CMD_WARNING_CONFIG_FAILED; | |
1463 | } | |
1464 | ||
1465 | /* Cannot delete default instance if vrf instances exist */ | |
1466 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1467 | struct listnode *node; | |
1468 | struct bgp *tmp_bgp; | |
1469 | ||
1470 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1471 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1472 | continue; | |
1473 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1474 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1475 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1476 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1477 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1478 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1479 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1480 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1481 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1482 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1483 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1484 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1485 | (bgp == bgp_get_evpn() && | |
1486 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1487 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1488 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1489 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1490 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1491 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1492 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1493 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
1494 | (tmp_bgp->vnihash && hashcount(tmp_bgp->vnihash))) { | |
1495 | vty_out(vty, | |
1496 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1497 | return CMD_WARNING_CONFIG_FAILED; | |
1498 | } | |
1499 | } | |
1500 | } | |
d62a17ae | 1501 | } |
718e3744 | 1502 | |
1ca2fd11 | 1503 | bgp_delete(bgp); |
718e3744 | 1504 | |
1ca2fd11 | 1505 | return CMD_SUCCESS; |
718e3744 | 1506 | } |
1507 | ||
718e3744 | 1508 | |
ff8a8a7a CS |
1509 | /* BGP router-id. */ |
1510 | ||
1ca2fd11 IR |
1511 | DEFPY (bgp_router_id, |
1512 | bgp_router_id_cmd, | |
1513 | "bgp router-id A.B.C.D", | |
1514 | BGP_STR | |
1515 | "Override configured router identifier\n" | |
1516 | "Manually configured router identifier\n") | |
718e3744 | 1517 | { |
1ca2fd11 IR |
1518 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1519 | bgp_router_id_static_set(bgp, router_id); | |
1520 | return CMD_SUCCESS; | |
ff8a8a7a | 1521 | } |
718e3744 | 1522 | |
1ca2fd11 IR |
1523 | DEFPY (no_bgp_router_id, |
1524 | no_bgp_router_id_cmd, | |
1525 | "no bgp router-id [A.B.C.D]", | |
1526 | NO_STR | |
1527 | BGP_STR | |
1528 | "Override configured router identifier\n" | |
1529 | "Manually configured router identifier\n") | |
ff8a8a7a | 1530 | { |
1ca2fd11 | 1531 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1532 | |
1ca2fd11 IR |
1533 | if (router_id_str) { |
1534 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1535 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1536 | return CMD_WARNING_CONFIG_FAILED; | |
1537 | } | |
1538 | } | |
718e3744 | 1539 | |
1ca2fd11 IR |
1540 | router_id.s_addr = 0; |
1541 | bgp_router_id_static_set(bgp, router_id); | |
1542 | ||
1543 | return CMD_SUCCESS; | |
ff8a8a7a | 1544 | } |
6b0655a2 | 1545 | |
ed0e57e3 | 1546 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1547 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1548 | NO_STR BGP_STR |
1549 | "Add community specific parameters\n" | |
1550 | "Create an alias for a community\n" | |
1551 | "Community (AA:BB or AA:BB:CC)\n" | |
1552 | "Alias name\n") | |
1553 | { | |
1554 | struct community_alias ca1; | |
1555 | struct community_alias ca2; | |
1556 | struct community_alias *lookup_community; | |
1557 | struct community_alias *lookup_alias; | |
1558 | ||
1559 | if (!community_str2com(community) && !lcommunity_str2com(community)) { | |
1560 | vty_out(vty, "Invalid community format\n"); | |
1561 | return CMD_WARNING; | |
1562 | } | |
1563 | ||
1564 | memset(&ca1, 0, sizeof(ca1)); | |
1565 | memset(&ca2, 0, sizeof(ca2)); | |
1566 | strlcpy(ca1.community, community, sizeof(ca1.community)); | |
b4ad2fae | 1567 | strlcpy(ca1.alias, alias_name, sizeof(ca1.alias)); |
ed0e57e3 DA |
1568 | |
1569 | lookup_community = bgp_ca_community_lookup(&ca1); | |
1570 | lookup_alias = bgp_ca_alias_lookup(&ca1); | |
1571 | ||
1572 | if (no) { | |
1573 | bgp_ca_alias_delete(&ca1); | |
1574 | bgp_ca_community_delete(&ca1); | |
1575 | } else { | |
1576 | if (lookup_alias) { | |
1577 | /* Lookup if community hash table has an item | |
1578 | * with the same alias name. | |
1579 | */ | |
1580 | strlcpy(ca2.community, lookup_alias->community, | |
1581 | sizeof(ca2.community)); | |
1582 | if (bgp_ca_community_lookup(&ca2)) { | |
1583 | vty_out(vty, | |
1584 | "community (%s) already has this alias (%s)\n", | |
1585 | lookup_alias->community, | |
1586 | lookup_alias->alias); | |
1587 | return CMD_WARNING; | |
1588 | } | |
1589 | bgp_ca_alias_delete(&ca1); | |
1590 | } | |
1591 | ||
1592 | if (lookup_community) | |
1593 | bgp_ca_community_delete(&ca1); | |
1594 | ||
1595 | bgp_ca_alias_insert(&ca1); | |
1596 | bgp_ca_community_insert(&ca1); | |
1597 | } | |
1598 | ||
1599 | return CMD_SUCCESS; | |
1600 | } | |
1601 | ||
9acb67cb DS |
1602 | DEFPY (bgp_global_suppress_fib_pending, |
1603 | bgp_global_suppress_fib_pending_cmd, | |
1604 | "[no] bgp suppress-fib-pending", | |
1605 | NO_STR | |
1606 | BGP_STR | |
1607 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1608 | { | |
1609 | bm_wait_for_fib_set(!no); | |
1610 | ||
1611 | return CMD_SUCCESS; | |
1612 | } | |
1613 | ||
c208c586 S |
1614 | DEFPY (bgp_suppress_fib_pending, |
1615 | bgp_suppress_fib_pending_cmd, | |
1616 | "[no] bgp suppress-fib-pending", | |
1617 | NO_STR | |
1618 | BGP_STR | |
1619 | "Advertise only routes that are programmed in kernel to peers\n") | |
1620 | { | |
1621 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1622 | ||
1623 | bgp_suppress_fib_pending_set(bgp, !no); | |
1624 | return CMD_SUCCESS; | |
1625 | } | |
1626 | ||
1627 | ||
718e3744 | 1628 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1629 | DEFUN (bgp_cluster_id, |
1630 | bgp_cluster_id_cmd, | |
1631 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1632 | BGP_STR | |
1633 | "Configure Route-Reflector Cluster-id\n" | |
1634 | "Route-Reflector Cluster-id in IP address format\n" | |
1635 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1636 | { |
1ca2fd11 | 1637 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1638 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1639 | int ret; |
1640 | struct in_addr cluster; | |
1641 | ||
1642 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1643 | if (!ret) { | |
1644 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1645 | return CMD_WARNING_CONFIG_FAILED; | |
1646 | } | |
718e3744 | 1647 | |
1ca2fd11 IR |
1648 | bgp_cluster_id_set(bgp, &cluster); |
1649 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1650 | |
1ca2fd11 | 1651 | return CMD_SUCCESS; |
718e3744 | 1652 | } |
1653 | ||
1ca2fd11 IR |
1654 | DEFUN (no_bgp_cluster_id, |
1655 | no_bgp_cluster_id_cmd, | |
1656 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1657 | NO_STR | |
1658 | BGP_STR | |
1659 | "Configure Route-Reflector Cluster-id\n" | |
1660 | "Route-Reflector Cluster-id in IP address format\n" | |
1661 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1662 | { |
1ca2fd11 IR |
1663 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1664 | bgp_cluster_id_unset(bgp); | |
1665 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1666 | |
1ca2fd11 | 1667 | return CMD_SUCCESS; |
718e3744 | 1668 | } |
1669 | ||
c163f297 DS |
1670 | DEFPY (bgp_norib, |
1671 | bgp_norib_cmd, | |
1672 | "bgp no-rib", | |
1673 | BGP_STR | |
1674 | "Disable BGP route installation to RIB (Zebra)\n") | |
1675 | { | |
1676 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1677 | vty_out(vty, | |
1678 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1679 | return CMD_SUCCESS; | |
1680 | } | |
1681 | ||
1682 | bgp_option_norib_set_runtime(); | |
1683 | ||
1684 | return CMD_SUCCESS; | |
1685 | } | |
1686 | ||
1687 | DEFPY (no_bgp_norib, | |
1688 | no_bgp_norib_cmd, | |
1689 | "no bgp no-rib", | |
1690 | NO_STR | |
1691 | BGP_STR | |
1692 | "Disable BGP route installation to RIB (Zebra)\n") | |
1693 | { | |
1694 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1695 | vty_out(vty, | |
1696 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1697 | return CMD_SUCCESS; | |
1698 | } | |
1699 | ||
1700 | bgp_option_norib_unset_runtime(); | |
1701 | ||
1702 | return CMD_SUCCESS; | |
1703 | } | |
1704 | ||
e46723a5 DS |
1705 | DEFPY (no_bgp_send_extra_data, |
1706 | no_bgp_send_extra_data_cmd, | |
1707 | "[no] bgp send-extra-data zebra", | |
1708 | NO_STR | |
1709 | BGP_STR | |
1710 | "Extra data to Zebra for display/use\n" | |
1711 | "To zebra\n") | |
1712 | { | |
ec0acb80 DA |
1713 | if (no) |
1714 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1715 | else | |
1716 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1717 | |
1718 | return CMD_SUCCESS; | |
1719 | } | |
1720 | ||
1ca2fd11 IR |
1721 | DEFUN (bgp_confederation_identifier, |
1722 | bgp_confederation_identifier_cmd, | |
1723 | "bgp confederation identifier (1-4294967295)", | |
e9273987 | 1724 | BGP_STR |
1ca2fd11 IR |
1725 | "AS confederation parameters\n" |
1726 | "AS number\n" | |
1727 | "Set routing domain confederation AS\n") | |
718e3744 | 1728 | { |
1ca2fd11 | 1729 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1730 | int idx_number = 3; |
1ca2fd11 | 1731 | as_t as; |
718e3744 | 1732 | |
1ca2fd11 | 1733 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1734 | |
1ca2fd11 | 1735 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1736 | |
1ca2fd11 | 1737 | return CMD_SUCCESS; |
718e3744 | 1738 | } |
1739 | ||
1ca2fd11 IR |
1740 | DEFUN (no_bgp_confederation_identifier, |
1741 | no_bgp_confederation_identifier_cmd, | |
1742 | "no bgp confederation identifier [(1-4294967295)]", | |
1743 | NO_STR | |
e9273987 | 1744 | BGP_STR |
1ca2fd11 IR |
1745 | "AS confederation parameters\n" |
1746 | "AS number\n" | |
1747 | "Set routing domain confederation AS\n") | |
ff8a8a7a | 1748 | { |
1ca2fd11 IR |
1749 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1750 | bgp_confederation_id_unset(bgp); | |
1751 | ||
1752 | return CMD_SUCCESS; | |
ff8a8a7a CS |
1753 | } |
1754 | ||
1ca2fd11 IR |
1755 | DEFUN (bgp_confederation_peers, |
1756 | bgp_confederation_peers_cmd, | |
1757 | "bgp confederation peers (1-4294967295)...", | |
e9273987 | 1758 | BGP_STR |
1ca2fd11 IR |
1759 | "AS confederation parameters\n" |
1760 | "Peer ASs in BGP confederation\n" | |
1761 | AS_STR) | |
718e3744 | 1762 | { |
1ca2fd11 | 1763 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1764 | int idx_asn = 3; |
1ca2fd11 | 1765 | as_t as; |
d62a17ae | 1766 | int i; |
718e3744 | 1767 | |
1ca2fd11 IR |
1768 | for (i = idx_asn; i < argc; i++) { |
1769 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1770 | |
1ca2fd11 IR |
1771 | if (bgp->as == as) { |
1772 | vty_out(vty, | |
1773 | "%% Local member-AS not allowed in confed peer list\n"); | |
1774 | continue; | |
1775 | } | |
1776 | ||
1777 | bgp_confederation_peers_add(bgp, as); | |
1778 | } | |
1779 | return CMD_SUCCESS; | |
718e3744 | 1780 | } |
1781 | ||
1ca2fd11 IR |
1782 | DEFUN (no_bgp_confederation_peers, |
1783 | no_bgp_confederation_peers_cmd, | |
1784 | "no bgp confederation peers (1-4294967295)...", | |
1785 | NO_STR | |
e9273987 | 1786 | BGP_STR |
1ca2fd11 IR |
1787 | "AS confederation parameters\n" |
1788 | "Peer ASs in BGP confederation\n" | |
1789 | AS_STR) | |
718e3744 | 1790 | { |
1ca2fd11 | 1791 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1792 | int idx_asn = 4; |
1ca2fd11 | 1793 | as_t as; |
d62a17ae | 1794 | int i; |
718e3744 | 1795 | |
1ca2fd11 IR |
1796 | for (i = idx_asn; i < argc; i++) { |
1797 | as = strtoul(argv[i]->arg, NULL, 10); | |
ff8a8a7a | 1798 | |
1ca2fd11 IR |
1799 | bgp_confederation_peers_remove(bgp, as); |
1800 | } | |
1801 | return CMD_SUCCESS; | |
718e3744 | 1802 | } |
6b0655a2 | 1803 | |
5e242b0d DS |
1804 | /** |
1805 | * Central routine for maximum-paths configuration. | |
1806 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1807 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1808 | */ | |
585f1adc IR |
1809 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1810 | const char *mpaths, uint16_t options, | |
1811 | int set) | |
d62a17ae | 1812 | { |
585f1adc IR |
1813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1814 | uint16_t maxpaths = 0; | |
d62a17ae | 1815 | int ret; |
585f1adc IR |
1816 | afi_t afi; |
1817 | safi_t safi; | |
1818 | ||
1819 | afi = bgp_node_afi(vty); | |
1820 | safi = bgp_node_safi(vty); | |
d62a17ae | 1821 | |
1822 | if (set) { | |
585f1adc | 1823 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 1824 | if (maxpaths > multipath_num) { |
585f1adc | 1825 | vty_out(vty, |
d62a17ae | 1826 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1827 | maxpaths, multipath_num); | |
1828 | return CMD_WARNING_CONFIG_FAILED; | |
1829 | } | |
1830 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1831 | options); | |
1832 | } else | |
1833 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1834 | ||
1835 | if (ret < 0) { | |
585f1adc | 1836 | vty_out(vty, |
d62a17ae | 1837 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1838 | (set == 1) ? "" : "un", | |
1839 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1840 | maxpaths, afi, safi); | |
1841 | return CMD_WARNING_CONFIG_FAILED; | |
1842 | } | |
1843 | ||
1844 | bgp_recalculate_all_bestpaths(bgp); | |
1845 | ||
1846 | return CMD_SUCCESS; | |
165b5fff JB |
1847 | } |
1848 | ||
1ca2fd11 IR |
1849 | DEFUN (bgp_maxmed_admin, |
1850 | bgp_maxmed_admin_cmd, | |
1851 | "bgp max-med administrative ", | |
1852 | BGP_STR | |
1853 | "Advertise routes with max-med\n" | |
1854 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 1855 | { |
1ca2fd11 | 1856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1857 | |
1ca2fd11 IR |
1858 | bgp->v_maxmed_admin = 1; |
1859 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 1860 | |
1ca2fd11 | 1861 | bgp_maxmed_update(bgp); |
abc920f8 | 1862 | |
1ca2fd11 | 1863 | return CMD_SUCCESS; |
ff8a8a7a CS |
1864 | } |
1865 | ||
1ca2fd11 IR |
1866 | DEFUN (bgp_maxmed_admin_medv, |
1867 | bgp_maxmed_admin_medv_cmd, | |
1868 | "bgp max-med administrative (0-4294967295)", | |
1869 | BGP_STR | |
1870 | "Advertise routes with max-med\n" | |
1871 | "Administratively applied, for an indefinite period\n" | |
1872 | "Max MED value to be used\n") | |
abc920f8 | 1873 | { |
1ca2fd11 | 1874 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1875 | int idx_number = 3; |
abc920f8 | 1876 | |
1ca2fd11 IR |
1877 | bgp->v_maxmed_admin = 1; |
1878 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1879 | |
1ca2fd11 | 1880 | bgp_maxmed_update(bgp); |
abc920f8 | 1881 | |
1ca2fd11 | 1882 | return CMD_SUCCESS; |
abc920f8 DS |
1883 | } |
1884 | ||
1ca2fd11 IR |
1885 | DEFUN (no_bgp_maxmed_admin, |
1886 | no_bgp_maxmed_admin_cmd, | |
1887 | "no bgp max-med administrative [(0-4294967295)]", | |
1888 | NO_STR | |
1889 | BGP_STR | |
1890 | "Advertise routes with max-med\n" | |
1891 | "Administratively applied, for an indefinite period\n" | |
1892 | "Max MED value to be used\n") | |
abc920f8 | 1893 | { |
1ca2fd11 IR |
1894 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1895 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1896 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1897 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 1898 | |
1ca2fd11 | 1899 | return CMD_SUCCESS; |
abc920f8 DS |
1900 | } |
1901 | ||
1ca2fd11 IR |
1902 | DEFUN (bgp_maxmed_onstartup, |
1903 | bgp_maxmed_onstartup_cmd, | |
1904 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1905 | BGP_STR | |
1906 | "Advertise routes with max-med\n" | |
1907 | "Effective on a startup\n" | |
1908 | "Time (seconds) period for max-med\n" | |
1909 | "Max MED value to be used\n") | |
abc920f8 | 1910 | { |
1ca2fd11 | 1911 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1912 | int idx = 0; |
4668a151 | 1913 | |
d62a17ae | 1914 | argv_find(argv, argc, "(5-86400)", &idx); |
1ca2fd11 | 1915 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 1916 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 1917 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 1918 | else |
1ca2fd11 | 1919 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 1920 | |
1ca2fd11 IR |
1921 | bgp_maxmed_update(bgp); |
1922 | ||
1923 | return CMD_SUCCESS; | |
abc920f8 DS |
1924 | } |
1925 | ||
1ca2fd11 IR |
1926 | DEFUN (no_bgp_maxmed_onstartup, |
1927 | no_bgp_maxmed_onstartup_cmd, | |
1928 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1929 | NO_STR | |
1930 | BGP_STR | |
1931 | "Advertise routes with max-med\n" | |
1932 | "Effective on a startup\n" | |
1933 | "Time (seconds) period for max-med\n" | |
1934 | "Max MED value to be used\n") | |
abc920f8 | 1935 | { |
1ca2fd11 IR |
1936 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1937 | ||
1938 | /* Cancel max-med onstartup if its on */ | |
1939 | if (bgp->t_maxmed_onstartup) { | |
1940 | thread_cancel(&bgp->t_maxmed_onstartup); | |
1941 | bgp->maxmed_onstartup_over = 1; | |
1942 | } | |
abc920f8 | 1943 | |
1ca2fd11 IR |
1944 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1945 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1946 | |
1ca2fd11 IR |
1947 | bgp_maxmed_update(bgp); |
1948 | ||
1949 | return CMD_SUCCESS; | |
abc920f8 DS |
1950 | } |
1951 | ||
d70583f7 D |
1952 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1953 | uint16_t update_delay, | |
1954 | uint16_t establish_wait) | |
1955 | { | |
1956 | struct listnode *node, *nnode; | |
1957 | struct bgp *bgp; | |
1958 | bool vrf_cfg = false; | |
1959 | ||
1960 | /* | |
1961 | * See if update-delay is set per-vrf and warn user to delete it | |
1962 | * Note that we only need to check this if this is the first time | |
1963 | * setting the global config. | |
1964 | */ | |
1965 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1966 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1967 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1968 | vty_out(vty, | |
1969 | "%% update-delay configuration found in vrf %s\n", | |
1970 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1971 | ? VRF_DEFAULT_NAME | |
1972 | : bgp->name); | |
1973 | vrf_cfg = true; | |
1974 | } | |
1975 | } | |
1976 | } | |
1977 | ||
1978 | if (vrf_cfg) { | |
1979 | vty_out(vty, | |
1980 | "%%Failed: global update-delay config not permitted\n"); | |
1981 | return CMD_WARNING; | |
1982 | } | |
1983 | ||
1984 | if (!establish_wait) { /* update-delay <delay> */ | |
1985 | bm->v_update_delay = update_delay; | |
1986 | bm->v_establish_wait = bm->v_update_delay; | |
1987 | } else { | |
1988 | /* update-delay <delay> <establish-wait> */ | |
1989 | if (update_delay < establish_wait) { | |
1990 | vty_out(vty, | |
1991 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1992 | return CMD_WARNING_CONFIG_FAILED; | |
1993 | } | |
1994 | ||
1995 | bm->v_update_delay = update_delay; | |
1996 | bm->v_establish_wait = establish_wait; | |
1997 | } | |
1998 | ||
1999 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2000 | bgp->v_update_delay = bm->v_update_delay; | |
2001 | bgp->v_establish_wait = bm->v_establish_wait; | |
2002 | } | |
2003 | ||
2004 | return CMD_SUCCESS; | |
2005 | } | |
2006 | ||
2007 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2008 | { | |
2009 | struct listnode *node, *nnode; | |
2010 | struct bgp *bgp; | |
2011 | ||
2012 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2013 | bm->v_establish_wait = bm->v_update_delay; | |
2014 | ||
2015 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2016 | bgp->v_update_delay = bm->v_update_delay; | |
2017 | bgp->v_establish_wait = bm->v_establish_wait; | |
2018 | } | |
2019 | ||
2020 | return CMD_SUCCESS; | |
2021 | } | |
2022 | ||
2023 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2024 | uint16_t establish_wait) | |
f188f2c4 | 2025 | { |
d62a17ae | 2026 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2027 | |
d70583f7 D |
2028 | /* if configured globally, per-instance config is not allowed */ |
2029 | if (bm->v_update_delay) { | |
2030 | vty_out(vty, | |
2031 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2032 | return CMD_WARNING_CONFIG_FAILED; | |
2033 | } | |
2034 | ||
f188f2c4 | 2035 | |
d70583f7 | 2036 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2037 | { |
2038 | bgp->v_update_delay = update_delay; | |
2039 | bgp->v_establish_wait = bgp->v_update_delay; | |
2040 | return CMD_SUCCESS; | |
2041 | } | |
f188f2c4 | 2042 | |
d62a17ae | 2043 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2044 | if (update_delay < establish_wait) { |
2045 | vty_out(vty, | |
2046 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2047 | return CMD_WARNING_CONFIG_FAILED; | |
2048 | } | |
f188f2c4 | 2049 | |
d62a17ae | 2050 | bgp->v_update_delay = update_delay; |
2051 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2052 | |
d62a17ae | 2053 | return CMD_SUCCESS; |
f188f2c4 DS |
2054 | } |
2055 | ||
d62a17ae | 2056 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2057 | { |
d62a17ae | 2058 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2059 | |
d70583f7 D |
2060 | /* If configured globally, cannot remove from one bgp instance */ |
2061 | if (bm->v_update_delay) { | |
2062 | vty_out(vty, | |
2063 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2064 | return CMD_WARNING_CONFIG_FAILED; | |
2065 | } | |
d62a17ae | 2066 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2067 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2068 | |
d62a17ae | 2069 | return CMD_SUCCESS; |
f188f2c4 DS |
2070 | } |
2071 | ||
2b791107 | 2072 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2073 | { |
d70583f7 D |
2074 | /* If configured globally, no need to display per-instance value */ |
2075 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2076 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2077 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2078 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2079 | vty_out(vty, "\n"); | |
2080 | } | |
f188f2c4 DS |
2081 | } |
2082 | ||
d70583f7 D |
2083 | /* Global update-delay configuration */ |
2084 | DEFPY (bgp_global_update_delay, | |
2085 | bgp_global_update_delay_cmd, | |
2086 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2087 | BGP_STR | |
2088 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2089 | "Max delay in seconds\n" | |
2090 | "Establish wait in seconds\n") | |
2091 | { | |
2092 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2093 | } | |
f188f2c4 | 2094 | |
d70583f7 D |
2095 | /* Global update-delay deconfiguration */ |
2096 | DEFPY (no_bgp_global_update_delay, | |
2097 | no_bgp_global_update_delay_cmd, | |
2098 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2099 | NO_STR | |
2100 | BGP_STR | |
f188f2c4 | 2101 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2102 | "Max delay in seconds\n" |
2103 | "Establish wait in seconds\n") | |
f188f2c4 | 2104 | { |
d70583f7 | 2105 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2106 | } |
2107 | ||
d70583f7 D |
2108 | /* Update-delay configuration */ |
2109 | ||
2110 | DEFPY (bgp_update_delay, | |
2111 | bgp_update_delay_cmd, | |
2112 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2113 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2114 | "Max delay in seconds\n" |
2115 | "Establish wait in seconds\n") | |
f188f2c4 | 2116 | { |
d70583f7 | 2117 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2118 | } |
2119 | ||
2120 | /* Update-delay deconfiguration */ | |
d70583f7 | 2121 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2122 | no_bgp_update_delay_cmd, |
838758ac DW |
2123 | "no update-delay [(0-3600) [(1-3600)]]", |
2124 | NO_STR | |
f188f2c4 | 2125 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2126 | "Max delay in seconds\n" |
2127 | "Establish wait in seconds\n") | |
f188f2c4 | 2128 | { |
d62a17ae | 2129 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2130 | } |
2131 | ||
5e242b0d | 2132 | |
1ca2fd11 IR |
2133 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2134 | bool set) | |
cb1faec9 | 2135 | { |
1ca2fd11 IR |
2136 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2137 | ||
8fa7732f QY |
2138 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2139 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2140 | |
2141 | return CMD_SUCCESS; | |
2142 | } | |
2143 | ||
1ca2fd11 IR |
2144 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2145 | bool set) | |
555e09d4 | 2146 | { |
1ca2fd11 IR |
2147 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2148 | ||
8fa7732f QY |
2149 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2150 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2151 | |
d62a17ae | 2152 | return CMD_SUCCESS; |
cb1faec9 DS |
2153 | } |
2154 | ||
2b791107 | 2155 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2156 | { |
555e09d4 QY |
2157 | uint32_t quanta = |
2158 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2159 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2160 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2161 | } |
2162 | ||
555e09d4 QY |
2163 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2164 | { | |
2165 | uint32_t quanta = | |
2166 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2167 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2168 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2169 | } |
cb1faec9 | 2170 | |
8fa7732f QY |
2171 | /* Packet quanta configuration |
2172 | * | |
2173 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2174 | * thread. When changing these limits be careful to prevent stack overflow. | |
2175 | * | |
2176 | * Furthermore, the maximums used here should correspond to | |
2177 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2178 | */ | |
1ca2fd11 IR |
2179 | DEFPY (bgp_wpkt_quanta, |
2180 | bgp_wpkt_quanta_cmd, | |
2181 | "[no] write-quanta (1-64)$quanta", | |
2182 | NO_STR | |
2183 | "How many packets to write to peer socket per run\n" | |
2184 | "Number of packets\n") | |
2185 | { | |
2186 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2187 | } | |
cb1faec9 | 2188 | |
1ca2fd11 IR |
2189 | DEFPY (bgp_rpkt_quanta, |
2190 | bgp_rpkt_quanta_cmd, | |
2191 | "[no] read-quanta (1-10)$quanta", | |
2192 | NO_STR | |
2193 | "How many packets to read from peer socket per I/O cycle\n" | |
2194 | "Number of packets\n") | |
2195 | { | |
2196 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2197 | } |
2198 | ||
2b791107 | 2199 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2200 | { |
37a333fe | 2201 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2202 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2203 | } |
2204 | ||
4668a151 | 2205 | |
1ca2fd11 IR |
2206 | DEFUN (bgp_coalesce_time, |
2207 | bgp_coalesce_time_cmd, | |
2208 | "coalesce-time (0-4294967295)", | |
2209 | "Subgroup coalesce timer\n" | |
2210 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2211 | { |
1ca2fd11 | 2212 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2213 | |
1ca2fd11 | 2214 | int idx = 0; |
d62a17ae | 2215 | argv_find(argv, argc, "(0-4294967295)", &idx); |
1ca2fd11 IR |
2216 | bgp->heuristic_coalesce = false; |
2217 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2218 | return CMD_SUCCESS; | |
3f9c7369 DS |
2219 | } |
2220 | ||
1ca2fd11 IR |
2221 | DEFUN (no_bgp_coalesce_time, |
2222 | no_bgp_coalesce_time_cmd, | |
2223 | "no coalesce-time (0-4294967295)", | |
2224 | NO_STR | |
2225 | "Subgroup coalesce timer\n" | |
2226 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2227 | { |
1ca2fd11 | 2228 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2229 | |
1ca2fd11 IR |
2230 | bgp->heuristic_coalesce = true; |
2231 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2232 | return CMD_SUCCESS; | |
3f9c7369 DS |
2233 | } |
2234 | ||
5e242b0d | 2235 | /* Maximum-paths configuration */ |
585f1adc IR |
2236 | DEFUN (bgp_maxpaths, |
2237 | bgp_maxpaths_cmd, | |
2238 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2239 | "Forward packets over multiple paths\n" | |
2240 | "Number of paths\n") | |
5e242b0d | 2241 | { |
d62a17ae | 2242 | int idx_number = 1; |
585f1adc IR |
2243 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2244 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2245 | } |
2246 | ||
d62a17ae | 2247 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2248 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2249 | "Forward packets over multiple paths\n" | |
2250 | "Number of paths\n") | |
596c17ba | 2251 | |
585f1adc IR |
2252 | DEFUN (bgp_maxpaths_ibgp, |
2253 | bgp_maxpaths_ibgp_cmd, | |
2254 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2255 | "Forward packets over multiple paths\n" | |
2256 | "iBGP-multipath\n" | |
2257 | "Number of paths\n") | |
165b5fff | 2258 | { |
d62a17ae | 2259 | int idx_number = 2; |
585f1adc IR |
2260 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2261 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2262 | } |
165b5fff | 2263 | |
d62a17ae | 2264 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2265 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2266 | "Forward packets over multiple paths\n" | |
2267 | "iBGP-multipath\n" | |
2268 | "Number of paths\n") | |
596c17ba | 2269 | |
585f1adc IR |
2270 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2271 | bgp_maxpaths_ibgp_cluster_cmd, | |
2272 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2273 | "Forward packets over multiple paths\n" | |
2274 | "iBGP-multipath\n" | |
2275 | "Number of paths\n" | |
2276 | "Match the cluster length\n") | |
5e242b0d | 2277 | { |
d62a17ae | 2278 | int idx_number = 2; |
585f1adc IR |
2279 | return bgp_maxpaths_config_vty( |
2280 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
2281 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
2282 | } |
2283 | ||
d62a17ae | 2284 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2285 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2286 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2287 | "Forward packets over multiple paths\n" | |
2288 | "iBGP-multipath\n" | |
2289 | "Number of paths\n" | |
2290 | "Match the cluster length\n") | |
596c17ba | 2291 | |
585f1adc IR |
2292 | DEFUN (no_bgp_maxpaths, |
2293 | no_bgp_maxpaths_cmd, | |
2294 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2295 | NO_STR | |
2296 | "Forward packets over multiple paths\n" | |
2297 | "Number of paths\n") | |
165b5fff | 2298 | { |
585f1adc | 2299 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2300 | } |
2301 | ||
d62a17ae | 2302 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2303 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2304 | "Forward packets over multiple paths\n" |
2305 | "Number of paths\n") | |
596c17ba | 2306 | |
585f1adc IR |
2307 | DEFUN (no_bgp_maxpaths_ibgp, |
2308 | no_bgp_maxpaths_ibgp_cmd, | |
2309 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2310 | NO_STR | |
2311 | "Forward packets over multiple paths\n" | |
2312 | "iBGP-multipath\n" | |
2313 | "Number of paths\n" | |
2314 | "Match the cluster length\n") | |
165b5fff | 2315 | { |
585f1adc | 2316 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2317 | } |
2318 | ||
d62a17ae | 2319 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2320 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2321 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2322 | NO_STR | |
2323 | "Forward packets over multiple paths\n" | |
2324 | "iBGP-multipath\n" | |
2325 | "Number of paths\n" | |
2326 | "Match the cluster length\n") | |
596c17ba | 2327 | |
dd65f45e DL |
2328 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2329 | afi_t afi, safi_t safi) | |
165b5fff | 2330 | { |
00908b7a | 2331 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2332 | vty_out(vty, " maximum-paths %d\n", |
2333 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2334 | } | |
165b5fff | 2335 | |
00908b7a | 2336 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2337 | vty_out(vty, " maximum-paths ibgp %d", |
2338 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2339 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2340 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2341 | vty_out(vty, " equal-cluster-length"); | |
2342 | vty_out(vty, "\n"); | |
2343 | } | |
165b5fff | 2344 | } |
6b0655a2 | 2345 | |
718e3744 | 2346 | /* BGP timers. */ |
2347 | ||
1ca2fd11 IR |
2348 | DEFUN (bgp_timers, |
2349 | bgp_timers_cmd, | |
2350 | "timers bgp (0-65535) (0-65535)", | |
2351 | "Adjust routing timers\n" | |
2352 | "BGP timers\n" | |
2353 | "Keepalive interval\n" | |
2354 | "Holdtime\n") | |
718e3744 | 2355 | { |
1ca2fd11 | 2356 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2357 | int idx_number = 2; |
2358 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2359 | unsigned long keepalive = 0; |
2360 | unsigned long holdtime = 0; | |
718e3744 | 2361 | |
1ca2fd11 IR |
2362 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2363 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2364 | |
1ca2fd11 IR |
2365 | /* Holdtime value check. */ |
2366 | if (holdtime < 3 && holdtime != 0) { | |
2367 | vty_out(vty, | |
2368 | "%% hold time value must be either 0 or greater than 3\n"); | |
2369 | return CMD_WARNING_CONFIG_FAILED; | |
2370 | } | |
718e3744 | 2371 | |
1ca2fd11 IR |
2372 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2373 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2374 | |
1ca2fd11 | 2375 | return CMD_SUCCESS; |
718e3744 | 2376 | } |
2377 | ||
1ca2fd11 IR |
2378 | DEFUN (no_bgp_timers, |
2379 | no_bgp_timers_cmd, | |
2380 | "no timers bgp [(0-65535) (0-65535)]", | |
2381 | NO_STR | |
2382 | "Adjust routing timers\n" | |
2383 | "BGP timers\n" | |
2384 | "Keepalive interval\n" | |
2385 | "Holdtime\n") | |
718e3744 | 2386 | { |
1ca2fd11 IR |
2387 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2388 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2389 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2390 | |
1ca2fd11 | 2391 | return CMD_SUCCESS; |
718e3744 | 2392 | } |
2393 | ||
b042667a TI |
2394 | /* BGP minimum holdtime. */ |
2395 | ||
2396 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2397 | "bgp minimum-holdtime (1-65535)", | |
2398 | "BGP specific commands\n" | |
2399 | "BGP minimum holdtime\n" | |
2400 | "Seconds\n") | |
2401 | { | |
2402 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2403 | int idx_number = 2; | |
2404 | unsigned long min_holdtime; | |
2405 | ||
2406 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2407 | ||
2408 | bgp->default_min_holdtime = min_holdtime; | |
2409 | ||
2410 | return CMD_SUCCESS; | |
2411 | } | |
2412 | ||
2413 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2414 | "no bgp minimum-holdtime [(1-65535)]", | |
2415 | NO_STR | |
2416 | "BGP specific commands\n" | |
2417 | "BGP minimum holdtime\n" | |
2418 | "Seconds\n") | |
2419 | { | |
2420 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2421 | ||
2422 | bgp->default_min_holdtime = 0; | |
2423 | ||
2424 | return CMD_SUCCESS; | |
2425 | } | |
ff8a8a7a | 2426 | |
1ca2fd11 IR |
2427 | DEFUN (bgp_client_to_client_reflection, |
2428 | bgp_client_to_client_reflection_cmd, | |
2429 | "bgp client-to-client reflection", | |
e9273987 | 2430 | BGP_STR |
1ca2fd11 IR |
2431 | "Configure client to client route reflection\n" |
2432 | "reflection of routes allowed\n") | |
718e3744 | 2433 | { |
1ca2fd11 IR |
2434 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2435 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2436 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2437 | |
1ca2fd11 | 2438 | return CMD_SUCCESS; |
718e3744 | 2439 | } |
2440 | ||
1ca2fd11 IR |
2441 | DEFUN (no_bgp_client_to_client_reflection, |
2442 | no_bgp_client_to_client_reflection_cmd, | |
2443 | "no bgp client-to-client reflection", | |
2444 | NO_STR | |
e9273987 | 2445 | BGP_STR |
1ca2fd11 IR |
2446 | "Configure client to client route reflection\n" |
2447 | "reflection of routes allowed\n") | |
718e3744 | 2448 | { |
1ca2fd11 IR |
2449 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2450 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2451 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2452 | |
1ca2fd11 | 2453 | return CMD_SUCCESS; |
718e3744 | 2454 | } |
2455 | ||
2456 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2457 | DEFUN (bgp_always_compare_med, |
2458 | bgp_always_compare_med_cmd, | |
2459 | "bgp always-compare-med", | |
e9273987 | 2460 | BGP_STR |
1ca2fd11 | 2461 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2462 | { |
1ca2fd11 IR |
2463 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2464 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2465 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2466 | |
1ca2fd11 | 2467 | return CMD_SUCCESS; |
718e3744 | 2468 | } |
2469 | ||
1ca2fd11 IR |
2470 | DEFUN (no_bgp_always_compare_med, |
2471 | no_bgp_always_compare_med_cmd, | |
2472 | "no bgp always-compare-med", | |
2473 | NO_STR | |
e9273987 | 2474 | BGP_STR |
1ca2fd11 | 2475 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2476 | { |
1ca2fd11 IR |
2477 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2478 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2479 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2480 | |
1ca2fd11 | 2481 | return CMD_SUCCESS; |
2adac256 DA |
2482 | } |
2483 | ||
2adac256 | 2484 | |
1ca2fd11 IR |
2485 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2486 | "bgp ebgp-requires-policy", | |
e9273987 | 2487 | BGP_STR |
1ca2fd11 | 2488 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2489 | { |
1ca2fd11 IR |
2490 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2491 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2492 | return CMD_SUCCESS; | |
2adac256 DA |
2493 | } |
2494 | ||
1ca2fd11 IR |
2495 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2496 | "no bgp ebgp-requires-policy", | |
2497 | NO_STR | |
e9273987 | 2498 | BGP_STR |
1ca2fd11 | 2499 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2500 | { |
1ca2fd11 IR |
2501 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2502 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2503 | return CMD_SUCCESS; | |
ff8a8a7a | 2504 | } |
9dac9fc8 | 2505 | |
1ca2fd11 IR |
2506 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2507 | "bgp suppress-duplicates", | |
e9273987 | 2508 | BGP_STR |
1ca2fd11 | 2509 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2510 | { |
1ca2fd11 IR |
2511 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2512 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2513 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2514 | } |
2515 | ||
1ca2fd11 IR |
2516 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2517 | "no bgp suppress-duplicates", | |
2518 | NO_STR | |
e9273987 | 2519 | BGP_STR |
1ca2fd11 | 2520 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2521 | { |
1ca2fd11 IR |
2522 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2523 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2524 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2525 | } |
2526 | ||
fb29348a DA |
2527 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2528 | "bgp reject-as-sets", | |
e9273987 | 2529 | BGP_STR |
fb29348a DA |
2530 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2531 | { | |
2532 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2533 | struct listnode *node, *nnode; | |
2534 | struct peer *peer; | |
2535 | ||
7f972cd8 | 2536 | bgp->reject_as_sets = true; |
fb29348a DA |
2537 | |
2538 | /* Reset existing BGP sessions to reject routes | |
2539 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2540 | */ | |
2541 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2542 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2543 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2544 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2545 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2546 | } | |
2547 | } | |
2548 | ||
2549 | return CMD_SUCCESS; | |
2550 | } | |
2551 | ||
2552 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2553 | "no bgp reject-as-sets", | |
2554 | NO_STR | |
e9273987 | 2555 | BGP_STR |
fb29348a DA |
2556 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2557 | { | |
2558 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2559 | struct listnode *node, *nnode; | |
2560 | struct peer *peer; | |
2561 | ||
7f972cd8 | 2562 | bgp->reject_as_sets = false; |
fb29348a DA |
2563 | |
2564 | /* Reset existing BGP sessions to reject routes | |
2565 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2566 | */ | |
2567 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2568 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2569 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2570 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2571 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2572 | } | |
2573 | } | |
2574 | ||
2575 | return CMD_SUCCESS; | |
2576 | } | |
9dac9fc8 | 2577 | |
718e3744 | 2578 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2579 | DEFUN (bgp_deterministic_med, |
718e3744 | 2580 | bgp_deterministic_med_cmd, |
2581 | "bgp deterministic-med", | |
e9273987 | 2582 | BGP_STR |
718e3744 | 2583 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2584 | { | |
1ca2fd11 IR |
2585 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2586 | ||
2587 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2588 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2589 | bgp_recalculate_all_bestpaths(bgp); | |
2590 | } | |
7aafcaca | 2591 | |
1ca2fd11 | 2592 | return CMD_SUCCESS; |
718e3744 | 2593 | } |
2594 | ||
1ca2fd11 | 2595 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2596 | no_bgp_deterministic_med_cmd, |
2597 | "no bgp deterministic-med", | |
2598 | NO_STR | |
e9273987 | 2599 | BGP_STR |
718e3744 | 2600 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2601 | { | |
1ca2fd11 IR |
2602 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2603 | int bestpath_per_as_used; | |
2604 | afi_t afi; | |
2605 | safi_t safi; | |
2606 | struct peer *peer; | |
2607 | struct listnode *node, *nnode; | |
2608 | ||
2609 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2610 | bestpath_per_as_used = 0; | |
2611 | ||
2612 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2613 | FOREACH_AFI_SAFI (afi, safi) | |
2614 | if (bgp_addpath_dmed_required( | |
2615 | peer->addpath_type[afi][safi])) { | |
2616 | bestpath_per_as_used = 1; | |
2617 | break; | |
2618 | } | |
2619 | ||
2620 | if (bestpath_per_as_used) | |
2621 | break; | |
2622 | } | |
2623 | ||
2624 | if (bestpath_per_as_used) { | |
2625 | vty_out(vty, | |
2626 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2627 | return CMD_WARNING_CONFIG_FAILED; | |
2628 | } else { | |
2629 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2630 | bgp_recalculate_all_bestpaths(bgp); | |
2631 | } | |
2632 | } | |
d62a17ae | 2633 | |
1ca2fd11 | 2634 | return CMD_SUCCESS; |
718e3744 | 2635 | } |
538621f2 | 2636 | |
055679e9 | 2637 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2638 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2639 | bgp_graceful_restart_cmd, |
2640 | "bgp graceful-restart", | |
e9273987 | 2641 | BGP_STR |
2ba1fe69 | 2642 | GR_CMD |
055679e9 | 2643 | ) |
538621f2 | 2644 | { |
055679e9 | 2645 | int ret = BGP_GR_FAILURE; |
2646 | ||
2647 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2648 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2649 | |
d62a17ae | 2650 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2651 | |
2652 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2653 | ||
36235319 QY |
2654 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2655 | ret); | |
5cce3f05 | 2656 | |
055679e9 | 2657 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2658 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2659 | vty_out(vty, |
2660 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2661 | return bgp_vty_return(vty, ret); |
538621f2 | 2662 | } |
2663 | ||
2664 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2665 | no_bgp_graceful_restart_cmd, |
2666 | "no bgp graceful-restart", | |
2667 | NO_STR | |
e9273987 | 2668 | BGP_STR |
2ba1fe69 | 2669 | NO_GR_CMD |
055679e9 | 2670 | ) |
538621f2 | 2671 | { |
d62a17ae | 2672 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2673 | |
2674 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2675 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2676 | |
2677 | int ret = BGP_GR_FAILURE; | |
2678 | ||
2679 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2680 | ||
36235319 QY |
2681 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2682 | ret); | |
5cce3f05 | 2683 | |
055679e9 | 2684 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2685 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2686 | vty_out(vty, |
2687 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2688 | |
2689 | return bgp_vty_return(vty, ret); | |
538621f2 | 2690 | } |
2691 | ||
93406d87 | 2692 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2693 | bgp_graceful_restart_stalepath_time_cmd, |
2694 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 2695 | BGP_STR |
2ba1fe69 | 2696 | "Graceful restart capability parameters\n" |
2697 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2698 | "Delay value (seconds)\n") | |
93406d87 | 2699 | { |
d62a17ae | 2700 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2701 | int idx_number = 3; | |
d7c0a89a | 2702 | uint32_t stalepath; |
93406d87 | 2703 | |
d62a17ae | 2704 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2705 | bgp->stalepath_time = stalepath; | |
2706 | return CMD_SUCCESS; | |
93406d87 | 2707 | } |
2708 | ||
eb6f1b41 | 2709 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2710 | bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2711 | "bgp graceful-restart restart-time (0-4095)", |
e9273987 | 2712 | BGP_STR |
2ba1fe69 | 2713 | "Graceful restart capability parameters\n" |
2714 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2715 | "Delay value (seconds)\n") | |
eb6f1b41 | 2716 | { |
d62a17ae | 2717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2718 | int idx_number = 3; | |
d7c0a89a | 2719 | uint32_t restart; |
eb6f1b41 | 2720 | |
d62a17ae | 2721 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2722 | bgp->restart_time = restart; | |
2723 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2724 | } |
2725 | ||
cfd47646 | 2726 | DEFUN (bgp_graceful_restart_select_defer_time, |
2727 | bgp_graceful_restart_select_defer_time_cmd, | |
2728 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 2729 | BGP_STR |
cfd47646 | 2730 | "Graceful restart capability parameters\n" |
2731 | "Set the time to defer the BGP route selection after restart\n" | |
2732 | "Delay value (seconds, 0 - disable)\n") | |
2733 | { | |
2734 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2735 | int idx_number = 3; | |
2736 | uint32_t defer_time; | |
2737 | ||
2738 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2739 | bgp->select_defer_time = defer_time; | |
2740 | if (defer_time == 0) | |
892fedb6 | 2741 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2742 | else |
892fedb6 | 2743 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2744 | |
2745 | return CMD_SUCCESS; | |
2746 | } | |
2747 | ||
93406d87 | 2748 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2749 | no_bgp_graceful_restart_stalepath_time_cmd, |
2750 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2751 | NO_STR | |
e9273987 | 2752 | BGP_STR |
2ba1fe69 | 2753 | "Graceful restart capability parameters\n" |
2754 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2755 | "Delay value (seconds)\n") | |
93406d87 | 2756 | { |
d62a17ae | 2757 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2758 | |
d62a17ae | 2759 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2760 | return CMD_SUCCESS; | |
93406d87 | 2761 | } |
2762 | ||
eb6f1b41 | 2763 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2764 | no_bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2765 | "no bgp graceful-restart restart-time [(0-4095)]", |
2ba1fe69 | 2766 | NO_STR |
e9273987 | 2767 | BGP_STR |
2ba1fe69 | 2768 | "Graceful restart capability parameters\n" |
2769 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2770 | "Delay value (seconds)\n") | |
eb6f1b41 | 2771 | { |
d62a17ae | 2772 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2773 | |
d62a17ae | 2774 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2775 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2776 | } |
2777 | ||
cfd47646 | 2778 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2779 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2780 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2781 | NO_STR | |
e9273987 | 2782 | BGP_STR |
cfd47646 | 2783 | "Graceful restart capability parameters\n" |
2784 | "Set the time to defer the BGP route selection after restart\n" | |
2785 | "Delay value (seconds)\n") | |
2786 | { | |
2787 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2788 | ||
2789 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2790 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2791 | |
2792 | return CMD_SUCCESS; | |
2793 | } | |
2794 | ||
43fc21b3 | 2795 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2796 | bgp_graceful_restart_preserve_fw_cmd, |
2797 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 2798 | BGP_STR |
2ba1fe69 | 2799 | "Graceful restart capability parameters\n" |
2800 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2801 | { |
d62a17ae | 2802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2803 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2804 | return CMD_SUCCESS; |
43fc21b3 JC |
2805 | } |
2806 | ||
2807 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2808 | no_bgp_graceful_restart_preserve_fw_cmd, |
2809 | "no bgp graceful-restart preserve-fw-state", | |
2810 | NO_STR | |
e9273987 | 2811 | BGP_STR |
2ba1fe69 | 2812 | "Graceful restart capability parameters\n" |
2813 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2814 | { |
d62a17ae | 2815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2816 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2817 | return CMD_SUCCESS; |
43fc21b3 JC |
2818 | } |
2819 | ||
055679e9 | 2820 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2821 | bgp_graceful_restart_disable_cmd, |
2822 | "bgp graceful-restart-disable", | |
e9273987 | 2823 | BGP_STR |
2ba1fe69 | 2824 | GR_DISABLE) |
055679e9 | 2825 | { |
2826 | int ret = BGP_GR_FAILURE; | |
2827 | ||
2828 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2829 | zlog_debug( | |
2ba1fe69 | 2830 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2831 | |
055679e9 | 2832 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2833 | ||
2834 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2835 | ||
dc95985f | 2836 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2837 | bgp->peer, ret); | |
5cce3f05 | 2838 | |
055679e9 | 2839 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2840 | zlog_debug( | |
2ba1fe69 | 2841 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2842 | vty_out(vty, |
2843 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2844 | ||
055679e9 | 2845 | return bgp_vty_return(vty, ret); |
2846 | } | |
2847 | ||
2848 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2849 | no_bgp_graceful_restart_disable_cmd, |
2850 | "no bgp graceful-restart-disable", | |
2851 | NO_STR | |
e9273987 | 2852 | BGP_STR |
2ba1fe69 | 2853 | NO_GR_DISABLE |
055679e9 | 2854 | ) |
2855 | { | |
2856 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2857 | ||
2858 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2859 | zlog_debug( | |
2ba1fe69 | 2860 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2861 | |
2862 | int ret = BGP_GR_FAILURE; | |
2863 | ||
2864 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2865 | ||
36235319 QY |
2866 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2867 | ret); | |
5cce3f05 | 2868 | |
055679e9 | 2869 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2870 | zlog_debug( | |
2ba1fe69 | 2871 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2872 | vty_out(vty, |
2873 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2874 | |
2875 | return bgp_vty_return(vty, ret); | |
2876 | } | |
2877 | ||
2878 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2879 | bgp_neighbor_graceful_restart_set_cmd, |
2880 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2881 | NEIGHBOR_STR | |
2882 | NEIGHBOR_ADDR_STR2 | |
2883 | GR_NEIGHBOR_CMD | |
055679e9 | 2884 | ) |
2885 | { | |
2886 | int idx_peer = 1; | |
2887 | struct peer *peer; | |
2888 | int ret = BGP_GR_FAILURE; | |
2889 | ||
dc95985f | 2890 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2891 | ||
055679e9 | 2892 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2893 | zlog_debug( | |
2ba1fe69 | 2894 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2895 | |
055679e9 | 2896 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2897 | if (!peer) | |
2898 | return CMD_WARNING_CONFIG_FAILED; | |
2899 | ||
2900 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2901 | ||
dc95985f | 2902 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2903 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2904 | |
2905 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2906 | zlog_debug( | |
2ba1fe69 | 2907 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2908 | vty_out(vty, |
2909 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2910 | |
2911 | return bgp_vty_return(vty, ret); | |
2912 | } | |
2913 | ||
2914 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2915 | no_bgp_neighbor_graceful_restart_set_cmd, |
2916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2917 | NO_STR | |
2918 | NEIGHBOR_STR | |
2919 | NEIGHBOR_ADDR_STR2 | |
2920 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2921 | ) |
2922 | { | |
2923 | int idx_peer = 2; | |
2924 | int ret = BGP_GR_FAILURE; | |
2925 | struct peer *peer; | |
2926 | ||
dc95985f | 2927 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2928 | ||
055679e9 | 2929 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2930 | if (!peer) | |
2931 | return CMD_WARNING_CONFIG_FAILED; | |
2932 | ||
2933 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2934 | zlog_debug( | |
2ba1fe69 | 2935 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2936 | |
2937 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2938 | ||
dc95985f | 2939 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2940 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2941 | |
2942 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2943 | zlog_debug( | |
2ba1fe69 | 2944 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2945 | vty_out(vty, |
2946 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2947 | |
2948 | return bgp_vty_return(vty, ret); | |
2949 | } | |
2950 | ||
2951 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2952 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2953 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2954 | NEIGHBOR_STR | |
2955 | NEIGHBOR_ADDR_STR2 | |
2956 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2957 | ) |
2958 | { | |
2959 | int idx_peer = 1; | |
2960 | struct peer *peer; | |
2961 | int ret = BGP_GR_FAILURE; | |
2962 | ||
dc95985f | 2963 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2964 | ||
055679e9 | 2965 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2966 | zlog_debug( | |
2ba1fe69 | 2967 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2968 | |
055679e9 | 2969 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2970 | ||
055679e9 | 2971 | if (!peer) |
2972 | return CMD_WARNING_CONFIG_FAILED; | |
2973 | ||
2974 | ||
2975 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2976 | |
dc95985f | 2977 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2978 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2979 | |
055679e9 | 2980 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2981 | zlog_debug( | |
2ba1fe69 | 2982 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2983 | vty_out(vty, |
2984 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2985 | |
2986 | return bgp_vty_return(vty, ret); | |
2987 | } | |
2988 | ||
2989 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2990 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2991 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2992 | NO_STR | |
2993 | NEIGHBOR_STR | |
2994 | NEIGHBOR_ADDR_STR2 | |
2995 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2996 | ) |
2997 | { | |
2998 | int idx_peer = 2; | |
2999 | int ret = BGP_GR_FAILURE; | |
3000 | struct peer *peer; | |
3001 | ||
dc95985f | 3002 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3003 | ||
055679e9 | 3004 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3005 | if (!peer) | |
3006 | return CMD_WARNING_CONFIG_FAILED; | |
3007 | ||
3008 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3009 | zlog_debug( | |
2ba1fe69 | 3010 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3011 | |
36235319 | 3012 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3013 | |
dc95985f | 3014 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3015 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3016 | |
3017 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3018 | zlog_debug( | |
2ba1fe69 | 3019 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3020 | vty_out(vty, |
3021 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3022 | |
3023 | return bgp_vty_return(vty, ret); | |
3024 | } | |
3025 | ||
3026 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3027 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3028 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3029 | NEIGHBOR_STR | |
3030 | NEIGHBOR_ADDR_STR2 | |
3031 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3032 | ) |
3033 | { | |
3034 | int idx_peer = 1; | |
3035 | struct peer *peer; | |
3036 | int ret = BGP_GR_FAILURE; | |
3037 | ||
dc95985f | 3038 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3039 | ||
055679e9 | 3040 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3041 | zlog_debug( | |
2ba1fe69 | 3042 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3043 | |
3044 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3045 | if (!peer) | |
3046 | return CMD_WARNING_CONFIG_FAILED; | |
3047 | ||
36235319 | 3048 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3049 | |
3050 | if (peer->bgp->t_startup) | |
3051 | bgp_peer_gr_flags_update(peer); | |
3052 | ||
dc95985f | 3053 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3054 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3055 | ||
055679e9 | 3056 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3057 | zlog_debug( | |
2ba1fe69 | 3058 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3059 | vty_out(vty, |
3060 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3061 | |
3062 | return bgp_vty_return(vty, ret); | |
3063 | } | |
3064 | ||
3065 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3066 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3067 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3068 | NO_STR | |
3069 | NEIGHBOR_STR | |
3070 | NEIGHBOR_ADDR_STR2 | |
3071 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3072 | ) |
3073 | { | |
3074 | int idx_peer = 2; | |
3075 | int ret = BGP_GR_FAILURE; | |
3076 | struct peer *peer; | |
3077 | ||
dc95985f | 3078 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3079 | ||
055679e9 | 3080 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3081 | if (!peer) | |
3082 | return CMD_WARNING_CONFIG_FAILED; | |
3083 | ||
3084 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3085 | zlog_debug( | |
2ba1fe69 | 3086 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3087 | |
3088 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3089 | ||
dc95985f | 3090 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3091 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3092 | |
3093 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3094 | zlog_debug( | |
2ba1fe69 | 3095 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3096 | vty_out(vty, |
3097 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3098 | |
3099 | return bgp_vty_return(vty, ret); | |
3100 | } | |
3101 | ||
d6e3c15b | 3102 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3103 | bgp_graceful_restart_disable_eor_cmd, | |
3104 | "bgp graceful-restart disable-eor", | |
e9273987 | 3105 | BGP_STR |
d6e3c15b | 3106 | "Graceful restart configuration parameters\n" |
3107 | "Disable EOR Check\n") | |
3108 | { | |
3109 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3110 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3111 | |
d6e3c15b | 3112 | return CMD_SUCCESS; |
3113 | } | |
3114 | ||
3115 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3116 | no_bgp_graceful_restart_disable_eor_cmd, | |
3117 | "no bgp graceful-restart disable-eor", | |
3118 | NO_STR | |
e9273987 | 3119 | BGP_STR |
d6e3c15b | 3120 | "Graceful restart configuration parameters\n" |
3121 | "Disable EOR Check\n") | |
3122 | { | |
3123 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3124 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3125 | |
3126 | return CMD_SUCCESS; | |
3127 | } | |
3128 | ||
3129 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3130 | bgp_graceful_restart_rib_stale_time_cmd, | |
3131 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3132 | BGP_STR |
dc95985f | 3133 | "Graceful restart configuration parameters\n" |
3134 | "Specify the stale route removal timer in rib\n" | |
3135 | "Delay value (seconds)\n") | |
3136 | { | |
3137 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3138 | int idx_number = 3; | |
3139 | uint32_t stale_time; | |
3140 | ||
3141 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3142 | bgp->rib_stale_time = stale_time; | |
3143 | /* Send the stale timer update message to RIB */ | |
3144 | if (bgp_zebra_stale_timer_update(bgp)) | |
3145 | return CMD_WARNING; | |
3146 | ||
3147 | return CMD_SUCCESS; | |
3148 | } | |
3149 | ||
3150 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3151 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3152 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3153 | NO_STR | |
e9273987 | 3154 | BGP_STR |
dc95985f | 3155 | "Graceful restart configuration parameters\n" |
3156 | "Specify the stale route removal timer in rib\n" | |
3157 | "Delay value (seconds)\n") | |
3158 | { | |
3159 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3160 | ||
3161 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3162 | /* Send the stale timer update message to RIB */ | |
3163 | if (bgp_zebra_stale_timer_update(bgp)) | |
3164 | return CMD_WARNING; | |
3165 | ||
d6e3c15b | 3166 | return CMD_SUCCESS; |
3167 | } | |
3168 | ||
8606be87 | 3169 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, |
7f8a9a24 DA |
3170 | "bgp long-lived-graceful-restart stale-time (1-4294967295)", |
3171 | BGP_STR | |
8606be87 DA |
3172 | "Enable Long-lived Graceful Restart\n" |
3173 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3174 | "Stale time value (seconds)\n") | |
3175 | { | |
3176 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3177 | ||
3178 | uint32_t llgr_stale_time; | |
3179 | ||
3180 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3181 | bgp->llgr_stale_time = llgr_stale_time; | |
3182 | ||
3183 | return CMD_SUCCESS; | |
3184 | } | |
3185 | ||
3186 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
7f8a9a24 | 3187 | "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]", |
8606be87 DA |
3188 | NO_STR BGP_STR |
3189 | "Enable Long-lived Graceful Restart\n" | |
3190 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3191 | "Stale time value (seconds)\n") | |
3192 | { | |
3193 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3194 | ||
3195 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3196 | ||
3197 | return CMD_SUCCESS; | |
3198 | } | |
3199 | ||
1ca2fd11 IR |
3200 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3201 | struct bgp *bgp) | |
05bd726c | 3202 | { |
3203 | bgp_static_redo_import_check(bgp); | |
3204 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3205 | bgp_clear_star_soft_out(vty, bgp->name); |
3206 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3207 | } |
3208 | ||
3209 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3210 | { | |
3211 | struct listnode *node, *nnode; | |
3212 | struct bgp *bgp; | |
3213 | bool vrf_cfg = false; | |
3214 | ||
3215 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3216 | return CMD_SUCCESS; | |
3217 | ||
3218 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3219 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3220 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3221 | vty_out(vty, | |
3222 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3223 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3224 | VRF_DEFAULT_NAME : bgp->name); | |
3225 | vrf_cfg = true; | |
3226 | } | |
3227 | } | |
3228 | ||
3229 | if (vrf_cfg) { | |
3230 | vty_out(vty, | |
3231 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3232 | return CMD_WARNING; | |
3233 | } | |
3234 | ||
3235 | /* Set flag globally */ | |
3236 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3237 | ||
3238 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3239 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3240 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3241 | |
3242 | return CMD_SUCCESS; | |
3243 | } | |
3244 | ||
3245 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3246 | { | |
3247 | struct listnode *node, *nnode; | |
3248 | struct bgp *bgp; | |
3249 | ||
3250 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3251 | return CMD_SUCCESS; | |
3252 | ||
3253 | /* Unset flag globally */ | |
3254 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3255 | ||
3256 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3257 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3258 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3259 | |
3260 | return CMD_SUCCESS; | |
3261 | } | |
3262 | ||
7f323236 DW |
3263 | /* "bgp graceful-shutdown" configuration */ |
3264 | DEFUN (bgp_graceful_shutdown, | |
3265 | bgp_graceful_shutdown_cmd, | |
3266 | "bgp graceful-shutdown", | |
3267 | BGP_STR | |
3268 | "Graceful shutdown parameters\n") | |
3269 | { | |
05bd726c | 3270 | if (vty->node == CONFIG_NODE) |
3271 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3272 | ||
1ca2fd11 | 3273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3274 | |
1ca2fd11 IR |
3275 | /* if configured globally, per-instance config is not allowed */ |
3276 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3277 | vty_out(vty, | |
3278 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3279 | return CMD_WARNING_CONFIG_FAILED; | |
3280 | } | |
3281 | ||
3282 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3283 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3284 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3285 | } | |
3286 | ||
3287 | return CMD_SUCCESS; | |
7f323236 DW |
3288 | } |
3289 | ||
1ca2fd11 | 3290 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3291 | no_bgp_graceful_shutdown_cmd, |
3292 | "no bgp graceful-shutdown", | |
3293 | NO_STR | |
3294 | BGP_STR | |
3295 | "Graceful shutdown parameters\n") | |
3296 | { | |
05bd726c | 3297 | if (vty->node == CONFIG_NODE) |
3298 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3299 | ||
1ca2fd11 | 3300 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3301 | |
1ca2fd11 IR |
3302 | /* If configured globally, cannot remove from one bgp instance */ |
3303 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3304 | vty_out(vty, | |
3305 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3306 | return CMD_WARNING_CONFIG_FAILED; | |
3307 | } | |
7f323236 | 3308 | |
1ca2fd11 IR |
3309 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3310 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3311 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3312 | } | |
3313 | ||
3314 | return CMD_SUCCESS; | |
7f323236 DW |
3315 | } |
3316 | ||
718e3744 | 3317 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3318 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3319 | bgp_fast_external_failover_cmd, |
3320 | "bgp fast-external-failover", | |
3321 | BGP_STR | |
3322 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3323 | { | |
1ca2fd11 IR |
3324 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3325 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3326 | return CMD_SUCCESS; | |
718e3744 | 3327 | } |
3328 | ||
1ca2fd11 | 3329 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3330 | no_bgp_fast_external_failover_cmd, |
3331 | "no bgp fast-external-failover", | |
3332 | NO_STR | |
3333 | BGP_STR | |
3334 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3335 | { | |
1ca2fd11 IR |
3336 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3337 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3338 | return CMD_SUCCESS; | |
718e3744 | 3339 | } |
6b0655a2 | 3340 | |
718e3744 | 3341 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3342 | DEFUN (bgp_bestpath_compare_router_id, |
3343 | bgp_bestpath_compare_router_id_cmd, | |
3344 | "bgp bestpath compare-routerid", | |
e9273987 | 3345 | BGP_STR |
1ca2fd11 IR |
3346 | "Change the default bestpath selection\n" |
3347 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3348 | { |
1ca2fd11 IR |
3349 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3350 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3351 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3352 | |
1ca2fd11 | 3353 | return CMD_SUCCESS; |
718e3744 | 3354 | } |
3355 | ||
1ca2fd11 IR |
3356 | DEFUN (no_bgp_bestpath_compare_router_id, |
3357 | no_bgp_bestpath_compare_router_id_cmd, | |
3358 | "no bgp bestpath compare-routerid", | |
3359 | NO_STR | |
e9273987 | 3360 | BGP_STR |
1ca2fd11 IR |
3361 | "Change the default bestpath selection\n" |
3362 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3363 | { |
1ca2fd11 IR |
3364 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3365 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3366 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3367 | |
1ca2fd11 | 3368 | return CMD_SUCCESS; |
718e3744 | 3369 | } |
6b0655a2 | 3370 | |
718e3744 | 3371 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3372 | DEFUN (bgp_bestpath_aspath_ignore, |
3373 | bgp_bestpath_aspath_ignore_cmd, | |
3374 | "bgp bestpath as-path ignore", | |
e9273987 | 3375 | BGP_STR |
1ca2fd11 IR |
3376 | "Change the default bestpath selection\n" |
3377 | "AS-path attribute\n" | |
3378 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3379 | { |
1ca2fd11 IR |
3380 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3381 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3382 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3383 | |
1ca2fd11 | 3384 | return CMD_SUCCESS; |
718e3744 | 3385 | } |
3386 | ||
1ca2fd11 IR |
3387 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3388 | no_bgp_bestpath_aspath_ignore_cmd, | |
3389 | "no bgp bestpath as-path ignore", | |
3390 | NO_STR | |
e9273987 | 3391 | BGP_STR |
1ca2fd11 IR |
3392 | "Change the default bestpath selection\n" |
3393 | "AS-path attribute\n" | |
3394 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3395 | { |
1ca2fd11 IR |
3396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3397 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3398 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3399 | |
1ca2fd11 | 3400 | return CMD_SUCCESS; |
718e3744 | 3401 | } |
6b0655a2 | 3402 | |
6811845b | 3403 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3404 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3405 | bgp_bestpath_aspath_confed_cmd, |
3406 | "bgp bestpath as-path confed", | |
e9273987 | 3407 | BGP_STR |
6811845b | 3408 | "Change the default bestpath selection\n" |
3409 | "AS-path attribute\n" | |
3410 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3411 | { | |
1ca2fd11 IR |
3412 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3413 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3414 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3415 | |
1ca2fd11 | 3416 | return CMD_SUCCESS; |
6811845b | 3417 | } |
3418 | ||
1ca2fd11 | 3419 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3420 | no_bgp_bestpath_aspath_confed_cmd, |
3421 | "no bgp bestpath as-path confed", | |
3422 | NO_STR | |
e9273987 | 3423 | BGP_STR |
6811845b | 3424 | "Change the default bestpath selection\n" |
3425 | "AS-path attribute\n" | |
3426 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3427 | { | |
1ca2fd11 IR |
3428 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3429 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3430 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3431 | |
1ca2fd11 | 3432 | return CMD_SUCCESS; |
6811845b | 3433 | } |
6b0655a2 | 3434 | |
2fdd455c | 3435 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3436 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3437 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3438 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3439 | BGP_STR |
16fc1eec DS |
3440 | "Change the default bestpath selection\n" |
3441 | "AS-path attribute\n" | |
3442 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3443 | "Generate an AS_SET\n" |
16fc1eec DS |
3444 | "Do not generate an AS_SET\n") |
3445 | { | |
1ca2fd11 | 3446 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3447 | int idx = 0; |
1ca2fd11 | 3448 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3449 | |
1ca2fd11 IR |
3450 | /* no-as-set is now the default behavior so we can silently |
3451 | * ignore it */ | |
d62a17ae | 3452 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3453 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3454 | else |
1ca2fd11 | 3455 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3456 | |
1ca2fd11 IR |
3457 | bgp_recalculate_all_bestpaths(bgp); |
3458 | ||
3459 | return CMD_SUCCESS; | |
16fc1eec DS |
3460 | } |
3461 | ||
1ca2fd11 | 3462 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3463 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3464 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3465 | NO_STR |
e9273987 | 3466 | BGP_STR |
16fc1eec DS |
3467 | "Change the default bestpath selection\n" |
3468 | "AS-path attribute\n" | |
3469 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3470 | "Generate an AS_SET\n" |
16fc1eec DS |
3471 | "Do not generate an AS_SET\n") |
3472 | { | |
1ca2fd11 IR |
3473 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3474 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3475 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3476 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3477 | |
1ca2fd11 | 3478 | return CMD_SUCCESS; |
2fdd455c | 3479 | } |
6b0655a2 | 3480 | |
ee88563a JM |
3481 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3482 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3483 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3484 | "bgp bestpath peer-type multipath-relax", | |
3485 | BGP_STR | |
3486 | "Change the default bestpath selection\n" | |
3487 | "Peer type\n" | |
3488 | "Allow load sharing across routes learned from different peer types\n") | |
3489 | { | |
3490 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3491 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3492 | bgp_recalculate_all_bestpaths(bgp); | |
3493 | ||
3494 | return CMD_SUCCESS; | |
3495 | } | |
3496 | ||
3497 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3498 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3499 | "no bgp bestpath peer-type multipath-relax", | |
3500 | NO_STR BGP_STR | |
3501 | "Change the default bestpath selection\n" | |
3502 | "Peer type\n" | |
3503 | "Allow load sharing across routes learned from different peer types\n") | |
3504 | { | |
3505 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3506 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3507 | bgp_recalculate_all_bestpaths(bgp); | |
3508 | ||
3509 | return CMD_SUCCESS; | |
3510 | } | |
3511 | ||
848973c7 | 3512 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3513 | DEFUN (bgp_log_neighbor_changes, |
3514 | bgp_log_neighbor_changes_cmd, | |
3515 | "bgp log-neighbor-changes", | |
e9273987 | 3516 | BGP_STR |
1ca2fd11 | 3517 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3518 | { |
1ca2fd11 IR |
3519 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3520 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3521 | return CMD_SUCCESS; | |
848973c7 | 3522 | } |
3523 | ||
1ca2fd11 IR |
3524 | DEFUN (no_bgp_log_neighbor_changes, |
3525 | no_bgp_log_neighbor_changes_cmd, | |
3526 | "no bgp log-neighbor-changes", | |
3527 | NO_STR | |
e9273987 | 3528 | BGP_STR |
1ca2fd11 | 3529 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3530 | { |
1ca2fd11 IR |
3531 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3532 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3533 | return CMD_SUCCESS; | |
848973c7 | 3534 | } |
6b0655a2 | 3535 | |
718e3744 | 3536 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3537 | DEFUN (bgp_bestpath_med, |
718e3744 | 3538 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3539 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3540 | BGP_STR |
718e3744 | 3541 | "Change the default bestpath selection\n" |
3542 | "MED attribute\n" | |
3543 | "Compare MED among confederation paths\n" | |
838758ac DW |
3544 | "Treat missing MED as the least preferred one\n" |
3545 | "Treat missing MED as the least preferred one\n" | |
3546 | "Compare MED among confederation paths\n") | |
718e3744 | 3547 | { |
1ca2fd11 | 3548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3549 | |
1ca2fd11 | 3550 | int idx = 0; |
d62a17ae | 3551 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3552 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3553 | idx = 0; |
3554 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3555 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3556 | |
1ca2fd11 | 3557 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3558 | |
1ca2fd11 | 3559 | return CMD_SUCCESS; |
718e3744 | 3560 | } |
3561 | ||
1ca2fd11 | 3562 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3563 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3564 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3565 | NO_STR |
e9273987 | 3566 | BGP_STR |
718e3744 | 3567 | "Change the default bestpath selection\n" |
3568 | "MED attribute\n" | |
3569 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3570 | "Treat missing MED as the least preferred one\n" |
3571 | "Treat missing MED as the least preferred one\n" | |
3572 | "Compare MED among confederation paths\n") | |
718e3744 | 3573 | { |
1ca2fd11 | 3574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3575 | |
1ca2fd11 | 3576 | int idx = 0; |
d62a17ae | 3577 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3578 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3579 | idx = 0; |
3580 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3581 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3582 | ||
3583 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3584 | |
1ca2fd11 | 3585 | return CMD_SUCCESS; |
718e3744 | 3586 | } |
3587 | ||
f7e1c681 | 3588 | /* "bgp bestpath bandwidth" configuration. */ |
3589 | DEFPY (bgp_bestpath_bw, | |
3590 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3591 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3592 | BGP_STR |
f7e1c681 | 3593 | "Change the default bestpath selection\n" |
3594 | "Link Bandwidth attribute\n" | |
3595 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3596 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3597 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3598 | { | |
3599 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3600 | afi_t afi; | |
3601 | safi_t safi; | |
3602 | ||
ad36d216 DS |
3603 | if (!bw_cfg) { |
3604 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3605 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3606 | } |
ad36d216 DS |
3607 | if (!strcmp(bw_cfg, "ignore")) |
3608 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3609 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3610 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3611 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3612 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3613 | else | |
3614 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3615 | |
3616 | /* This config is used in route install, so redo that. */ | |
3617 | FOREACH_AFI_SAFI (afi, safi) { | |
3618 | if (!bgp_fibupd_safi(safi)) | |
3619 | continue; | |
3620 | bgp_zebra_announce_table(bgp, afi, safi); | |
3621 | } | |
3622 | ||
3623 | return CMD_SUCCESS; | |
3624 | } | |
3625 | ||
ad36d216 DS |
3626 | DEFPY (no_bgp_bestpath_bw, |
3627 | no_bgp_bestpath_bw_cmd, | |
3628 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3629 | NO_STR | |
e9273987 | 3630 | BGP_STR |
ad36d216 DS |
3631 | "Change the default bestpath selection\n" |
3632 | "Link Bandwidth attribute\n" | |
3633 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3634 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3635 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3636 | { | |
3637 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3638 | afi_t afi; | |
3639 | safi_t safi; | |
3640 | ||
3641 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3642 | ||
3643 | /* This config is used in route install, so redo that. */ | |
3644 | FOREACH_AFI_SAFI (afi, safi) { | |
3645 | if (!bgp_fibupd_safi(safi)) | |
3646 | continue; | |
3647 | bgp_zebra_announce_table(bgp, afi, safi); | |
3648 | } | |
3649 | return CMD_SUCCESS; | |
3650 | } | |
3651 | ||
b16bcbba | 3652 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3653 | "[no] bgp default <ipv4-unicast|" |
3654 | "ipv4-multicast|" | |
3655 | "ipv4-vpn|" | |
3656 | "ipv4-labeled-unicast|" | |
3657 | "ipv4-flowspec|" | |
3658 | "ipv6-unicast|" | |
3659 | "ipv6-multicast|" | |
3660 | "ipv6-vpn|" | |
3661 | "ipv6-labeled-unicast|" | |
3662 | "ipv6-flowspec|" | |
3663 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3664 | NO_STR |
e9273987 | 3665 | BGP_STR |
e84c59af | 3666 | "Configure BGP defaults\n" |
b16bcbba | 3667 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3668 | "Activate ipv4-multicast for a peer by default\n" |
3669 | "Activate ipv4-vpn for a peer by default\n" | |
3670 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3671 | "Activate ipv4-flowspec for a peer by default\n" | |
3672 | "Activate ipv6-unicast for a peer by default\n" | |
3673 | "Activate ipv6-multicast for a peer by default\n" | |
3674 | "Activate ipv6-vpn for a peer by default\n" | |
3675 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3676 | "Activate ipv6-flowspec for a peer by default\n" | |
3677 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3678 | { |
3679 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3680 | char afi_safi_str[strlen(afi_safi) + 1]; |
3681 | char *afi_safi_str_tok; | |
e84c59af | 3682 | |
b16bcbba TA |
3683 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3684 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3685 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3686 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3687 | safi_t safi; |
e84c59af | 3688 | |
38d11af5 TA |
3689 | if (strmatch(safi_str, "labeled")) |
3690 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3691 | else | |
3692 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba TA |
3693 | |
3694 | if (no) | |
3695 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3696 | else { |
3697 | if ((safi == SAFI_LABELED_UNICAST | |
3698 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3699 | || (safi == SAFI_UNICAST | |
3700 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3701 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3702 | else | |
3703 | bgp->default_af[afi][safi] = true; | |
3704 | } | |
718e3744 | 3705 | |
d62a17ae | 3706 | return CMD_SUCCESS; |
718e3744 | 3707 | } |
6b0655a2 | 3708 | |
04b6bdc0 | 3709 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 3710 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
3711 | bgp_default_show_hostname_cmd, |
3712 | "bgp default show-hostname", | |
e9273987 | 3713 | BGP_STR |
04b6bdc0 | 3714 | "Configure BGP defaults\n" |
0437e105 | 3715 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3716 | { |
1ca2fd11 IR |
3717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3718 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3719 | return CMD_SUCCESS; | |
ff8a8a7a CS |
3720 | } |
3721 | ||
1ca2fd11 IR |
3722 | DEFUN (no_bgp_default_show_hostname, |
3723 | no_bgp_default_show_hostname_cmd, | |
3724 | "no bgp default show-hostname", | |
3725 | NO_STR | |
e9273987 | 3726 | BGP_STR |
1ca2fd11 IR |
3727 | "Configure BGP defaults\n" |
3728 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 3729 | { |
1ca2fd11 IR |
3730 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3731 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3732 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3733 | } |
3734 | ||
aef999a2 | 3735 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
3736 | DEFUN (bgp_default_show_nexthop_hostname, |
3737 | bgp_default_show_nexthop_hostname_cmd, | |
3738 | "bgp default show-nexthop-hostname", | |
e9273987 | 3739 | BGP_STR |
1d80f243 IR |
3740 | "Configure BGP defaults\n" |
3741 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3742 | { |
1ca2fd11 IR |
3743 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3744 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3745 | return CMD_SUCCESS; | |
aef999a2 DA |
3746 | } |
3747 | ||
3748 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3749 | no_bgp_default_show_nexthop_hostname_cmd, | |
3750 | "no bgp default show-nexthop-hostname", | |
3751 | NO_STR | |
e9273987 | 3752 | BGP_STR |
aef999a2 DA |
3753 | "Configure BGP defaults\n" |
3754 | "Show hostname for nexthop in certain command outputs\n") | |
3755 | { | |
1ca2fd11 IR |
3756 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3757 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3758 | return CMD_SUCCESS; | |
aef999a2 DA |
3759 | } |
3760 | ||
8233ef81 | 3761 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
3762 | DEFUN (bgp_network_import_check, |
3763 | bgp_network_import_check_cmd, | |
3764 | "bgp network import-check", | |
e9273987 | 3765 | BGP_STR |
1ca2fd11 IR |
3766 | "BGP network command\n" |
3767 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3768 | { |
1ca2fd11 IR |
3769 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3770 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3771 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3772 | bgp_static_redo_import_check(bgp); | |
3773 | } | |
078430f6 | 3774 | |
1ca2fd11 | 3775 | return CMD_SUCCESS; |
718e3744 | 3776 | } |
3777 | ||
d62a17ae | 3778 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3779 | "bgp network import-check exact", | |
e9273987 | 3780 | BGP_STR |
d62a17ae | 3781 | "BGP network command\n" |
3782 | "Check BGP network route exists in IGP\n" | |
3783 | "Match route precisely\n") | |
8233ef81 | 3784 | |
1ca2fd11 IR |
3785 | DEFUN (no_bgp_network_import_check, |
3786 | no_bgp_network_import_check_cmd, | |
3787 | "no bgp network import-check", | |
3788 | NO_STR | |
e9273987 | 3789 | BGP_STR |
1ca2fd11 IR |
3790 | "BGP network command\n" |
3791 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3792 | { |
1ca2fd11 IR |
3793 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3794 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3795 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3796 | bgp_static_redo_import_check(bgp); | |
3797 | } | |
6b0655a2 | 3798 | |
1ca2fd11 | 3799 | return CMD_SUCCESS; |
ff8a8a7a | 3800 | } |
718e3744 | 3801 | |
1ca2fd11 IR |
3802 | DEFUN (bgp_default_local_preference, |
3803 | bgp_default_local_preference_cmd, | |
3804 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 3805 | BGP_STR |
1ca2fd11 IR |
3806 | "Configure BGP defaults\n" |
3807 | "local preference (higher=more preferred)\n" | |
3808 | "Configure default local preference value\n") | |
ff8a8a7a | 3809 | { |
1ca2fd11 | 3810 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3811 | int idx_number = 3; |
1ca2fd11 | 3812 | uint32_t local_pref; |
718e3744 | 3813 | |
1ca2fd11 | 3814 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3815 | |
1ca2fd11 IR |
3816 | bgp_default_local_preference_set(bgp, local_pref); |
3817 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3818 | |
1ca2fd11 | 3819 | return CMD_SUCCESS; |
718e3744 | 3820 | } |
3821 | ||
1ca2fd11 IR |
3822 | DEFUN (no_bgp_default_local_preference, |
3823 | no_bgp_default_local_preference_cmd, | |
3824 | "no bgp default local-preference [(0-4294967295)]", | |
3825 | NO_STR | |
e9273987 | 3826 | BGP_STR |
1ca2fd11 IR |
3827 | "Configure BGP defaults\n" |
3828 | "local preference (higher=more preferred)\n" | |
3829 | "Configure default local preference value\n") | |
ff8a8a7a | 3830 | { |
1ca2fd11 IR |
3831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3832 | bgp_default_local_preference_unset(bgp); | |
3833 | bgp_clear_star_soft_in(vty, bgp->name); | |
3834 | ||
3835 | return CMD_SUCCESS; | |
ff8a8a7a | 3836 | } |
6b0655a2 | 3837 | |
ff8a8a7a | 3838 | |
1ca2fd11 IR |
3839 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3840 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3841 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 3842 | BGP_STR |
1ca2fd11 IR |
3843 | "Configure BGP defaults\n" |
3844 | "subgroup-pkt-queue-max\n" | |
3845 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3846 | { |
1ca2fd11 | 3847 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3848 | int idx_number = 3; |
1ca2fd11 | 3849 | uint32_t max_size; |
3f9c7369 | 3850 | |
1ca2fd11 | 3851 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3852 | |
1ca2fd11 | 3853 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 3854 | |
1ca2fd11 | 3855 | return CMD_SUCCESS; |
8bd9d948 DS |
3856 | } |
3857 | ||
1ca2fd11 IR |
3858 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
3859 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3860 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3861 | NO_STR | |
e9273987 | 3862 | BGP_STR |
1ca2fd11 IR |
3863 | "Configure BGP defaults\n" |
3864 | "subgroup-pkt-queue-max\n" | |
3865 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 3866 | { |
1ca2fd11 IR |
3867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3868 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3869 | return CMD_SUCCESS; | |
ff8a8a7a | 3870 | } |
813d4307 | 3871 | |
8bd9d948 | 3872 | |
1ca2fd11 IR |
3873 | DEFUN (bgp_rr_allow_outbound_policy, |
3874 | bgp_rr_allow_outbound_policy_cmd, | |
3875 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 3876 | BGP_STR |
1ca2fd11 IR |
3877 | "Allow modifications made by out route-map\n" |
3878 | "on ibgp neighbors\n") | |
ff8a8a7a | 3879 | { |
1ca2fd11 | 3880 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3881 | |
1ca2fd11 IR |
3882 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3883 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3884 | update_group_announce_rrclients(bgp); | |
3885 | bgp_clear_star_soft_out(vty, bgp->name); | |
3886 | } | |
8bd9d948 | 3887 | |
1ca2fd11 IR |
3888 | return CMD_SUCCESS; |
3889 | } | |
ff8a8a7a | 3890 | |
1ca2fd11 IR |
3891 | DEFUN (no_bgp_rr_allow_outbound_policy, |
3892 | no_bgp_rr_allow_outbound_policy_cmd, | |
3893 | "no bgp route-reflector allow-outbound-policy", | |
3894 | NO_STR | |
e9273987 | 3895 | BGP_STR |
1ca2fd11 IR |
3896 | "Allow modifications made by out route-map\n" |
3897 | "on ibgp neighbors\n") | |
8bd9d948 | 3898 | { |
1ca2fd11 | 3899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3900 | |
1ca2fd11 IR |
3901 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3902 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3903 | update_group_announce_rrclients(bgp); | |
3904 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 3905 | } |
8bd9d948 | 3906 | |
1ca2fd11 | 3907 | return CMD_SUCCESS; |
8bd9d948 DS |
3908 | } |
3909 | ||
1ca2fd11 IR |
3910 | DEFUN (bgp_listen_limit, |
3911 | bgp_listen_limit_cmd, | |
3912 | "bgp listen limit (1-65535)", | |
e9273987 | 3913 | BGP_STR |
1ca2fd11 IR |
3914 | "BGP Dynamic Neighbors listen commands\n" |
3915 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3916 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3917 | { |
1ca2fd11 | 3918 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3919 | int idx_number = 3; |
1ca2fd11 IR |
3920 | int listen_limit; |
3921 | ||
3922 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 3923 | |
1ca2fd11 | 3924 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3925 | |
1ca2fd11 | 3926 | return CMD_SUCCESS; |
f14e6fdb DS |
3927 | } |
3928 | ||
1ca2fd11 IR |
3929 | DEFUN (no_bgp_listen_limit, |
3930 | no_bgp_listen_limit_cmd, | |
3931 | "no bgp listen limit [(1-65535)]", | |
3932 | NO_STR | |
e9273987 | 3933 | BGP_STR |
1ca2fd11 IR |
3934 | "BGP Dynamic Neighbors listen commands\n" |
3935 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3936 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3937 | { |
1ca2fd11 IR |
3938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3939 | bgp_listen_limit_unset(bgp); | |
3940 | return CMD_SUCCESS; | |
f14e6fdb DS |
3941 | } |
3942 | ||
3943 | ||
20eb8864 | 3944 | /* |
3945 | * Check if this listen range is already configured. Check for exact | |
3946 | * match or overlap based on input. | |
3947 | */ | |
d62a17ae | 3948 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3949 | struct prefix *range, int exact) | |
3950 | { | |
3951 | struct listnode *node, *nnode; | |
3952 | struct listnode *node1, *nnode1; | |
3953 | struct peer_group *group; | |
3954 | struct prefix *lr; | |
3955 | afi_t afi; | |
3956 | int match; | |
3957 | ||
3958 | afi = family2afi(range->family); | |
3959 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3960 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3961 | lr)) { | |
3962 | if (exact) | |
3963 | match = prefix_same(range, lr); | |
3964 | else | |
3965 | match = (prefix_match(range, lr) | |
3966 | || prefix_match(lr, range)); | |
3967 | if (match) | |
3968 | return group; | |
3969 | } | |
3970 | } | |
3971 | ||
3972 | return NULL; | |
20eb8864 | 3973 | } |
3974 | ||
f14e6fdb DS |
3975 | DEFUN (bgp_listen_range, |
3976 | bgp_listen_range_cmd, | |
d7b9898c | 3977 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 3978 | BGP_STR |
d7fa34c1 QY |
3979 | "Configure BGP dynamic neighbors listen range\n" |
3980 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3981 | NEIGHBOR_ADDR_STR |
3982 | "Member of the peer-group\n" | |
3983 | "Peer-group name\n") | |
f14e6fdb | 3984 | { |
d62a17ae | 3985 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3986 | struct prefix range; | |
3987 | struct peer_group *group, *existing_group; | |
3988 | afi_t afi; | |
3989 | int ret; | |
3990 | int idx = 0; | |
3991 | ||
3992 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3993 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3994 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3995 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3996 | char *peergroup = argv[idx]->arg; |
3997 | ||
3998 | /* Convert IP prefix string to struct prefix. */ | |
3999 | ret = str2prefix(prefix, &range); | |
4000 | if (!ret) { | |
4001 | vty_out(vty, "%% Malformed listen range\n"); | |
4002 | return CMD_WARNING_CONFIG_FAILED; | |
4003 | } | |
4004 | ||
4005 | afi = family2afi(range.family); | |
4006 | ||
4007 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4008 | vty_out(vty, | |
4009 | "%% Malformed listen range (link-local address)\n"); | |
4010 | return CMD_WARNING_CONFIG_FAILED; | |
4011 | } | |
4012 | ||
4013 | apply_mask(&range); | |
4014 | ||
4015 | /* Check if same listen range is already configured. */ | |
4016 | existing_group = listen_range_exists(bgp, &range, 1); | |
4017 | if (existing_group) { | |
4018 | if (strcmp(existing_group->name, peergroup) == 0) | |
4019 | return CMD_SUCCESS; | |
4020 | else { | |
4021 | vty_out(vty, | |
4022 | "%% Same listen range is attached to peer-group %s\n", | |
4023 | existing_group->name); | |
4024 | return CMD_WARNING_CONFIG_FAILED; | |
4025 | } | |
4026 | } | |
4027 | ||
4028 | /* Check if an overlapping listen range exists. */ | |
4029 | if (listen_range_exists(bgp, &range, 0)) { | |
4030 | vty_out(vty, | |
4031 | "%% Listen range overlaps with existing listen range\n"); | |
4032 | return CMD_WARNING_CONFIG_FAILED; | |
4033 | } | |
4034 | ||
4035 | group = peer_group_lookup(bgp, peergroup); | |
4036 | if (!group) { | |
4037 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4038 | return CMD_WARNING_CONFIG_FAILED; | |
4039 | } | |
4040 | ||
4041 | ret = peer_group_listen_range_add(group, &range); | |
4042 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4043 | } |
4044 | ||
4045 | DEFUN (no_bgp_listen_range, | |
4046 | no_bgp_listen_range_cmd, | |
d7b9898c | 4047 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4048 | NO_STR |
e9273987 | 4049 | BGP_STR |
d7fa34c1 QY |
4050 | "Unconfigure BGP dynamic neighbors listen range\n" |
4051 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4052 | NEIGHBOR_ADDR_STR | |
4053 | "Member of the peer-group\n" | |
4054 | "Peer-group name\n") | |
f14e6fdb | 4055 | { |
d62a17ae | 4056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4057 | struct prefix range; | |
4058 | struct peer_group *group; | |
4059 | afi_t afi; | |
4060 | int ret; | |
4061 | int idx = 0; | |
4062 | ||
4063 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4064 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4065 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4066 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4067 | char *peergroup = argv[idx]->arg; |
4068 | ||
4069 | /* Convert IP prefix string to struct prefix. */ | |
4070 | ret = str2prefix(prefix, &range); | |
4071 | if (!ret) { | |
4072 | vty_out(vty, "%% Malformed listen range\n"); | |
4073 | return CMD_WARNING_CONFIG_FAILED; | |
4074 | } | |
4075 | ||
4076 | afi = family2afi(range.family); | |
4077 | ||
4078 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4079 | vty_out(vty, | |
4080 | "%% Malformed listen range (link-local address)\n"); | |
4081 | return CMD_WARNING_CONFIG_FAILED; | |
4082 | } | |
4083 | ||
4084 | apply_mask(&range); | |
4085 | ||
4086 | group = peer_group_lookup(bgp, peergroup); | |
4087 | if (!group) { | |
4088 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4089 | return CMD_WARNING_CONFIG_FAILED; | |
4090 | } | |
4091 | ||
4092 | ret = peer_group_listen_range_del(group, &range); | |
4093 | return bgp_vty_return(vty, ret); | |
4094 | } | |
4095 | ||
2b791107 | 4096 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4097 | { |
4098 | struct peer_group *group; | |
4099 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4100 | struct prefix *range; | |
4101 | afi_t afi; | |
d62a17ae | 4102 | |
4103 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4104 | vty_out(vty, " bgp listen limit %d\n", | |
4105 | bgp->dynamic_neighbors_limit); | |
4106 | ||
4107 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4108 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4109 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4110 | nrnode, range)) { | |
d62a17ae | 4111 | vty_out(vty, |
2dbe669b DA |
4112 | " bgp listen range %pFX peer-group %s\n", |
4113 | range, group->name); | |
d62a17ae | 4114 | } |
4115 | } | |
4116 | } | |
f14e6fdb DS |
4117 | } |
4118 | ||
4119 | ||
1ca2fd11 IR |
4120 | DEFUN (bgp_disable_connected_route_check, |
4121 | bgp_disable_connected_route_check_cmd, | |
4122 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4123 | BGP_STR |
1ca2fd11 | 4124 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4125 | { |
1ca2fd11 IR |
4126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4127 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4128 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4129 | |
1ca2fd11 | 4130 | return CMD_SUCCESS; |
907f92c8 DS |
4131 | } |
4132 | ||
1ca2fd11 IR |
4133 | DEFUN (no_bgp_disable_connected_route_check, |
4134 | no_bgp_disable_connected_route_check_cmd, | |
4135 | "no bgp disable-ebgp-connected-route-check", | |
4136 | NO_STR | |
e9273987 | 4137 | BGP_STR |
1ca2fd11 | 4138 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4139 | { |
1ca2fd11 IR |
4140 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4141 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4142 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4143 | |
1ca2fd11 | 4144 | return CMD_SUCCESS; |
d62a17ae | 4145 | } |
4146 | ||
4147 | ||
28c6e247 IR |
4148 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4149 | const char *as_str) | |
4150 | { | |
4151 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4152 | int ret; | |
4153 | as_t as; | |
4154 | int as_type = AS_SPECIFIED; | |
4155 | union sockunion su; | |
4156 | ||
4157 | if (as_str[0] == 'i') { | |
4158 | as = 0; | |
4159 | as_type = AS_INTERNAL; | |
4160 | } else if (as_str[0] == 'e') { | |
4161 | as = 0; | |
4162 | as_type = AS_EXTERNAL; | |
4163 | } else { | |
4164 | /* Get AS number. */ | |
4165 | as = strtoul(as_str, NULL, 10); | |
4166 | } | |
4167 | ||
4168 | /* If peer is peer group or interface peer, call proper function. */ | |
4169 | ret = str2sockunion(peer_str, &su); | |
4170 | if (ret < 0) { | |
4171 | struct peer *peer; | |
4172 | ||
4173 | /* Check if existing interface peer */ | |
4174 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4175 | ||
4176 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4177 | ||
4178 | /* if not interface peer, check peer-group settings */ | |
4179 | if (ret < 0 && !peer) { | |
4180 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4181 | if (ret < 0) { | |
4182 | vty_out(vty, | |
4183 | "%% Create the peer-group or interface first\n"); | |
4184 | return CMD_WARNING_CONFIG_FAILED; | |
4185 | } | |
4186 | return CMD_SUCCESS; | |
4187 | } | |
4188 | } else { | |
4189 | if (peer_address_self_check(bgp, &su)) { | |
4190 | vty_out(vty, | |
4191 | "%% Can not configure the local system as neighbor\n"); | |
4192 | return CMD_WARNING_CONFIG_FAILED; | |
4193 | } | |
4194 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4195 | } | |
4196 | ||
4197 | /* This peer belongs to peer group. */ | |
4198 | switch (ret) { | |
4199 | case BGP_ERR_PEER_GROUP_MEMBER: | |
4200 | vty_out(vty, | |
4201 | "%% Peer-group member cannot override remote-as of peer-group\n"); | |
4202 | return CMD_WARNING_CONFIG_FAILED; | |
4203 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
4204 | vty_out(vty, | |
4205 | "%% Peer-group members must be all internal or all external\n"); | |
4206 | return CMD_WARNING_CONFIG_FAILED; | |
4207 | } | |
4208 | return bgp_vty_return(vty, ret); | |
4209 | } | |
4210 | ||
1ca2fd11 IR |
4211 | DEFUN (bgp_default_shutdown, |
4212 | bgp_default_shutdown_cmd, | |
4213 | "[no] bgp default shutdown", | |
4214 | NO_STR | |
4215 | BGP_STR | |
4216 | "Configure BGP defaults\n" | |
4217 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4218 | { |
1ca2fd11 IR |
4219 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4220 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4221 | return CMD_SUCCESS; | |
f26845f9 QY |
4222 | } |
4223 | ||
736b68f3 DS |
4224 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4225 | BGP_STR | |
9ddf4b81 | 4226 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4227 | "Add a shutdown message (RFC 8203)\n" |
4228 | "Shutdown message\n") | |
9cf59432 | 4229 | { |
736b68f3 | 4230 | char *msgstr = NULL; |
8389c83a | 4231 | |
9cf59432 DS |
4232 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4233 | ||
8389c83a | 4234 | if (argc > 3) |
f80e35b6 | 4235 | msgstr = argv_concat(argv, argc, 3); |
8389c83a | 4236 | |
b776f48c DA |
4237 | if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) { |
4238 | vty_out(vty, "%% Shutdown message size exceeded %d\n", | |
4239 | BGP_ADMIN_SHUTDOWN_MSG_LEN); | |
4240 | return CMD_WARNING_CONFIG_FAILED; | |
4241 | } | |
4242 | ||
8389c83a DS |
4243 | bgp_shutdown_enable(bgp, msgstr); |
4244 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4245 | |
4246 | return CMD_SUCCESS; | |
4247 | } | |
4248 | ||
736b68f3 | 4249 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4250 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4251 | { |
4252 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4253 | ||
4254 | bgp_shutdown_enable(bgp, NULL); | |
4255 | ||
4256 | return CMD_SUCCESS; | |
4257 | } | |
8389c83a | 4258 | |
736b68f3 | 4259 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4260 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4261 | { |
4262 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4263 | ||
4264 | bgp_shutdown_disable(bgp); | |
4265 | ||
4266 | return CMD_SUCCESS; | |
4267 | } | |
4268 | ||
9ddf4b81 | 4269 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4270 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4271 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4272 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4273 | |
28c6e247 IR |
4274 | DEFUN (neighbor_remote_as, |
4275 | neighbor_remote_as_cmd, | |
4276 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4277 | NEIGHBOR_STR | |
4278 | NEIGHBOR_ADDR_STR2 | |
4279 | "Specify a BGP neighbor\n" | |
4280 | AS_STR | |
4281 | "Internal BGP peer\n" | |
4282 | "External BGP peer\n") | |
718e3744 | 4283 | { |
d62a17ae | 4284 | int idx_peer = 1; |
4285 | int idx_remote_as = 3; | |
28c6e247 IR |
4286 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4287 | argv[idx_remote_as]->arg); | |
d62a17ae | 4288 | } |
f852eb98 PG |
4289 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4290 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4291 | * when nexthop becomes unreachable | |
4292 | */ | |
4293 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4294 | BGP_STR "Fast convergence for bgp sessions\n") | |
4295 | { | |
4296 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4297 | bgp->fast_convergence = true; | |
4298 | ||
4299 | return CMD_SUCCESS; | |
4300 | } | |
4301 | ||
4302 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4303 | "no bgp fast-convergence", | |
4304 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4305 | { | |
4306 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4307 | bgp->fast_convergence = false; | |
4308 | ||
4309 | return CMD_SUCCESS; | |
4310 | } | |
d62a17ae | 4311 | |
28c6e247 IR |
4312 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4313 | int v6only, | |
4314 | const char *peer_group_name, | |
4315 | const char *as_str) | |
d62a17ae | 4316 | { |
28c6e247 IR |
4317 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4318 | as_t as = 0; | |
4319 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4320 | struct peer *peer; |
4321 | struct peer_group *group; | |
4322 | int ret = 0; | |
d62a17ae | 4323 | |
4324 | group = peer_group_lookup(bgp, conf_if); | |
4325 | ||
4326 | if (group) { | |
28c6e247 IR |
4327 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4328 | return CMD_WARNING_CONFIG_FAILED; | |
4329 | } | |
4330 | ||
4331 | if (as_str) { | |
4332 | if (as_str[0] == 'i') { | |
4333 | as_type = AS_INTERNAL; | |
4334 | } else if (as_str[0] == 'e') { | |
4335 | as_type = AS_EXTERNAL; | |
4336 | } else { | |
4337 | /* Get AS number. */ | |
4338 | as = strtoul(as_str, NULL, 10); | |
4339 | as_type = AS_SPECIFIED; | |
4340 | } | |
d62a17ae | 4341 | } |
4342 | ||
4343 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4344 | if (peer) { | |
28c6e247 | 4345 | if (as_str) |
e84c59af | 4346 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4347 | } else { |
e84c59af DA |
4348 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4349 | NULL); | |
d62a17ae | 4350 | |
4351 | if (!peer) { | |
28c6e247 IR |
4352 | vty_out(vty, "%% BGP failed to create peer\n"); |
4353 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4354 | } |
4355 | ||
4356 | if (v6only) | |
527de3dc | 4357 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4358 | |
4359 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4360 | * this | |
4361 | * any unnumbered peer in order to not worry about run-time | |
4362 | * transitions | |
4363 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4364 | * address | |
4365 | * gets deleted later etc.) | |
4366 | */ | |
4367 | if (peer->ifp) | |
4368 | bgp_zebra_initiate_radv(bgp, peer); | |
4369 | } | |
4370 | ||
4371 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4372 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4373 | if (v6only) | |
527de3dc | 4374 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4375 | else |
527de3dc | 4376 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4377 | |
4378 | /* v6only flag changed. Reset bgp seesion */ | |
4379 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4380 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4381 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4382 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4383 | } else | |
4384 | bgp_session_reset(peer); | |
4385 | } | |
4386 | ||
9fb964de PM |
4387 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4388 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4389 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4390 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4391 | } |
d62a17ae | 4392 | |
4393 | if (peer_group_name) { | |
4394 | group = peer_group_lookup(bgp, peer_group_name); | |
4395 | if (!group) { | |
28c6e247 IR |
4396 | vty_out(vty, "%% Configure the peer-group first\n"); |
4397 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4398 | } |
4399 | ||
8395c1f8 | 4400 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4401 | } |
4402 | ||
28c6e247 | 4403 | return bgp_vty_return(vty, ret); |
a80beece DS |
4404 | } |
4405 | ||
28c6e247 IR |
4406 | DEFUN (neighbor_interface_config, |
4407 | neighbor_interface_config_cmd, | |
4408 | "neighbor WORD interface [peer-group PGNAME]", | |
4409 | NEIGHBOR_STR | |
4410 | "Interface name or neighbor tag\n" | |
4411 | "Enable BGP on interface\n" | |
4412 | "Member of the peer-group\n" | |
4413 | "Peer-group name\n") | |
4c48cf63 | 4414 | { |
d62a17ae | 4415 | int idx_word = 1; |
4416 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4417 | |
d62a17ae | 4418 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4419 | return peer_conf_interface_get( |
4420 | vty, argv[idx_word]->arg, 0, | |
4421 | argv[idx_peer_group_word]->arg, NULL); | |
4422 | else | |
4423 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4424 | NULL, NULL); | |
4c48cf63 DW |
4425 | } |
4426 | ||
28c6e247 IR |
4427 | DEFUN (neighbor_interface_config_v6only, |
4428 | neighbor_interface_config_v6only_cmd, | |
4429 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4430 | NEIGHBOR_STR | |
4431 | "Interface name or neighbor tag\n" | |
4432 | "Enable BGP on interface\n" | |
4433 | "Enable BGP with v6 link-local only\n" | |
4434 | "Member of the peer-group\n" | |
4435 | "Peer-group name\n") | |
4c48cf63 | 4436 | { |
d62a17ae | 4437 | int idx_word = 1; |
4438 | int idx_peer_group_word = 5; | |
31500417 | 4439 | |
d62a17ae | 4440 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4441 | return peer_conf_interface_get( |
4442 | vty, argv[idx_word]->arg, 1, | |
4443 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4444 | |
28c6e247 | 4445 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4446 | } |
4447 | ||
a80beece | 4448 | |
28c6e247 IR |
4449 | DEFUN (neighbor_interface_config_remote_as, |
4450 | neighbor_interface_config_remote_as_cmd, | |
4451 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4452 | NEIGHBOR_STR | |
4453 | "Interface name or neighbor tag\n" | |
4454 | "Enable BGP on interface\n" | |
4455 | "Specify a BGP neighbor\n" | |
4456 | AS_STR | |
4457 | "Internal BGP peer\n" | |
4458 | "External BGP peer\n") | |
b3a39dc5 | 4459 | { |
d62a17ae | 4460 | int idx_word = 1; |
4461 | int idx_remote_as = 4; | |
28c6e247 IR |
4462 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4463 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4464 | } |
4465 | ||
28c6e247 IR |
4466 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4467 | neighbor_interface_v6only_config_remote_as_cmd, | |
4468 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4469 | NEIGHBOR_STR | |
4470 | "Interface name or neighbor tag\n" | |
4471 | "Enable BGP with v6 link-local only\n" | |
4472 | "Enable BGP on interface\n" | |
4473 | "Specify a BGP neighbor\n" | |
4474 | AS_STR | |
4475 | "Internal BGP peer\n" | |
4476 | "External BGP peer\n") | |
b3a39dc5 | 4477 | { |
d62a17ae | 4478 | int idx_word = 1; |
4479 | int idx_remote_as = 5; | |
28c6e247 IR |
4480 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4481 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4482 | } |
4483 | ||
28c6e247 IR |
4484 | DEFUN (neighbor_peer_group, |
4485 | neighbor_peer_group_cmd, | |
4486 | "neighbor WORD peer-group", | |
4487 | NEIGHBOR_STR | |
4488 | "Interface name or neighbor tag\n" | |
4489 | "Configure peer-group\n") | |
718e3744 | 4490 | { |
28c6e247 | 4491 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4492 | int idx_word = 1; |
28c6e247 IR |
4493 | struct peer *peer; |
4494 | struct peer_group *group; | |
718e3744 | 4495 | |
28c6e247 IR |
4496 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4497 | if (peer) { | |
4498 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4499 | return CMD_WARNING_CONFIG_FAILED; | |
4500 | } | |
718e3744 | 4501 | |
28c6e247 IR |
4502 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4503 | if (!group) { | |
4504 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4505 | return CMD_WARNING_CONFIG_FAILED; | |
4506 | } | |
718e3744 | 4507 | |
28c6e247 | 4508 | return CMD_SUCCESS; |
718e3744 | 4509 | } |
4510 | ||
1d80f243 IR |
4511 | DEFUN (no_neighbor, |
4512 | no_neighbor_cmd, | |
4513 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4514 | NO_STR | |
4515 | NEIGHBOR_STR | |
4516 | NEIGHBOR_ADDR_STR2 | |
4517 | "Specify a BGP neighbor\n" | |
4518 | AS_STR | |
4519 | "Internal BGP peer\n" | |
4520 | "External BGP peer\n") | |
718e3744 | 4521 | { |
28c6e247 | 4522 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4523 | int idx_peer = 2; |
28c6e247 | 4524 | int ret; |
d62a17ae | 4525 | union sockunion su; |
28c6e247 IR |
4526 | struct peer_group *group; |
4527 | struct peer *peer; | |
4528 | struct peer *other; | |
d62a17ae | 4529 | |
28c6e247 IR |
4530 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4531 | if (ret < 0) { | |
4532 | /* look up for neighbor by interface name config. */ | |
4533 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4534 | if (peer) { | |
4535 | /* Request zebra to terminate IPv6 RAs on this | |
4536 | * interface. */ | |
4537 | if (peer->ifp) | |
4538 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4539 | peer_notify_unconfig(peer); | |
4540 | peer_delete(peer); | |
4541 | return CMD_SUCCESS; | |
d62a17ae | 4542 | } |
28c6e247 IR |
4543 | |
4544 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4545 | if (group) { | |
4546 | peer_group_notify_unconfig(group); | |
4547 | peer_group_delete(group); | |
4e2786df | 4548 | } else { |
28c6e247 | 4549 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4550 | return CMD_WARNING_CONFIG_FAILED; |
4551 | } | |
28c6e247 IR |
4552 | } else { |
4553 | peer = peer_lookup(bgp, &su); | |
4554 | if (peer) { | |
4555 | if (peer_dynamic_neighbor(peer)) { | |
4556 | vty_out(vty, | |
4557 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4558 | return CMD_WARNING_CONFIG_FAILED; | |
4559 | } | |
d62a17ae | 4560 | |
28c6e247 | 4561 | other = peer->doppelganger; |
f4b8ec07 | 4562 | |
28c6e247 IR |
4563 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4564 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4565 | |
28c6e247 IR |
4566 | peer_notify_unconfig(peer); |
4567 | peer_delete(peer); | |
4568 | if (other && other->status != Deleted) { | |
4569 | peer_notify_unconfig(other); | |
4570 | peer_delete(other); | |
4571 | } | |
4572 | } | |
4573 | } | |
4574 | ||
4575 | return CMD_SUCCESS; | |
a80beece DS |
4576 | } |
4577 | ||
28c6e247 IR |
4578 | DEFUN (no_neighbor_interface_config, |
4579 | no_neighbor_interface_config_cmd, | |
4580 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4581 | NO_STR | |
4582 | NEIGHBOR_STR | |
4583 | "Interface name\n" | |
4584 | "Configure BGP on interface\n" | |
4585 | "Enable BGP with v6 link-local only\n" | |
4586 | "Member of the peer-group\n" | |
4587 | "Peer-group name\n" | |
4588 | "Specify a BGP neighbor\n" | |
4589 | AS_STR | |
4590 | "Internal BGP peer\n" | |
4591 | "External BGP peer\n") | |
718e3744 | 4592 | { |
28c6e247 | 4593 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4594 | int idx_word = 2; |
28c6e247 | 4595 | struct peer *peer; |
718e3744 | 4596 | |
28c6e247 IR |
4597 | /* look up for neighbor by interface name config. */ |
4598 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4599 | if (peer) { | |
4600 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4601 | if (peer->ifp) | |
4602 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4603 | peer_notify_unconfig(peer); | |
4604 | peer_delete(peer); | |
4605 | } else { | |
4606 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4607 | return CMD_WARNING_CONFIG_FAILED; | |
4608 | } | |
4609 | return CMD_SUCCESS; | |
718e3744 | 4610 | } |
4611 | ||
28c6e247 IR |
4612 | DEFUN (no_neighbor_peer_group, |
4613 | no_neighbor_peer_group_cmd, | |
4614 | "no neighbor WORD peer-group", | |
4615 | NO_STR | |
4616 | NEIGHBOR_STR | |
4617 | "Neighbor tag\n" | |
4618 | "Configure peer-group\n") | |
718e3744 | 4619 | { |
28c6e247 IR |
4620 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4621 | int idx_word = 2; | |
4622 | struct peer_group *group; | |
f4b8ec07 | 4623 | |
28c6e247 IR |
4624 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4625 | if (group) { | |
4626 | peer_group_notify_unconfig(group); | |
4627 | peer_group_delete(group); | |
f4b8ec07 | 4628 | } else { |
28c6e247 | 4629 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4630 | return CMD_WARNING_CONFIG_FAILED; |
4631 | } | |
28c6e247 IR |
4632 | return CMD_SUCCESS; |
4633 | } | |
f4b8ec07 | 4634 | |
28c6e247 IR |
4635 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4636 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4637 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4638 | NO_STR | |
4639 | NEIGHBOR_STR | |
4640 | "Interface name or neighbor tag\n" | |
4641 | "Specify a BGP neighbor\n" | |
4642 | AS_STR | |
4643 | "Internal BGP peer\n" | |
4644 | "External BGP peer\n") | |
4645 | { | |
4646 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4647 | int idx_word = 2; | |
4648 | struct peer_group *group; | |
4649 | struct peer *peer; | |
f4b8ec07 | 4650 | |
28c6e247 IR |
4651 | /* look up for neighbor by interface name config. */ |
4652 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4653 | if (peer) { | |
4654 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4655 | return CMD_SUCCESS; | |
4656 | } | |
f4b8ec07 | 4657 | |
28c6e247 IR |
4658 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4659 | if (group) | |
4660 | peer_group_remote_as_delete(group); | |
4661 | else { | |
4662 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4663 | return CMD_WARNING_CONFIG_FAILED; | |
4664 | } | |
4665 | return CMD_SUCCESS; | |
718e3744 | 4666 | } |
6b0655a2 | 4667 | |
28c6e247 IR |
4668 | DEFUN (neighbor_local_as, |
4669 | neighbor_local_as_cmd, | |
4670 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4671 | NEIGHBOR_STR | |
4672 | NEIGHBOR_ADDR_STR2 | |
4673 | "Specify a local-as number\n" | |
4674 | "AS number used as local AS\n") | |
718e3744 | 4675 | { |
d62a17ae | 4676 | int idx_peer = 1; |
4677 | int idx_number = 3; | |
28c6e247 IR |
4678 | struct peer *peer; |
4679 | int ret; | |
4680 | as_t as; | |
718e3744 | 4681 | |
28c6e247 IR |
4682 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4683 | if (!peer) | |
d62a17ae | 4684 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4685 | |
28c6e247 IR |
4686 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4687 | ret = peer_local_as_set(peer, as, 0, 0); | |
4688 | return bgp_vty_return(vty, ret); | |
718e3744 | 4689 | } |
4690 | ||
28c6e247 IR |
4691 | DEFUN (neighbor_local_as_no_prepend, |
4692 | neighbor_local_as_no_prepend_cmd, | |
4693 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4694 | NEIGHBOR_STR | |
4695 | NEIGHBOR_ADDR_STR2 | |
4696 | "Specify a local-as number\n" | |
4697 | "AS number used as local AS\n" | |
4698 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4699 | { |
d62a17ae | 4700 | int idx_peer = 1; |
4701 | int idx_number = 3; | |
28c6e247 IR |
4702 | struct peer *peer; |
4703 | int ret; | |
4704 | as_t as; | |
718e3744 | 4705 | |
28c6e247 IR |
4706 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4707 | if (!peer) | |
d62a17ae | 4708 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4709 | |
28c6e247 IR |
4710 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4711 | ret = peer_local_as_set(peer, as, 1, 0); | |
4712 | return bgp_vty_return(vty, ret); | |
718e3744 | 4713 | } |
4714 | ||
28c6e247 IR |
4715 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4716 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4717 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4718 | NEIGHBOR_STR | |
4719 | NEIGHBOR_ADDR_STR2 | |
4720 | "Specify a local-as number\n" | |
4721 | "AS number used as local AS\n" | |
4722 | "Do not prepend local-as to updates from ebgp peers\n" | |
4723 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4724 | { |
d62a17ae | 4725 | int idx_peer = 1; |
4726 | int idx_number = 3; | |
28c6e247 IR |
4727 | struct peer *peer; |
4728 | int ret; | |
4729 | as_t as; | |
9d3f9705 | 4730 | |
28c6e247 IR |
4731 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4732 | if (!peer) | |
d62a17ae | 4733 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4734 | |
28c6e247 IR |
4735 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4736 | ret = peer_local_as_set(peer, as, 1, 1); | |
4737 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4738 | } |
4739 | ||
28c6e247 IR |
4740 | DEFUN (no_neighbor_local_as, |
4741 | no_neighbor_local_as_cmd, | |
4742 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4743 | NO_STR | |
4744 | NEIGHBOR_STR | |
4745 | NEIGHBOR_ADDR_STR2 | |
4746 | "Specify a local-as number\n" | |
4747 | "AS number used as local AS\n" | |
4748 | "Do not prepend local-as to updates from ebgp peers\n" | |
4749 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4750 | { |
d62a17ae | 4751 | int idx_peer = 2; |
28c6e247 IR |
4752 | struct peer *peer; |
4753 | int ret; | |
718e3744 | 4754 | |
28c6e247 IR |
4755 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4756 | if (!peer) | |
d62a17ae | 4757 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4758 | |
28c6e247 IR |
4759 | ret = peer_local_as_unset(peer); |
4760 | return bgp_vty_return(vty, ret); | |
718e3744 | 4761 | } |
4762 | ||
718e3744 | 4763 | |
3f9c7369 DS |
4764 | DEFUN (neighbor_solo, |
4765 | neighbor_solo_cmd, | |
9ccf14f7 | 4766 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4767 | NEIGHBOR_STR |
4768 | NEIGHBOR_ADDR_STR2 | |
4769 | "Solo peer - part of its own update group\n") | |
4770 | { | |
d62a17ae | 4771 | int idx_peer = 1; |
4772 | struct peer *peer; | |
4773 | int ret; | |
3f9c7369 | 4774 | |
d62a17ae | 4775 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4776 | if (!peer) | |
4777 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4778 | |
d62a17ae | 4779 | ret = update_group_adjust_soloness(peer, 1); |
4780 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4781 | } |
4782 | ||
4783 | DEFUN (no_neighbor_solo, | |
4784 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4786 | NO_STR |
4787 | NEIGHBOR_STR | |
4788 | NEIGHBOR_ADDR_STR2 | |
4789 | "Solo peer - part of its own update group\n") | |
4790 | { | |
d62a17ae | 4791 | int idx_peer = 2; |
4792 | struct peer *peer; | |
4793 | int ret; | |
3f9c7369 | 4794 | |
d62a17ae | 4795 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4796 | if (!peer) | |
4797 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4798 | |
d62a17ae | 4799 | ret = update_group_adjust_soloness(peer, 0); |
4800 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4801 | } |
4802 | ||
28c6e247 IR |
4803 | DEFUN (neighbor_password, |
4804 | neighbor_password_cmd, | |
4805 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4806 | NEIGHBOR_STR | |
4807 | NEIGHBOR_ADDR_STR2 | |
4808 | "Set a password\n" | |
4809 | "The password\n") | |
0df7c91f | 4810 | { |
d62a17ae | 4811 | int idx_peer = 1; |
4812 | int idx_line = 3; | |
28c6e247 IR |
4813 | struct peer *peer; |
4814 | int ret; | |
0df7c91f | 4815 | |
28c6e247 IR |
4816 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4817 | if (!peer) | |
d62a17ae | 4818 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4819 | |
28c6e247 IR |
4820 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4821 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4822 | } |
4823 | ||
28c6e247 IR |
4824 | DEFUN (no_neighbor_password, |
4825 | no_neighbor_password_cmd, | |
4826 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4827 | NO_STR | |
4828 | NEIGHBOR_STR | |
4829 | NEIGHBOR_ADDR_STR2 | |
4830 | "Set a password\n" | |
4831 | "The password\n") | |
0df7c91f | 4832 | { |
d62a17ae | 4833 | int idx_peer = 2; |
28c6e247 IR |
4834 | struct peer *peer; |
4835 | int ret; | |
0df7c91f | 4836 | |
28c6e247 IR |
4837 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4838 | if (!peer) | |
d62a17ae | 4839 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4840 | |
28c6e247 IR |
4841 | ret = peer_password_unset(peer); |
4842 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4843 | } |
6b0655a2 | 4844 | |
28c6e247 IR |
4845 | DEFUN (neighbor_activate, |
4846 | neighbor_activate_cmd, | |
4847 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4848 | NEIGHBOR_STR | |
4849 | NEIGHBOR_ADDR_STR2 | |
4850 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4851 | { |
d62a17ae | 4852 | int idx_peer = 1; |
28c6e247 IR |
4853 | int ret; |
4854 | struct peer *peer; | |
56ceae84 | 4855 | |
28c6e247 IR |
4856 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4857 | if (!peer) | |
d62a17ae | 4858 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4859 | |
28c6e247 IR |
4860 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4861 | return bgp_vty_return(vty, ret); | |
718e3744 | 4862 | } |
4863 | ||
d62a17ae | 4864 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4865 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4866 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4867 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4868 | |
28c6e247 IR |
4869 | DEFUN (no_neighbor_activate, |
4870 | no_neighbor_activate_cmd, | |
4871 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4872 | NO_STR | |
4873 | NEIGHBOR_STR | |
4874 | NEIGHBOR_ADDR_STR2 | |
4875 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4876 | { |
d62a17ae | 4877 | int idx_peer = 2; |
28c6e247 IR |
4878 | int ret; |
4879 | struct peer *peer; | |
f4b8ec07 | 4880 | |
28c6e247 IR |
4881 | /* Lookup peer. */ |
4882 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4883 | if (!peer) | |
d62a17ae | 4884 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4885 | |
28c6e247 IR |
4886 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4887 | return bgp_vty_return(vty, ret); | |
718e3744 | 4888 | } |
6b0655a2 | 4889 | |
d62a17ae | 4890 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4891 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4892 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4893 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4894 | |
28c6e247 IR |
4895 | DEFUN (neighbor_set_peer_group, |
4896 | neighbor_set_peer_group_cmd, | |
4897 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4898 | NEIGHBOR_STR | |
4899 | NEIGHBOR_ADDR_STR2 | |
4900 | "Member of the peer-group\n" | |
4901 | "Peer-group name\n") | |
718e3744 | 4902 | { |
28c6e247 | 4903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4904 | int idx_peer = 1; |
4905 | int idx_word = 3; | |
28c6e247 IR |
4906 | int ret; |
4907 | as_t as; | |
4908 | union sockunion su; | |
4909 | struct peer *peer; | |
4910 | struct peer_group *group; | |
4911 | ||
4912 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4913 | if (ret < 0) { | |
4914 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4915 | if (!peer) { | |
4916 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4917 | argv[idx_peer]->arg); | |
4918 | return CMD_WARNING_CONFIG_FAILED; | |
4919 | } | |
4920 | } else { | |
4921 | if (peer_address_self_check(bgp, &su)) { | |
4922 | vty_out(vty, | |
4923 | "%% Can not configure the local system as neighbor\n"); | |
4924 | return CMD_WARNING_CONFIG_FAILED; | |
4925 | } | |
2a059a54 | 4926 | |
28c6e247 IR |
4927 | /* Disallow for dynamic neighbor. */ |
4928 | peer = peer_lookup(bgp, &su); | |
4929 | if (peer && peer_dynamic_neighbor(peer)) { | |
4930 | vty_out(vty, | |
4931 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4932 | return CMD_WARNING_CONFIG_FAILED; | |
4933 | } | |
4934 | } | |
4935 | ||
4936 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4937 | if (!group) { | |
4938 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 4939 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 4940 | } |
d62a17ae | 4941 | |
28c6e247 | 4942 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 4943 | |
28c6e247 IR |
4944 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { |
4945 | vty_out(vty, | |
4946 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4947 | as); | |
4948 | return CMD_WARNING_CONFIG_FAILED; | |
4949 | } | |
4950 | ||
4951 | return bgp_vty_return(vty, ret); | |
d62a17ae | 4952 | } |
4953 | ||
4954 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4955 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4956 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4957 | "Member of the peer-group\n" | |
4958 | "Peer-group name\n") | |
596c17ba | 4959 | |
28c6e247 IR |
4960 | DEFUN (no_neighbor_set_peer_group, |
4961 | no_neighbor_set_peer_group_cmd, | |
4962 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4963 | NO_STR | |
4964 | NEIGHBOR_STR | |
4965 | NEIGHBOR_ADDR_STR2 | |
4966 | "Member of the peer-group\n" | |
4967 | "Peer-group name\n") | |
718e3744 | 4968 | { |
28c6e247 | 4969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4970 | int idx_peer = 2; |
28c6e247 IR |
4971 | int idx_word = 4; |
4972 | int ret; | |
4973 | struct peer *peer; | |
4974 | struct peer_group *group; | |
d62a17ae | 4975 | |
28c6e247 IR |
4976 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
4977 | if (!peer) | |
d62a17ae | 4978 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 4979 | |
28c6e247 IR |
4980 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4981 | if (!group) { | |
4982 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4983 | return CMD_WARNING_CONFIG_FAILED; | |
4984 | } | |
718e3744 | 4985 | |
28c6e247 IR |
4986 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4987 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4988 | ||
4989 | peer_notify_unconfig(peer); | |
4990 | ret = peer_delete(peer); | |
4991 | ||
4992 | return bgp_vty_return(vty, ret); | |
718e3744 | 4993 | } |
6b0655a2 | 4994 | |
d62a17ae | 4995 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 4996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4997 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4998 | "Member of the peer-group\n" | |
4999 | "Peer-group name\n") | |
596c17ba | 5000 | |
d62a17ae | 5001 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5002 | uint32_t flag, int set) |
718e3744 | 5003 | { |
d62a17ae | 5004 | int ret; |
5005 | struct peer *peer; | |
718e3744 | 5006 | |
d62a17ae | 5007 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5008 | if (!peer) | |
5009 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5010 | |
7ebe625c QY |
5011 | /* |
5012 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5013 | * we should not accept disable-connected-check. | |
5014 | */ | |
5015 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5016 | vty_out(vty, | |
3efd0893 | 5017 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
5018 | ip_str); |
5019 | return CMD_WARNING_CONFIG_FAILED; | |
5020 | } | |
5021 | ||
d62a17ae | 5022 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
5023 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 5024 | |
d62a17ae | 5025 | if (set) |
5026 | ret = peer_flag_set(peer, flag); | |
5027 | else | |
5028 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 5029 | |
d62a17ae | 5030 | return bgp_vty_return(vty, ret); |
718e3744 | 5031 | } |
5032 | ||
47cbc09b | 5033 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 5034 | { |
d62a17ae | 5035 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5036 | } |
5037 | ||
d62a17ae | 5038 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5039 | uint32_t flag) |
718e3744 | 5040 | { |
d62a17ae | 5041 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5042 | } |
5043 | ||
5044 | /* neighbor passive. */ | |
28c6e247 IR |
5045 | DEFUN (neighbor_passive, |
5046 | neighbor_passive_cmd, | |
5047 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5048 | NEIGHBOR_STR | |
5049 | NEIGHBOR_ADDR_STR2 | |
5050 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5051 | { |
d62a17ae | 5052 | int idx_peer = 1; |
28c6e247 | 5053 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5054 | } |
5055 | ||
28c6e247 IR |
5056 | DEFUN (no_neighbor_passive, |
5057 | no_neighbor_passive_cmd, | |
5058 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5059 | NO_STR | |
5060 | NEIGHBOR_STR | |
5061 | NEIGHBOR_ADDR_STR2 | |
5062 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5063 | { |
d62a17ae | 5064 | int idx_peer = 2; |
28c6e247 | 5065 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5066 | } |
6b0655a2 | 5067 | |
718e3744 | 5068 | /* neighbor shutdown. */ |
28c6e247 IR |
5069 | DEFUN (neighbor_shutdown_msg, |
5070 | neighbor_shutdown_msg_cmd, | |
5071 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5072 | NEIGHBOR_STR | |
5073 | NEIGHBOR_ADDR_STR2 | |
5074 | "Administratively shut down this neighbor\n" | |
5075 | "Add a shutdown message (RFC 8203)\n" | |
5076 | "Shutdown message\n") | |
718e3744 | 5077 | { |
d62a17ae | 5078 | int idx_peer = 1; |
73d70fa6 | 5079 | |
d62a17ae | 5080 | if (argc >= 5) { |
28c6e247 IR |
5081 | struct peer *peer = |
5082 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5083 | char *message; |
73d70fa6 | 5084 | |
28c6e247 IR |
5085 | if (!peer) |
5086 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5087 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5088 | peer_tx_shutdown_message_set(peer, message); |
5089 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5090 | } |
73d70fa6 | 5091 | |
28c6e247 | 5092 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5093 | } |
5094 | ||
1d80f243 | 5095 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5096 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5097 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5098 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5099 | |
28c6e247 IR |
5100 | DEFUN (no_neighbor_shutdown_msg, |
5101 | no_neighbor_shutdown_msg_cmd, | |
5102 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5103 | NO_STR | |
5104 | NEIGHBOR_STR | |
5105 | NEIGHBOR_ADDR_STR2 | |
5106 | "Administratively shut down this neighbor\n" | |
5107 | "Remove a shutdown message (RFC 8203)\n" | |
5108 | "Shutdown message\n") | |
718e3744 | 5109 | { |
d62a17ae | 5110 | int idx_peer = 2; |
73d70fa6 | 5111 | |
28c6e247 IR |
5112 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5113 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5114 | } |
6b0655a2 | 5115 | |
1d80f243 | 5116 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5118 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5119 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5120 | |
8336c896 DA |
5121 | DEFUN(neighbor_shutdown_rtt, |
5122 | neighbor_shutdown_rtt_cmd, | |
5123 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5124 | NEIGHBOR_STR | |
5125 | NEIGHBOR_ADDR_STR2 | |
5126 | "Administratively shut down this neighbor\n" | |
5127 | "Shutdown if round-trip-time is higher than expected\n" | |
5128 | "Round-trip-time in milliseconds\n" | |
5129 | "Specify the number of keepalives before shutdown\n" | |
5130 | "The number of keepalives with higher RTT to shutdown\n") | |
5131 | { | |
5132 | int idx_peer = 1; | |
5133 | int idx_rtt = 4; | |
5134 | int idx_count = 0; | |
5135 | struct peer *peer; | |
5136 | ||
5137 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5138 | ||
5139 | if (!peer) | |
5140 | return CMD_WARNING_CONFIG_FAILED; | |
5141 | ||
5142 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5143 | ||
5144 | if (argv_find(argv, argc, "count", &idx_count)) | |
5145 | peer->rtt_keepalive_conf = | |
5146 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5147 | ||
5148 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5149 | PEER_FLAG_RTT_SHUTDOWN); | |
5150 | } | |
5151 | ||
5152 | DEFUN(no_neighbor_shutdown_rtt, | |
5153 | no_neighbor_shutdown_rtt_cmd, | |
5154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5155 | NO_STR | |
5156 | NEIGHBOR_STR | |
5157 | NEIGHBOR_ADDR_STR2 | |
5158 | "Administratively shut down this neighbor\n" | |
5159 | "Shutdown if round-trip-time is higher than expected\n" | |
5160 | "Round-trip-time in milliseconds\n" | |
5161 | "Specify the number of keepalives before shutdown\n" | |
5162 | "The number of keepalives with higher RTT to shutdown\n") | |
5163 | { | |
5164 | int idx_peer = 2; | |
5165 | struct peer *peer; | |
5166 | ||
5167 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5168 | ||
5169 | if (!peer) | |
5170 | return CMD_WARNING_CONFIG_FAILED; | |
5171 | ||
5172 | peer->rtt_expected = 0; | |
5173 | peer->rtt_keepalive_conf = 1; | |
5174 | ||
5175 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5176 | PEER_FLAG_RTT_SHUTDOWN); | |
5177 | } | |
5178 | ||
718e3744 | 5179 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5180 | DEFUN (neighbor_capability_dynamic, |
5181 | neighbor_capability_dynamic_cmd, | |
5182 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5183 | NEIGHBOR_STR | |
5184 | NEIGHBOR_ADDR_STR2 | |
5185 | "Advertise capability to the peer\n" | |
5186 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5187 | { |
d62a17ae | 5188 | int idx_peer = 1; |
28c6e247 IR |
5189 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5190 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5191 | } |
5192 | ||
28c6e247 IR |
5193 | DEFUN (no_neighbor_capability_dynamic, |
5194 | no_neighbor_capability_dynamic_cmd, | |
5195 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5196 | NO_STR | |
5197 | NEIGHBOR_STR | |
5198 | NEIGHBOR_ADDR_STR2 | |
5199 | "Advertise capability to the peer\n" | |
5200 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5201 | { |
d62a17ae | 5202 | int idx_peer = 2; |
28c6e247 IR |
5203 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5204 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5205 | } |
6b0655a2 | 5206 | |
718e3744 | 5207 | /* neighbor dont-capability-negotiate */ |
5208 | DEFUN (neighbor_dont_capability_negotiate, | |
5209 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5210 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5211 | NEIGHBOR_STR |
5212 | NEIGHBOR_ADDR_STR2 | |
5213 | "Do not perform capability negotiation\n") | |
5214 | { | |
d62a17ae | 5215 | int idx_peer = 1; |
5216 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5217 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5218 | } |
5219 | ||
5220 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5221 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5222 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5223 | NO_STR |
5224 | NEIGHBOR_STR | |
5225 | NEIGHBOR_ADDR_STR2 | |
5226 | "Do not perform capability negotiation\n") | |
5227 | { | |
28c6e247 IR |
5228 | int idx_peer = 2; |
5229 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5230 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5231 | } |
5232 | ||
28c6e247 IR |
5233 | /* neighbor capability extended next hop encoding */ |
5234 | DEFUN (neighbor_capability_enhe, | |
5235 | neighbor_capability_enhe_cmd, | |
5236 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5237 | NEIGHBOR_STR | |
5238 | NEIGHBOR_ADDR_STR2 | |
5239 | "Advertise capability to the peer\n" | |
5240 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5241 | { |
28c6e247 IR |
5242 | int idx_peer = 1; |
5243 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5244 | PEER_FLAG_CAPABILITY_ENHE); | |
5245 | } | |
f4b8ec07 | 5246 | |
28c6e247 IR |
5247 | DEFUN (no_neighbor_capability_enhe, |
5248 | no_neighbor_capability_enhe_cmd, | |
5249 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5250 | NO_STR | |
5251 | NEIGHBOR_STR | |
5252 | NEIGHBOR_ADDR_STR2 | |
5253 | "Advertise capability to the peer\n" | |
5254 | "Advertise extended next-hop capability to the peer\n") | |
5255 | { | |
5256 | int idx_peer = 2; | |
5257 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5258 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5259 | } |
5260 | ||
d62a17ae | 5261 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5262 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5263 | int set) |
718e3744 | 5264 | { |
d62a17ae | 5265 | int ret; |
5266 | struct peer *peer; | |
718e3744 | 5267 | |
d62a17ae | 5268 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5269 | if (!peer) | |
5270 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5271 | |
d62a17ae | 5272 | if (set) |
5273 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5274 | else | |
5275 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5276 | |
d62a17ae | 5277 | return bgp_vty_return(vty, ret); |
718e3744 | 5278 | } |
5279 | ||
d62a17ae | 5280 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5281 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5282 | { |
d62a17ae | 5283 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5284 | } |
5285 | ||
d62a17ae | 5286 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5287 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5288 | { |
d62a17ae | 5289 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5290 | } |
6b0655a2 | 5291 | |
718e3744 | 5292 | /* neighbor capability orf prefix-list. */ |
5293 | DEFUN (neighbor_capability_orf_prefix, | |
5294 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5295 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5296 | NEIGHBOR_STR |
5297 | NEIGHBOR_ADDR_STR2 | |
5298 | "Advertise capability to the peer\n" | |
5299 | "Advertise ORF capability to the peer\n" | |
5300 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5301 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5302 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5303 | "Capability to SEND the ORF to this neighbor\n") | |
5304 | { | |
d62a17ae | 5305 | int idx_send_recv = 5; |
db45f64d DS |
5306 | char *peer_str = argv[1]->arg; |
5307 | struct peer *peer; | |
5308 | afi_t afi = bgp_node_afi(vty); | |
5309 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5310 | |
db45f64d DS |
5311 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5312 | if (!peer) | |
d62a17ae | 5313 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5314 | |
db45f64d DS |
5315 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5316 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5317 | PEER_FLAG_ORF_PREFIX_SM); | |
5318 | ||
5319 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5320 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5321 | PEER_FLAG_ORF_PREFIX_RM); | |
5322 | ||
5323 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5324 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5325 | PEER_FLAG_ORF_PREFIX_SM) | |
5326 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5327 | PEER_FLAG_ORF_PREFIX_RM); | |
5328 | ||
5329 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5330 | } |
5331 | ||
5332 | ALIAS_HIDDEN( | |
5333 | neighbor_capability_orf_prefix, | |
5334 | neighbor_capability_orf_prefix_hidden_cmd, | |
5335 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5336 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5337 | "Advertise capability to the peer\n" | |
5338 | "Advertise ORF capability to the peer\n" | |
5339 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5340 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5341 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5342 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5343 | |
718e3744 | 5344 | DEFUN (no_neighbor_capability_orf_prefix, |
5345 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5346 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5347 | NO_STR |
5348 | NEIGHBOR_STR | |
5349 | NEIGHBOR_ADDR_STR2 | |
5350 | "Advertise capability to the peer\n" | |
5351 | "Advertise ORF capability to the peer\n" | |
5352 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5353 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5354 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5355 | "Capability to SEND the ORF to this neighbor\n") | |
5356 | { | |
d62a17ae | 5357 | int idx_send_recv = 6; |
db45f64d DS |
5358 | char *peer_str = argv[2]->arg; |
5359 | struct peer *peer; | |
5360 | afi_t afi = bgp_node_afi(vty); | |
5361 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5362 | |
db45f64d DS |
5363 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5364 | if (!peer) | |
d62a17ae | 5365 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5366 | |
db45f64d DS |
5367 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5368 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5369 | PEER_FLAG_ORF_PREFIX_SM); | |
5370 | ||
5371 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5372 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5373 | PEER_FLAG_ORF_PREFIX_RM); | |
5374 | ||
5375 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5376 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5377 | PEER_FLAG_ORF_PREFIX_SM) | |
5378 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5379 | PEER_FLAG_ORF_PREFIX_RM); | |
5380 | ||
5381 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5382 | } |
5383 | ||
5384 | ALIAS_HIDDEN( | |
5385 | no_neighbor_capability_orf_prefix, | |
5386 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5387 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5388 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5389 | "Advertise capability to the peer\n" | |
5390 | "Advertise ORF capability to the peer\n" | |
5391 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5392 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5393 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5394 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5395 | |
718e3744 | 5396 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5397 | DEFUN (neighbor_nexthop_self, |
5398 | neighbor_nexthop_self_cmd, | |
5399 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5400 | NEIGHBOR_STR | |
5401 | NEIGHBOR_ADDR_STR2 | |
5402 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5403 | { |
d62a17ae | 5404 | int idx_peer = 1; |
28c6e247 IR |
5405 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5406 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5407 | } |
9e7a53c1 | 5408 | |
d62a17ae | 5409 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5410 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5411 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5412 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5413 | |
f4b8ec07 | 5414 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5415 | DEFUN (neighbor_nexthop_self_force, |
5416 | neighbor_nexthop_self_force_cmd, | |
5417 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5418 | NEIGHBOR_STR | |
5419 | NEIGHBOR_ADDR_STR2 | |
5420 | "Disable the next hop calculation for this neighbor\n" | |
5421 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5422 | { |
5423 | int idx_peer = 1; | |
28c6e247 IR |
5424 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5425 | bgp_node_safi(vty), | |
5426 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5427 | } |
5428 | ||
d62a17ae | 5429 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5430 | neighbor_nexthop_self_force_hidden_cmd, | |
5431 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5432 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5433 | "Disable the next hop calculation for this neighbor\n" | |
5434 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5435 | |
1bc4e531 DA |
5436 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5437 | neighbor_nexthop_self_all_hidden_cmd, | |
5438 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5439 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5440 | "Disable the next hop calculation for this neighbor\n" | |
5441 | "Set the next hop to self for reflected routes\n") | |
5442 | ||
28c6e247 IR |
5443 | DEFUN (no_neighbor_nexthop_self, |
5444 | no_neighbor_nexthop_self_cmd, | |
5445 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5446 | NO_STR | |
5447 | NEIGHBOR_STR | |
5448 | NEIGHBOR_ADDR_STR2 | |
5449 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5450 | { |
d62a17ae | 5451 | int idx_peer = 2; |
28c6e247 IR |
5452 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5453 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5454 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5455 | } |
6b0655a2 | 5456 | |
d62a17ae | 5457 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5458 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5459 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5460 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5461 | |
28c6e247 IR |
5462 | DEFUN (no_neighbor_nexthop_self_force, |
5463 | no_neighbor_nexthop_self_force_cmd, | |
5464 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5465 | NO_STR | |
5466 | NEIGHBOR_STR | |
5467 | NEIGHBOR_ADDR_STR2 | |
5468 | "Disable the next hop calculation for this neighbor\n" | |
5469 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5470 | { |
d62a17ae | 5471 | int idx_peer = 2; |
28c6e247 IR |
5472 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5473 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5474 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5475 | } |
a538debe | 5476 | |
d62a17ae | 5477 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5478 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5479 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5480 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5481 | "Disable the next hop calculation for this neighbor\n" | |
5482 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5483 | |
1bc4e531 DA |
5484 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5485 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5486 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5487 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5488 | "Disable the next hop calculation for this neighbor\n" | |
5489 | "Set the next hop to self for reflected routes\n") | |
5490 | ||
c7122e14 | 5491 | /* neighbor as-override */ |
28c6e247 IR |
5492 | DEFUN (neighbor_as_override, |
5493 | neighbor_as_override_cmd, | |
5494 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5495 | NEIGHBOR_STR | |
5496 | NEIGHBOR_ADDR_STR2 | |
5497 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5498 | { |
d62a17ae | 5499 | int idx_peer = 1; |
28c6e247 IR |
5500 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5501 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5502 | } |
5503 | ||
d62a17ae | 5504 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5505 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5506 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5507 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5508 | |
28c6e247 IR |
5509 | DEFUN (no_neighbor_as_override, |
5510 | no_neighbor_as_override_cmd, | |
5511 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5512 | NO_STR | |
5513 | NEIGHBOR_STR | |
5514 | NEIGHBOR_ADDR_STR2 | |
5515 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5516 | { |
d62a17ae | 5517 | int idx_peer = 2; |
28c6e247 IR |
5518 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5519 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5520 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5521 | } |
5522 | ||
d62a17ae | 5523 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5524 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5525 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5526 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5527 | |
718e3744 | 5528 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5529 | DEFUN (neighbor_remove_private_as, |
5530 | neighbor_remove_private_as_cmd, | |
5531 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5532 | NEIGHBOR_STR | |
5533 | NEIGHBOR_ADDR_STR2 | |
5534 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5535 | { |
d62a17ae | 5536 | int idx_peer = 1; |
28c6e247 IR |
5537 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5538 | bgp_node_safi(vty), | |
5539 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5540 | } |
5541 | ||
d62a17ae | 5542 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5543 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5544 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5545 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5546 | |
28c6e247 IR |
5547 | DEFUN (neighbor_remove_private_as_all, |
5548 | neighbor_remove_private_as_all_cmd, | |
5549 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5550 | NEIGHBOR_STR | |
5551 | NEIGHBOR_ADDR_STR2 | |
5552 | "Remove private ASNs in outbound updates\n" | |
5553 | "Apply to all AS numbers\n") | |
5000f21c | 5554 | { |
d62a17ae | 5555 | int idx_peer = 1; |
28c6e247 IR |
5556 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5557 | bgp_node_safi(vty), | |
5558 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5559 | } |
5560 | ||
d62a17ae | 5561 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5562 | neighbor_remove_private_as_all_hidden_cmd, | |
5563 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5564 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5565 | "Remove private ASNs in outbound updates\n" | |
5566 | "Apply to all AS numbers") | |
596c17ba | 5567 | |
28c6e247 IR |
5568 | DEFUN (neighbor_remove_private_as_replace_as, |
5569 | neighbor_remove_private_as_replace_as_cmd, | |
5570 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5571 | NEIGHBOR_STR | |
5572 | NEIGHBOR_ADDR_STR2 | |
5573 | "Remove private ASNs in outbound updates\n" | |
5574 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5575 | { |
d62a17ae | 5576 | int idx_peer = 1; |
28c6e247 IR |
5577 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5578 | bgp_node_safi(vty), | |
5579 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5580 | } |
5581 | ||
d62a17ae | 5582 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5583 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5584 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5585 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5586 | "Remove private ASNs in outbound updates\n" | |
5587 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5588 | |
28c6e247 IR |
5589 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5590 | neighbor_remove_private_as_all_replace_as_cmd, | |
5591 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5592 | NEIGHBOR_STR | |
5593 | NEIGHBOR_ADDR_STR2 | |
5594 | "Remove private ASNs in outbound updates\n" | |
5595 | "Apply to all AS numbers\n" | |
5596 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5597 | { |
d62a17ae | 5598 | int idx_peer = 1; |
28c6e247 IR |
5599 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5600 | bgp_node_safi(vty), | |
5601 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5602 | } |
5603 | ||
d62a17ae | 5604 | ALIAS_HIDDEN( |
5605 | neighbor_remove_private_as_all_replace_as, | |
5606 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5607 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5608 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5609 | "Remove private ASNs in outbound updates\n" | |
5610 | "Apply to all AS numbers\n" | |
5611 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5612 | |
28c6e247 IR |
5613 | DEFUN (no_neighbor_remove_private_as, |
5614 | no_neighbor_remove_private_as_cmd, | |
5615 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5616 | NO_STR | |
5617 | NEIGHBOR_STR | |
5618 | NEIGHBOR_ADDR_STR2 | |
5619 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5620 | { |
d62a17ae | 5621 | int idx_peer = 2; |
28c6e247 IR |
5622 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5623 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5624 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5625 | } |
6b0655a2 | 5626 | |
d62a17ae | 5627 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5628 | no_neighbor_remove_private_as_hidden_cmd, | |
5629 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5630 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5631 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5632 | |
28c6e247 IR |
5633 | DEFUN (no_neighbor_remove_private_as_all, |
5634 | no_neighbor_remove_private_as_all_cmd, | |
5635 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5636 | NO_STR | |
5637 | NEIGHBOR_STR | |
5638 | NEIGHBOR_ADDR_STR2 | |
5639 | "Remove private ASNs in outbound updates\n" | |
5640 | "Apply to all AS numbers\n") | |
88b8ed8d | 5641 | { |
d62a17ae | 5642 | int idx_peer = 2; |
28c6e247 IR |
5643 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5644 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5645 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5646 | } |
5000f21c | 5647 | |
d62a17ae | 5648 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5649 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5650 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5651 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5652 | "Remove private ASNs in outbound updates\n" | |
5653 | "Apply to all AS numbers\n") | |
596c17ba | 5654 | |
28c6e247 IR |
5655 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5656 | no_neighbor_remove_private_as_replace_as_cmd, | |
5657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5658 | NO_STR | |
5659 | NEIGHBOR_STR | |
5660 | NEIGHBOR_ADDR_STR2 | |
5661 | "Remove private ASNs in outbound updates\n" | |
5662 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5663 | { |
d62a17ae | 5664 | int idx_peer = 2; |
28c6e247 IR |
5665 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5666 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5667 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5668 | } |
5000f21c | 5669 | |
d62a17ae | 5670 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5671 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5672 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5673 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5674 | "Remove private ASNs in outbound updates\n" | |
5675 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5676 | |
28c6e247 IR |
5677 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5678 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5679 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5680 | NO_STR | |
5681 | NEIGHBOR_STR | |
5682 | NEIGHBOR_ADDR_STR2 | |
5683 | "Remove private ASNs in outbound updates\n" | |
5684 | "Apply to all AS numbers\n" | |
5685 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5686 | { |
d62a17ae | 5687 | int idx_peer = 2; |
28c6e247 IR |
5688 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5689 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5690 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5691 | } |
5000f21c | 5692 | |
d62a17ae | 5693 | ALIAS_HIDDEN( |
5694 | no_neighbor_remove_private_as_all_replace_as, | |
5695 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5696 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5697 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5698 | "Remove private ASNs in outbound updates\n" | |
5699 | "Apply to all AS numbers\n" | |
5700 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5701 | |
5000f21c | 5702 | |
718e3744 | 5703 | /* neighbor send-community. */ |
28c6e247 IR |
5704 | DEFUN (neighbor_send_community, |
5705 | neighbor_send_community_cmd, | |
5706 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5707 | NEIGHBOR_STR | |
5708 | NEIGHBOR_ADDR_STR2 | |
5709 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5710 | { |
d62a17ae | 5711 | int idx_peer = 1; |
27c05d4d | 5712 | |
f63d4054 IR |
5713 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5714 | bgp_node_safi(vty), | |
5715 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5716 | } |
5717 | ||
d62a17ae | 5718 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5719 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5720 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5721 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5722 | |
28c6e247 IR |
5723 | DEFUN (no_neighbor_send_community, |
5724 | no_neighbor_send_community_cmd, | |
5725 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5726 | NO_STR | |
5727 | NEIGHBOR_STR | |
5728 | NEIGHBOR_ADDR_STR2 | |
5729 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5730 | { |
d62a17ae | 5731 | int idx_peer = 2; |
27c05d4d | 5732 | |
f63d4054 IR |
5733 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5734 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5735 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5736 | } |
6b0655a2 | 5737 | |
d62a17ae | 5738 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5740 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5741 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5742 | |
718e3744 | 5743 | /* neighbor send-community extended. */ |
28c6e247 IR |
5744 | DEFUN (neighbor_send_community_type, |
5745 | neighbor_send_community_type_cmd, | |
5746 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5747 | NEIGHBOR_STR | |
5748 | NEIGHBOR_ADDR_STR2 | |
5749 | "Send Community attribute to this neighbor\n" | |
5750 | "Send Standard and Extended Community attributes\n" | |
5751 | "Send Standard, Large and Extended Community attributes\n" | |
5752 | "Send Extended Community attributes\n" | |
5753 | "Send Standard Community attributes\n" | |
5754 | "Send Large Community attributes\n") | |
718e3744 | 5755 | { |
27c05d4d | 5756 | const char *type = argv[argc - 1]->text; |
db45f64d | 5757 | char *peer_str = argv[1]->arg; |
28c6e247 | 5758 | struct peer *peer; |
db45f64d | 5759 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 5760 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 5761 | |
28c6e247 IR |
5762 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5763 | if (!peer) | |
5764 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 5765 | |
28c6e247 IR |
5766 | if (strmatch(type, "standard")) |
5767 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5768 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5769 | |
28c6e247 IR |
5770 | if (strmatch(type, "extended")) |
5771 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5772 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5773 | |
28c6e247 IR |
5774 | if (strmatch(type, "large")) |
5775 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5776 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 5777 | |
28c6e247 IR |
5778 | if (strmatch(type, "both")) { |
5779 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5780 | PEER_FLAG_SEND_COMMUNITY) | |
5781 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5782 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5783 | } |
28c6e247 IR |
5784 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
5785 | PEER_FLAG_SEND_COMMUNITY) | |
5786 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5787 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5788 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5789 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5790 | } |
5791 | ||
5792 | ALIAS_HIDDEN( | |
5793 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5794 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5795 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5796 | "Send Community attribute to this neighbor\n" | |
5797 | "Send Standard and Extended Community attributes\n" | |
5798 | "Send Standard, Large and Extended Community attributes\n" | |
5799 | "Send Extended Community attributes\n" | |
5800 | "Send Standard Community attributes\n" | |
5801 | "Send Large Community attributes\n") | |
596c17ba | 5802 | |
28c6e247 IR |
5803 | DEFUN (no_neighbor_send_community_type, |
5804 | no_neighbor_send_community_type_cmd, | |
5805 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5806 | NO_STR | |
5807 | NEIGHBOR_STR | |
5808 | NEIGHBOR_ADDR_STR2 | |
5809 | "Send Community attribute to this neighbor\n" | |
5810 | "Send Standard and Extended Community attributes\n" | |
5811 | "Send Standard, Large and Extended Community attributes\n" | |
5812 | "Send Extended Community attributes\n" | |
5813 | "Send Standard Community attributes\n" | |
5814 | "Send Large Community attributes\n") | |
718e3744 | 5815 | { |
d62a17ae | 5816 | const char *type = argv[argc - 1]->text; |
db45f64d | 5817 | char *peer_str = argv[2]->arg; |
28c6e247 | 5818 | struct peer *peer; |
db45f64d DS |
5819 | afi_t afi = bgp_node_afi(vty); |
5820 | safi_t safi = bgp_node_safi(vty); | |
5821 | ||
28c6e247 IR |
5822 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5823 | if (!peer) | |
f4b8ec07 CS |
5824 | return CMD_WARNING_CONFIG_FAILED; |
5825 | ||
28c6e247 IR |
5826 | if (strmatch(type, "standard")) |
5827 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5828 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5829 | |
28c6e247 IR |
5830 | if (strmatch(type, "extended")) |
5831 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5832 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5833 | |
28c6e247 IR |
5834 | if (strmatch(type, "large")) |
5835 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5836 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
5837 | |
5838 | if (strmatch(type, "both")) { | |
db45f64d | 5839 | |
28c6e247 IR |
5840 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5841 | PEER_FLAG_SEND_COMMUNITY) | |
5842 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5843 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5844 | } |
5845 | ||
28c6e247 IR |
5846 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5847 | PEER_FLAG_SEND_COMMUNITY) | |
5848 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5849 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5850 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5851 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5852 | } |
5853 | ||
5854 | ALIAS_HIDDEN( | |
5855 | no_neighbor_send_community_type, | |
5856 | no_neighbor_send_community_type_hidden_cmd, | |
5857 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5858 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5859 | "Send Community attribute to this neighbor\n" | |
5860 | "Send Standard and Extended Community attributes\n" | |
5861 | "Send Standard, Large and Extended Community attributes\n" | |
5862 | "Send Extended Community attributes\n" | |
5863 | "Send Standard Community attributes\n" | |
5864 | "Send Large Community attributes\n") | |
596c17ba | 5865 | |
718e3744 | 5866 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
5867 | DEFUN (neighbor_soft_reconfiguration, |
5868 | neighbor_soft_reconfiguration_cmd, | |
5869 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5870 | NEIGHBOR_STR | |
5871 | NEIGHBOR_ADDR_STR2 | |
5872 | "Per neighbor soft reconfiguration\n" | |
5873 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5874 | { |
d62a17ae | 5875 | int idx_peer = 1; |
28c6e247 IR |
5876 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5877 | bgp_node_safi(vty), | |
5878 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5879 | } |
5880 | ||
d62a17ae | 5881 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5882 | neighbor_soft_reconfiguration_hidden_cmd, | |
5883 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5884 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5885 | "Per neighbor soft reconfiguration\n" | |
5886 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5887 | |
28c6e247 IR |
5888 | DEFUN (no_neighbor_soft_reconfiguration, |
5889 | no_neighbor_soft_reconfiguration_cmd, | |
5890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5891 | NO_STR | |
5892 | NEIGHBOR_STR | |
5893 | NEIGHBOR_ADDR_STR2 | |
5894 | "Per neighbor soft reconfiguration\n" | |
5895 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5896 | { |
d62a17ae | 5897 | int idx_peer = 2; |
28c6e247 IR |
5898 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5899 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5900 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5901 | } |
6b0655a2 | 5902 | |
d62a17ae | 5903 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5904 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5906 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5907 | "Per neighbor soft reconfiguration\n" | |
5908 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5909 | |
28c6e247 IR |
5910 | DEFUN (neighbor_route_reflector_client, |
5911 | neighbor_route_reflector_client_cmd, | |
5912 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5913 | NEIGHBOR_STR | |
5914 | NEIGHBOR_ADDR_STR2 | |
5915 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5916 | { |
d62a17ae | 5917 | int idx_peer = 1; |
28c6e247 | 5918 | struct peer *peer; |
718e3744 | 5919 | |
5920 | ||
28c6e247 IR |
5921 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5922 | if (!peer) | |
d62a17ae | 5923 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5924 | |
28c6e247 IR |
5925 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5926 | bgp_node_safi(vty), | |
5927 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5928 | } |
5929 | ||
d62a17ae | 5930 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5931 | neighbor_route_reflector_client_hidden_cmd, | |
5932 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5933 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5934 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5935 | |
28c6e247 IR |
5936 | DEFUN (no_neighbor_route_reflector_client, |
5937 | no_neighbor_route_reflector_client_cmd, | |
5938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5939 | NO_STR | |
5940 | NEIGHBOR_STR | |
5941 | NEIGHBOR_ADDR_STR2 | |
5942 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5943 | { |
d62a17ae | 5944 | int idx_peer = 2; |
28c6e247 IR |
5945 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5946 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5947 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5948 | } |
6b0655a2 | 5949 | |
d62a17ae | 5950 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5951 | no_neighbor_route_reflector_client_hidden_cmd, | |
5952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5953 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5954 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5955 | |
718e3744 | 5956 | /* neighbor route-server-client. */ |
28c6e247 IR |
5957 | DEFUN (neighbor_route_server_client, |
5958 | neighbor_route_server_client_cmd, | |
5959 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5960 | NEIGHBOR_STR | |
5961 | NEIGHBOR_ADDR_STR2 | |
5962 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 5963 | { |
d62a17ae | 5964 | int idx_peer = 1; |
28c6e247 | 5965 | struct peer *peer; |
f4b8ec07 | 5966 | |
28c6e247 IR |
5967 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5968 | if (!peer) | |
d62a17ae | 5969 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
5970 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5971 | bgp_node_safi(vty), | |
5972 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5973 | } |
5974 | ||
d62a17ae | 5975 | ALIAS_HIDDEN(neighbor_route_server_client, |
5976 | neighbor_route_server_client_hidden_cmd, | |
5977 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5978 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5979 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5980 | |
28c6e247 IR |
5981 | DEFUN (no_neighbor_route_server_client, |
5982 | no_neighbor_route_server_client_cmd, | |
5983 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5984 | NO_STR | |
5985 | NEIGHBOR_STR | |
5986 | NEIGHBOR_ADDR_STR2 | |
5987 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5988 | { |
d62a17ae | 5989 | int idx_peer = 2; |
28c6e247 IR |
5990 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5991 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5992 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5993 | } |
6b0655a2 | 5994 | |
d62a17ae | 5995 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5996 | no_neighbor_route_server_client_hidden_cmd, | |
5997 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5998 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5999 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6000 | |
fee0f4c6 | 6001 | DEFUN (neighbor_nexthop_local_unchanged, |
6002 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6003 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6004 | NEIGHBOR_STR |
6005 | NEIGHBOR_ADDR_STR2 | |
6006 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6007 | "Leave link-local nexthop unchanged for this peer\n") | |
6008 | { | |
d62a17ae | 6009 | int idx_peer = 1; |
6010 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6011 | bgp_node_safi(vty), | |
6012 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6013 | } |
6b0655a2 | 6014 | |
fee0f4c6 | 6015 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6016 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6017 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6018 | NO_STR |
6019 | NEIGHBOR_STR | |
6020 | NEIGHBOR_ADDR_STR2 | |
6021 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6022 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6023 | { |
d62a17ae | 6024 | int idx_peer = 2; |
6025 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6026 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6027 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6028 | } |
6b0655a2 | 6029 | |
28c6e247 IR |
6030 | DEFUN (neighbor_attr_unchanged, |
6031 | neighbor_attr_unchanged_cmd, | |
6032 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6033 | NEIGHBOR_STR | |
6034 | NEIGHBOR_ADDR_STR2 | |
6035 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6036 | "As-path attribute\n" | |
6037 | "Nexthop attribute\n" | |
6038 | "Med attribute\n") | |
718e3744 | 6039 | { |
d62a17ae | 6040 | int idx = 0; |
8eeb0335 | 6041 | char *peer_str = argv[1]->arg; |
28c6e247 | 6042 | struct peer *peer; |
db45f64d DS |
6043 | bool aspath = false; |
6044 | bool nexthop = false; | |
6045 | bool med = false; | |
8eeb0335 DW |
6046 | afi_t afi = bgp_node_afi(vty); |
6047 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6048 | int ret = 0; |
f4b8ec07 | 6049 | |
28c6e247 IR |
6050 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6051 | if (!peer) | |
8eeb0335 | 6052 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6053 | |
6054 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6055 | aspath = true; |
6056 | ||
d62a17ae | 6057 | idx = 0; |
6058 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6059 | nexthop = true; |
6060 | ||
d62a17ae | 6061 | idx = 0; |
6062 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6063 | med = true; |
d62a17ae | 6064 | |
8eeb0335 | 6065 | /* no flags means all of them! */ |
db45f64d | 6066 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6067 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6068 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6069 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6070 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6071 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6072 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6073 | } else { |
28c6e247 IR |
6074 | if (!aspath) { |
6075 | if (peer_af_flag_check(peer, afi, safi, | |
6076 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6077 | ret |= peer_af_flag_unset_vty( | |
6078 | vty, peer_str, afi, safi, | |
6079 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6080 | } | |
6081 | } else | |
6082 | ret |= peer_af_flag_set_vty( | |
6083 | vty, peer_str, afi, safi, | |
6084 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6085 | ||
6086 | if (!nexthop) { | |
6087 | if (peer_af_flag_check(peer, afi, safi, | |
6088 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6089 | ret |= peer_af_flag_unset_vty( | |
6090 | vty, peer_str, afi, safi, | |
6091 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6092 | } | |
6093 | } else | |
6094 | ret |= peer_af_flag_set_vty( | |
6095 | vty, peer_str, afi, safi, | |
6096 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6097 | ||
6098 | if (!med) { | |
6099 | if (peer_af_flag_check(peer, afi, safi, | |
6100 | PEER_FLAG_MED_UNCHANGED)) { | |
6101 | ret |= peer_af_flag_unset_vty( | |
6102 | vty, peer_str, afi, safi, | |
6103 | PEER_FLAG_MED_UNCHANGED); | |
6104 | } | |
6105 | } else | |
6106 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6107 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6108 | } |
6109 | ||
28c6e247 | 6110 | return ret; |
d62a17ae | 6111 | } |
6112 | ||
6113 | ALIAS_HIDDEN( | |
6114 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6115 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6116 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6117 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6118 | "As-path attribute\n" | |
6119 | "Nexthop attribute\n" | |
6120 | "Med attribute\n") | |
596c17ba | 6121 | |
28c6e247 IR |
6122 | DEFUN (no_neighbor_attr_unchanged, |
6123 | no_neighbor_attr_unchanged_cmd, | |
6124 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6125 | NO_STR | |
6126 | NEIGHBOR_STR | |
6127 | NEIGHBOR_ADDR_STR2 | |
6128 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6129 | "As-path attribute\n" | |
6130 | "Nexthop attribute\n" | |
6131 | "Med attribute\n") | |
718e3744 | 6132 | { |
d62a17ae | 6133 | int idx = 0; |
db45f64d | 6134 | char *peer_str = argv[2]->arg; |
28c6e247 | 6135 | struct peer *peer; |
db45f64d DS |
6136 | bool aspath = false; |
6137 | bool nexthop = false; | |
6138 | bool med = false; | |
6139 | afi_t afi = bgp_node_afi(vty); | |
6140 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6141 | int ret = 0; |
f4b8ec07 | 6142 | |
28c6e247 IR |
6143 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6144 | if (!peer) | |
db45f64d | 6145 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6146 | |
6147 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6148 | aspath = true; |
6149 | ||
d62a17ae | 6150 | idx = 0; |
6151 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6152 | nexthop = true; |
6153 | ||
d62a17ae | 6154 | idx = 0; |
6155 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6156 | med = true; |
d62a17ae | 6157 | |
28c6e247 IR |
6158 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6159 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6160 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6161 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6162 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6163 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6164 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6165 | |
6166 | if (aspath) | |
28c6e247 IR |
6167 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6168 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6169 | |
6170 | if (nexthop) | |
28c6e247 IR |
6171 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6172 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6173 | |
db45f64d | 6174 | if (med) |
28c6e247 IR |
6175 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6176 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6177 | |
28c6e247 | 6178 | return ret; |
d62a17ae | 6179 | } |
6180 | ||
6181 | ALIAS_HIDDEN( | |
6182 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6184 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6185 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6186 | "As-path attribute\n" | |
6187 | "Nexthop attribute\n" | |
6188 | "Med attribute\n") | |
718e3744 | 6189 | |
28c6e247 IR |
6190 | /* EBGP multihop configuration. */ |
6191 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6192 | const char *ttl_str) | |
718e3744 | 6193 | { |
28c6e247 IR |
6194 | struct peer *peer; |
6195 | unsigned int ttl; | |
718e3744 | 6196 | |
28c6e247 IR |
6197 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6198 | if (!peer) | |
d62a17ae | 6199 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6200 | |
28c6e247 IR |
6201 | if (peer->conf_if) |
6202 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6203 | ||
6204 | if (!ttl_str) | |
6205 | ttl = MAXTTL; | |
6206 | else | |
6207 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6208 | |
28c6e247 | 6209 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6210 | } |
6211 | ||
28c6e247 | 6212 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6213 | { |
28c6e247 | 6214 | struct peer *peer; |
718e3744 | 6215 | |
28c6e247 IR |
6216 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6217 | if (!peer) | |
d62a17ae | 6218 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6219 | |
28c6e247 | 6220 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6221 | } |
6222 | ||
28c6e247 IR |
6223 | /* neighbor ebgp-multihop. */ |
6224 | DEFUN (neighbor_ebgp_multihop, | |
6225 | neighbor_ebgp_multihop_cmd, | |
6226 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6227 | NEIGHBOR_STR | |
6228 | NEIGHBOR_ADDR_STR2 | |
6229 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6230 | { |
28c6e247 IR |
6231 | int idx_peer = 1; |
6232 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6233 | } | |
f4b8ec07 | 6234 | |
28c6e247 IR |
6235 | DEFUN (neighbor_ebgp_multihop_ttl, |
6236 | neighbor_ebgp_multihop_ttl_cmd, | |
6237 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6238 | NEIGHBOR_STR | |
6239 | NEIGHBOR_ADDR_STR2 | |
6240 | "Allow EBGP neighbors not on directly connected networks\n" | |
6241 | "maximum hop count\n") | |
6242 | { | |
6243 | int idx_peer = 1; | |
6244 | int idx_number = 3; | |
6245 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6246 | argv[idx_number]->arg); | |
6247 | } | |
f4b8ec07 | 6248 | |
28c6e247 IR |
6249 | DEFUN (no_neighbor_ebgp_multihop, |
6250 | no_neighbor_ebgp_multihop_cmd, | |
6251 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6252 | NO_STR | |
6253 | NEIGHBOR_STR | |
6254 | NEIGHBOR_ADDR_STR2 | |
6255 | "Allow EBGP neighbors not on directly connected networks\n" | |
6256 | "maximum hop count\n") | |
6257 | { | |
6258 | int idx_peer = 2; | |
6259 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6260 | } |
6261 | ||
6b0655a2 | 6262 | |
6ffd2079 | 6263 | /* disable-connected-check */ |
28c6e247 IR |
6264 | DEFUN (neighbor_disable_connected_check, |
6265 | neighbor_disable_connected_check_cmd, | |
6266 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6267 | NEIGHBOR_STR | |
6268 | NEIGHBOR_ADDR_STR2 | |
6269 | "one-hop away EBGP peer using loopback address\n" | |
6270 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6271 | { |
d62a17ae | 6272 | int idx_peer = 1; |
28c6e247 IR |
6273 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6274 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6275 | } |
6276 | ||
28c6e247 IR |
6277 | DEFUN (no_neighbor_disable_connected_check, |
6278 | no_neighbor_disable_connected_check_cmd, | |
6279 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6280 | NO_STR | |
6281 | NEIGHBOR_STR | |
6282 | NEIGHBOR_ADDR_STR2 | |
6283 | "one-hop away EBGP peer using loopback address\n" | |
6284 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6285 | { |
d62a17ae | 6286 | int idx_peer = 2; |
28c6e247 IR |
6287 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6288 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6289 | } |
6290 | ||
7ab294ea DA |
6291 | /* disable-link-bw-encoding-ieee */ |
6292 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6293 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6294 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6295 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6296 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6297 | { |
6298 | int idx_peer = 1; | |
6299 | ||
6300 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6301 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6302 | } | |
6303 | ||
7ab294ea DA |
6304 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6305 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6306 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6307 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6308 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6309 | { |
6310 | int idx_peer = 2; | |
6311 | ||
6312 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6313 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6314 | } | |
6315 | ||
d08c0c80 DA |
6316 | /* extended-optional-parameters */ |
6317 | DEFUN(neighbor_extended_optional_parameters, | |
6318 | neighbor_extended_optional_parameters_cmd, | |
6319 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6320 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6321 | "Force the extended optional parameters format for OPEN messages\n") | |
6322 | { | |
6323 | int idx_peer = 1; | |
6324 | ||
6325 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6326 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6327 | } | |
6328 | ||
6329 | DEFUN(no_neighbor_extended_optional_parameters, | |
6330 | no_neighbor_extended_optional_parameters_cmd, | |
6331 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6332 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6333 | "Force the extended optional parameters format for OPEN messages\n") | |
6334 | { | |
6335 | int idx_peer = 2; | |
6336 | ||
6337 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6338 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6339 | } | |
47cbc09b PM |
6340 | |
6341 | /* enforce-first-as */ | |
28c6e247 IR |
6342 | DEFUN (neighbor_enforce_first_as, |
6343 | neighbor_enforce_first_as_cmd, | |
6344 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6345 | NEIGHBOR_STR | |
6346 | NEIGHBOR_ADDR_STR2 | |
6347 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6348 | { |
6349 | int idx_peer = 1; | |
f4b8ec07 | 6350 | |
28c6e247 IR |
6351 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6352 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6353 | } |
6354 | ||
28c6e247 IR |
6355 | DEFUN (no_neighbor_enforce_first_as, |
6356 | no_neighbor_enforce_first_as_cmd, | |
6357 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6358 | NO_STR | |
6359 | NEIGHBOR_STR | |
6360 | NEIGHBOR_ADDR_STR2 | |
6361 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6362 | { |
6363 | int idx_peer = 2; | |
f4b8ec07 | 6364 | |
28c6e247 IR |
6365 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6366 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6367 | } |
6368 | ||
6369 | ||
28c6e247 IR |
6370 | DEFUN (neighbor_description, |
6371 | neighbor_description_cmd, | |
6372 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6373 | NEIGHBOR_STR | |
6374 | NEIGHBOR_ADDR_STR2 | |
6375 | "Neighbor specific description\n" | |
6376 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6377 | { |
d62a17ae | 6378 | int idx_peer = 1; |
6379 | int idx_line = 3; | |
28c6e247 | 6380 | struct peer *peer; |
d62a17ae | 6381 | char *str; |
718e3744 | 6382 | |
28c6e247 IR |
6383 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6384 | if (!peer) | |
d62a17ae | 6385 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6386 | |
d62a17ae | 6387 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6388 | |
28c6e247 | 6389 | peer_description_set(peer, str); |
718e3744 | 6390 | |
d62a17ae | 6391 | XFREE(MTYPE_TMP, str); |
718e3744 | 6392 | |
28c6e247 | 6393 | return CMD_SUCCESS; |
718e3744 | 6394 | } |
6395 | ||
28c6e247 IR |
6396 | DEFUN (no_neighbor_description, |
6397 | no_neighbor_description_cmd, | |
6398 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6399 | NO_STR | |
6400 | NEIGHBOR_STR | |
6401 | NEIGHBOR_ADDR_STR2 | |
6402 | "Neighbor specific description\n") | |
718e3744 | 6403 | { |
d62a17ae | 6404 | int idx_peer = 2; |
28c6e247 | 6405 | struct peer *peer; |
f4b8ec07 | 6406 | |
28c6e247 IR |
6407 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6408 | if (!peer) | |
d62a17ae | 6409 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6410 | |
28c6e247 | 6411 | peer_description_unset(peer); |
718e3744 | 6412 | |
28c6e247 | 6413 | return CMD_SUCCESS; |
718e3744 | 6414 | } |
6415 | ||
1d80f243 | 6416 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6418 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6419 | "Neighbor specific description\n" | |
6420 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6421 | |
28c6e247 IR |
6422 | /* Neighbor update-source. */ |
6423 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6424 | const char *source_str) | |
6425 | { | |
6426 | struct peer *peer; | |
6427 | struct prefix p; | |
6428 | union sockunion su; | |
6429 | ||
6430 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6431 | if (!peer) | |
6432 | return CMD_WARNING_CONFIG_FAILED; | |
6433 | ||
6434 | if (peer->conf_if) | |
6435 | return CMD_WARNING; | |
6436 | ||
6437 | if (source_str) { | |
6438 | if (str2sockunion(source_str, &su) == 0) | |
6439 | peer_update_source_addr_set(peer, &su); | |
6440 | else { | |
6441 | if (str2prefix(source_str, &p)) { | |
6442 | vty_out(vty, | |
6443 | "%% Invalid update-source, remove prefix length \n"); | |
6444 | return CMD_WARNING_CONFIG_FAILED; | |
6445 | } else | |
6446 | peer_update_source_if_set(peer, source_str); | |
6447 | } | |
6448 | } else | |
6449 | peer_update_source_unset(peer); | |
6450 | ||
6451 | return CMD_SUCCESS; | |
6452 | } | |
6453 | ||
d62a17ae | 6454 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6455 | "IPv4 address\n" \ | |
6456 | "IPv6 address\n" \ | |
6457 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6458 | |
28c6e247 IR |
6459 | DEFUN (neighbor_update_source, |
6460 | neighbor_update_source_cmd, | |
6461 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6462 | NEIGHBOR_STR | |
6463 | NEIGHBOR_ADDR_STR2 | |
6464 | "Source of routing updates\n" | |
6465 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6466 | { |
d62a17ae | 6467 | int idx_peer = 1; |
6468 | int idx_peer_2 = 3; | |
28c6e247 | 6469 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6470 | argv[idx_peer_2]->arg); |
718e3744 | 6471 | } |
6472 | ||
28c6e247 IR |
6473 | DEFUN (no_neighbor_update_source, |
6474 | no_neighbor_update_source_cmd, | |
6475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6476 | NO_STR | |
6477 | NEIGHBOR_STR | |
6478 | NEIGHBOR_ADDR_STR2 | |
6479 | "Source of routing updates\n" | |
6480 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6481 | { |
d62a17ae | 6482 | int idx_peer = 2; |
28c6e247 | 6483 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6484 | } |
6b0655a2 | 6485 | |
d62a17ae | 6486 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6487 | afi_t afi, safi_t safi, | |
6488 | const char *rmap, int set) | |
718e3744 | 6489 | { |
d62a17ae | 6490 | int ret; |
6491 | struct peer *peer; | |
80912664 | 6492 | struct route_map *route_map = NULL; |
718e3744 | 6493 | |
d62a17ae | 6494 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6495 | if (!peer) | |
6496 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6497 | |
1de27621 | 6498 | if (set) { |
80912664 DS |
6499 | if (rmap) |
6500 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6501 | ret = peer_default_originate_set(peer, afi, safi, |
6502 | rmap, route_map); | |
6503 | } else | |
d62a17ae | 6504 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6505 | |
d62a17ae | 6506 | return bgp_vty_return(vty, ret); |
718e3744 | 6507 | } |
6508 | ||
6509 | /* neighbor default-originate. */ | |
6510 | DEFUN (neighbor_default_originate, | |
6511 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6512 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6513 | NEIGHBOR_STR |
6514 | NEIGHBOR_ADDR_STR2 | |
6515 | "Originate default route to this neighbor\n") | |
6516 | { | |
d62a17ae | 6517 | int idx_peer = 1; |
6518 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6519 | bgp_node_afi(vty), | |
6520 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6521 | } |
6522 | ||
d62a17ae | 6523 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6524 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6525 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6526 | "Originate default route to this neighbor\n") | |
596c17ba | 6527 | |
718e3744 | 6528 | DEFUN (neighbor_default_originate_rmap, |
6529 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 6530 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 6531 | NEIGHBOR_STR |
6532 | NEIGHBOR_ADDR_STR2 | |
6533 | "Originate default route to this neighbor\n" | |
6534 | "Route-map to specify criteria to originate default\n" | |
6535 | "route-map name\n") | |
6536 | { | |
d62a17ae | 6537 | int idx_peer = 1; |
6538 | int idx_word = 4; | |
6539 | return peer_default_originate_set_vty( | |
6540 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6541 | argv[idx_word]->arg, 1); | |
718e3744 | 6542 | } |
6543 | ||
d62a17ae | 6544 | ALIAS_HIDDEN( |
6545 | neighbor_default_originate_rmap, | |
6546 | neighbor_default_originate_rmap_hidden_cmd, | |
6547 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6548 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6549 | "Originate default route to this neighbor\n" | |
6550 | "Route-map to specify criteria to originate default\n" | |
6551 | "route-map name\n") | |
596c17ba | 6552 | |
718e3744 | 6553 | DEFUN (no_neighbor_default_originate, |
6554 | no_neighbor_default_originate_cmd, | |
a636c635 | 6555 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 6556 | NO_STR |
6557 | NEIGHBOR_STR | |
6558 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6559 | "Originate default route to this neighbor\n" |
6560 | "Route-map to specify criteria to originate default\n" | |
6561 | "route-map name\n") | |
718e3744 | 6562 | { |
d62a17ae | 6563 | int idx_peer = 2; |
6564 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6565 | bgp_node_afi(vty), | |
6566 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6567 | } |
6568 | ||
d62a17ae | 6569 | ALIAS_HIDDEN( |
6570 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6571 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6572 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6573 | "Originate default route to this neighbor\n" | |
6574 | "Route-map to specify criteria to originate default\n" | |
6575 | "route-map name\n") | |
596c17ba | 6576 | |
6b0655a2 | 6577 | |
28c6e247 IR |
6578 | /* Set neighbor's BGP port. */ |
6579 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6580 | const char *port_str) | |
718e3744 | 6581 | { |
28c6e247 IR |
6582 | struct peer *peer; |
6583 | uint16_t port; | |
6584 | struct servent *sp; | |
6585 | ||
6586 | peer = peer_lookup_vty(vty, ip_str); | |
6587 | if (!peer) | |
6588 | return CMD_WARNING_CONFIG_FAILED; | |
6589 | ||
6590 | if (!port_str) { | |
6591 | sp = getservbyname("bgp", "tcp"); | |
6592 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6593 | } else { | |
6594 | port = strtoul(port_str, NULL, 10); | |
6595 | } | |
718e3744 | 6596 | |
28c6e247 | 6597 | peer_port_set(peer, port); |
718e3744 | 6598 | |
28c6e247 IR |
6599 | return CMD_SUCCESS; |
6600 | } | |
f4b8ec07 | 6601 | |
28c6e247 IR |
6602 | /* Set specified peer's BGP port. */ |
6603 | DEFUN (neighbor_port, | |
6604 | neighbor_port_cmd, | |
6605 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
6606 | NEIGHBOR_STR | |
6607 | NEIGHBOR_ADDR_STR | |
6608 | "Neighbor's BGP port\n" | |
6609 | "TCP port number\n") | |
6610 | { | |
6611 | int idx_ip = 1; | |
6612 | int idx_number = 3; | |
6613 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6614 | argv[idx_number]->arg); | |
f4b8ec07 | 6615 | } |
6b0655a2 | 6616 | |
28c6e247 IR |
6617 | DEFUN (no_neighbor_port, |
6618 | no_neighbor_port_cmd, | |
6619 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
6620 | NO_STR | |
6621 | NEIGHBOR_STR | |
6622 | NEIGHBOR_ADDR_STR | |
6623 | "Neighbor's BGP port\n" | |
6624 | "TCP port number\n") | |
718e3744 | 6625 | { |
f4b8ec07 | 6626 | int idx_ip = 2; |
28c6e247 IR |
6627 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
6628 | } | |
6629 | ||
6630 | ||
6631 | /* neighbor weight. */ | |
6632 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6633 | safi_t safi, const char *weight_str) | |
6634 | { | |
6635 | int ret; | |
6636 | struct peer *peer; | |
6637 | unsigned long weight; | |
718e3744 | 6638 | |
28c6e247 IR |
6639 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6640 | if (!peer) | |
6641 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6642 | |
28c6e247 | 6643 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6644 | |
28c6e247 IR |
6645 | ret = peer_weight_set(peer, afi, safi, weight); |
6646 | return bgp_vty_return(vty, ret); | |
718e3744 | 6647 | } |
6648 | ||
28c6e247 IR |
6649 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6650 | safi_t safi) | |
718e3744 | 6651 | { |
28c6e247 IR |
6652 | int ret; |
6653 | struct peer *peer; | |
f4b8ec07 | 6654 | |
28c6e247 IR |
6655 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6656 | if (!peer) | |
d62a17ae | 6657 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6658 | |
28c6e247 IR |
6659 | ret = peer_weight_unset(peer, afi, safi); |
6660 | return bgp_vty_return(vty, ret); | |
6661 | } | |
f4b8ec07 | 6662 | |
28c6e247 IR |
6663 | DEFUN (neighbor_weight, |
6664 | neighbor_weight_cmd, | |
6665 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6666 | NEIGHBOR_STR | |
6667 | NEIGHBOR_ADDR_STR2 | |
6668 | "Set default weight for routes from this neighbor\n" | |
6669 | "default weight\n") | |
6670 | { | |
6671 | int idx_peer = 1; | |
6672 | int idx_number = 3; | |
6673 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6674 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6675 | } |
6676 | ||
d62a17ae | 6677 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6678 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6679 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6680 | "Set default weight for routes from this neighbor\n" | |
6681 | "default weight\n") | |
596c17ba | 6682 | |
28c6e247 IR |
6683 | DEFUN (no_neighbor_weight, |
6684 | no_neighbor_weight_cmd, | |
6685 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6686 | NO_STR | |
6687 | NEIGHBOR_STR | |
6688 | NEIGHBOR_ADDR_STR2 | |
6689 | "Set default weight for routes from this neighbor\n" | |
6690 | "default weight\n") | |
718e3744 | 6691 | { |
d62a17ae | 6692 | int idx_peer = 2; |
28c6e247 IR |
6693 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
6694 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6695 | } |
6696 | ||
d62a17ae | 6697 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6698 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6699 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6700 | "Set default weight for routes from this neighbor\n" | |
6701 | "default weight\n") | |
596c17ba | 6702 | |
6b0655a2 | 6703 | |
718e3744 | 6704 | /* Override capability negotiation. */ |
c36bc05f IR |
6705 | DEFUN (neighbor_override_capability, |
6706 | neighbor_override_capability_cmd, | |
6707 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6708 | NEIGHBOR_STR | |
6709 | NEIGHBOR_ADDR_STR2 | |
6710 | "Override capability negotiation result\n") | |
718e3744 | 6711 | { |
d62a17ae | 6712 | int idx_peer = 1; |
c36bc05f IR |
6713 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6714 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6715 | } |
6716 | ||
c36bc05f IR |
6717 | DEFUN (no_neighbor_override_capability, |
6718 | no_neighbor_override_capability_cmd, | |
6719 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6720 | NO_STR | |
6721 | NEIGHBOR_STR | |
6722 | NEIGHBOR_ADDR_STR2 | |
6723 | "Override capability negotiation result\n") | |
718e3744 | 6724 | { |
d62a17ae | 6725 | int idx_peer = 2; |
c36bc05f IR |
6726 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6727 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6728 | } |
6b0655a2 | 6729 | |
c36bc05f IR |
6730 | DEFUN (neighbor_strict_capability, |
6731 | neighbor_strict_capability_cmd, | |
6732 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6733 | NEIGHBOR_STR | |
6734 | NEIGHBOR_ADDR_STR2 | |
6735 | "Strict capability negotiation match\n") | |
718e3744 | 6736 | { |
9fb964de PM |
6737 | int idx_peer = 1; |
6738 | ||
c36bc05f IR |
6739 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6740 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6741 | } |
6742 | ||
c36bc05f IR |
6743 | DEFUN (no_neighbor_strict_capability, |
6744 | no_neighbor_strict_capability_cmd, | |
6745 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6746 | NO_STR | |
6747 | NEIGHBOR_STR | |
6748 | NEIGHBOR_ADDR_STR2 | |
6749 | "Strict capability negotiation match\n") | |
718e3744 | 6750 | { |
9fb964de | 6751 | int idx_peer = 2; |
8611c7f3 | 6752 | |
c36bc05f IR |
6753 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6754 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6755 | } |
6b0655a2 | 6756 | |
28c6e247 IR |
6757 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6758 | const char *keep_str, const char *hold_str) | |
718e3744 | 6759 | { |
28c6e247 IR |
6760 | int ret; |
6761 | struct peer *peer; | |
6762 | uint32_t keepalive; | |
6763 | uint32_t holdtime; | |
718e3744 | 6764 | |
28c6e247 IR |
6765 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6766 | if (!peer) | |
d62a17ae | 6767 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6768 | |
28c6e247 IR |
6769 | keepalive = strtoul(keep_str, NULL, 10); |
6770 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6771 | |
28c6e247 | 6772 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6773 | |
28c6e247 | 6774 | return bgp_vty_return(vty, ret); |
718e3744 | 6775 | } |
6b0655a2 | 6776 | |
28c6e247 | 6777 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6778 | { |
28c6e247 IR |
6779 | int ret; |
6780 | struct peer *peer; | |
718e3744 | 6781 | |
28c6e247 IR |
6782 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6783 | if (!peer) | |
d62a17ae | 6784 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6785 | |
28c6e247 | 6786 | ret = peer_timers_unset(peer); |
718e3744 | 6787 | |
28c6e247 | 6788 | return bgp_vty_return(vty, ret); |
718e3744 | 6789 | } |
6b0655a2 | 6790 | |
28c6e247 IR |
6791 | DEFUN (neighbor_timers, |
6792 | neighbor_timers_cmd, | |
6793 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
6794 | NEIGHBOR_STR | |
6795 | NEIGHBOR_ADDR_STR2 | |
6796 | "BGP per neighbor timers\n" | |
6797 | "Keepalive interval\n" | |
6798 | "Holdtime\n") | |
718e3744 | 6799 | { |
f4b8ec07 | 6800 | int idx_peer = 1; |
28c6e247 IR |
6801 | int idx_number = 3; |
6802 | int idx_number_2 = 4; | |
6803 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6804 | argv[idx_number]->arg, | |
6805 | argv[idx_number_2]->arg); | |
6806 | } | |
6807 | ||
6808 | DEFUN (no_neighbor_timers, | |
6809 | no_neighbor_timers_cmd, | |
6810 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
6811 | NO_STR | |
6812 | NEIGHBOR_STR | |
6813 | NEIGHBOR_ADDR_STR2 | |
6814 | "BGP per neighbor timers\n" | |
6815 | "Keepalive interval\n" | |
6816 | "Holdtime\n") | |
6817 | { | |
6818 | int idx_peer = 2; | |
6819 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
6820 | } | |
6821 | ||
6822 | ||
6823 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
6824 | const char *time_str) | |
6825 | { | |
6826 | int ret; | |
6827 | struct peer *peer; | |
6828 | uint32_t connect; | |
718e3744 | 6829 | |
28c6e247 IR |
6830 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6831 | if (!peer) | |
d62a17ae | 6832 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6833 | |
28c6e247 IR |
6834 | connect = strtoul(time_str, NULL, 10); |
6835 | ||
6836 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 6837 | |
28c6e247 | 6838 | return bgp_vty_return(vty, ret); |
718e3744 | 6839 | } |
6840 | ||
28c6e247 | 6841 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6842 | { |
28c6e247 IR |
6843 | int ret; |
6844 | struct peer *peer; | |
718e3744 | 6845 | |
28c6e247 IR |
6846 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6847 | if (!peer) | |
d62a17ae | 6848 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6849 | |
28c6e247 IR |
6850 | ret = peer_timers_connect_unset(peer); |
6851 | ||
6852 | return bgp_vty_return(vty, ret); | |
6853 | } | |
6854 | ||
6855 | DEFUN (neighbor_timers_connect, | |
6856 | neighbor_timers_connect_cmd, | |
6857 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
6858 | NEIGHBOR_STR | |
6859 | NEIGHBOR_ADDR_STR2 | |
6860 | "BGP per neighbor timers\n" | |
6861 | "BGP connect timer\n" | |
6862 | "Connect timer\n") | |
6863 | { | |
6864 | int idx_peer = 1; | |
6865 | int idx_number = 4; | |
6866 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6867 | argv[idx_number]->arg); | |
6868 | } | |
718e3744 | 6869 | |
28c6e247 IR |
6870 | DEFUN (no_neighbor_timers_connect, |
6871 | no_neighbor_timers_connect_cmd, | |
6872 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
6873 | NO_STR | |
6874 | NEIGHBOR_STR | |
6875 | NEIGHBOR_ADDR_STR2 | |
6876 | "BGP per neighbor timers\n" | |
6877 | "BGP connect timer\n" | |
6878 | "Connect timer\n") | |
6879 | { | |
6880 | int idx_peer = 2; | |
6881 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6882 | } |
6883 | ||
d43114f3 DS |
6884 | DEFPY (neighbor_timers_delayopen, |
6885 | neighbor_timers_delayopen_cmd, | |
6886 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
6887 | NEIGHBOR_STR | |
6888 | NEIGHBOR_ADDR_STR2 | |
6889 | "BGP per neighbor timers\n" | |
6890 | "RFC 4271 DelayOpenTimer\n" | |
6891 | "DelayOpenTime timer interval\n") | |
6892 | { | |
6893 | struct peer *peer; | |
6894 | ||
6895 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6896 | if (!peer) | |
6897 | return CMD_WARNING_CONFIG_FAILED; | |
6898 | ||
6899 | if (!interval) { | |
6900 | if (peer_timers_delayopen_unset(peer)) | |
6901 | return CMD_WARNING_CONFIG_FAILED; | |
6902 | } else { | |
6903 | if (peer_timers_delayopen_set(peer, interval)) | |
6904 | return CMD_WARNING_CONFIG_FAILED; | |
6905 | } | |
6906 | ||
6907 | return CMD_SUCCESS; | |
6908 | } | |
6909 | ||
6910 | DEFPY (no_neighbor_timers_delayopen, | |
6911 | no_neighbor_timers_delayopen_cmd, | |
6912 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
6913 | NO_STR | |
6914 | NEIGHBOR_STR | |
6915 | NEIGHBOR_ADDR_STR2 | |
6916 | "BGP per neighbor timers\n" | |
6917 | "RFC 4271 DelayOpenTimer\n" | |
6918 | "DelayOpenTime timer interval\n") | |
6919 | { | |
6920 | struct peer *peer; | |
6921 | ||
6922 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6923 | if (!peer) | |
6924 | return CMD_WARNING_CONFIG_FAILED; | |
6925 | ||
6926 | if (peer_timers_delayopen_unset(peer)) | |
6927 | return CMD_WARNING_CONFIG_FAILED; | |
6928 | ||
6929 | return CMD_SUCCESS; | |
6930 | } | |
6931 | ||
28c6e247 IR |
6932 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6933 | const char *time_str, int set) | |
718e3744 | 6934 | { |
28c6e247 IR |
6935 | int ret; |
6936 | struct peer *peer; | |
6937 | uint32_t routeadv = 0; | |
718e3744 | 6938 | |
28c6e247 IR |
6939 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6940 | if (!peer) | |
d62a17ae | 6941 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6942 | |
28c6e247 IR |
6943 | if (time_str) |
6944 | routeadv = strtoul(time_str, NULL, 10); | |
6945 | ||
6946 | if (set) | |
6947 | ret = peer_advertise_interval_set(peer, routeadv); | |
6948 | else | |
6949 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6950 | |
28c6e247 | 6951 | return bgp_vty_return(vty, ret); |
718e3744 | 6952 | } |
6953 | ||
28c6e247 IR |
6954 | DEFUN (neighbor_advertise_interval, |
6955 | neighbor_advertise_interval_cmd, | |
6956 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
6957 | NEIGHBOR_STR | |
6958 | NEIGHBOR_ADDR_STR2 | |
6959 | "Minimum interval between sending BGP routing updates\n" | |
6960 | "time in seconds\n") | |
718e3744 | 6961 | { |
28c6e247 IR |
6962 | int idx_peer = 1; |
6963 | int idx_number = 3; | |
6964 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6965 | argv[idx_number]->arg, 1); | |
6966 | } | |
f4b8ec07 | 6967 | |
28c6e247 IR |
6968 | DEFUN (no_neighbor_advertise_interval, |
6969 | no_neighbor_advertise_interval_cmd, | |
6970 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
6971 | NO_STR | |
6972 | NEIGHBOR_STR | |
6973 | NEIGHBOR_ADDR_STR2 | |
6974 | "Minimum interval between sending BGP routing updates\n" | |
6975 | "time in seconds\n") | |
6976 | { | |
6977 | int idx_peer = 2; | |
6978 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6979 | } |
6980 | ||
6b0655a2 | 6981 | |
518f0eb1 DS |
6982 | /* Time to wait before processing route-map updates */ |
6983 | DEFUN (bgp_set_route_map_delay_timer, | |
6984 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6985 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6986 | SET_STR |
6987 | "BGP route-map delay timer\n" | |
6988 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6989 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6990 | { |
d62a17ae | 6991 | int idx_number = 3; |
d7c0a89a | 6992 | uint32_t rmap_delay_timer; |
d62a17ae | 6993 | |
6994 | if (argv[idx_number]->arg) { | |
6995 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6996 | bm->rmap_update_timer = rmap_delay_timer; | |
6997 | ||
6998 | /* if the dynamic update handling is being disabled, and a timer | |
6999 | * is | |
7000 | * running, stop the timer and act as if the timer has already | |
7001 | * fired. | |
7002 | */ | |
7003 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7004 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7005 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7006 | NULL, 0); | |
7007 | } | |
7008 | return CMD_SUCCESS; | |
7009 | } else { | |
7010 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7011 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7012 | } |
518f0eb1 DS |
7013 | } |
7014 | ||
7015 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7016 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7017 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7018 | NO_STR |
3a2d747c | 7019 | BGP_STR |
518f0eb1 | 7020 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7021 | "Reset to default time to wait for processing route-map changes\n" |
7022 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7023 | { |
518f0eb1 | 7024 | |
d62a17ae | 7025 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7026 | |
d62a17ae | 7027 | return CMD_SUCCESS; |
518f0eb1 DS |
7028 | } |
7029 | ||
28c6e247 IR |
7030 | /* neighbor interface */ |
7031 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7032 | const char *str) | |
718e3744 | 7033 | { |
28c6e247 | 7034 | struct peer *peer; |
718e3744 | 7035 | |
28c6e247 IR |
7036 | peer = peer_lookup_vty(vty, ip_str); |
7037 | if (!peer || peer->conf_if) { | |
7038 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7039 | return CMD_WARNING_CONFIG_FAILED; | |
7040 | } | |
718e3744 | 7041 | |
28c6e247 IR |
7042 | if (str) |
7043 | peer_interface_set(peer, str); | |
7044 | else | |
7045 | peer_interface_unset(peer); | |
718e3744 | 7046 | |
28c6e247 | 7047 | return CMD_SUCCESS; |
718e3744 | 7048 | } |
7049 | ||
28c6e247 IR |
7050 | DEFUN (neighbor_interface, |
7051 | neighbor_interface_cmd, | |
7052 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7053 | NEIGHBOR_STR | |
7054 | NEIGHBOR_ADDR_STR | |
7055 | "Interface\n" | |
7056 | "Interface name\n") | |
718e3744 | 7057 | { |
28c6e247 IR |
7058 | int idx_ip = 1; |
7059 | int idx_word = 3; | |
294d8425 | 7060 | |
28c6e247 IR |
7061 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7062 | } | |
f4b8ec07 | 7063 | |
28c6e247 IR |
7064 | DEFUN (no_neighbor_interface, |
7065 | no_neighbor_interface_cmd, | |
294d8425 | 7066 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7067 | NO_STR |
7068 | NEIGHBOR_STR | |
294d8425 | 7069 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7070 | "Interface\n" |
7071 | "Interface name\n") | |
7072 | { | |
7073 | int idx_peer = 2; | |
294d8425 | 7074 | |
28c6e247 | 7075 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7076 | } |
6b0655a2 | 7077 | |
718e3744 | 7078 | DEFUN (neighbor_distribute_list, |
7079 | neighbor_distribute_list_cmd, | |
c60dec36 | 7080 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7081 | NEIGHBOR_STR |
7082 | NEIGHBOR_ADDR_STR2 | |
7083 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7084 | "IP Access-list name\n" |
7085 | "Filter incoming updates\n" | |
7086 | "Filter outgoing updates\n") | |
7087 | { | |
d62a17ae | 7088 | int idx_peer = 1; |
7089 | int idx_acl = 3; | |
7090 | int direct, ret; | |
7091 | struct peer *peer; | |
a8206004 | 7092 | |
d62a17ae | 7093 | const char *pstr = argv[idx_peer]->arg; |
7094 | const char *acl = argv[idx_acl]->arg; | |
7095 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7096 | |
d62a17ae | 7097 | peer = peer_and_group_lookup_vty(vty, pstr); |
7098 | if (!peer) | |
7099 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7100 | |
d62a17ae | 7101 | /* Check filter direction. */ |
7102 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7103 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7104 | direct, acl); | |
a8206004 | 7105 | |
d62a17ae | 7106 | return bgp_vty_return(vty, ret); |
718e3744 | 7107 | } |
7108 | ||
d62a17ae | 7109 | ALIAS_HIDDEN( |
7110 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7111 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7112 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7113 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7114 | "IP Access-list name\n" |
7115 | "Filter incoming updates\n" | |
7116 | "Filter outgoing updates\n") | |
596c17ba | 7117 | |
718e3744 | 7118 | DEFUN (no_neighbor_distribute_list, |
7119 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7121 | NO_STR |
7122 | NEIGHBOR_STR | |
7123 | NEIGHBOR_ADDR_STR2 | |
7124 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7125 | "IP Access-list name\n" |
7126 | "Filter incoming updates\n" | |
7127 | "Filter outgoing updates\n") | |
7128 | { | |
d62a17ae | 7129 | int idx_peer = 2; |
7130 | int direct, ret; | |
7131 | struct peer *peer; | |
a8206004 | 7132 | |
d62a17ae | 7133 | const char *pstr = argv[idx_peer]->arg; |
7134 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7135 | |
d62a17ae | 7136 | peer = peer_and_group_lookup_vty(vty, pstr); |
7137 | if (!peer) | |
7138 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7139 | |
d62a17ae | 7140 | /* Check filter direction. */ |
7141 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7142 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7143 | direct); | |
a8206004 | 7144 | |
d62a17ae | 7145 | return bgp_vty_return(vty, ret); |
718e3744 | 7146 | } |
6b0655a2 | 7147 | |
d62a17ae | 7148 | ALIAS_HIDDEN( |
7149 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7151 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7152 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7153 | "IP Access-list name\n" |
7154 | "Filter incoming updates\n" | |
7155 | "Filter outgoing updates\n") | |
596c17ba | 7156 | |
718e3744 | 7157 | /* Set prefix list to the peer. */ |
642ef664 IR |
7158 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7159 | afi_t afi, safi_t safi, | |
7160 | const char *name_str, | |
7161 | const char *direct_str) | |
718e3744 | 7162 | { |
642ef664 IR |
7163 | int ret; |
7164 | int direct = FILTER_IN; | |
7165 | struct peer *peer; | |
718e3744 | 7166 | |
642ef664 IR |
7167 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7168 | if (!peer) | |
d62a17ae | 7169 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7170 | |
642ef664 IR |
7171 | /* Check filter direction. */ |
7172 | if (strncmp(direct_str, "i", 1) == 0) | |
7173 | direct = FILTER_IN; | |
7174 | else if (strncmp(direct_str, "o", 1) == 0) | |
7175 | direct = FILTER_OUT; | |
718e3744 | 7176 | |
642ef664 | 7177 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7178 | |
642ef664 IR |
7179 | return bgp_vty_return(vty, ret); |
7180 | } | |
7181 | ||
7182 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7183 | afi_t afi, safi_t safi, | |
7184 | const char *direct_str) | |
7185 | { | |
7186 | int ret; | |
7187 | struct peer *peer; | |
7188 | int direct = FILTER_IN; | |
7189 | ||
7190 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7191 | if (!peer) | |
7192 | return CMD_WARNING_CONFIG_FAILED; | |
7193 | ||
7194 | /* Check filter direction. */ | |
7195 | if (strncmp(direct_str, "i", 1) == 0) | |
7196 | direct = FILTER_IN; | |
7197 | else if (strncmp(direct_str, "o", 1) == 0) | |
7198 | direct = FILTER_OUT; | |
7199 | ||
7200 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7201 | ||
7202 | return bgp_vty_return(vty, ret); | |
7203 | } | |
7204 | ||
7205 | DEFUN (neighbor_prefix_list, | |
7206 | neighbor_prefix_list_cmd, | |
7207 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7208 | NEIGHBOR_STR | |
7209 | NEIGHBOR_ADDR_STR2 | |
7210 | "Filter updates to/from this neighbor\n" | |
7211 | "Name of a prefix list\n" | |
7212 | "Filter incoming updates\n" | |
7213 | "Filter outgoing updates\n") | |
7214 | { | |
7215 | int idx_peer = 1; | |
7216 | int idx_word = 3; | |
7217 | int idx_in_out = 4; | |
7218 | return peer_prefix_list_set_vty( | |
7219 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7220 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7221 | } |
7222 | ||
d62a17ae | 7223 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7224 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7225 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7226 | "Filter updates to/from this neighbor\n" | |
7227 | "Name of a prefix list\n" | |
7228 | "Filter incoming updates\n" | |
7229 | "Filter outgoing updates\n") | |
596c17ba | 7230 | |
642ef664 IR |
7231 | DEFUN (no_neighbor_prefix_list, |
7232 | no_neighbor_prefix_list_cmd, | |
7233 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7234 | NO_STR | |
7235 | NEIGHBOR_STR | |
7236 | NEIGHBOR_ADDR_STR2 | |
7237 | "Filter updates to/from this neighbor\n" | |
7238 | "Name of a prefix list\n" | |
7239 | "Filter incoming updates\n" | |
7240 | "Filter outgoing updates\n") | |
7241 | { | |
7242 | int idx_peer = 2; | |
7243 | int idx_in_out = 5; | |
7244 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7245 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7246 | argv[idx_in_out]->arg); | |
7247 | } | |
7248 | ||
7249 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7250 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7251 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7252 | "Filter updates to/from this neighbor\n" | |
7253 | "Name of a prefix list\n" | |
7254 | "Filter incoming updates\n" | |
7255 | "Filter outgoing updates\n") | |
7256 | ||
d62a17ae | 7257 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7258 | safi_t safi, const char *name_str, | |
7259 | const char *direct_str) | |
718e3744 | 7260 | { |
d62a17ae | 7261 | int ret; |
7262 | struct peer *peer; | |
7263 | int direct = FILTER_IN; | |
718e3744 | 7264 | |
d62a17ae | 7265 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7266 | if (!peer) | |
7267 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7268 | |
d62a17ae | 7269 | /* Check filter direction. */ |
7270 | if (strncmp(direct_str, "i", 1) == 0) | |
7271 | direct = FILTER_IN; | |
7272 | else if (strncmp(direct_str, "o", 1) == 0) | |
7273 | direct = FILTER_OUT; | |
718e3744 | 7274 | |
d62a17ae | 7275 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7276 | |
d62a17ae | 7277 | return bgp_vty_return(vty, ret); |
718e3744 | 7278 | } |
7279 | ||
d62a17ae | 7280 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7281 | safi_t safi, const char *direct_str) | |
718e3744 | 7282 | { |
d62a17ae | 7283 | int ret; |
7284 | struct peer *peer; | |
7285 | int direct = FILTER_IN; | |
718e3744 | 7286 | |
d62a17ae | 7287 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7288 | if (!peer) | |
7289 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7290 | |
d62a17ae | 7291 | /* Check filter direction. */ |
7292 | if (strncmp(direct_str, "i", 1) == 0) | |
7293 | direct = FILTER_IN; | |
7294 | else if (strncmp(direct_str, "o", 1) == 0) | |
7295 | direct = FILTER_OUT; | |
718e3744 | 7296 | |
d62a17ae | 7297 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7298 | |
d62a17ae | 7299 | return bgp_vty_return(vty, ret); |
718e3744 | 7300 | } |
7301 | ||
7302 | DEFUN (neighbor_filter_list, | |
7303 | neighbor_filter_list_cmd, | |
de71d43e | 7304 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7305 | NEIGHBOR_STR |
7306 | NEIGHBOR_ADDR_STR2 | |
7307 | "Establish BGP filters\n" | |
7308 | "AS path access-list name\n" | |
7309 | "Filter incoming routes\n" | |
7310 | "Filter outgoing routes\n") | |
7311 | { | |
d62a17ae | 7312 | int idx_peer = 1; |
7313 | int idx_word = 3; | |
7314 | int idx_in_out = 4; | |
7315 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7316 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7317 | argv[idx_in_out]->arg); | |
718e3744 | 7318 | } |
7319 | ||
d62a17ae | 7320 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7321 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7322 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7323 | "Establish BGP filters\n" | |
7324 | "AS path access-list name\n" | |
7325 | "Filter incoming routes\n" | |
7326 | "Filter outgoing routes\n") | |
596c17ba | 7327 | |
718e3744 | 7328 | DEFUN (no_neighbor_filter_list, |
7329 | no_neighbor_filter_list_cmd, | |
de71d43e | 7330 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7331 | NO_STR |
7332 | NEIGHBOR_STR | |
7333 | NEIGHBOR_ADDR_STR2 | |
7334 | "Establish BGP filters\n" | |
7335 | "AS path access-list name\n" | |
7336 | "Filter incoming routes\n" | |
7337 | "Filter outgoing routes\n") | |
7338 | { | |
d62a17ae | 7339 | int idx_peer = 2; |
7340 | int idx_in_out = 5; | |
7341 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7342 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7343 | argv[idx_in_out]->arg); | |
718e3744 | 7344 | } |
6b0655a2 | 7345 | |
d62a17ae | 7346 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7347 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7348 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7349 | "Establish BGP filters\n" | |
7350 | "AS path access-list name\n" | |
7351 | "Filter incoming routes\n" | |
7352 | "Filter outgoing routes\n") | |
596c17ba | 7353 | |
7f7940e6 MK |
7354 | /* Set advertise-map to the peer. */ |
7355 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7356 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7357 | const char *advertise_str, |
7358 | const char *condition_str, bool condition, | |
7359 | bool set) | |
7f7940e6 MK |
7360 | { |
7361 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7362 | struct peer *peer; | |
7363 | struct route_map *advertise_map; | |
7364 | struct route_map *condition_map; | |
7365 | ||
7366 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7367 | if (!peer) | |
7368 | return ret; | |
7369 | ||
7370 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7371 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7372 | ||
cf2ad4d8 MK |
7373 | if (set) |
7374 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7375 | advertise_map, condition_str, | |
7376 | condition_map, condition); | |
7377 | else | |
7378 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7379 | advertise_map, condition_str, | |
7380 | condition_map, condition); | |
7f7940e6 MK |
7381 | |
7382 | return bgp_vty_return(vty, ret); | |
7383 | } | |
7384 | ||
389e4f92 QY |
7385 | DEFPY (bgp_condadv_period, |
7386 | bgp_condadv_period_cmd, | |
7387 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7388 | NO_STR | |
7389 | BGP_STR | |
7390 | "Conditional advertisement settings\n" | |
7391 | "Set period to rescan BGP table to check if condition is met\n" | |
7392 | "Period between BGP table scans, in seconds; default 60\n") | |
7393 | { | |
7394 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7395 | ||
7396 | bgp->condition_check_period = | |
7397 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7398 | ||
7399 | return CMD_SUCCESS; | |
7400 | } | |
7401 | ||
cf2ad4d8 | 7402 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7403 | neighbor_advertise_map_cmd, |
52b84062 | 7404 | "[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 | 7405 | NO_STR |
7f7940e6 MK |
7406 | NEIGHBOR_STR |
7407 | NEIGHBOR_ADDR_STR2 | |
7408 | "Route-map to conditionally advertise routes\n" | |
7409 | "Name of advertise map\n" | |
7410 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7411 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7412 | "Name of the exist or non exist map\n") |
7f7940e6 | 7413 | { |
7f7940e6 MK |
7414 | bool condition = CONDITION_EXIST; |
7415 | ||
52b84062 | 7416 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7417 | condition = CONDITION_NON_EXIST; |
7418 | ||
52b84062 MK |
7419 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7420 | bgp_node_safi(vty), advertise_str, | |
7421 | condition_str, condition, !no); | |
7f7940e6 MK |
7422 | } |
7423 | ||
7424 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7425 | "[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 |
7426 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7427 | "Route-map to conditionally advertise routes\n" | |
7428 | "Name of advertise map\n" | |
7429 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7430 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7431 | "Name of the exist or non exist map\n") |
7f7940e6 | 7432 | |
718e3744 | 7433 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7434 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7435 | afi_t afi, safi_t safi, const char *name_str, | |
7436 | const char *direct_str) | |
718e3744 | 7437 | { |
0ea8d871 IR |
7438 | int ret; |
7439 | struct peer *peer; | |
7440 | int direct = RMAP_IN; | |
7441 | struct route_map *route_map; | |
718e3744 | 7442 | |
0ea8d871 IR |
7443 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7444 | if (!peer) | |
d62a17ae | 7445 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7446 | |
0ea8d871 IR |
7447 | /* Check filter direction. */ |
7448 | if (strncmp(direct_str, "in", 2) == 0) | |
7449 | direct = RMAP_IN; | |
7450 | else if (strncmp(direct_str, "o", 1) == 0) | |
7451 | direct = RMAP_OUT; | |
718e3744 | 7452 | |
0ea8d871 IR |
7453 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7454 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7455 | |
0ea8d871 IR |
7456 | return bgp_vty_return(vty, ret); |
7457 | } | |
7458 | ||
7459 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7460 | afi_t afi, safi_t safi, | |
7461 | const char *direct_str) | |
7462 | { | |
7463 | int ret; | |
7464 | struct peer *peer; | |
7465 | int direct = RMAP_IN; | |
7466 | ||
7467 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7468 | if (!peer) | |
7469 | return CMD_WARNING_CONFIG_FAILED; | |
7470 | ||
7471 | /* Check filter direction. */ | |
7472 | if (strncmp(direct_str, "in", 2) == 0) | |
7473 | direct = RMAP_IN; | |
7474 | else if (strncmp(direct_str, "o", 1) == 0) | |
7475 | direct = RMAP_OUT; | |
7476 | ||
7477 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7478 | ||
7479 | return bgp_vty_return(vty, ret); | |
7480 | } | |
7481 | ||
7482 | DEFUN (neighbor_route_map, | |
7483 | neighbor_route_map_cmd, | |
7484 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7485 | NEIGHBOR_STR | |
7486 | NEIGHBOR_ADDR_STR2 | |
7487 | "Apply route map to neighbor\n" | |
7488 | "Name of route map\n" | |
7489 | "Apply map to incoming routes\n" | |
7490 | "Apply map to outbound routes\n") | |
7491 | { | |
7492 | int idx_peer = 1; | |
7493 | int idx_word = 3; | |
7494 | int idx_in_out = 4; | |
7495 | return peer_route_map_set_vty( | |
7496 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7497 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7498 | } |
7499 | ||
d6d7ed37 IR |
7500 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7501 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7502 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7503 | "Apply route map to neighbor\n" | |
7504 | "Name of route map\n" | |
7505 | "Apply map to incoming routes\n" | |
7506 | "Apply map to outbound routes\n") | |
7507 | ||
0ea8d871 IR |
7508 | DEFUN (no_neighbor_route_map, |
7509 | no_neighbor_route_map_cmd, | |
7510 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7511 | NO_STR | |
7512 | NEIGHBOR_STR | |
7513 | NEIGHBOR_ADDR_STR2 | |
7514 | "Apply route map to neighbor\n" | |
7515 | "Name of route map\n" | |
7516 | "Apply map to incoming routes\n" | |
7517 | "Apply map to outbound routes\n") | |
7518 | { | |
7519 | int idx_peer = 2; | |
7520 | int idx_in_out = 5; | |
7521 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7522 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7523 | argv[idx_in_out]->arg); | |
7524 | } | |
7525 | ||
7526 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
d6d7ed37 IR |
7527 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
7528 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7529 | "Apply route map to neighbor\n" | |
7530 | "Name of route map\n" | |
7531 | "Apply map to incoming routes\n" | |
7532 | "Apply map to outbound routes\n") | |
7533 | ||
718e3744 | 7534 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7535 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7536 | afi_t afi, safi_t safi, | |
7537 | const char *name_str) | |
718e3744 | 7538 | { |
d62a17ae | 7539 | int ret; |
7540 | struct peer *peer; | |
1de27621 | 7541 | struct route_map *route_map; |
718e3744 | 7542 | |
d62a17ae | 7543 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7544 | if (!peer) | |
7545 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7546 | |
1de27621 DA |
7547 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7548 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7549 | |
d62a17ae | 7550 | return bgp_vty_return(vty, ret); |
718e3744 | 7551 | } |
7552 | ||
7553 | /* Unset route-map from the peer. */ | |
d62a17ae | 7554 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7555 | afi_t afi, safi_t safi) | |
718e3744 | 7556 | { |
d62a17ae | 7557 | int ret; |
7558 | struct peer *peer; | |
718e3744 | 7559 | |
d62a17ae | 7560 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7561 | if (!peer) | |
7562 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7563 | |
d62a17ae | 7564 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7565 | |
d62a17ae | 7566 | return bgp_vty_return(vty, ret); |
718e3744 | 7567 | } |
7568 | ||
7569 | DEFUN (neighbor_unsuppress_map, | |
7570 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7571 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7572 | NEIGHBOR_STR |
7573 | NEIGHBOR_ADDR_STR2 | |
7574 | "Route-map to selectively unsuppress suppressed routes\n" | |
7575 | "Name of route map\n") | |
7576 | { | |
d62a17ae | 7577 | int idx_peer = 1; |
7578 | int idx_word = 3; | |
7579 | return peer_unsuppress_map_set_vty( | |
7580 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7581 | argv[idx_word]->arg); | |
718e3744 | 7582 | } |
7583 | ||
d62a17ae | 7584 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7585 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7586 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7587 | "Route-map to selectively unsuppress suppressed routes\n" | |
7588 | "Name of route map\n") | |
596c17ba | 7589 | |
718e3744 | 7590 | DEFUN (no_neighbor_unsuppress_map, |
7591 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7592 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7593 | NO_STR |
7594 | NEIGHBOR_STR | |
7595 | NEIGHBOR_ADDR_STR2 | |
7596 | "Route-map to selectively unsuppress suppressed routes\n" | |
7597 | "Name of route map\n") | |
7598 | { | |
d62a17ae | 7599 | int idx_peer = 2; |
7600 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7601 | bgp_node_afi(vty), | |
7602 | bgp_node_safi(vty)); | |
718e3744 | 7603 | } |
6b0655a2 | 7604 | |
d62a17ae | 7605 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7606 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7607 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7608 | "Route-map to selectively unsuppress suppressed routes\n" | |
7609 | "Name of route map\n") | |
596c17ba | 7610 | |
7e62b792 IR |
7611 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7612 | afi_t afi, safi_t safi, | |
7613 | const char *num_str, | |
7614 | const char *threshold_str, int warning, | |
7615 | const char *restart_str, | |
7616 | const char *force_str) | |
7617 | { | |
7618 | int ret; | |
7619 | struct peer *peer; | |
7620 | uint32_t max; | |
7621 | uint8_t threshold; | |
7622 | uint16_t restart; | |
7623 | ||
7624 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7625 | if (!peer) | |
7626 | return CMD_WARNING_CONFIG_FAILED; | |
7627 | ||
7628 | max = strtoul(num_str, NULL, 10); | |
7629 | if (threshold_str) | |
7630 | threshold = atoi(threshold_str); | |
7631 | else | |
7632 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
7633 | ||
7634 | if (restart_str) | |
7635 | restart = atoi(restart_str); | |
7636 | else | |
7637 | restart = 0; | |
7638 | ||
7639 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
7640 | restart, force_str ? true : false); | |
7641 | ||
7642 | return bgp_vty_return(vty, ret); | |
7643 | } | |
7644 | ||
7645 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
7646 | afi_t afi, safi_t safi) | |
7647 | { | |
7648 | int ret; | |
7649 | struct peer *peer; | |
7650 | ||
7651 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7652 | if (!peer) | |
7653 | return CMD_WARNING_CONFIG_FAILED; | |
7654 | ||
7655 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
7656 | ||
7657 | return bgp_vty_return(vty, ret); | |
7658 | } | |
7659 | ||
fde246e8 | 7660 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
7661 | DEFUN(neighbor_maximum_prefix_out, |
7662 | neighbor_maximum_prefix_out_cmd, | |
7663 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7664 | NEIGHBOR_STR | |
7665 | NEIGHBOR_ADDR_STR2 | |
7666 | "Maximum number of prefixes to be sent to this peer\n" | |
7667 | "Maximum no. of prefix limit\n") | |
fde246e8 DA |
7668 | { |
7669 | int idx_peer = 1; | |
7670 | int idx_number = 3; | |
7e62b792 IR |
7671 | struct peer *peer; |
7672 | uint32_t max; | |
fde246e8 DA |
7673 | afi_t afi = bgp_node_afi(vty); |
7674 | safi_t safi = bgp_node_safi(vty); | |
7675 | ||
7e62b792 IR |
7676 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7677 | if (!peer) | |
fde246e8 DA |
7678 | return CMD_WARNING_CONFIG_FAILED; |
7679 | ||
7e62b792 | 7680 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 7681 | |
7e62b792 IR |
7682 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7683 | peer->pmax_out[afi][safi] = max; | |
fde246e8 | 7684 | |
7e62b792 | 7685 | return CMD_SUCCESS; |
fde246e8 DA |
7686 | } |
7687 | ||
1d80f243 IR |
7688 | DEFUN(no_neighbor_maximum_prefix_out, |
7689 | no_neighbor_maximum_prefix_out_cmd, | |
7690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
7691 | NO_STR | |
7692 | NEIGHBOR_STR | |
7693 | NEIGHBOR_ADDR_STR2 | |
7694 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 DA |
7695 | { |
7696 | int idx_peer = 2; | |
7e62b792 | 7697 | struct peer *peer; |
fde246e8 DA |
7698 | afi_t afi = bgp_node_afi(vty); |
7699 | safi_t safi = bgp_node_safi(vty); | |
7700 | ||
7e62b792 IR |
7701 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7702 | if (!peer) | |
fde246e8 DA |
7703 | return CMD_WARNING_CONFIG_FAILED; |
7704 | ||
7e62b792 IR |
7705 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7706 | peer->pmax_out[afi][safi] = 0; | |
fde246e8 | 7707 | |
7e62b792 | 7708 | return CMD_SUCCESS; |
fde246e8 DA |
7709 | } |
7710 | ||
9cbd06e0 DA |
7711 | /* Maximum number of prefix configuration. Prefix count is different |
7712 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7713 | each peer configuration. */ |
1d80f243 IR |
7714 | DEFUN (neighbor_maximum_prefix, |
7715 | neighbor_maximum_prefix_cmd, | |
7716 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7717 | NEIGHBOR_STR | |
7718 | NEIGHBOR_ADDR_STR2 | |
7719 | "Maximum number of prefix accept from this peer\n" | |
7720 | "maximum no. of prefix limit\n" | |
7721 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7722 | { |
d62a17ae | 7723 | int idx_peer = 1; |
7724 | int idx_number = 3; | |
9cbd06e0 | 7725 | int idx_force = 0; |
7e62b792 | 7726 | char *force = NULL; |
9cbd06e0 DA |
7727 | |
7728 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7729 | force = argv[idx_force]->arg; |
9cbd06e0 | 7730 | |
7e62b792 IR |
7731 | return peer_maximum_prefix_set_vty( |
7732 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7733 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 7734 | } |
7735 | ||
d62a17ae | 7736 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7737 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7738 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7739 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7740 | "maximum no. of prefix limit\n" |
7741 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7742 | |
1d80f243 IR |
7743 | DEFUN (neighbor_maximum_prefix_threshold, |
7744 | neighbor_maximum_prefix_threshold_cmd, | |
7745 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7746 | NEIGHBOR_STR | |
7747 | NEIGHBOR_ADDR_STR2 | |
7748 | "Maximum number of prefix accept from this peer\n" | |
7749 | "maximum no. of prefix limit\n" | |
7750 | "Threshold value (%) at which to generate a warning msg\n" | |
7751 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7752 | { |
d62a17ae | 7753 | int idx_peer = 1; |
7754 | int idx_number = 3; | |
7755 | int idx_number_2 = 4; | |
9cbd06e0 | 7756 | int idx_force = 0; |
7e62b792 | 7757 | char *force = NULL; |
9cbd06e0 DA |
7758 | |
7759 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7760 | force = argv[idx_force]->arg; |
9cbd06e0 | 7761 | |
7e62b792 IR |
7762 | return peer_maximum_prefix_set_vty( |
7763 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7764 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 7765 | } |
e0701b79 | 7766 | |
d62a17ae | 7767 | ALIAS_HIDDEN( |
7768 | neighbor_maximum_prefix_threshold, | |
7769 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7770 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7771 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7772 | "Maximum number of prefix accept from this peer\n" | |
7773 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7774 | "Threshold value (%) at which to generate a warning msg\n" |
7775 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7776 | |
1d80f243 IR |
7777 | DEFUN (neighbor_maximum_prefix_warning, |
7778 | neighbor_maximum_prefix_warning_cmd, | |
7779 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7780 | NEIGHBOR_STR | |
7781 | NEIGHBOR_ADDR_STR2 | |
7782 | "Maximum number of prefix accept from this peer\n" | |
7783 | "maximum no. of prefix limit\n" | |
7784 | "Only give warning message when limit is exceeded\n" | |
7785 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7786 | { |
d62a17ae | 7787 | int idx_peer = 1; |
7788 | int idx_number = 3; | |
9cbd06e0 | 7789 | int idx_force = 0; |
7e62b792 | 7790 | char *force = NULL; |
9cbd06e0 DA |
7791 | |
7792 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7793 | force = argv[idx_force]->arg; |
9cbd06e0 | 7794 | |
7e62b792 IR |
7795 | return peer_maximum_prefix_set_vty( |
7796 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7797 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 7798 | } |
7799 | ||
d62a17ae | 7800 | ALIAS_HIDDEN( |
7801 | neighbor_maximum_prefix_warning, | |
7802 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7803 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7804 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7805 | "Maximum number of prefix accept from this peer\n" | |
7806 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7807 | "Only give warning message when limit is exceeded\n" |
7808 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7809 | |
1d80f243 IR |
7810 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7811 | neighbor_maximum_prefix_threshold_warning_cmd, | |
7812 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7813 | NEIGHBOR_STR | |
7814 | NEIGHBOR_ADDR_STR2 | |
7815 | "Maximum number of prefix accept from this peer\n" | |
7816 | "maximum no. of prefix limit\n" | |
7817 | "Threshold value (%) at which to generate a warning msg\n" | |
7818 | "Only give warning message when limit is exceeded\n" | |
7819 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7820 | { |
d62a17ae | 7821 | int idx_peer = 1; |
7822 | int idx_number = 3; | |
7823 | int idx_number_2 = 4; | |
9cbd06e0 | 7824 | int idx_force = 0; |
7e62b792 | 7825 | char *force = NULL; |
9cbd06e0 DA |
7826 | |
7827 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7828 | force = argv[idx_force]->arg; |
9cbd06e0 | 7829 | |
7e62b792 IR |
7830 | return peer_maximum_prefix_set_vty( |
7831 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7832 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 7833 | } |
7834 | ||
d62a17ae | 7835 | ALIAS_HIDDEN( |
7836 | neighbor_maximum_prefix_threshold_warning, | |
7837 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7838 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7839 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7840 | "Maximum number of prefix accept from this peer\n" | |
7841 | "maximum no. of prefix limit\n" | |
7842 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7843 | "Only give warning message when limit is exceeded\n" |
7844 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7845 | |
1d80f243 IR |
7846 | DEFUN (neighbor_maximum_prefix_restart, |
7847 | neighbor_maximum_prefix_restart_cmd, | |
7848 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7849 | NEIGHBOR_STR | |
7850 | NEIGHBOR_ADDR_STR2 | |
7851 | "Maximum number of prefix accept from this peer\n" | |
7852 | "maximum no. of prefix limit\n" | |
7853 | "Restart bgp connection after limit is exceeded\n" | |
7854 | "Restart interval in minutes\n" | |
7855 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7856 | { |
d62a17ae | 7857 | int idx_peer = 1; |
7858 | int idx_number = 3; | |
7859 | int idx_number_2 = 5; | |
9cbd06e0 | 7860 | int idx_force = 0; |
7e62b792 | 7861 | char *force = NULL; |
9cbd06e0 DA |
7862 | |
7863 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7864 | force = argv[idx_force]->arg; |
9cbd06e0 | 7865 | |
7e62b792 IR |
7866 | return peer_maximum_prefix_set_vty( |
7867 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7868 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 7869 | } |
7870 | ||
d62a17ae | 7871 | ALIAS_HIDDEN( |
7872 | neighbor_maximum_prefix_restart, | |
7873 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7874 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7875 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7876 | "Maximum number of prefix accept from this peer\n" | |
7877 | "maximum no. of prefix limit\n" | |
7878 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7879 | "Restart interval in minutes\n" |
7880 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7881 | |
1d80f243 IR |
7882 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7883 | neighbor_maximum_prefix_threshold_restart_cmd, | |
7884 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
7885 | NEIGHBOR_STR | |
7886 | NEIGHBOR_ADDR_STR2 | |
7887 | "Maximum number of prefixes to accept from this peer\n" | |
7888 | "maximum no. of prefix limit\n" | |
7889 | "Threshold value (%) at which to generate a warning msg\n" | |
7890 | "Restart bgp connection after limit is exceeded\n" | |
7891 | "Restart interval in minutes\n" | |
7892 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7893 | { |
d62a17ae | 7894 | int idx_peer = 1; |
7895 | int idx_number = 3; | |
7896 | int idx_number_2 = 4; | |
7897 | int idx_number_3 = 6; | |
9cbd06e0 | 7898 | int idx_force = 0; |
7e62b792 | 7899 | char *force = NULL; |
9cbd06e0 DA |
7900 | |
7901 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7902 | force = argv[idx_force]->arg; |
9cbd06e0 | 7903 | |
7e62b792 IR |
7904 | return peer_maximum_prefix_set_vty( |
7905 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7906 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
7907 | argv[idx_number_3]->arg, force); | |
d62a17ae | 7908 | } |
7909 | ||
7910 | ALIAS_HIDDEN( | |
7911 | neighbor_maximum_prefix_threshold_restart, | |
7912 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7913 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7914 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7915 | "Maximum number of prefixes to accept from this peer\n" | |
7916 | "maximum no. of prefix limit\n" | |
7917 | "Threshold value (%) at which to generate a warning msg\n" | |
7918 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7919 | "Restart interval in minutes\n" |
7920 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7921 | |
1d80f243 IR |
7922 | DEFUN (no_neighbor_maximum_prefix, |
7923 | no_neighbor_maximum_prefix_cmd, | |
7924 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
7925 | NO_STR | |
7926 | NEIGHBOR_STR | |
7927 | NEIGHBOR_ADDR_STR2 | |
7928 | "Maximum number of prefixes to accept from this peer\n" | |
7929 | "maximum no. of prefix limit\n" | |
7930 | "Threshold value (%) at which to generate a warning msg\n" | |
7931 | "Restart bgp connection after limit is exceeded\n" | |
7932 | "Restart interval in minutes\n" | |
7933 | "Only give warning message when limit is exceeded\n" | |
7934 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7935 | { |
d62a17ae | 7936 | int idx_peer = 2; |
7e62b792 IR |
7937 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
7938 | bgp_node_afi(vty), | |
7939 | bgp_node_safi(vty)); | |
718e3744 | 7940 | } |
e52702f2 | 7941 | |
d62a17ae | 7942 | ALIAS_HIDDEN( |
7943 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7944 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7945 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7946 | "Maximum number of prefixes to accept from this peer\n" | |
7947 | "maximum no. of prefix limit\n" | |
7948 | "Threshold value (%) at which to generate a warning msg\n" | |
7949 | "Restart bgp connection after limit is exceeded\n" | |
7950 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7951 | "Only give warning message when limit is exceeded\n" |
7952 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7953 | |
718e3744 | 7954 | |
718e3744 | 7955 | /* "neighbor allowas-in" */ |
7956 | DEFUN (neighbor_allowas_in, | |
7957 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7958 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7959 | NEIGHBOR_STR |
7960 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7961 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7962 | "Number of occurrences of AS number\n" |
fd8503f5 | 7963 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7964 | { |
d62a17ae | 7965 | int idx_peer = 1; |
7966 | int idx_number_origin = 3; | |
7967 | int ret; | |
7968 | int origin = 0; | |
7969 | struct peer *peer; | |
7970 | int allow_num = 0; | |
7971 | ||
7972 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7973 | if (!peer) | |
7974 | return CMD_WARNING_CONFIG_FAILED; | |
7975 | ||
7976 | if (argc <= idx_number_origin) | |
7977 | allow_num = 3; | |
7978 | else { | |
7979 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7980 | origin = 1; | |
7981 | else | |
7982 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7983 | } | |
7984 | ||
7985 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7986 | allow_num, origin); | |
7987 | ||
7988 | return bgp_vty_return(vty, ret); | |
7989 | } | |
7990 | ||
7991 | ALIAS_HIDDEN( | |
7992 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7993 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7994 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7995 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7996 | "Number of occurrences of AS number\n" |
d62a17ae | 7997 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7998 | |
718e3744 | 7999 | DEFUN (no_neighbor_allowas_in, |
8000 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8001 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8002 | NO_STR |
8003 | NEIGHBOR_STR | |
8004 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8005 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8006 | "Number of occurrences of AS number\n" |
fd8503f5 | 8007 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8008 | { |
d62a17ae | 8009 | int idx_peer = 2; |
8010 | int ret; | |
8011 | struct peer *peer; | |
718e3744 | 8012 | |
d62a17ae | 8013 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8014 | if (!peer) | |
8015 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8016 | |
d62a17ae | 8017 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8018 | bgp_node_safi(vty)); | |
718e3744 | 8019 | |
d62a17ae | 8020 | return bgp_vty_return(vty, ret); |
718e3744 | 8021 | } |
6b0655a2 | 8022 | |
d62a17ae | 8023 | ALIAS_HIDDEN( |
8024 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8025 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8026 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8027 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8028 | "Number of occurrences of AS number\n" |
d62a17ae | 8029 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8030 | |
28c6e247 IR |
8031 | DEFUN (neighbor_ttl_security, |
8032 | neighbor_ttl_security_cmd, | |
8033 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8034 | NEIGHBOR_STR | |
8035 | NEIGHBOR_ADDR_STR2 | |
8036 | "BGP ttl-security parameters\n" | |
8037 | "Specify the maximum number of hops to the BGP peer\n" | |
8038 | "Number of hops to BGP peer\n") | |
fa411a21 | 8039 | { |
d62a17ae | 8040 | int idx_peer = 1; |
8041 | int idx_number = 4; | |
28c6e247 IR |
8042 | struct peer *peer; |
8043 | int gtsm_hops; | |
d62a17ae | 8044 | |
28c6e247 IR |
8045 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8046 | if (!peer) | |
d62a17ae | 8047 | return CMD_WARNING_CONFIG_FAILED; |
8048 | ||
28c6e247 IR |
8049 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8050 | ||
8051 | /* | |
8052 | * If 'neighbor swpX', then this is for directly connected peers, | |
8053 | * we should not accept a ttl-security hops value greater than 1. | |
8054 | */ | |
8055 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8056 | vty_out(vty, | |
8057 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8058 | argv[idx_peer]->arg); | |
8059 | return CMD_WARNING_CONFIG_FAILED; | |
8060 | } | |
7ebe625c | 8061 | |
28c6e247 | 8062 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8063 | } |
8064 | ||
1d80f243 IR |
8065 | DEFUN (no_neighbor_ttl_security, |
8066 | no_neighbor_ttl_security_cmd, | |
8067 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8068 | NO_STR | |
8069 | NEIGHBOR_STR | |
8070 | NEIGHBOR_ADDR_STR2 | |
8071 | "BGP ttl-security parameters\n" | |
8072 | "Specify the maximum number of hops to the BGP peer\n" | |
8073 | "Number of hops to BGP peer\n") | |
fa411a21 | 8074 | { |
d62a17ae | 8075 | int idx_peer = 2; |
28c6e247 | 8076 | struct peer *peer; |
fa411a21 | 8077 | |
28c6e247 IR |
8078 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8079 | if (!peer) | |
d62a17ae | 8080 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8081 | |
28c6e247 | 8082 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8083 | } |
6b0655a2 | 8084 | |
7c0e4312 DA |
8085 | /* disable-addpath-rx */ |
8086 | DEFUN(neighbor_disable_addpath_rx, | |
8087 | neighbor_disable_addpath_rx_cmd, | |
8088 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8089 | NEIGHBOR_STR | |
8090 | NEIGHBOR_ADDR_STR2 | |
8091 | "Do not accept additional paths\n") | |
8092 | { | |
8093 | char *peer_str = argv[1]->arg; | |
8094 | struct peer *peer; | |
8095 | afi_t afi = bgp_node_afi(vty); | |
8096 | safi_t safi = bgp_node_safi(vty); | |
8097 | ||
8098 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8099 | if (!peer) | |
8100 | return CMD_WARNING_CONFIG_FAILED; | |
8101 | ||
8102 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8103 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8104 | } | |
8105 | ||
8106 | DEFUN(no_neighbor_disable_addpath_rx, | |
8107 | no_neighbor_disable_addpath_rx_cmd, | |
8108 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8109 | NO_STR | |
8110 | NEIGHBOR_STR | |
8111 | NEIGHBOR_ADDR_STR2 | |
8112 | "Do not accept additional paths\n") | |
8113 | { | |
8114 | char *peer_str = argv[2]->arg; | |
8115 | struct peer *peer; | |
8116 | afi_t afi = bgp_node_afi(vty); | |
8117 | safi_t safi = bgp_node_safi(vty); | |
8118 | ||
8119 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8120 | if (!peer) | |
8121 | return CMD_WARNING_CONFIG_FAILED; | |
8122 | ||
8123 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8124 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8125 | } | |
8126 | ||
adbac85e DW |
8127 | DEFUN (neighbor_addpath_tx_all_paths, |
8128 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8129 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8130 | NEIGHBOR_STR |
8131 | NEIGHBOR_ADDR_STR2 | |
8132 | "Use addpath to advertise all paths to a neighbor\n") | |
8133 | { | |
d62a17ae | 8134 | int idx_peer = 1; |
8135 | struct peer *peer; | |
adbac85e | 8136 | |
d62a17ae | 8137 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8138 | if (!peer) | |
8139 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8140 | |
dcc68b5e MS |
8141 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8142 | BGP_ADDPATH_ALL); | |
8143 | return CMD_SUCCESS; | |
adbac85e DW |
8144 | } |
8145 | ||
d62a17ae | 8146 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8147 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8148 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8149 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8150 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8151 | |
adbac85e DW |
8152 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8153 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8155 | NO_STR |
8156 | NEIGHBOR_STR | |
8157 | NEIGHBOR_ADDR_STR2 | |
8158 | "Use addpath to advertise all paths to a neighbor\n") | |
8159 | { | |
d62a17ae | 8160 | int idx_peer = 2; |
dcc68b5e MS |
8161 | struct peer *peer; |
8162 | ||
8163 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8164 | if (!peer) | |
8165 | return CMD_WARNING_CONFIG_FAILED; | |
8166 | ||
8167 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8168 | != BGP_ADDPATH_ALL) { | |
8169 | vty_out(vty, | |
8170 | "%% Peer not currently configured to transmit all paths."); | |
8171 | return CMD_WARNING_CONFIG_FAILED; | |
8172 | } | |
8173 | ||
8174 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8175 | BGP_ADDPATH_NONE); | |
8176 | ||
8177 | return CMD_SUCCESS; | |
adbac85e DW |
8178 | } |
8179 | ||
d62a17ae | 8180 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8181 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8182 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8183 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8184 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8185 | |
06370dac DW |
8186 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8187 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8188 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8189 | NEIGHBOR_STR |
8190 | NEIGHBOR_ADDR_STR2 | |
8191 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8192 | { | |
d62a17ae | 8193 | int idx_peer = 1; |
8194 | struct peer *peer; | |
06370dac | 8195 | |
d62a17ae | 8196 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8197 | if (!peer) | |
8198 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8199 | |
dcc68b5e MS |
8200 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8201 | BGP_ADDPATH_BEST_PER_AS); | |
8202 | ||
8203 | return CMD_SUCCESS; | |
06370dac DW |
8204 | } |
8205 | ||
d62a17ae | 8206 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8207 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8208 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8209 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8210 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8211 | |
06370dac DW |
8212 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8213 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8215 | NO_STR |
8216 | NEIGHBOR_STR | |
8217 | NEIGHBOR_ADDR_STR2 | |
8218 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8219 | { | |
d62a17ae | 8220 | int idx_peer = 2; |
dcc68b5e MS |
8221 | struct peer *peer; |
8222 | ||
8223 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8224 | if (!peer) | |
8225 | return CMD_WARNING_CONFIG_FAILED; | |
8226 | ||
8227 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8228 | != BGP_ADDPATH_BEST_PER_AS) { | |
8229 | vty_out(vty, | |
8230 | "%% Peer not currently configured to transmit all best path per as."); | |
8231 | return CMD_WARNING_CONFIG_FAILED; | |
8232 | } | |
8233 | ||
8234 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8235 | BGP_ADDPATH_NONE); | |
8236 | ||
8237 | return CMD_SUCCESS; | |
06370dac DW |
8238 | } |
8239 | ||
d62a17ae | 8240 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8241 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8242 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8243 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8244 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8245 | |
2b31007c RZ |
8246 | DEFPY( |
8247 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8248 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8249 | NEIGHBOR_STR | |
8250 | NEIGHBOR_ADDR_STR2 | |
8251 | "Detect AS loops before sending to neighbor\n") | |
8252 | { | |
8253 | struct peer *peer; | |
8254 | ||
8255 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8256 | if (!peer) | |
8257 | return CMD_WARNING_CONFIG_FAILED; | |
8258 | ||
8259 | peer->as_path_loop_detection = true; | |
8260 | ||
8261 | return CMD_SUCCESS; | |
8262 | } | |
8263 | ||
8264 | DEFPY( | |
8265 | no_neighbor_aspath_loop_detection, | |
8266 | no_neighbor_aspath_loop_detection_cmd, | |
8267 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8268 | NO_STR | |
8269 | NEIGHBOR_STR | |
8270 | NEIGHBOR_ADDR_STR2 | |
8271 | "Detect AS loops before sending to neighbor\n") | |
8272 | { | |
8273 | struct peer *peer; | |
8274 | ||
8275 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8276 | if (!peer) | |
8277 | return CMD_WARNING_CONFIG_FAILED; | |
8278 | ||
8279 | peer->as_path_loop_detection = false; | |
8280 | ||
8281 | return CMD_SUCCESS; | |
8282 | } | |
8283 | ||
b9c7bc5a | 8284 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8285 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8286 | { |
b9c7bc5a PZ |
8287 | struct ecommunity *ecom = NULL; |
8288 | struct ecommunity *ecomadd; | |
ddb5b488 | 8289 | |
b9c7bc5a | 8290 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8291 | if (is_rt6) |
8292 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8293 | ECOMMUNITY_ROUTE_TARGET, | |
8294 | 0); | |
8295 | else | |
8296 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8297 | ECOMMUNITY_ROUTE_TARGET, | |
8298 | 0); | |
b9c7bc5a PZ |
8299 | if (!ecomadd) { |
8300 | vty_out(vty, "Malformed community-list value\n"); | |
8301 | if (ecom) | |
8302 | ecommunity_free(&ecom); | |
8303 | return CMD_WARNING_CONFIG_FAILED; | |
8304 | } | |
ddb5b488 | 8305 | |
b9c7bc5a PZ |
8306 | if (ecom) { |
8307 | ecommunity_merge(ecom, ecomadd); | |
8308 | ecommunity_free(&ecomadd); | |
8309 | } else { | |
8310 | ecom = ecomadd; | |
8311 | } | |
8312 | } | |
8313 | ||
8314 | if (*list) { | |
8315 | ecommunity_free(&*list); | |
ddb5b488 | 8316 | } |
b9c7bc5a PZ |
8317 | *list = ecom; |
8318 | ||
8319 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8320 | } |
8321 | ||
0ca70ba5 DS |
8322 | /* |
8323 | * v2vimport is true if we are handling a `import vrf ...` command | |
8324 | */ | |
8325 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8326 | { |
0ca70ba5 DS |
8327 | afi_t afi; |
8328 | ||
ddb5b488 | 8329 | switch (vty->node) { |
b9c7bc5a | 8330 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8331 | afi = AFI_IP; |
8332 | break; | |
b9c7bc5a | 8333 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8334 | afi = AFI_IP6; |
8335 | break; | |
ddb5b488 PZ |
8336 | default: |
8337 | vty_out(vty, | |
b9c7bc5a | 8338 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8339 | return AFI_MAX; |
ddb5b488 | 8340 | } |
69b07479 | 8341 | |
0ca70ba5 DS |
8342 | if (!v2vimport) { |
8343 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8344 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8345 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8346 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8347 | vty_out(vty, | |
8348 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8349 | return AFI_MAX; | |
8350 | } | |
8351 | } else { | |
8352 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8353 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8354 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8355 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8356 | vty_out(vty, | |
8357 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8358 | return AFI_MAX; | |
8359 | } | |
8360 | } | |
8361 | return afi; | |
ddb5b488 PZ |
8362 | } |
8363 | ||
585f1adc IR |
8364 | DEFPY (af_rd_vpn_export, |
8365 | af_rd_vpn_export_cmd, | |
8366 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8367 | NO_STR | |
8368 | "Specify route distinguisher\n" | |
8369 | "Between current address-family and vpn\n" | |
8370 | "For routes leaked from current address-family to vpn\n" | |
8371 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8372 | { |
585f1adc IR |
8373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8374 | struct prefix_rd prd; | |
8375 | int ret; | |
ddb5b488 | 8376 | afi_t afi; |
b9c7bc5a | 8377 | int idx = 0; |
585f1adc | 8378 | bool yes = true; |
b9c7bc5a | 8379 | |
585f1adc IR |
8380 | if (argv_find(argv, argc, "no", &idx)) |
8381 | yes = false; | |
ddb5b488 | 8382 | |
585f1adc IR |
8383 | if (yes) { |
8384 | ret = str2prefix_rd(rd_str, &prd); | |
8385 | if (!ret) { | |
8386 | vty_out(vty, "%% Malformed rd\n"); | |
8387 | return CMD_WARNING_CONFIG_FAILED; | |
8388 | } | |
8389 | } | |
ddb5b488 | 8390 | |
585f1adc IR |
8391 | afi = vpn_policy_getafi(vty, bgp, false); |
8392 | if (afi == AFI_MAX) | |
8393 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8394 | |
585f1adc IR |
8395 | /* |
8396 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8397 | */ | |
8398 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8399 | bgp_get_default(), bgp); | |
ddb5b488 | 8400 | |
585f1adc IR |
8401 | if (yes) { |
8402 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8403 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8404 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8405 | } else { | |
8406 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8407 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8408 | } | |
69b07479 | 8409 | |
585f1adc IR |
8410 | /* post-change: re-export vpn routes */ |
8411 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8412 | bgp_get_default(), bgp); | |
8413 | ||
8414 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8415 | } |
8416 | ||
b9c7bc5a PZ |
8417 | ALIAS (af_rd_vpn_export, |
8418 | af_no_rd_vpn_export_cmd, | |
8419 | "no rd vpn export", | |
ddb5b488 | 8420 | NO_STR |
b9c7bc5a PZ |
8421 | "Specify route distinguisher\n" |
8422 | "Between current address-family and vpn\n" | |
8423 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8424 | |
b9c7bc5a PZ |
8425 | DEFPY (af_label_vpn_export, |
8426 | af_label_vpn_export_cmd, | |
e70e9f8e | 8427 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8428 | NO_STR |
ddb5b488 | 8429 | "label value for VRF\n" |
b9c7bc5a PZ |
8430 | "Between current address-family and vpn\n" |
8431 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8432 | "Label Value <0-1048575>\n" |
8433 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8434 | { |
8435 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8436 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8437 | afi_t afi; |
b9c7bc5a | 8438 | int idx = 0; |
c6423c31 | 8439 | bool yes = true; |
b9c7bc5a PZ |
8440 | |
8441 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8442 | yes = false; |
ddb5b488 | 8443 | |
21a16cc2 PZ |
8444 | /* If "no ...", squash trailing parameter */ |
8445 | if (!yes) | |
8446 | label_auto = NULL; | |
8447 | ||
e70e9f8e PZ |
8448 | if (yes) { |
8449 | if (!label_auto) | |
8450 | label = label_val; /* parser should force unsigned */ | |
8451 | } | |
ddb5b488 | 8452 | |
0ca70ba5 | 8453 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8454 | if (afi == AFI_MAX) |
8455 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8456 | |
e70e9f8e | 8457 | |
69b07479 DS |
8458 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8459 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8460 | /* no change */ | |
8461 | return CMD_SUCCESS; | |
e70e9f8e | 8462 | |
69b07479 DS |
8463 | /* |
8464 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8465 | */ | |
8466 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8467 | bgp_get_default(), bgp); | |
8468 | ||
8469 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8470 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8471 | ||
8472 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8473 | ||
8474 | /* | |
8475 | * label has previously been automatically | |
8476 | * assigned by labelpool: release it | |
8477 | * | |
8478 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8479 | * means the automatic assignment is in flight | |
8480 | * and therefore the labelpool callback must | |
8481 | * detect that the auto label is not needed. | |
8482 | */ | |
8483 | ||
8484 | bgp_lp_release(LP_TYPE_VRF, | |
8485 | &bgp->vpn_policy[afi], | |
8486 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8487 | } |
69b07479 DS |
8488 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8489 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8490 | } | |
ddb5b488 | 8491 | |
69b07479 DS |
8492 | bgp->vpn_policy[afi].tovpn_label = label; |
8493 | if (label_auto) { | |
8494 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8495 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8496 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8497 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8498 | } |
8499 | ||
69b07479 DS |
8500 | /* post-change: re-export vpn routes */ |
8501 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8502 | bgp_get_default(), bgp); | |
8503 | ||
0d020cd6 | 8504 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
8505 | return CMD_SUCCESS; |
8506 | } | |
8507 | ||
b72c9e14 HS |
8508 | DEFPY (af_sid_vpn_export, |
8509 | af_sid_vpn_export_cmd, | |
8510 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
8511 | NO_STR | |
8512 | "sid value for VRF\n" | |
8513 | "Between current address-family and vpn\n" | |
8514 | "For routes leaked from current address-family to vpn\n" | |
8515 | "Sid allocation index\n" | |
8516 | "Automatically assign a label\n") | |
8517 | { | |
8518 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8519 | afi_t afi; | |
8520 | int debug = 0; | |
8521 | int idx = 0; | |
8522 | bool yes = true; | |
8523 | ||
8524 | if (argv_find(argv, argc, "no", &idx)) | |
8525 | yes = false; | |
8526 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
8527 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
8528 | ||
8529 | afi = vpn_policy_getafi(vty, bgp, false); | |
8530 | if (afi == AFI_MAX) | |
8531 | return CMD_WARNING_CONFIG_FAILED; | |
8532 | ||
8533 | if (!yes) { | |
8534 | /* implement me */ | |
8535 | vty_out(vty, "It's not implemented"); | |
8536 | return CMD_WARNING_CONFIG_FAILED; | |
8537 | } | |
8538 | ||
8539 | /* skip when it's already configured */ | |
8540 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8541 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8542 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
8543 | return CMD_SUCCESS; | |
8544 | ||
7de4c885 HS |
8545 | /* |
8546 | * mode change between sid_idx and sid_auto isn't supported. | |
8547 | * user must negate sid vpn export when they want to change the mode | |
8548 | */ | |
b72c9e14 HS |
8549 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
8550 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8551 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
8552 | vty_out(vty, "it's already configured as %s.\n", | |
8553 | sid_auto ? "auto-mode" : "idx-mode"); | |
8554 | return CMD_WARNING_CONFIG_FAILED; | |
8555 | } | |
8556 | ||
8557 | /* pre-change */ | |
8558 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8559 | bgp_get_default(), bgp); | |
8560 | ||
8561 | if (sid_auto) { | |
8562 | /* SID allocation auto-mode */ | |
8563 | if (debug) | |
8564 | zlog_debug("%s: auto sid alloc.", __func__); | |
8565 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8566 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
8567 | } else { | |
8568 | /* SID allocation index-mode */ | |
8569 | if (debug) | |
8570 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
8571 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
8572 | } | |
8573 | ||
8574 | /* post-change */ | |
8575 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8576 | bgp_get_default(), bgp); | |
8577 | return CMD_SUCCESS; | |
8578 | } | |
8579 | ||
b9c7bc5a PZ |
8580 | ALIAS (af_label_vpn_export, |
8581 | af_no_label_vpn_export_cmd, | |
8582 | "no label vpn export", | |
8583 | NO_STR | |
8584 | "label value for VRF\n" | |
8585 | "Between current address-family and vpn\n" | |
8586 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8587 | |
585f1adc | 8588 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 8589 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 8590 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8591 | NO_STR |
ddb5b488 | 8592 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8593 | "Between current address-family and vpn\n" |
8594 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8595 | "IPv4 prefix\n" |
8596 | "IPv6 prefix\n") | |
8597 | { | |
585f1adc | 8598 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 8599 | afi_t afi; |
ddb5b488 PZ |
8600 | struct prefix p; |
8601 | ||
8c85ca28 QY |
8602 | if (!no) { |
8603 | if (!nexthop_su) { | |
8604 | vty_out(vty, "%% Nexthop required\n"); | |
8605 | return CMD_WARNING_CONFIG_FAILED; | |
8606 | } | |
8c85ca28 | 8607 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8608 | return CMD_WARNING_CONFIG_FAILED; |
8609 | } | |
ddb5b488 | 8610 | |
585f1adc IR |
8611 | afi = vpn_policy_getafi(vty, bgp, false); |
8612 | if (afi == AFI_MAX) | |
8613 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8614 | |
585f1adc IR |
8615 | /* |
8616 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8617 | */ | |
8618 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8619 | bgp_get_default(), bgp); | |
ddb5b488 | 8620 | |
585f1adc IR |
8621 | if (!no) { |
8622 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
8623 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8624 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8625 | } else { | |
8626 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8627 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8628 | } | |
69b07479 | 8629 | |
585f1adc IR |
8630 | /* post-change: re-export vpn routes */ |
8631 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8632 | bgp_get_default(), bgp); | |
37a87b8f | 8633 | |
585f1adc | 8634 | return CMD_SUCCESS; |
ddb5b488 PZ |
8635 | } |
8636 | ||
b9c7bc5a | 8637 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8638 | { |
b9c7bc5a PZ |
8639 | if (!strcmp(dstr, "import")) { |
8640 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8641 | } else if (!strcmp(dstr, "export")) { | |
8642 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8643 | } else if (!strcmp(dstr, "both")) { | |
8644 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8645 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8646 | } else { | |
8647 | vty_out(vty, "%% direction parse error\n"); | |
8648 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8649 | } |
ddb5b488 PZ |
8650 | return CMD_SUCCESS; |
8651 | } | |
8652 | ||
b9c7bc5a PZ |
8653 | DEFPY (af_rt_vpn_imexport, |
8654 | af_rt_vpn_imexport_cmd, | |
8655 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8656 | NO_STR | |
8657 | "Specify route target list\n" | |
ddb5b488 | 8658 | "Specify route target list\n" |
b9c7bc5a PZ |
8659 | "Between current address-family and vpn\n" |
8660 | "For routes leaked from vpn to current address-family: match any\n" | |
8661 | "For routes leaked from current address-family to vpn: set\n" | |
8662 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8663 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8664 | { | |
8665 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8666 | int ret; | |
8667 | struct ecommunity *ecom = NULL; | |
8668 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8669 | vpn_policy_direction_t dir; |
8670 | afi_t afi; | |
8671 | int idx = 0; | |
c6423c31 | 8672 | bool yes = true; |
ddb5b488 | 8673 | |
b9c7bc5a | 8674 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8675 | yes = false; |
b9c7bc5a | 8676 | |
0ca70ba5 | 8677 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8678 | if (afi == AFI_MAX) |
8679 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8680 | |
b9c7bc5a | 8681 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8682 | if (ret != CMD_SUCCESS) |
8683 | return ret; | |
8684 | ||
b9c7bc5a PZ |
8685 | if (yes) { |
8686 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8687 | vty_out(vty, "%% Missing RTLIST\n"); | |
8688 | return CMD_WARNING_CONFIG_FAILED; | |
8689 | } | |
c6423c31 | 8690 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8691 | if (ret != CMD_SUCCESS) { |
8692 | return ret; | |
8693 | } | |
ddb5b488 PZ |
8694 | } |
8695 | ||
69b07479 DS |
8696 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8697 | if (!dodir[dir]) | |
ddb5b488 | 8698 | continue; |
ddb5b488 | 8699 | |
69b07479 | 8700 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8701 | |
69b07479 DS |
8702 | if (yes) { |
8703 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8704 | ecommunity_free( | |
8705 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8706 | bgp->vpn_policy[afi].rtlist[dir] = | |
8707 | ecommunity_dup(ecom); | |
8708 | } else { | |
8709 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8710 | ecommunity_free( | |
8711 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8712 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8713 | } |
69b07479 DS |
8714 | |
8715 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8716 | } |
69b07479 | 8717 | |
d555f3e9 PZ |
8718 | if (ecom) |
8719 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8720 | |
8721 | return CMD_SUCCESS; | |
8722 | } | |
8723 | ||
b9c7bc5a PZ |
8724 | ALIAS (af_rt_vpn_imexport, |
8725 | af_no_rt_vpn_imexport_cmd, | |
8726 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8727 | NO_STR |
8728 | "Specify route target list\n" | |
b9c7bc5a PZ |
8729 | "Specify route target list\n" |
8730 | "Between current address-family and vpn\n" | |
8731 | "For routes leaked from vpn to current address-family\n" | |
8732 | "For routes leaked from current address-family to vpn\n" | |
8733 | "both import and export\n") | |
8734 | ||
585f1adc | 8735 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
8736 | af_route_map_vpn_imexport_cmd, |
8737 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8738 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8739 | NO_STR | |
ddb5b488 | 8740 | "Specify route map\n" |
b9c7bc5a PZ |
8741 | "Between current address-family and vpn\n" |
8742 | "For routes leaked from vpn to current address-family\n" | |
8743 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8744 | "name of route-map\n") |
8745 | { | |
585f1adc IR |
8746 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8747 | int ret; | |
8748 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
8749 | vpn_policy_direction_t dir; | |
ddb5b488 | 8750 | afi_t afi; |
ddb5b488 | 8751 | int idx = 0; |
585f1adc | 8752 | bool yes = true; |
ddb5b488 | 8753 | |
585f1adc IR |
8754 | if (argv_find(argv, argc, "no", &idx)) |
8755 | yes = false; | |
ddb5b488 | 8756 | |
585f1adc IR |
8757 | afi = vpn_policy_getafi(vty, bgp, false); |
8758 | if (afi == AFI_MAX) | |
8759 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8760 | |
585f1adc IR |
8761 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
8762 | if (ret != CMD_SUCCESS) | |
8763 | return ret; | |
ddb5b488 | 8764 | |
585f1adc IR |
8765 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8766 | if (!dodir[dir]) | |
8767 | continue; | |
69b07479 | 8768 | |
585f1adc IR |
8769 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
8770 | ||
8771 | if (yes) { | |
8772 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8773 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8774 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8775 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8776 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8777 | bgp->vpn_policy[afi].rmap[dir] = | |
8778 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8779 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8780 | return CMD_SUCCESS; | |
8781 | } else { | |
8782 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8783 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8784 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8785 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8786 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8787 | } | |
8788 | ||
8789 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8790 | } | |
ddb5b488 | 8791 | |
585f1adc | 8792 | return CMD_SUCCESS; |
ddb5b488 PZ |
8793 | } |
8794 | ||
b9c7bc5a PZ |
8795 | ALIAS (af_route_map_vpn_imexport, |
8796 | af_no_route_map_vpn_imexport_cmd, | |
8797 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8798 | NO_STR |
8799 | "Specify route map\n" | |
b9c7bc5a PZ |
8800 | "Between current address-family and vpn\n" |
8801 | "For routes leaked from vpn to current address-family\n" | |
8802 | "For routes leaked from current address-family to vpn\n") | |
8803 | ||
bb4f6190 | 8804 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8805 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8806 | "Import routes from another VRF\n" |
8807 | "Vrf routes being filtered\n" | |
8808 | "Specify route map\n" | |
8809 | "name of route-map\n") | |
8810 | { | |
8811 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
8812 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
8813 | afi_t afi; | |
bb4f6190 DS |
8814 | struct bgp *bgp_default; |
8815 | ||
0ca70ba5 | 8816 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8817 | if (afi == AFI_MAX) |
8818 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8819 | |
8820 | bgp_default = bgp_get_default(); | |
8821 | if (!bgp_default) { | |
8822 | int32_t ret; | |
8823 | as_t as = bgp->as; | |
8824 | ||
8825 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8826 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8827 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8828 | |
8829 | if (ret) { | |
8830 | vty_out(vty, | |
8831 | "VRF default is not configured as a bgp instance\n"); | |
8832 | return CMD_WARNING; | |
8833 | } | |
8834 | } | |
8835 | ||
69b07479 | 8836 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8837 | |
ae6a6fb4 DS |
8838 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8839 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8840 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8841 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8842 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8843 | bgp->vpn_policy[afi].rmap[dir] = | |
8844 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8845 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8846 | return CMD_SUCCESS; | |
8847 | ||
8848 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8849 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8850 | |
69b07479 DS |
8851 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8852 | ||
bb4f6190 DS |
8853 | return CMD_SUCCESS; |
8854 | } | |
8855 | ||
ae6a6fb4 DS |
8856 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
8857 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
8858 | NO_STR |
8859 | "Import routes from another VRF\n" | |
8860 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
8861 | "Specify route map\n" |
8862 | "name of route-map\n") | |
8863 | { | |
8864 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8865 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8866 | afi_t afi; | |
8867 | ||
8868 | afi = vpn_policy_getafi(vty, bgp, true); | |
8869 | if (afi == AFI_MAX) | |
8870 | return CMD_WARNING_CONFIG_FAILED; | |
8871 | ||
8872 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8873 | ||
8874 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8875 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8876 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8877 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8878 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8879 | ||
8880 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8881 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8882 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8883 | ||
8884 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8885 | ||
8886 | return CMD_SUCCESS; | |
8887 | } | |
bb4f6190 | 8888 | |
585f1adc IR |
8889 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
8890 | "[no] import vrf VIEWVRFNAME$import_name", | |
8891 | NO_STR | |
8892 | "Import routes from another VRF\n" | |
8893 | "VRF to import from\n" | |
8894 | "The name of the VRF\n") | |
12a844a5 | 8895 | { |
585f1adc IR |
8896 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8897 | struct listnode *node; | |
8898 | struct bgp *vrf_bgp, *bgp_default; | |
8899 | int32_t ret = 0; | |
8900 | as_t as = bgp->as; | |
8901 | bool remove = false; | |
8902 | int32_t idx = 0; | |
8903 | char *vname; | |
8904 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
8905 | safi_t safi; |
8906 | afi_t afi; | |
8907 | ||
867f0cca | 8908 | if (import_name == NULL) { |
8909 | vty_out(vty, "%% Missing import name\n"); | |
8910 | return CMD_WARNING; | |
8911 | } | |
8912 | ||
ae6a6fb4 DS |
8913 | if (strcmp(import_name, "route-map") == 0) { |
8914 | vty_out(vty, "%% Must include route-map name\n"); | |
8915 | return CMD_WARNING; | |
8916 | } | |
8917 | ||
585f1adc IR |
8918 | if (argv_find(argv, argc, "no", &idx)) |
8919 | remove = true; | |
8920 | ||
8921 | afi = vpn_policy_getafi(vty, bgp, true); | |
8922 | if (afi == AFI_MAX) | |
8923 | return CMD_WARNING_CONFIG_FAILED; | |
8924 | ||
12a844a5 DS |
8925 | safi = bgp_node_safi(vty); |
8926 | ||
585f1adc IR |
8927 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
8928 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
8929 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
8930 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8931 | remove ? "unimport" : "import", import_name); | |
8932 | return CMD_WARNING; | |
8933 | } | |
25679caa | 8934 | |
585f1adc IR |
8935 | bgp_default = bgp_get_default(); |
8936 | if (!bgp_default) { | |
8937 | /* Auto-create assuming the same AS */ | |
8938 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
8939 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 8940 | |
585f1adc IR |
8941 | if (ret) { |
8942 | vty_out(vty, | |
8943 | "VRF default is not configured as a bgp instance\n"); | |
8944 | return CMD_WARNING; | |
8945 | } | |
8946 | } | |
12a844a5 | 8947 | |
585f1adc IR |
8948 | vrf_bgp = bgp_lookup_by_name(import_name); |
8949 | if (!vrf_bgp) { | |
8950 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
8951 | vrf_bgp = bgp_default; | |
8952 | else | |
8953 | /* Auto-create assuming the same AS */ | |
8954 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
8955 | ||
8956 | if (ret) { | |
8957 | vty_out(vty, | |
8958 | "VRF %s is not configured as a bgp instance\n", | |
8959 | import_name); | |
8960 | return CMD_WARNING; | |
8961 | } | |
8962 | } | |
8963 | ||
8964 | if (remove) { | |
8965 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
8966 | } else { | |
8967 | /* Already importing from "import_vrf"? */ | |
8968 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
8969 | vname)) { | |
8970 | if (strcmp(vname, import_name) == 0) | |
8971 | return CMD_WARNING; | |
8972 | } | |
8973 | ||
8974 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
8975 | } | |
8976 | ||
8977 | return CMD_SUCCESS; | |
12a844a5 DS |
8978 | } |
8979 | ||
b9c7bc5a | 8980 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 8981 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
8982 | bgp_imexport_vpn_cmd, |
8983 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
8984 | NO_STR |
8985 | "Import routes to this address-family\n" | |
8986 | "Export routes from this address-family\n" | |
8987 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 8988 | { |
585f1adc IR |
8989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8990 | int previous_state; | |
37a87b8f | 8991 | afi_t afi; |
585f1adc IR |
8992 | safi_t safi; |
8993 | int idx = 0; | |
8994 | bool yes = true; | |
8995 | int flag; | |
8996 | vpn_policy_direction_t dir; | |
8997 | ||
8998 | if (argv_find(argv, argc, "no", &idx)) | |
8999 | yes = false; | |
9000 | ||
9001 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9002 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9003 | ||
9004 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9005 | return CMD_WARNING_CONFIG_FAILED; | |
9006 | } | |
ddb5b488 | 9007 | |
b9c7bc5a PZ |
9008 | afi = bgp_node_afi(vty); |
9009 | safi = bgp_node_safi(vty); | |
585f1adc IR |
9010 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
9011 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9012 | return CMD_WARNING_CONFIG_FAILED; | |
9013 | } | |
ddb5b488 | 9014 | |
b9c7bc5a | 9015 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
9016 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
9017 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 9018 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
9019 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
9020 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
9021 | } else { |
9022 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9023 | return CMD_WARNING_CONFIG_FAILED; | |
9024 | } | |
9025 | ||
585f1adc | 9026 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 9027 | |
585f1adc IR |
9028 | if (yes) { |
9029 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9030 | if (!previous_state) { | |
9031 | /* trigger export current vrf */ | |
9032 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9033 | } | |
9034 | } else { | |
9035 | if (previous_state) { | |
9036 | /* trigger un-export current vrf */ | |
9037 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9038 | } | |
9039 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9040 | } | |
37a87b8f | 9041 | |
1ca2fd11 IR |
9042 | hook_call(bgp_snmp_init_stats, bgp); |
9043 | ||
585f1adc | 9044 | return CMD_SUCCESS; |
ddb5b488 PZ |
9045 | } |
9046 | ||
301ad80a PG |
9047 | DEFPY (af_routetarget_import, |
9048 | af_routetarget_import_cmd, | |
9a659715 | 9049 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9050 | NO_STR |
9051 | "Specify route target list\n" | |
9052 | "Specify route target list\n" | |
9a659715 PG |
9053 | "Specify route target list\n" |
9054 | "Specify route target list\n" | |
301ad80a PG |
9055 | "Flow-spec redirect type route target\n" |
9056 | "Import routes to this address-family\n" | |
9a659715 | 9057 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9058 | { |
9059 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9060 | int ret; | |
9061 | struct ecommunity *ecom = NULL; | |
301ad80a | 9062 | afi_t afi; |
9a659715 | 9063 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9064 | bool yes = true; |
9065 | bool rt6 = false; | |
301ad80a PG |
9066 | |
9067 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9068 | yes = false; |
301ad80a | 9069 | |
9a659715 PG |
9070 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9071 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9072 | rt6 = true; |
301ad80a | 9073 | |
0ca70ba5 | 9074 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9075 | if (afi == AFI_MAX) |
9076 | return CMD_WARNING_CONFIG_FAILED; | |
9077 | ||
9a659715 PG |
9078 | if (rt6 && afi != AFI_IP6) |
9079 | return CMD_WARNING_CONFIG_FAILED; | |
9080 | ||
301ad80a PG |
9081 | if (yes) { |
9082 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9083 | vty_out(vty, "%% Missing RTLIST\n"); | |
9084 | return CMD_WARNING_CONFIG_FAILED; | |
9085 | } | |
9a659715 | 9086 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9087 | if (ret != CMD_SUCCESS) |
9088 | return ret; | |
9089 | } | |
69b07479 DS |
9090 | |
9091 | if (yes) { | |
9092 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9093 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9094 | .import_redirect_rtlist); |
69b07479 DS |
9095 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9096 | ecommunity_dup(ecom); | |
9097 | } else { | |
9098 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9099 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9100 | .import_redirect_rtlist); |
69b07479 | 9101 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9102 | } |
69b07479 | 9103 | |
301ad80a PG |
9104 | if (ecom) |
9105 | ecommunity_free(&ecom); | |
9106 | ||
9107 | return CMD_SUCCESS; | |
9108 | } | |
9109 | ||
505e5056 | 9110 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9111 | address_family_ipv4_safi_cmd, |
9112 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9113 | "Enter Address Family command mode\n" | |
9114 | "Address Family\n" | |
9115 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9116 | { |
f51bae9c | 9117 | |
d62a17ae | 9118 | if (argc == 3) { |
585f1adc IR |
9119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9120 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9121 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9122 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9123 | && safi != SAFI_EVPN) { |
31947174 MK |
9124 | vty_out(vty, |
9125 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9126 | return CMD_WARNING_CONFIG_FAILED; |
9127 | } | |
585f1adc IR |
9128 | vty->node = bgp_node_type(AFI_IP, safi); |
9129 | } else | |
9130 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9131 | |
d62a17ae | 9132 | return CMD_SUCCESS; |
718e3744 | 9133 | } |
9134 | ||
505e5056 | 9135 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9136 | address_family_ipv6_safi_cmd, |
9137 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9138 | "Enter Address Family command mode\n" | |
9139 | "Address Family\n" | |
9140 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9141 | { |
d62a17ae | 9142 | if (argc == 3) { |
585f1adc IR |
9143 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9144 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9145 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9146 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9147 | && safi != SAFI_EVPN) { |
31947174 MK |
9148 | vty_out(vty, |
9149 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9150 | return CMD_WARNING_CONFIG_FAILED; |
9151 | } | |
585f1adc IR |
9152 | vty->node = bgp_node_type(AFI_IP6, safi); |
9153 | } else | |
9154 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9155 | |
d62a17ae | 9156 | return CMD_SUCCESS; |
25ffbdc1 | 9157 | } |
718e3744 | 9158 | |
d6902373 | 9159 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9160 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9161 | address_family_vpnv4_cmd, |
8334fd5a | 9162 | "address-family vpnv4 [unicast]", |
718e3744 | 9163 | "Enter Address Family command mode\n" |
8c3deaae | 9164 | "Address Family\n" |
3a2d747c | 9165 | "Address Family modifier\n") |
718e3744 | 9166 | { |
d62a17ae | 9167 | vty->node = BGP_VPNV4_NODE; |
9168 | return CMD_SUCCESS; | |
718e3744 | 9169 | } |
9170 | ||
505e5056 | 9171 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9172 | address_family_vpnv6_cmd, |
8334fd5a | 9173 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9174 | "Enter Address Family command mode\n" |
8c3deaae | 9175 | "Address Family\n" |
3a2d747c | 9176 | "Address Family modifier\n") |
8ecd3266 | 9177 | { |
d62a17ae | 9178 | vty->node = BGP_VPNV6_NODE; |
9179 | return CMD_SUCCESS; | |
8ecd3266 | 9180 | } |
64e4a6c5 | 9181 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9182 | |
505e5056 | 9183 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9184 | address_family_evpn_cmd, |
7111c1a0 | 9185 | "address-family l2vpn evpn", |
4e0b7b6d | 9186 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9187 | "Address Family\n" |
9188 | "Address Family modifier\n") | |
4e0b7b6d | 9189 | { |
2131d5cf | 9190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9191 | vty->node = BGP_EVPN_NODE; |
9192 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9193 | } |
9194 | ||
bfaab44d HS |
9195 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9196 | bgp_segment_routing_srv6_cmd, | |
9197 | "segment-routing srv6", | |
9198 | "Segment-Routing configuration\n" | |
9199 | "Segment-Routing SRv6 configuration\n") | |
9200 | { | |
9201 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9202 | bgp->srv6_enabled = true; |
bfaab44d HS |
9203 | vty->node = BGP_SRV6_NODE; |
9204 | return CMD_SUCCESS; | |
9205 | } | |
9206 | ||
0249b8b6 HS |
9207 | DEFUN (no_bgp_segment_routing_srv6, |
9208 | no_bgp_segment_routing_srv6_cmd, | |
9209 | "no segment-routing srv6", | |
9210 | NO_STR | |
9211 | "Segment-Routing configuration\n" | |
9212 | "Segment-Routing SRv6 configuration\n") | |
9213 | { | |
9214 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9215 | ||
9216 | if (strlen(bgp->srv6_locator_name) > 0) | |
9217 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9218 | return CMD_WARNING_CONFIG_FAILED; | |
9219 | ||
9220 | bgp->srv6_enabled = false; | |
9221 | return CMD_SUCCESS; | |
9222 | } | |
9223 | ||
a0281b2e HS |
9224 | DEFPY (bgp_srv6_locator, |
9225 | bgp_srv6_locator_cmd, | |
9226 | "locator NAME$name", | |
9227 | "Specify SRv6 locator\n" | |
9228 | "Specify SRv6 locator\n") | |
9229 | { | |
9230 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9231 | int ret; |
a0281b2e HS |
9232 | |
9233 | if (strlen(bgp->srv6_locator_name) > 0 | |
9234 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9235 | vty_out(vty, "srv6 locator is already configured\n"); | |
9236 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9237 | } |
9238 | ||
9239 | snprintf(bgp->srv6_locator_name, | |
9240 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9241 | |
7de4c885 | 9242 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9243 | if (ret < 0) |
9244 | return CMD_WARNING_CONFIG_FAILED; | |
9245 | ||
9246 | return CMD_SUCCESS; | |
9247 | } | |
9248 | ||
0249b8b6 HS |
9249 | DEFPY (no_bgp_srv6_locator, |
9250 | no_bgp_srv6_locator_cmd, | |
9251 | "no locator NAME$name", | |
9252 | NO_STR | |
9253 | "Specify SRv6 locator\n" | |
9254 | "Specify SRv6 locator\n") | |
9255 | { | |
9256 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9257 | ||
9258 | /* when locator isn't configured, do nothing */ | |
9259 | if (strlen(bgp->srv6_locator_name) < 1) | |
9260 | return CMD_SUCCESS; | |
9261 | ||
9262 | /* name validation */ | |
9263 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9264 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9265 | return CMD_WARNING_CONFIG_FAILED; | |
9266 | } | |
9267 | ||
9268 | /* unset locator */ | |
9269 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9270 | return CMD_WARNING_CONFIG_FAILED; | |
9271 | ||
9272 | return CMD_SUCCESS; | |
9273 | } | |
9274 | ||
ea372e81 HS |
9275 | DEFPY (show_bgp_srv6, |
9276 | show_bgp_srv6_cmd, | |
9277 | "show bgp segment-routing srv6", | |
9278 | SHOW_STR | |
9279 | BGP_STR | |
9280 | "BGP Segment Routing\n" | |
9281 | "BGP Segment Routing SRv6\n") | |
9282 | { | |
9283 | struct bgp *bgp; | |
9284 | struct listnode *node; | |
9285 | struct prefix_ipv6 *chunk; | |
9286 | struct bgp_srv6_function *func; | |
9287 | struct in6_addr *tovpn4_sid; | |
9288 | struct in6_addr *tovpn6_sid; | |
9289 | char buf[256]; | |
9290 | char buf_tovpn4_sid[256]; | |
9291 | char buf_tovpn6_sid[256]; | |
9292 | ||
9293 | bgp = bgp_get_default(); | |
96db4340 | 9294 | if (!bgp) |
ea372e81 HS |
9295 | return CMD_SUCCESS; |
9296 | ||
9297 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9298 | vty_out(vty, "locator_chunks:\n"); | |
9299 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
9300 | prefix2str(chunk, buf, sizeof(buf)); | |
9301 | vty_out(vty, "- %s\n", buf); | |
9302 | } | |
9303 | ||
9304 | vty_out(vty, "functions:\n"); | |
9305 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9306 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9307 | vty_out(vty, "- sid: %s\n", buf); | |
9308 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9309 | } | |
9310 | ||
9311 | vty_out(vty, "bgps:\n"); | |
9312 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9313 | vty_out(vty, "- name: %s\n", | |
9314 | bgp->name ? bgp->name : "default"); | |
9315 | ||
9316 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
9317 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
9318 | if (tovpn4_sid) | |
9319 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
9320 | sizeof(buf_tovpn4_sid)); | |
9321 | if (tovpn6_sid) | |
9322 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
9323 | sizeof(buf_tovpn6_sid)); | |
9324 | ||
9325 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
9326 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
9327 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
9328 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
9329 | } | |
9330 | ||
9331 | return CMD_SUCCESS; | |
9332 | } | |
9333 | ||
505e5056 | 9334 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9335 | exit_address_family_cmd, |
9336 | "exit-address-family", | |
9337 | "Exit from Address Family configuration mode\n") | |
9338 | { | |
d62a17ae | 9339 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9340 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9341 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9342 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9343 | || vty->node == BGP_EVPN_NODE |
9344 | || vty->node == BGP_FLOWSPECV4_NODE | |
9345 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9346 | vty->node = BGP_NODE; |
9347 | return CMD_SUCCESS; | |
718e3744 | 9348 | } |
6b0655a2 | 9349 | |
8ad7271d | 9350 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9351 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9352 | const char *ip_str, afi_t afi, safi_t safi, | |
9353 | struct prefix_rd *prd) | |
9354 | { | |
9355 | int ret; | |
9356 | struct prefix match; | |
9bcb3eef DS |
9357 | struct bgp_dest *dest; |
9358 | struct bgp_dest *rm; | |
d62a17ae | 9359 | struct bgp *bgp; |
9360 | struct bgp_table *table; | |
9361 | struct bgp_table *rib; | |
9362 | ||
9363 | /* BGP structure lookup. */ | |
9364 | if (view_name) { | |
9365 | bgp = bgp_lookup_by_name(view_name); | |
9366 | if (bgp == NULL) { | |
9367 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9368 | view_name); | |
9369 | return CMD_WARNING; | |
9370 | } | |
9371 | } else { | |
9372 | bgp = bgp_get_default(); | |
9373 | if (bgp == NULL) { | |
9374 | vty_out(vty, "%% No BGP process is configured\n"); | |
9375 | return CMD_WARNING; | |
9376 | } | |
9377 | } | |
9378 | ||
9379 | /* Check IP address argument. */ | |
9380 | ret = str2prefix(ip_str, &match); | |
9381 | if (!ret) { | |
9382 | vty_out(vty, "%% address is malformed\n"); | |
9383 | return CMD_WARNING; | |
9384 | } | |
9385 | ||
9386 | match.family = afi2family(afi); | |
9387 | rib = bgp->rib[afi][safi]; | |
9388 | ||
9389 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9390 | for (dest = bgp_table_top(rib); dest; |
9391 | dest = bgp_route_next(dest)) { | |
9392 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9393 | |
9bcb3eef | 9394 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9395 | continue; |
9396 | ||
9bcb3eef | 9397 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9398 | if (table == NULL) |
9399 | continue; | |
9400 | ||
4953391b DA |
9401 | rm = bgp_node_match(table, &match); |
9402 | if (rm != NULL) { | |
b54892e0 | 9403 | const struct prefix *rm_p = |
9bcb3eef | 9404 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9405 | |
9406 | if (rm_p->prefixlen == match.prefixlen) { | |
9407 | SET_FLAG(rm->flags, | |
9408 | BGP_NODE_USER_CLEAR); | |
9409 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9410 | } |
9bcb3eef | 9411 | bgp_dest_unlock_node(rm); |
d62a17ae | 9412 | } |
9413 | } | |
9414 | } else { | |
4953391b DA |
9415 | dest = bgp_node_match(rib, &match); |
9416 | if (dest != NULL) { | |
9bcb3eef | 9417 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 9418 | |
9bcb3eef DS |
9419 | if (dest_p->prefixlen == match.prefixlen) { |
9420 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9421 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9422 | } |
9bcb3eef | 9423 | bgp_dest_unlock_node(dest); |
d62a17ae | 9424 | } |
9425 | } | |
9426 | ||
9427 | return CMD_SUCCESS; | |
8ad7271d DS |
9428 | } |
9429 | ||
b09b5ae0 | 9430 | /* one clear bgp command to rule them all */ |
718e3744 | 9431 | DEFUN (clear_ip_bgp_all, |
9432 | clear_ip_bgp_all_cmd, | |
3cb14f26 | 9433 | "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|message-stats>]", |
718e3744 | 9434 | CLEAR_STR |
9435 | IP_STR | |
9436 | BGP_STR | |
838758ac | 9437 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9438 | BGP_AFI_HELP_STR |
fd5e7b70 | 9439 | "Address Family\n" |
510afcd6 | 9440 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9441 | "Address Family modifier\n" |
b09b5ae0 | 9442 | "Clear all peers\n" |
453c92f6 | 9443 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9444 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9445 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9446 | "Clear peers with the AS number\n" |
9447 | "Clear all external peers\n" | |
718e3744 | 9448 | "Clear all members of peer-group\n" |
b09b5ae0 | 9449 | "BGP peer-group name\n" |
b09b5ae0 DW |
9450 | BGP_SOFT_STR |
9451 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9452 | BGP_SOFT_OUT_STR |
9453 | BGP_SOFT_IN_STR | |
9454 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
3cb14f26 DS |
9455 | BGP_SOFT_OUT_STR |
9456 | "Reset message statistics\n") | |
718e3744 | 9457 | { |
d62a17ae | 9458 | char *vrf = NULL; |
9459 | ||
dc912615 DS |
9460 | afi_t afi = AFI_UNSPEC; |
9461 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9462 | enum clear_sort clr_sort = clear_peer; |
9463 | enum bgp_clear_type clr_type; | |
9464 | char *clr_arg = NULL; | |
9465 | ||
9466 | int idx = 0; | |
9467 | ||
9468 | /* clear [ip] bgp */ | |
9469 | if (argv_find(argv, argc, "ip", &idx)) | |
9470 | afi = AFI_IP; | |
9471 | ||
9a8bdf1c PG |
9472 | /* [<vrf> VIEWVRFNAME] */ |
9473 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9474 | vrf = argv[idx + 1]->arg; | |
9475 | idx += 2; | |
9476 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9477 | vrf = NULL; | |
9478 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9479 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9480 | vrf = argv[idx + 1]->arg; |
9481 | idx += 2; | |
9482 | } | |
d62a17ae | 9483 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9484 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9485 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9486 | ||
d7b9898c | 9487 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9488 | if (argv_find(argv, argc, "*", &idx)) { |
9489 | clr_sort = clear_all; | |
9490 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9491 | clr_sort = clear_peer; | |
9492 | clr_arg = argv[idx]->arg; | |
9493 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9494 | clr_sort = clear_peer; | |
9495 | clr_arg = argv[idx]->arg; | |
9496 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9497 | clr_sort = clear_group; | |
9498 | idx++; | |
9499 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9500 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9501 | clr_sort = clear_peer; |
9502 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9503 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9504 | clr_sort = clear_peer; | |
9505 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9506 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9507 | clr_sort = clear_as; | |
9508 | clr_arg = argv[idx]->arg; | |
9509 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9510 | clr_sort = clear_external; | |
9511 | } | |
9512 | ||
3cb14f26 | 9513 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ |
d62a17ae | 9514 | if (argv_find(argv, argc, "soft", &idx)) { |
9515 | if (argv_find(argv, argc, "in", &idx) | |
9516 | || argv_find(argv, argc, "out", &idx)) | |
9517 | clr_type = strmatch(argv[idx]->text, "in") | |
9518 | ? BGP_CLEAR_SOFT_IN | |
9519 | : BGP_CLEAR_SOFT_OUT; | |
9520 | else | |
9521 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9522 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9523 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9524 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9525 | : BGP_CLEAR_SOFT_IN; | |
9526 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9527 | clr_type = BGP_CLEAR_SOFT_OUT; | |
3cb14f26 DS |
9528 | } else if (argv_find(argv, argc, "message-stats", &idx)) { |
9529 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
d62a17ae | 9530 | } else |
9531 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9532 | ||
1ca2fd11 | 9533 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 9534 | } |
01080f7c | 9535 | |
8ad7271d DS |
9536 | DEFUN (clear_ip_bgp_prefix, |
9537 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9538 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9539 | CLEAR_STR |
9540 | IP_STR | |
9541 | BGP_STR | |
838758ac | 9542 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9543 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9544 | "IPv4 prefix\n") |
8ad7271d | 9545 | { |
d62a17ae | 9546 | char *vrf = NULL; |
9547 | char *prefix = NULL; | |
8ad7271d | 9548 | |
d62a17ae | 9549 | int idx = 0; |
01080f7c | 9550 | |
d62a17ae | 9551 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9552 | if (argv_find(argv, argc, "vrf", &idx)) { |
9553 | vrf = argv[idx + 1]->arg; | |
9554 | idx += 2; | |
9555 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9556 | vrf = NULL; | |
9557 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9558 | /* [<view> VIEWVRFNAME] */ | |
9559 | vrf = argv[idx + 1]->arg; | |
9560 | idx += 2; | |
9561 | } | |
0c7b1b01 | 9562 | |
d62a17ae | 9563 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9564 | |
d62a17ae | 9565 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9566 | } |
8ad7271d | 9567 | |
b09b5ae0 DW |
9568 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9569 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9570 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9571 | CLEAR_STR |
3a2d747c | 9572 | IP_STR |
718e3744 | 9573 | BGP_STR |
8c3deaae | 9574 | "Address Family\n" |
46f296b4 | 9575 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9576 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9577 | "IPv6 prefix\n") |
718e3744 | 9578 | { |
9b475e76 PG |
9579 | int idx_safi = 0; |
9580 | int idx_ipv6_prefix = 0; | |
9581 | safi_t safi = SAFI_UNICAST; | |
9582 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9583 | argv[idx_ipv6_prefix]->arg : NULL; | |
9584 | ||
9585 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9586 | return bgp_clear_prefix( |
9b475e76 PG |
9587 | vty, NULL, prefix, AFI_IP6, |
9588 | safi, NULL); | |
838758ac | 9589 | } |
01080f7c | 9590 | |
b09b5ae0 DW |
9591 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9592 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9593 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9594 | CLEAR_STR |
3a2d747c | 9595 | IP_STR |
718e3744 | 9596 | BGP_STR |
838758ac | 9597 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9598 | "Address Family\n" |
46f296b4 | 9599 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9600 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9601 | "IPv6 prefix\n") |
718e3744 | 9602 | { |
9b475e76 | 9603 | int idx_safi = 0; |
9a8bdf1c | 9604 | int idx_vrfview = 0; |
9b475e76 PG |
9605 | int idx_ipv6_prefix = 0; |
9606 | safi_t safi = SAFI_UNICAST; | |
9607 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9608 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9609 | char *vrfview = NULL; |
9b475e76 | 9610 | |
9a8bdf1c PG |
9611 | /* [<view|vrf> VIEWVRFNAME] */ |
9612 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9613 | vrfview = argv[idx_vrfview + 1]->arg; | |
9614 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9615 | vrfview = NULL; | |
9616 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9617 | /* [<view> VIEWVRFNAME] */ | |
9618 | vrfview = argv[idx_vrfview + 1]->arg; | |
9619 | } | |
9b475e76 PG |
9620 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9621 | ||
d62a17ae | 9622 | return bgp_clear_prefix( |
9b475e76 PG |
9623 | vty, vrfview, prefix, |
9624 | AFI_IP6, safi, NULL); | |
718e3744 | 9625 | } |
9626 | ||
b09b5ae0 DW |
9627 | DEFUN (show_bgp_views, |
9628 | show_bgp_views_cmd, | |
d6e3c605 | 9629 | "show [ip] bgp views", |
b09b5ae0 | 9630 | SHOW_STR |
d6e3c605 | 9631 | IP_STR |
01080f7c | 9632 | BGP_STR |
b09b5ae0 | 9633 | "Show the defined BGP views\n") |
01080f7c | 9634 | { |
d62a17ae | 9635 | struct list *inst = bm->bgp; |
9636 | struct listnode *node; | |
9637 | struct bgp *bgp; | |
01080f7c | 9638 | |
d62a17ae | 9639 | vty_out(vty, "Defined BGP views:\n"); |
9640 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9641 | /* Skip VRFs. */ | |
9642 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9643 | continue; | |
9644 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9645 | bgp->as); | |
9646 | } | |
e52702f2 | 9647 | |
d62a17ae | 9648 | return CMD_SUCCESS; |
e0081f70 ML |
9649 | } |
9650 | ||
8386ac43 | 9651 | DEFUN (show_bgp_vrfs, |
9652 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9653 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9654 | SHOW_STR |
d6e3c605 | 9655 | IP_STR |
8386ac43 | 9656 | BGP_STR |
9657 | "Show BGP VRFs\n" | |
9973d184 | 9658 | JSON_STR) |
8386ac43 | 9659 | { |
fe1dc5a3 | 9660 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9661 | struct list *inst = bm->bgp; |
9662 | struct listnode *node; | |
9663 | struct bgp *bgp; | |
9f049418 | 9664 | bool uj = use_json(argc, argv); |
d62a17ae | 9665 | json_object *json = NULL; |
9666 | json_object *json_vrfs = NULL; | |
9667 | int count = 0; | |
d62a17ae | 9668 | |
d62a17ae | 9669 | if (uj) { |
9670 | json = json_object_new_object(); | |
9671 | json_vrfs = json_object_new_object(); | |
9672 | } | |
9673 | ||
9674 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9675 | const char *name, *type; | |
9676 | struct peer *peer; | |
7fe96307 | 9677 | struct listnode *node2, *nnode2; |
d62a17ae | 9678 | int peers_cfg, peers_estb; |
9679 | json_object *json_vrf = NULL; | |
d62a17ae | 9680 | |
9681 | /* Skip Views. */ | |
9682 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9683 | continue; | |
9684 | ||
9685 | count++; | |
efb4077a | 9686 | if (!uj && count == 1) { |
fe1dc5a3 | 9687 | vty_out(vty, |
efb4077a | 9688 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9689 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9690 | "#PeersEstb", "Name"); |
9691 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9692 | "L3-VNI", "RouterMAC", "Interface"); | |
9693 | } | |
d62a17ae | 9694 | |
9695 | peers_cfg = peers_estb = 0; | |
9696 | if (uj) | |
9697 | json_vrf = json_object_new_object(); | |
9698 | ||
9699 | ||
7fe96307 | 9700 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9701 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9702 | continue; | |
9703 | peers_cfg++; | |
feb17238 | 9704 | if (peer_established(peer)) |
d62a17ae | 9705 | peers_estb++; |
9706 | } | |
9707 | ||
9708 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9709 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9710 | type = "DFLT"; |
9711 | } else { | |
9712 | name = bgp->name; | |
9713 | type = "VRF"; | |
9714 | } | |
9715 | ||
a8bf7d9c | 9716 | |
d62a17ae | 9717 | if (uj) { |
a4d82a8a PZ |
9718 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9719 | ? -1 | |
9720 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9721 | char buf[BUFSIZ] = {0}; |
9722 | ||
d62a17ae | 9723 | json_object_string_add(json_vrf, "type", type); |
9724 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
c949c771 DA |
9725 | json_object_string_addf(json_vrf, "routerId", "%pI4", |
9726 | &bgp->router_id); | |
d62a17ae | 9727 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9728 | peers_cfg); | |
9729 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9730 | peers_estb); | |
9731 | ||
fe1dc5a3 | 9732 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9733 | json_object_string_add( |
9734 | json_vrf, "rmac", | |
9735 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9736 | json_object_string_add(json_vrf, "interface", |
9737 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9738 | bgp->vrf_id)); | |
d62a17ae | 9739 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9740 | } else { |
23d0a753 | 9741 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9742 | type, |
9743 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9744 | : (int)bgp->vrf_id, | |
23d0a753 | 9745 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9746 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9747 | bgp->l3vni, | |
9748 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9749 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9750 | bgp->vrf_id)); | |
9751 | } | |
d62a17ae | 9752 | } |
9753 | ||
9754 | if (uj) { | |
9755 | json_object_object_add(json, "vrfs", json_vrfs); | |
9756 | ||
9757 | json_object_int_add(json, "totalVrfs", count); | |
9758 | ||
75eeda93 | 9759 | vty_json(vty, json); |
d62a17ae | 9760 | } else { |
9761 | if (count) | |
9762 | vty_out(vty, | |
9763 | "\nTotal number of VRFs (including default): %d\n", | |
9764 | count); | |
9765 | } | |
9766 | ||
9767 | return CMD_SUCCESS; | |
8386ac43 | 9768 | } |
9769 | ||
48ecf8f5 DS |
9770 | DEFUN (show_bgp_mac_hash, |
9771 | show_bgp_mac_hash_cmd, | |
9772 | "show bgp mac hash", | |
9773 | SHOW_STR | |
9774 | BGP_STR | |
9775 | "Mac Address\n" | |
9776 | "Mac Address database\n") | |
9777 | { | |
9778 | bgp_mac_dump_table(vty); | |
9779 | ||
9780 | return CMD_SUCCESS; | |
9781 | } | |
acf71666 | 9782 | |
e3b78da8 | 9783 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9784 | { |
0291c246 | 9785 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9786 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9787 | |
23d0a753 | 9788 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9789 | } |
9790 | ||
9791 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9792 | { | |
9793 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9794 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9795 | |
9796 | vty_out(vty, "Tunnel-ip database:\n"); | |
9797 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9798 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9799 | vty); |
9800 | } | |
9801 | ||
15c81ca4 DS |
9802 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9803 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9804 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9805 | "martian next-hops\n" |
9806 | "martian next-hop database\n") | |
acf71666 | 9807 | { |
0291c246 | 9808 | struct bgp *bgp = NULL; |
15c81ca4 | 9809 | int idx = 0; |
9a8bdf1c PG |
9810 | char *name = NULL; |
9811 | ||
9812 | /* [<vrf> VIEWVRFNAME] */ | |
9813 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9814 | name = argv[idx + 1]->arg; | |
9815 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9816 | name = NULL; | |
9817 | } else if (argv_find(argv, argc, "view", &idx)) | |
9818 | /* [<view> VIEWVRFNAME] */ | |
9819 | name = argv[idx + 1]->arg; | |
9820 | if (name) | |
9821 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9822 | else |
9823 | bgp = bgp_get_default(); | |
acf71666 | 9824 | |
acf71666 MK |
9825 | if (!bgp) { |
9826 | vty_out(vty, "%% No BGP process is configured\n"); | |
9827 | return CMD_WARNING; | |
9828 | } | |
9829 | bgp_show_martian_nexthops(vty, bgp); | |
9830 | ||
9831 | return CMD_SUCCESS; | |
9832 | } | |
9833 | ||
f412b39a | 9834 | DEFUN (show_bgp_memory, |
4bf6a362 | 9835 | show_bgp_memory_cmd, |
7fa12b13 | 9836 | "show [ip] bgp memory", |
4bf6a362 | 9837 | SHOW_STR |
3a2d747c | 9838 | IP_STR |
4bf6a362 PJ |
9839 | BGP_STR |
9840 | "Global BGP memory statistics\n") | |
9841 | { | |
d62a17ae | 9842 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9843 | unsigned long count; | |
9844 | ||
9845 | /* RIB related usage stats */ | |
9846 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9847 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9848 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9849 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9850 | |
9851 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9852 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9853 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 9854 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 9855 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
9856 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9857 | count, | |
4b7e6066 DS |
9858 | mtype_memstr( |
9859 | memstrbuf, sizeof(memstrbuf), | |
9860 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 9861 | |
9862 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9863 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9864 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9865 | count * sizeof(struct bgp_static))); | |
9866 | ||
9867 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9868 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9869 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9870 | count * sizeof(struct bpacket))); | |
9871 | ||
9872 | /* Adj-In/Out */ | |
9873 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9874 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9875 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9876 | count * sizeof(struct bgp_adj_in))); | |
9877 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9878 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9879 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9880 | count * sizeof(struct bgp_adj_out))); | |
9881 | ||
9882 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9883 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9884 | count, | |
9885 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9886 | count * sizeof(struct bgp_nexthop_cache))); | |
9887 | ||
9888 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9889 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9890 | count, | |
9891 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9892 | count * sizeof(struct bgp_damp_info))); | |
9893 | ||
9894 | /* Attributes */ | |
9895 | count = attr_count(); | |
9896 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9897 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9898 | count * sizeof(struct attr))); | |
9899 | ||
9900 | if ((count = attr_unknown_count())) | |
9901 | vty_out(vty, "%ld unknown attributes\n", count); | |
9902 | ||
9903 | /* AS_PATH attributes */ | |
9904 | count = aspath_count(); | |
9905 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9906 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9907 | count * sizeof(struct aspath))); | |
9908 | ||
9909 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9910 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9911 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9912 | count * sizeof(struct assegment))); | |
9913 | ||
9914 | /* Other attributes */ | |
9915 | if ((count = community_count())) | |
9916 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9917 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9918 | count * sizeof(struct community))); | |
d62a17ae | 9919 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
9920 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9921 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9922 | count * sizeof(struct ecommunity))); | |
d62a17ae | 9923 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
9924 | vty_out(vty, | |
9925 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
9926 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9927 | count * sizeof(struct lcommunity))); | |
d62a17ae | 9928 | |
9929 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9930 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9931 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9932 | count * sizeof(struct cluster_list))); | |
9933 | ||
9934 | /* Peer related usage */ | |
9935 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9936 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9937 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9938 | count * sizeof(struct peer))); | |
9939 | ||
9940 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9941 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9942 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9943 | count * sizeof(struct peer_group))); | |
9944 | ||
9945 | /* Other */ | |
d62a17ae | 9946 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
9947 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
9948 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9949 | count * sizeof(regex_t))); | |
d62a17ae | 9950 | return CMD_SUCCESS; |
4bf6a362 | 9951 | } |
fee0f4c6 | 9952 | |
57a9c8a8 DS |
9953 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
9954 | { | |
9955 | json_object *bestpath = json_object_new_object(); | |
9956 | ||
892fedb6 | 9957 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
9958 | json_object_string_add(bestpath, "asPath", "ignore"); |
9959 | ||
892fedb6 | 9960 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
9961 | json_object_string_add(bestpath, "asPath", "confed"); |
9962 | ||
892fedb6 DA |
9963 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
9964 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 9965 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9966 | "as-set"); |
9967 | else | |
a4d82a8a | 9968 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9969 | "true"); |
9970 | } else | |
a4d82a8a | 9971 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 9972 | |
ee88563a JM |
9973 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
9974 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
9975 | ||
892fedb6 | 9976 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 9977 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
9978 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
9979 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
9980 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 9981 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 9982 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
9983 | json_object_string_add(bestpath, "med", |
9984 | "missing-as-worst"); | |
9985 | else | |
9986 | json_object_string_add(bestpath, "med", "true"); | |
9987 | } | |
9988 | ||
9989 | json_object_object_add(json, "bestPath", bestpath); | |
9990 | } | |
9991 | ||
3577f1c5 DD |
9992 | /* Print the error code/subcode for why the peer is down */ |
9993 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
9994 | json_object *json_peer, bool use_json) | |
9995 | { | |
9996 | const char *code_str; | |
9997 | const char *subcode_str; | |
9998 | ||
9999 | if (use_json) { | |
10000 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10001 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10002 | char errorcodesubcode_hexstr[5]; | |
10003 | char errorcodesubcode_str[256]; | |
10004 | ||
10005 | code_str = bgp_notify_code_str(peer->notify.code); | |
10006 | subcode_str = bgp_notify_subcode_str( | |
10007 | peer->notify.code, | |
10008 | peer->notify.subcode); | |
10009 | ||
772270f3 QY |
10010 | snprintf(errorcodesubcode_hexstr, |
10011 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10012 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10013 | json_object_string_add(json_peer, |
10014 | "lastErrorCodeSubcode", | |
10015 | errorcodesubcode_hexstr); | |
10016 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10017 | code_str, subcode_str); | |
10018 | json_object_string_add(json_peer, | |
10019 | "lastNotificationReason", | |
10020 | errorcodesubcode_str); | |
10021 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10022 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10023 | && (peer->notify.subcode | |
10024 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10025 | || peer->notify.subcode | |
10026 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10027 | && peer->notify.length) { | |
10028 | char msgbuf[1024]; | |
10029 | const char *msg_str; | |
10030 | ||
10031 | msg_str = bgp_notify_admin_message( | |
10032 | msgbuf, sizeof(msgbuf), | |
10033 | (uint8_t *)peer->notify.data, | |
10034 | peer->notify.length); | |
10035 | if (msg_str) | |
10036 | json_object_string_add( | |
10037 | json_peer, | |
10038 | "lastShutdownDescription", | |
10039 | msg_str); | |
10040 | } | |
10041 | ||
c258527b | 10042 | } |
3577f1c5 DD |
10043 | json_object_string_add(json_peer, "lastResetDueTo", |
10044 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10045 | json_object_int_add(json_peer, "lastResetCode", |
10046 | peer->last_reset); | |
3577f1c5 DD |
10047 | } else { |
10048 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10049 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10050 | code_str = bgp_notify_code_str(peer->notify.code); | |
10051 | subcode_str = | |
10052 | bgp_notify_subcode_str(peer->notify.code, | |
10053 | peer->notify.subcode); | |
10054 | vty_out(vty, " Notification %s (%s%s)\n", | |
10055 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10056 | ? "sent" | |
10057 | : "received", | |
10058 | code_str, subcode_str); | |
10059 | } else { | |
e91c24c8 | 10060 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10061 | peer_down_str[(int)peer->last_reset]); |
10062 | } | |
10063 | } | |
10064 | } | |
10065 | ||
10066 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10067 | safi_t safi) | |
10068 | { | |
feb17238 | 10069 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10070 | } |
10071 | ||
10072 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10073 | struct peer *peer, json_object *json_peer, | |
10074 | int max_neighbor_width, bool use_json) | |
10075 | { | |
10076 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10077 | int len; | |
10078 | ||
10079 | if (use_json) { | |
10080 | if (peer_dynamic_neighbor(peer)) | |
10081 | json_object_boolean_true_add(json_peer, | |
10082 | "dynamicPeer"); | |
10083 | if (peer->hostname) | |
10084 | json_object_string_add(json_peer, "hostname", | |
10085 | peer->hostname); | |
10086 | ||
10087 | if (peer->domainname) | |
10088 | json_object_string_add(json_peer, "domainname", | |
10089 | peer->domainname); | |
10090 | json_object_int_add(json_peer, "connectionsEstablished", | |
10091 | peer->established); | |
10092 | json_object_int_add(json_peer, "connectionsDropped", | |
10093 | peer->dropped); | |
10094 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10095 | use_json, json_peer); | |
feb17238 | 10096 | if (peer_established(peer)) |
3577f1c5 DD |
10097 | json_object_string_add(json_peer, "lastResetDueTo", |
10098 | "AFI/SAFI Not Negotiated"); | |
10099 | else | |
10100 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10101 | } else { | |
10102 | dn_flag[1] = '\0'; | |
10103 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10104 | if (peer->hostname | |
892fedb6 | 10105 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10106 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10107 | peer->hostname, peer->host); | |
10108 | else | |
10109 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10110 | ||
10111 | /* pad the neighbor column with spaces */ | |
10112 | if (len < max_neighbor_width) | |
10113 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10114 | " "); | |
e91c24c8 | 10115 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10116 | peer->dropped, |
10117 | peer_uptime(peer->uptime, timebuf, | |
10118 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10119 | if (peer_established(peer)) |
3577f1c5 DD |
10120 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10121 | else | |
10122 | bgp_show_peer_reset(vty, peer, NULL, | |
10123 | false); | |
10124 | } | |
10125 | } | |
c258527b | 10126 | |
565e9ddd | 10127 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10128 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10129 | { | |
10130 | static char stripped[BUFSIZ]; | |
cb75bb31 DA |
10131 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; |
10132 | ||
cb75bb31 DA |
10133 | strlcpy(stripped, desc, len + 1); |
10134 | ||
10135 | return stripped; | |
10136 | } | |
3577f1c5 | 10137 | |
8c1d4cd5 LS |
10138 | /* Determine whether var peer should be filtered out of the summary. */ |
10139 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10140 | struct peer *fpeer, int as_type, | |
10141 | as_t as) | |
10142 | { | |
10143 | ||
10144 | /* filter neighbor XXXX */ | |
10145 | if (fpeer && fpeer != peer) | |
10146 | return true; | |
10147 | ||
10148 | /* filter remote-as (internal|external) */ | |
10149 | if (as_type != AS_UNSPECIFIED) { | |
10150 | if (peer->as_type == AS_SPECIFIED) { | |
10151 | if (as_type == AS_INTERNAL) { | |
10152 | if (peer->as != peer->local_as) | |
10153 | return true; | |
10154 | } else if (peer->as == peer->local_as) | |
10155 | return true; | |
10156 | } else if (as_type != peer->as_type) | |
10157 | return true; | |
10158 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10159 | return true; | |
10160 | ||
10161 | return false; | |
10162 | } | |
10163 | ||
565e9ddd DA |
10164 | /* Show BGP peer's summary information. |
10165 | * | |
10166 | * Peer's description is stripped according to if `wide` option is given | |
10167 | * or not. | |
10168 | * | |
10169 | * When adding new columns to `show bgp summary` output, please make | |
10170 | * sure `Desc` is the lastest column to show because it can contain | |
10171 | * whitespaces and the whole output will be tricky. | |
10172 | */ | |
d62a17ae | 10173 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10174 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10175 | uint16_t show_flags) |
d62a17ae | 10176 | { |
10177 | struct peer *peer; | |
10178 | struct listnode *node, *nnode; | |
10179 | unsigned int count = 0, dn_count = 0; | |
10180 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10181 | char neighbor_buf[VTY_BUFSIZ]; | |
10182 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10183 | int len, failed_count = 0; |
ce1944f0 | 10184 | unsigned int filtered_count = 0; |
d62a17ae | 10185 | int max_neighbor_width = 0; |
10186 | int pfx_rcd_safi; | |
3c13337d | 10187 | json_object *json = NULL; |
d62a17ae | 10188 | json_object *json_peer = NULL; |
10189 | json_object *json_peers = NULL; | |
50e05855 | 10190 | struct peer_af *paf; |
d3ada366 | 10191 | struct bgp_filter *filter; |
85eeb029 DA |
10192 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10193 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10194 | bool show_established = | |
10195 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10196 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10197 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10198 | |
10199 | /* labeled-unicast routes are installed in the unicast table so in order | |
10200 | * to | |
10201 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10202 | */ | |
3577f1c5 | 10203 | |
d62a17ae | 10204 | if (safi == SAFI_LABELED_UNICAST) |
10205 | pfx_rcd_safi = SAFI_UNICAST; | |
10206 | else | |
10207 | pfx_rcd_safi = safi; | |
10208 | ||
10209 | if (use_json) { | |
3c13337d | 10210 | json = json_object_new_object(); |
d62a17ae | 10211 | json_peers = json_object_new_object(); |
3577f1c5 | 10212 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10213 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10214 | as_type, as)) { | |
ce1944f0 | 10215 | filtered_count++; |
8c1d4cd5 LS |
10216 | count++; |
10217 | continue; | |
10218 | } | |
10219 | ||
3577f1c5 DD |
10220 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10221 | continue; | |
10222 | ||
10223 | if (peer->afc[afi][safi]) { | |
10224 | /* See if we have at least a single failed peer */ | |
10225 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10226 | failed_count++; | |
10227 | count++; | |
10228 | } | |
10229 | if (peer_dynamic_neighbor(peer)) | |
10230 | dn_count++; | |
10231 | } | |
c258527b | 10232 | |
d62a17ae | 10233 | } else { |
10234 | /* Loop over all neighbors that will be displayed to determine | |
10235 | * how many | |
10236 | * characters are needed for the Neighbor column | |
10237 | */ | |
10238 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10239 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10240 | as_type, as)) { | |
ce1944f0 | 10241 | filtered_count++; |
8c1d4cd5 LS |
10242 | count++; |
10243 | continue; | |
10244 | } | |
10245 | ||
d62a17ae | 10246 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10247 | continue; | |
10248 | ||
10249 | if (peer->afc[afi][safi]) { | |
10250 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10251 | if (peer_dynamic_neighbor(peer)) | |
10252 | dn_flag[0] = '*'; | |
10253 | ||
10254 | if (peer->hostname | |
892fedb6 DA |
10255 | && CHECK_FLAG(bgp->flags, |
10256 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10257 | snprintf(neighbor_buf, |
10258 | sizeof(neighbor_buf), | |
10259 | "%s%s(%s) ", dn_flag, | |
10260 | peer->hostname, peer->host); | |
d62a17ae | 10261 | else |
772270f3 QY |
10262 | snprintf(neighbor_buf, |
10263 | sizeof(neighbor_buf), "%s%s ", | |
10264 | dn_flag, peer->host); | |
d62a17ae | 10265 | |
10266 | len = strlen(neighbor_buf); | |
10267 | ||
10268 | if (len > max_neighbor_width) | |
10269 | max_neighbor_width = len; | |
c258527b | 10270 | |
3577f1c5 DD |
10271 | /* See if we have at least a single failed peer */ |
10272 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10273 | failed_count++; | |
10274 | count++; | |
d62a17ae | 10275 | } |
10276 | } | |
f933309e | 10277 | |
d62a17ae | 10278 | /* Originally we displayed the Neighbor column as 16 |
10279 | * characters wide so make that the default | |
10280 | */ | |
10281 | if (max_neighbor_width < neighbor_col_default_width) | |
10282 | max_neighbor_width = neighbor_col_default_width; | |
10283 | } | |
f933309e | 10284 | |
3577f1c5 DD |
10285 | if (show_failed && !failed_count) { |
10286 | if (use_json) { | |
10287 | json_object_int_add(json, "failedPeersCount", 0); | |
10288 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10289 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 | 10290 | |
75eeda93 | 10291 | vty_json(vty, json); |
3577f1c5 DD |
10292 | } else { |
10293 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10294 | } |
10295 | return CMD_SUCCESS; | |
10296 | } | |
c258527b | 10297 | |
3577f1c5 | 10298 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10299 | filtered_count = 0; |
800867d8 | 10300 | dn_count = 0; |
d62a17ae | 10301 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10302 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10303 | continue; | |
10304 | ||
ea47320b DL |
10305 | if (!peer->afc[afi][safi]) |
10306 | continue; | |
d62a17ae | 10307 | |
ea47320b DL |
10308 | if (!count) { |
10309 | unsigned long ents; | |
10310 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10311 | int64_t vrf_id_ui; |
d62a17ae | 10312 | |
a4d82a8a PZ |
10313 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10314 | ? -1 | |
10315 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10316 | |
10317 | /* Usage summary and header */ | |
10318 | if (use_json) { | |
c949c771 DA |
10319 | json_object_string_addf(json, "routerId", |
10320 | "%pI4", | |
10321 | &bgp->router_id); | |
60466a63 QY |
10322 | json_object_int_add(json, "as", bgp->as); |
10323 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10324 | json_object_string_add( |
10325 | json, "vrfName", | |
10326 | (bgp->inst_type | |
10327 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10328 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10329 | : bgp->name); |
10330 | } else { | |
10331 | vty_out(vty, | |
23d0a753 DA |
10332 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10333 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10334 | bgp->vrf_id == VRF_UNKNOWN |
10335 | ? -1 | |
10336 | : (int)bgp->vrf_id); | |
ea47320b DL |
10337 | vty_out(vty, "\n"); |
10338 | } | |
d62a17ae | 10339 | |
ea47320b | 10340 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10341 | if (use_json) { |
ea47320b | 10342 | json_object_int_add( |
60466a63 | 10343 | json, "updateDelayLimit", |
ea47320b | 10344 | bgp->v_update_delay); |
d62a17ae | 10345 | |
ea47320b DL |
10346 | if (bgp->v_update_delay |
10347 | != bgp->v_establish_wait) | |
d62a17ae | 10348 | json_object_int_add( |
10349 | json, | |
ea47320b DL |
10350 | "updateDelayEstablishWait", |
10351 | bgp->v_establish_wait); | |
d62a17ae | 10352 | |
60466a63 | 10353 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10354 | json_object_string_add( |
10355 | json, | |
10356 | "updateDelayFirstNeighbor", | |
10357 | bgp->update_delay_begin_time); | |
10358 | json_object_boolean_true_add( | |
10359 | json, | |
10360 | "updateDelayInProgress"); | |
10361 | } else { | |
10362 | if (bgp->update_delay_over) { | |
d62a17ae | 10363 | json_object_string_add( |
10364 | json, | |
10365 | "updateDelayFirstNeighbor", | |
10366 | bgp->update_delay_begin_time); | |
ea47320b | 10367 | json_object_string_add( |
d62a17ae | 10368 | json, |
ea47320b DL |
10369 | "updateDelayBestpathResumed", |
10370 | bgp->update_delay_end_time); | |
10371 | json_object_string_add( | |
d62a17ae | 10372 | json, |
ea47320b DL |
10373 | "updateDelayZebraUpdateResume", |
10374 | bgp->update_delay_zebra_resume_time); | |
10375 | json_object_string_add( | |
10376 | json, | |
10377 | "updateDelayPeerUpdateResume", | |
10378 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10379 | } |
ea47320b DL |
10380 | } |
10381 | } else { | |
10382 | vty_out(vty, | |
10383 | "Read-only mode update-delay limit: %d seconds\n", | |
10384 | bgp->v_update_delay); | |
10385 | if (bgp->v_update_delay | |
10386 | != bgp->v_establish_wait) | |
d62a17ae | 10387 | vty_out(vty, |
ea47320b DL |
10388 | " Establish wait: %d seconds\n", |
10389 | bgp->v_establish_wait); | |
d62a17ae | 10390 | |
60466a63 | 10391 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10392 | vty_out(vty, |
10393 | " First neighbor established: %s\n", | |
10394 | bgp->update_delay_begin_time); | |
10395 | vty_out(vty, | |
10396 | " Delay in progress\n"); | |
10397 | } else { | |
10398 | if (bgp->update_delay_over) { | |
d62a17ae | 10399 | vty_out(vty, |
10400 | " First neighbor established: %s\n", | |
10401 | bgp->update_delay_begin_time); | |
10402 | vty_out(vty, | |
ea47320b DL |
10403 | " Best-paths resumed: %s\n", |
10404 | bgp->update_delay_end_time); | |
10405 | vty_out(vty, | |
10406 | " zebra update resumed: %s\n", | |
10407 | bgp->update_delay_zebra_resume_time); | |
10408 | vty_out(vty, | |
10409 | " peers update resumed: %s\n", | |
10410 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10411 | } |
10412 | } | |
10413 | } | |
ea47320b | 10414 | } |
d62a17ae | 10415 | |
ea47320b DL |
10416 | if (use_json) { |
10417 | if (bgp_maxmed_onstartup_configured(bgp) | |
10418 | && bgp->maxmed_active) | |
10419 | json_object_boolean_true_add( | |
60466a63 | 10420 | json, "maxMedOnStartup"); |
ea47320b DL |
10421 | if (bgp->v_maxmed_admin) |
10422 | json_object_boolean_true_add( | |
60466a63 | 10423 | json, "maxMedAdministrative"); |
d62a17ae | 10424 | |
ea47320b DL |
10425 | json_object_int_add( |
10426 | json, "tableVersion", | |
60466a63 | 10427 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10428 | |
60466a63 QY |
10429 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10430 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10431 | json_object_int_add( |
10432 | json, "ribMemory", | |
9bcb3eef | 10433 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10434 | |
210ec2a0 | 10435 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10436 | json_object_int_add(json, "peerCount", ents); |
10437 | json_object_int_add(json, "peerMemory", | |
10438 | ents * sizeof(struct peer)); | |
d62a17ae | 10439 | |
ea47320b DL |
10440 | if ((ents = listcount(bgp->group))) { |
10441 | json_object_int_add( | |
60466a63 | 10442 | json, "peerGroupCount", ents); |
ea47320b DL |
10443 | json_object_int_add( |
10444 | json, "peerGroupMemory", | |
996c9314 LB |
10445 | ents * sizeof(struct |
10446 | peer_group)); | |
ea47320b | 10447 | } |
d62a17ae | 10448 | |
ea47320b DL |
10449 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10450 | BGP_CONFIG_DAMPENING)) | |
10451 | json_object_boolean_true_add( | |
60466a63 | 10452 | json, "dampeningEnabled"); |
ea47320b | 10453 | } else { |
96c81f66 LS |
10454 | if (!show_terse) { |
10455 | if (bgp_maxmed_onstartup_configured(bgp) | |
10456 | && bgp->maxmed_active) | |
10457 | vty_out(vty, | |
10458 | "Max-med on-startup active\n"); | |
10459 | if (bgp->v_maxmed_admin) | |
10460 | vty_out(vty, | |
10461 | "Max-med administrative active\n"); | |
d62a17ae | 10462 | |
96c81f66 LS |
10463 | vty_out(vty, |
10464 | "BGP table version %" PRIu64 | |
10465 | "\n", | |
10466 | bgp_table_version( | |
10467 | bgp->rib[afi][safi])); | |
ea47320b | 10468 | |
96c81f66 LS |
10469 | ents = bgp_table_count( |
10470 | bgp->rib[afi][safi]); | |
d62a17ae | 10471 | vty_out(vty, |
96c81f66 | 10472 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 10473 | ents, |
10474 | mtype_memstr( | |
10475 | memstrbuf, | |
10476 | sizeof(memstrbuf), | |
96c81f66 LS |
10477 | ents |
10478 | * sizeof( | |
10479 | struct | |
10480 | bgp_dest))); | |
d62a17ae | 10481 | |
96c81f66 LS |
10482 | /* Peer related usage */ |
10483 | ents = bgp->af_peer_count[afi][safi]; | |
10484 | vty_out(vty, | |
10485 | "Peers %ld, using %s of memory\n", | |
10486 | ents, | |
10487 | mtype_memstr( | |
10488 | memstrbuf, | |
10489 | sizeof(memstrbuf), | |
10490 | ents | |
10491 | * sizeof( | |
10492 | struct | |
10493 | peer))); | |
d62a17ae | 10494 | |
96c81f66 LS |
10495 | if ((ents = listcount(bgp->group))) |
10496 | vty_out(vty, | |
10497 | "Peer groups %ld, using %s of memory\n", | |
10498 | ents, | |
10499 | mtype_memstr( | |
10500 | memstrbuf, | |
10501 | sizeof(memstrbuf), | |
10502 | ents | |
10503 | * sizeof( | |
10504 | struct | |
10505 | peer_group))); | |
10506 | ||
10507 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10508 | BGP_CONFIG_DAMPENING)) | |
10509 | vty_out(vty, | |
10510 | "Dampening enabled.\n"); | |
10511 | } | |
10512 | if (show_failed) { | |
10513 | vty_out(vty, "\n"); | |
10514 | ||
10515 | /* Subtract 8 here because 'Neighbor' is | |
10516 | * 8 characters */ | |
10517 | vty_out(vty, "Neighbor"); | |
10518 | vty_out(vty, "%*s", | |
10519 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
10520 | vty_out(vty, |
10521 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 10522 | } |
d62a17ae | 10523 | } |
ea47320b | 10524 | } |
d62a17ae | 10525 | |
d55811cc | 10526 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10527 | filter = &peer->filter[afi][safi]; |
db92d226 | 10528 | |
ea47320b | 10529 | count++; |
3577f1c5 DD |
10530 | /* Works for both failed & successful cases */ |
10531 | if (peer_dynamic_neighbor(peer)) | |
10532 | dn_count++; | |
d62a17ae | 10533 | |
ea47320b | 10534 | if (use_json) { |
3577f1c5 | 10535 | json_peer = NULL; |
8c1d4cd5 | 10536 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10537 | as_type, as)) { |
10538 | filtered_count++; | |
8c1d4cd5 | 10539 | continue; |
ce1944f0 | 10540 | } |
3577f1c5 DD |
10541 | if (show_failed && |
10542 | bgp_has_peer_failed(peer, afi, safi)) { | |
10543 | json_peer = json_object_new_object(); | |
10544 | bgp_show_failed_summary(vty, bgp, peer, | |
10545 | json_peer, 0, use_json); | |
10546 | } else if (!show_failed) { | |
10b49f14 | 10547 | if (show_established |
ce1944f0 LS |
10548 | && bgp_has_peer_failed(peer, afi, safi)) { |
10549 | filtered_count++; | |
10b49f14 | 10550 | continue; |
ce1944f0 | 10551 | } |
10b49f14 | 10552 | |
3577f1c5 DD |
10553 | json_peer = json_object_new_object(); |
10554 | if (peer_dynamic_neighbor(peer)) { | |
10555 | json_object_boolean_true_add(json_peer, | |
10556 | "dynamicPeer"); | |
10557 | } | |
d62a17ae | 10558 | |
3577f1c5 DD |
10559 | if (peer->hostname) |
10560 | json_object_string_add(json_peer, "hostname", | |
10561 | peer->hostname); | |
10562 | ||
10563 | if (peer->domainname) | |
10564 | json_object_string_add(json_peer, "domainname", | |
10565 | peer->domainname); | |
10566 | ||
10567 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
10568 | json_object_int_add( |
10569 | json_peer, "localAs", | |
10570 | peer->change_local_as | |
10571 | ? peer->change_local_as | |
10572 | : peer->local_as); | |
3577f1c5 DD |
10573 | json_object_int_add(json_peer, "version", 4); |
10574 | json_object_int_add(json_peer, "msgRcvd", | |
10575 | PEER_TOTAL_RX(peer)); | |
10576 | json_object_int_add(json_peer, "msgSent", | |
10577 | PEER_TOTAL_TX(peer)); | |
10578 | ||
43aa5965 QY |
10579 | atomic_size_t outq_count, inq_count; |
10580 | outq_count = atomic_load_explicit( | |
10581 | &peer->obuf->count, | |
10582 | memory_order_relaxed); | |
10583 | inq_count = atomic_load_explicit( | |
10584 | &peer->ibuf->count, | |
10585 | memory_order_relaxed); | |
10586 | ||
3577f1c5 DD |
10587 | json_object_int_add(json_peer, "tableVersion", |
10588 | peer->version[afi][safi]); | |
10589 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10590 | outq_count); |
10591 | json_object_int_add(json_peer, "inq", | |
10592 | inq_count); | |
3577f1c5 DD |
10593 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10594 | use_json, json_peer); | |
10595 | ||
3577f1c5 DD |
10596 | json_object_int_add(json_peer, "pfxRcd", |
10597 | peer->pcount[afi][pfx_rcd_safi]); | |
10598 | ||
3577f1c5 | 10599 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
10600 | json_object_int_add( |
10601 | json_peer, "pfxSnt", | |
10602 | (PAF_SUBGRP(paf))->scount); | |
10603 | else | |
10604 | json_object_int_add(json_peer, "pfxSnt", | |
10605 | 0); | |
0e1f8ab5 DA |
10606 | |
10607 | /* BGP FSM state */ | |
cb9196e7 | 10608 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10609 | || CHECK_FLAG(peer->bgp->flags, |
10610 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10611 | json_object_string_add(json_peer, |
10612 | "state", | |
3577f1c5 DD |
10613 | "Idle (Admin)"); |
10614 | else if (peer->afc_recv[afi][safi]) | |
10615 | json_object_string_add( | |
0e1f8ab5 DA |
10616 | json_peer, "state", |
10617 | lookup_msg(bgp_status_msg, | |
10618 | peer->status, NULL)); | |
10619 | else if (CHECK_FLAG( | |
10620 | peer->sflags, | |
10621 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10622 | json_object_string_add(json_peer, | |
10623 | "state", | |
3577f1c5 DD |
10624 | "Idle (PfxCt)"); |
10625 | else | |
10626 | json_object_string_add( | |
0e1f8ab5 DA |
10627 | json_peer, "state", |
10628 | lookup_msg(bgp_status_msg, | |
10629 | peer->status, NULL)); | |
10630 | ||
10631 | /* BGP peer state */ | |
10632 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10633 | || CHECK_FLAG(peer->bgp->flags, | |
10634 | BGP_FLAG_SHUTDOWN)) | |
10635 | json_object_string_add(json_peer, | |
10636 | "peerState", | |
10637 | "Admin"); | |
10638 | else if (CHECK_FLAG( | |
10639 | peer->sflags, | |
10640 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10641 | json_object_string_add(json_peer, | |
10642 | "peerState", | |
10643 | "PfxCt"); | |
10644 | else if (CHECK_FLAG(peer->flags, | |
10645 | PEER_FLAG_PASSIVE)) | |
10646 | json_object_string_add(json_peer, | |
10647 | "peerState", | |
10648 | "Passive"); | |
10649 | else if (CHECK_FLAG(peer->sflags, | |
10650 | PEER_STATUS_NSF_WAIT)) | |
10651 | json_object_string_add(json_peer, | |
10652 | "peerState", | |
10653 | "NSF passive"); | |
10654 | else if (CHECK_FLAG( | |
10655 | peer->bgp->flags, | |
10656 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10657 | && (!bgp_inbound_policy_exists(peer, | |
10658 | filter) | |
10659 | || !bgp_outbound_policy_exists( | |
10660 | peer, filter))) | |
10661 | json_object_string_add(json_peer, | |
10662 | "peerState", | |
10663 | "Policy"); | |
10664 | else | |
10665 | json_object_string_add( | |
10666 | json_peer, "peerState", "OK"); | |
10667 | ||
200116db DD |
10668 | json_object_int_add(json_peer, "connectionsEstablished", |
10669 | peer->established); | |
10670 | json_object_int_add(json_peer, "connectionsDropped", | |
10671 | peer->dropped); | |
aa72bd7e PG |
10672 | if (peer->desc) |
10673 | json_object_string_add( | |
10674 | json_peer, "desc", peer->desc); | |
b4e9dcba | 10675 | } |
3577f1c5 DD |
10676 | /* Avoid creating empty peer dicts in JSON */ |
10677 | if (json_peer == NULL) | |
10678 | continue; | |
ea47320b DL |
10679 | |
10680 | if (peer->conf_if) | |
60466a63 | 10681 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10682 | "interface"); |
10683 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10684 | json_object_string_add(json_peer, "idType", |
10685 | "ipv4"); | |
ea47320b | 10686 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10687 | json_object_string_add(json_peer, "idType", |
10688 | "ipv6"); | |
ea47320b DL |
10689 | json_object_object_add(json_peers, peer->host, |
10690 | json_peer); | |
10691 | } else { | |
8c1d4cd5 | 10692 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10693 | as_type, as)) { |
10694 | filtered_count++; | |
8c1d4cd5 | 10695 | continue; |
ce1944f0 | 10696 | } |
3577f1c5 DD |
10697 | if (show_failed && |
10698 | bgp_has_peer_failed(peer, afi, safi)) { | |
10699 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10700 | max_neighbor_width, | |
10701 | use_json); | |
10702 | } else if (!show_failed) { | |
10b49f14 | 10703 | if (show_established |
ce1944f0 LS |
10704 | && bgp_has_peer_failed(peer, afi, safi)) { |
10705 | filtered_count++; | |
10b49f14 | 10706 | continue; |
ce1944f0 | 10707 | } |
96c81f66 LS |
10708 | |
10709 | if ((count - filtered_count) == 1) { | |
10710 | /* display headline before the first | |
10711 | * neighbor line */ | |
10712 | vty_out(vty, "\n"); | |
10713 | ||
10714 | /* Subtract 8 here because 'Neighbor' is | |
10715 | * 8 characters */ | |
10716 | vty_out(vty, "Neighbor"); | |
10717 | vty_out(vty, "%*s", | |
10718 | max_neighbor_width - 8, " "); | |
10719 | vty_out(vty, | |
10720 | show_wide | |
10721 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10722 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
10723 | } | |
10724 | ||
3577f1c5 DD |
10725 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10726 | if (peer_dynamic_neighbor(peer)) { | |
10727 | dn_flag[0] = '*'; | |
10728 | } | |
d62a17ae | 10729 | |
3577f1c5 | 10730 | if (peer->hostname |
892fedb6 DA |
10731 | && CHECK_FLAG(bgp->flags, |
10732 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10733 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10734 | peer->hostname, |
10735 | peer->host); | |
d62a17ae | 10736 | else |
3577f1c5 DD |
10737 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10738 | ||
10739 | /* pad the neighbor column with spaces */ | |
10740 | if (len < max_neighbor_width) | |
10741 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10742 | " "); | |
10743 | ||
43aa5965 QY |
10744 | atomic_size_t outq_count, inq_count; |
10745 | outq_count = atomic_load_explicit( | |
10746 | &peer->obuf->count, | |
10747 | memory_order_relaxed); | |
10748 | inq_count = atomic_load_explicit( | |
10749 | &peer->ibuf->count, | |
10750 | memory_order_relaxed); | |
10751 | ||
85eeb029 DA |
10752 | if (show_wide) |
10753 | vty_out(vty, | |
10754 | "4 %10u %10u %9u %9u %8" PRIu64 | |
10755 | " %4zu %4zu %8s", | |
10756 | peer->as, | |
10757 | peer->change_local_as | |
10758 | ? peer->change_local_as | |
10759 | : peer->local_as, | |
10760 | PEER_TOTAL_RX(peer), | |
10761 | PEER_TOTAL_TX(peer), | |
10762 | peer->version[afi][safi], | |
10763 | inq_count, outq_count, | |
10764 | peer_uptime(peer->uptime, | |
10765 | timebuf, | |
10766 | BGP_UPTIME_LEN, 0, | |
10767 | NULL)); | |
10768 | else | |
10769 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
10770 | " %4zu %4zu %8s", | |
10771 | peer->as, PEER_TOTAL_RX(peer), | |
10772 | PEER_TOTAL_TX(peer), | |
10773 | peer->version[afi][safi], | |
10774 | inq_count, outq_count, | |
10775 | peer_uptime(peer->uptime, | |
10776 | timebuf, | |
10777 | BGP_UPTIME_LEN, 0, | |
10778 | NULL)); | |
3577f1c5 | 10779 | |
feb17238 | 10780 | if (peer_established(peer)) { |
d3ada366 DA |
10781 | if (peer->afc_recv[afi][safi]) { |
10782 | if (CHECK_FLAG( | |
10783 | bgp->flags, | |
10784 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10785 | && !bgp_inbound_policy_exists( | |
10786 | peer, filter)) | |
10787 | vty_out(vty, " %12s", | |
10788 | "(Policy)"); | |
10789 | else | |
10790 | vty_out(vty, | |
6cde4b45 | 10791 | " %12u", |
d3ada366 DA |
10792 | peer->pcount |
10793 | [afi] | |
10794 | [pfx_rcd_safi]); | |
10795 | } else { | |
749d0f27 | 10796 | vty_out(vty, " NoNeg"); |
d3ada366 | 10797 | } |
db92d226 | 10798 | |
d3ada366 DA |
10799 | if (paf && PAF_SUBGRP(paf)) { |
10800 | if (CHECK_FLAG( | |
10801 | bgp->flags, | |
10802 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10803 | && !bgp_outbound_policy_exists( | |
10804 | peer, filter)) | |
10805 | vty_out(vty, " %8s", | |
10806 | "(Policy)"); | |
10807 | else | |
10808 | vty_out(vty, | |
6cde4b45 | 10809 | " %8u", |
d3ada366 DA |
10810 | (PAF_SUBGRP( |
10811 | paf)) | |
10812 | ->scount); | |
749d0f27 DA |
10813 | } else { |
10814 | vty_out(vty, " NoNeg"); | |
d3ada366 | 10815 | } |
db92d226 | 10816 | } else { |
736b68f3 DS |
10817 | if (CHECK_FLAG(peer->flags, |
10818 | PEER_FLAG_SHUTDOWN) | |
10819 | || CHECK_FLAG(peer->bgp->flags, | |
10820 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10821 | vty_out(vty, " Idle (Admin)"); |
10822 | else if (CHECK_FLAG( | |
10823 | peer->sflags, | |
10824 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10825 | vty_out(vty, " Idle (PfxCt)"); | |
10826 | else | |
10827 | vty_out(vty, " %12s", | |
10828 | lookup_msg(bgp_status_msg, | |
10829 | peer->status, NULL)); | |
db92d226 | 10830 | |
6cde4b45 | 10831 | vty_out(vty, " %8u", 0); |
3577f1c5 | 10832 | } |
565e9ddd DA |
10833 | /* Make sure `Desc` column is the lastest in |
10834 | * the output. | |
10835 | */ | |
aa72bd7e | 10836 | if (peer->desc) |
cb75bb31 DA |
10837 | vty_out(vty, " %s", |
10838 | bgp_peer_description_stripped( | |
85eeb029 DA |
10839 | peer->desc, |
10840 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
10841 | else |
10842 | vty_out(vty, " N/A"); | |
3577f1c5 | 10843 | vty_out(vty, "\n"); |
d62a17ae | 10844 | } |
3577f1c5 | 10845 | |
d62a17ae | 10846 | } |
10847 | } | |
f933309e | 10848 | |
d62a17ae | 10849 | if (use_json) { |
10850 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10851 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
10852 | json_object_int_add(json, "displayedPeers", |
10853 | count - filtered_count); | |
d62a17ae | 10854 | json_object_int_add(json, "totalPeers", count); |
10855 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10856 | ||
3577f1c5 DD |
10857 | if (!show_failed) |
10858 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10859 | |
75eeda93 | 10860 | vty_json(vty, json); |
d62a17ae | 10861 | } else { |
ce1944f0 | 10862 | if (count) { |
96c81f66 LS |
10863 | if (filtered_count == count) |
10864 | vty_out(vty, "\n%% No matching neighbor\n"); | |
10865 | else { | |
10866 | if (show_failed) | |
10867 | vty_out(vty, "\nDisplayed neighbors %d", | |
10868 | failed_count); | |
10869 | else if (as_type != AS_UNSPECIFIED || as | |
10870 | || fpeer || show_established) | |
ce1944f0 LS |
10871 | vty_out(vty, "\nDisplayed neighbors %d", |
10872 | count - filtered_count); | |
96c81f66 LS |
10873 | |
10874 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
10875 | count); | |
ce1944f0 | 10876 | } |
ce1944f0 | 10877 | } else { |
d6ceaca3 | 10878 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10879 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10880 | } |
b05a1c8b | 10881 | |
d6ceaca3 | 10882 | if (dn_count) { |
d62a17ae | 10883 | vty_out(vty, "* - dynamic neighbor\n"); |
10884 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10885 | dn_count, bgp->dynamic_neighbors_limit); | |
10886 | } | |
10887 | } | |
1ff9a340 | 10888 | |
d62a17ae | 10889 | return CMD_SUCCESS; |
718e3744 | 10890 | } |
10891 | ||
d62a17ae | 10892 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 10893 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 10894 | as_t as, uint16_t show_flags) |
d62a17ae | 10895 | { |
10896 | int is_first = 1; | |
10897 | int afi_wildcard = (afi == AFI_MAX); | |
10898 | int safi_wildcard = (safi == SAFI_MAX); | |
10899 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 10900 | bool nbr_output = false; |
85eeb029 | 10901 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10902 | |
10903 | if (use_json && is_wildcard) | |
10904 | vty_out(vty, "{\n"); | |
10905 | if (afi_wildcard) | |
10906 | afi = 1; /* AFI_IP */ | |
10907 | while (afi < AFI_MAX) { | |
10908 | if (safi_wildcard) | |
10909 | safi = 1; /* SAFI_UNICAST */ | |
10910 | while (safi < SAFI_MAX) { | |
318cac96 | 10911 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 10912 | nbr_output = true; |
f86897b9 | 10913 | |
d62a17ae | 10914 | if (is_wildcard) { |
10915 | /* | |
10916 | * So limit output to those afi/safi | |
10917 | * pairs that | |
10918 | * actualy have something interesting in | |
10919 | * them | |
10920 | */ | |
10921 | if (use_json) { | |
d62a17ae | 10922 | if (!is_first) |
10923 | vty_out(vty, ",\n"); | |
10924 | else | |
10925 | is_first = 0; | |
10926 | ||
10927 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
10928 | get_afi_safi_str(afi, |
10929 | safi, | |
10930 | true)); | |
d62a17ae | 10931 | } else { |
6cac2fcc LS |
10932 | vty_out(vty, |
10933 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
10934 | get_afi_safi_str(afi, |
10935 | safi, | |
6cac2fcc LS |
10936 | false), |
10937 | bgp->name_pretty); | |
d62a17ae | 10938 | } |
10939 | } | |
8c1d4cd5 LS |
10940 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
10941 | as_type, as, show_flags); | |
d62a17ae | 10942 | } |
10943 | safi++; | |
d62a17ae | 10944 | if (!safi_wildcard) |
10945 | safi = SAFI_MAX; | |
10946 | } | |
10947 | afi++; | |
ee851c8c | 10948 | if (!afi_wildcard) |
d62a17ae | 10949 | afi = AFI_MAX; |
10950 | } | |
10951 | ||
10952 | if (use_json && is_wildcard) | |
10953 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
10954 | else if (!nbr_output) { |
10955 | if (use_json) | |
10956 | vty_out(vty, "{}\n"); | |
10957 | else | |
6cac2fcc LS |
10958 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
10959 | bgp->name_pretty); | |
ca61fd25 | 10960 | } |
d62a17ae | 10961 | } |
10962 | ||
10963 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
10964 | safi_t safi, |
10965 | const char *neighbor, | |
10966 | int as_type, as_t as, | |
96c81f66 | 10967 | uint16_t show_flags) |
d62a17ae | 10968 | { |
10969 | struct listnode *node, *nnode; | |
10970 | struct bgp *bgp; | |
8c1d4cd5 | 10971 | struct peer *fpeer = NULL; |
d62a17ae | 10972 | int is_first = 1; |
9f049418 | 10973 | bool nbr_output = false; |
85eeb029 | 10974 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10975 | |
10976 | if (use_json) | |
10977 | vty_out(vty, "{\n"); | |
10978 | ||
10979 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10980 | nbr_output = true; |
d62a17ae | 10981 | if (use_json) { |
d62a17ae | 10982 | if (!is_first) |
10983 | vty_out(vty, ",\n"); | |
10984 | else | |
10985 | is_first = 0; | |
10986 | ||
10987 | vty_out(vty, "\"%s\":", | |
10988 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10989 | ? VRF_DEFAULT_NAME |
d62a17ae | 10990 | : bgp->name); |
d62a17ae | 10991 | } |
8c1d4cd5 LS |
10992 | if (neighbor) { |
10993 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10994 | use_json); | |
10995 | if (!fpeer) | |
10996 | continue; | |
10997 | } | |
10998 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
10999 | as, show_flags); | |
d62a17ae | 11000 | } |
11001 | ||
11002 | if (use_json) | |
11003 | vty_out(vty, "}\n"); | |
9f049418 DS |
11004 | else if (!nbr_output) |
11005 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11006 | } |
11007 | ||
11008 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11009 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11010 | as_t as, uint16_t show_flags) |
d62a17ae | 11011 | { |
11012 | struct bgp *bgp; | |
85eeb029 | 11013 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11014 | struct peer *fpeer = NULL; |
d62a17ae | 11015 | |
11016 | if (name) { | |
11017 | if (strmatch(name, "all")) { | |
85eeb029 | 11018 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11019 | neighbor, as_type, |
11020 | as, show_flags); | |
d62a17ae | 11021 | return CMD_SUCCESS; |
11022 | } else { | |
11023 | bgp = bgp_lookup_by_name(name); | |
11024 | ||
11025 | if (!bgp) { | |
11026 | if (use_json) | |
11027 | vty_out(vty, "{}\n"); | |
11028 | else | |
11029 | vty_out(vty, | |
ca61fd25 | 11030 | "%% BGP instance not found\n"); |
d62a17ae | 11031 | return CMD_WARNING; |
11032 | } | |
11033 | ||
8c1d4cd5 LS |
11034 | if (neighbor) { |
11035 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11036 | use_json); | |
11037 | if (!fpeer) | |
11038 | return CMD_WARNING; | |
11039 | } | |
11040 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11041 | as_type, as, show_flags); | |
d62a17ae | 11042 | return CMD_SUCCESS; |
11043 | } | |
11044 | } | |
11045 | ||
11046 | bgp = bgp_get_default(); | |
11047 | ||
8c1d4cd5 LS |
11048 | if (bgp) { |
11049 | if (neighbor) { | |
11050 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11051 | use_json); | |
11052 | if (!fpeer) | |
11053 | return CMD_WARNING; | |
11054 | } | |
11055 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11056 | as, show_flags); | |
11057 | } else { | |
ca61fd25 DS |
11058 | if (use_json) |
11059 | vty_out(vty, "{}\n"); | |
11060 | else | |
11061 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11062 | return CMD_WARNING; |
11063 | } | |
d62a17ae | 11064 | |
11065 | return CMD_SUCCESS; | |
4fb25c53 DW |
11066 | } |
11067 | ||
716b2d8a | 11068 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11069 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11070 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11071 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11072 | "]] [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 |
11073 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11074 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11075 | "Display the entries for all address families\n" | |
11076 | "Summary of BGP neighbor status\n" | |
11077 | "Show only sessions in Established state\n" | |
11078 | "Show only sessions not in Established state\n" | |
11079 | "Show only the specified neighbor session\n" | |
11080 | "Neighbor to display information about\n" | |
11081 | "Neighbor to display information about\n" | |
11082 | "Neighbor on BGP configured interface\n" | |
11083 | "Show only the specified remote AS sessions\n" | |
11084 | "AS number\n" | |
11085 | "Internal (iBGP) AS sessions\n" | |
11086 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11087 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11088 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11089 | { |
d62a17ae | 11090 | char *vrf = NULL; |
11091 | afi_t afi = AFI_MAX; | |
11092 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11093 | as_t as = 0; /* 0 means AS filter not set */ |
11094 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11095 | uint16_t show_flags = 0; |
d62a17ae | 11096 | |
11097 | int idx = 0; | |
11098 | ||
11099 | /* show [ip] bgp */ | |
96f3485c | 11100 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11101 | afi = AFI_IP; |
9a8bdf1c PG |
11102 | /* [<vrf> VIEWVRFNAME] */ |
11103 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11104 | vrf = argv[idx + 1]->arg; | |
11105 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11106 | vrf = NULL; | |
11107 | } else if (argv_find(argv, argc, "view", &idx)) | |
11108 | /* [<view> VIEWVRFNAME] */ | |
11109 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11110 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11111 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11112 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11113 | } | |
11114 | ||
3577f1c5 | 11115 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11116 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11117 | ||
10b49f14 | 11118 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11119 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11120 | ||
8c1d4cd5 LS |
11121 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11122 | if (argv[idx + 1]->arg[0] == 'i') | |
11123 | as_type = AS_INTERNAL; | |
11124 | else if (argv[idx + 1]->arg[0] == 'e') | |
11125 | as_type = AS_EXTERNAL; | |
11126 | else | |
11127 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11128 | } | |
11129 | ||
96c81f66 LS |
11130 | if (argv_find(argv, argc, "terse", &idx)) |
11131 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11132 | ||
85eeb029 DA |
11133 | if (argv_find(argv, argc, "wide", &idx)) |
11134 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11135 | ||
11136 | if (argv_find(argv, argc, "json", &idx)) | |
11137 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11138 | |
8c1d4cd5 LS |
11139 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11140 | show_flags); | |
d62a17ae | 11141 | } |
11142 | ||
5cb5f4d0 | 11143 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11144 | { |
5cb5f4d0 DD |
11145 | if (for_json) |
11146 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11147 | else |
5cb5f4d0 | 11148 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11149 | } |
11150 | ||
d62a17ae | 11151 | |
11152 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11153 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11154 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11155 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11156 | bool use_json, json_object *json_pref) |
d62a17ae | 11157 | { |
11158 | /* Send-Mode */ | |
11159 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11160 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11161 | if (use_json) { | |
11162 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11163 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11164 | json_object_string_add(json_pref, "sendMode", | |
11165 | "advertisedAndReceived"); | |
11166 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11167 | json_object_string_add(json_pref, "sendMode", | |
11168 | "advertised"); | |
11169 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11170 | json_object_string_add(json_pref, "sendMode", | |
11171 | "received"); | |
11172 | } else { | |
11173 | vty_out(vty, " Send-mode: "); | |
11174 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11175 | vty_out(vty, "advertised"); | |
11176 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11177 | vty_out(vty, "%sreceived", | |
11178 | CHECK_FLAG(p->af_cap[afi][safi], | |
11179 | adv_smcap) | |
11180 | ? ", " | |
11181 | : ""); | |
11182 | vty_out(vty, "\n"); | |
11183 | } | |
11184 | } | |
11185 | ||
11186 | /* Receive-Mode */ | |
11187 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11188 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11189 | if (use_json) { | |
11190 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11191 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11192 | json_object_string_add(json_pref, "recvMode", | |
11193 | "advertisedAndReceived"); | |
11194 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11195 | json_object_string_add(json_pref, "recvMode", | |
11196 | "advertised"); | |
11197 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11198 | json_object_string_add(json_pref, "recvMode", | |
11199 | "received"); | |
11200 | } else { | |
11201 | vty_out(vty, " Receive-mode: "); | |
11202 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11203 | vty_out(vty, "advertised"); | |
11204 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11205 | vty_out(vty, "%sreceived", | |
11206 | CHECK_FLAG(p->af_cap[afi][safi], | |
11207 | adv_rmcap) | |
11208 | ? ", " | |
11209 | : ""); | |
11210 | vty_out(vty, "\n"); | |
11211 | } | |
11212 | } | |
11213 | } | |
11214 | ||
13909c4f DS |
11215 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11216 | struct peer *p, | |
11217 | bool use_json, | |
11218 | json_object *json) | |
2986cac2 | 11219 | { |
08c2d52a | 11220 | bool rbit_status = false; |
2986cac2 | 11221 | |
11222 | if (!use_json) | |
a53ca37b | 11223 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11224 | |
13909c4f DS |
11225 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11226 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11227 | && (peer_established(p))) { |
2986cac2 | 11228 | |
11229 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11230 | rbit_status = true; |
2986cac2 | 11231 | else |
08c2d52a | 11232 | rbit_status = false; |
2986cac2 | 11233 | } |
11234 | ||
11235 | if (rbit_status) { | |
11236 | if (use_json) | |
13909c4f | 11237 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11238 | else |
11239 | vty_out(vty, "True\n"); | |
11240 | } else { | |
11241 | if (use_json) | |
13909c4f | 11242 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11243 | else |
11244 | vty_out(vty, "False\n"); | |
11245 | } | |
11246 | } | |
11247 | ||
13909c4f DS |
11248 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11249 | struct peer *peer, | |
11250 | bool use_json, | |
11251 | json_object *json) | |
2986cac2 | 11252 | { |
2bb5d39b | 11253 | const char *mode = "NotApplicable"; |
2986cac2 | 11254 | |
11255 | if (!use_json) | |
a53ca37b | 11256 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11257 | |
13909c4f | 11258 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11259 | && (peer_established(peer))) { |
2986cac2 | 11260 | |
13909c4f DS |
11261 | if ((peer->nsf_af_count == 0) |
11262 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11263 | |
2986cac2 | 11264 | mode = "Disable"; |
11265 | ||
13909c4f DS |
11266 | } else if (peer->nsf_af_count == 0 |
11267 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11268 | |
2986cac2 | 11269 | mode = "Helper"; |
11270 | ||
13909c4f DS |
11271 | } else if (peer->nsf_af_count != 0 |
11272 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11273 | |
2986cac2 | 11274 | mode = "Restart"; |
2986cac2 | 11275 | } |
11276 | } | |
11277 | ||
11278 | if (use_json) { | |
13909c4f | 11279 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11280 | } else |
11281 | vty_out(vty, mode, "\n"); | |
11282 | } | |
11283 | ||
13909c4f DS |
11284 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11285 | struct peer *p, | |
11286 | bool use_json, | |
11287 | json_object *json) | |
2986cac2 | 11288 | { |
11289 | const char *mode = "Invalid"; | |
11290 | ||
11291 | if (!use_json) | |
a53ca37b | 11292 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11293 | |
11294 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11295 | mode = "Helper"; | |
11296 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11297 | mode = "Restart"; | |
11298 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11299 | mode = "Disable"; | |
2ba1fe69 | 11300 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11301 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11302 | mode = "Helper*"; | |
11303 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11304 | mode = "Restart*"; | |
11305 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11306 | mode = "Disable*"; | |
11307 | else | |
11308 | mode = "Invalid*"; | |
2ba1fe69 | 11309 | } |
2986cac2 | 11310 | |
11311 | if (use_json) { | |
13909c4f | 11312 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11313 | } else { |
11314 | vty_out(vty, mode, "\n"); | |
11315 | } | |
11316 | } | |
11317 | ||
13909c4f DS |
11318 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11319 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11320 | { |
2ba1fe69 | 11321 | afi_t afi; |
11322 | safi_t safi; | |
2986cac2 | 11323 | json_object *json_afi_safi = NULL; |
11324 | json_object *json_timer = NULL; | |
11325 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11326 | bool eor_flag = false; |
2986cac2 | 11327 | |
df8d723c DA |
11328 | FOREACH_AFI_SAFI_NSF (afi, safi) { |
11329 | if (!peer->afc[afi][safi]) | |
11330 | continue; | |
2986cac2 | 11331 | |
df8d723c DA |
11332 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || |
11333 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11334 | continue; | |
9e3b51a7 | 11335 | |
df8d723c DA |
11336 | if (use_json) { |
11337 | json_afi_safi = json_object_new_object(); | |
11338 | json_endofrib_status = json_object_new_object(); | |
11339 | json_timer = json_object_new_object(); | |
11340 | } | |
2986cac2 | 11341 | |
df8d723c DA |
11342 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) |
11343 | eor_flag = true; | |
11344 | else | |
11345 | eor_flag = false; | |
2986cac2 | 11346 | |
df8d723c DA |
11347 | if (!use_json) { |
11348 | vty_out(vty, " %s:\n", | |
11349 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 11350 | |
df8d723c DA |
11351 | vty_out(vty, " F bit: "); |
11352 | } | |
2986cac2 | 11353 | |
df8d723c DA |
11354 | if (peer->nsf[afi][safi] && |
11355 | CHECK_FLAG(peer->af_cap[afi][safi], | |
11356 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11357 | |
df8d723c DA |
11358 | if (use_json) { |
11359 | json_object_boolean_true_add(json_afi_safi, | |
11360 | "fBit"); | |
11361 | } else | |
11362 | vty_out(vty, "True\n"); | |
11363 | } else { | |
11364 | if (use_json) | |
11365 | json_object_boolean_false_add(json_afi_safi, | |
11366 | "fBit"); | |
11367 | else | |
11368 | vty_out(vty, "False\n"); | |
11369 | } | |
2986cac2 | 11370 | |
df8d723c DA |
11371 | if (!use_json) |
11372 | vty_out(vty, " End-of-RIB sent: "); | |
2986cac2 | 11373 | |
df8d723c DA |
11374 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11375 | PEER_STATUS_EOR_SEND)) { | |
11376 | if (use_json) { | |
11377 | json_object_boolean_true_add( | |
11378 | json_endofrib_status, "endOfRibSend"); | |
9e3b51a7 | 11379 | |
df8d723c DA |
11380 | PRINT_EOR_JSON(eor_flag); |
11381 | } else { | |
11382 | vty_out(vty, "Yes\n"); | |
11383 | vty_out(vty, | |
11384 | " End-of-RIB sent after update: "); | |
2986cac2 | 11385 | |
df8d723c DA |
11386 | PRINT_EOR(eor_flag); |
11387 | } | |
11388 | } else { | |
11389 | if (use_json) { | |
11390 | json_object_boolean_false_add( | |
11391 | json_endofrib_status, "endOfRibSend"); | |
11392 | json_object_boolean_false_add( | |
11393 | json_endofrib_status, | |
11394 | "endOfRibSentAfterUpdate"); | |
13909c4f | 11395 | } else { |
df8d723c DA |
11396 | vty_out(vty, "No\n"); |
11397 | vty_out(vty, | |
11398 | " End-of-RIB sent after update: "); | |
11399 | vty_out(vty, "No\n"); | |
13909c4f | 11400 | } |
df8d723c | 11401 | } |
2986cac2 | 11402 | |
df8d723c DA |
11403 | if (!use_json) |
11404 | vty_out(vty, " End-of-RIB received: "); | |
a53ca37b | 11405 | |
df8d723c DA |
11406 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11407 | PEER_STATUS_EOR_RECEIVED)) { | |
11408 | if (use_json) | |
11409 | json_object_boolean_true_add( | |
11410 | json_endofrib_status, "endOfRibRecv"); | |
11411 | else | |
11412 | vty_out(vty, "Yes\n"); | |
11413 | } else { | |
11414 | if (use_json) | |
11415 | json_object_boolean_false_add( | |
11416 | json_endofrib_status, "endOfRibRecv"); | |
11417 | else | |
11418 | vty_out(vty, "No\n"); | |
11419 | } | |
11420 | ||
11421 | if (use_json) { | |
11422 | json_object_int_add(json_timer, "stalePathTimer", | |
11423 | peer->bgp->stalepath_time); | |
11424 | ||
11425 | if (peer->t_gr_stale != NULL) { | |
11426 | json_object_int_add(json_timer, | |
11427 | "stalePathTimerRemaining", | |
11428 | thread_timer_remain_second( | |
11429 | peer->t_gr_stale)); | |
a53ca37b DA |
11430 | } |
11431 | ||
df8d723c DA |
11432 | /* Display Configured Selection |
11433 | * Deferral only when when | |
11434 | * Gr mode is enabled. | |
11435 | */ | |
11436 | if (CHECK_FLAG(peer->flags, | |
11437 | PEER_FLAG_GRACEFUL_RESTART)) { | |
13909c4f | 11438 | json_object_int_add(json_timer, |
df8d723c | 11439 | "selectionDeferralTimer", |
13909c4f | 11440 | peer->bgp->stalepath_time); |
df8d723c | 11441 | } |
2986cac2 | 11442 | |
df8d723c DA |
11443 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
11444 | NULL) { | |
2986cac2 | 11445 | |
df8d723c DA |
11446 | json_object_int_add( |
11447 | json_timer, | |
11448 | "selectionDeferralTimerRemaining", | |
11449 | thread_timer_remain_second( | |
11450 | peer->bgp->gr_info[afi][safi] | |
11451 | .t_select_deferral)); | |
11452 | } | |
11453 | } else { | |
11454 | vty_out(vty, " Timers:\n"); | |
11455 | vty_out(vty, | |
11456 | " Configured Stale Path Time(sec): %u\n", | |
11457 | peer->bgp->stalepath_time); | |
2986cac2 | 11458 | |
df8d723c | 11459 | if (peer->t_gr_stale != NULL) |
13909c4f | 11460 | vty_out(vty, |
df8d723c DA |
11461 | " Stale Path Remaining(sec): %ld\n", |
11462 | thread_timer_remain_second( | |
11463 | peer->t_gr_stale)); | |
11464 | /* Display Configured Selection | |
11465 | * Deferral only when when | |
11466 | * Gr mode is enabled. | |
11467 | */ | |
11468 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
11469 | vty_out(vty, | |
11470 | " Configured Selection Deferral Time(sec): %u\n", | |
11471 | peer->bgp->select_defer_time); | |
2986cac2 | 11472 | |
df8d723c DA |
11473 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
11474 | NULL) | |
11475 | vty_out(vty, | |
11476 | " Selection Deferral Time Remaining(sec): %ld\n", | |
11477 | thread_timer_remain_second( | |
11478 | peer->bgp->gr_info[afi][safi] | |
11479 | .t_select_deferral)); | |
11480 | } | |
11481 | if (use_json) { | |
11482 | json_object_object_add(json_afi_safi, "endOfRibStatus", | |
11483 | json_endofrib_status); | |
11484 | json_object_object_add(json_afi_safi, "timers", | |
11485 | json_timer); | |
11486 | json_object_object_add( | |
11487 | json, get_afi_safi_str(afi, safi, true), | |
11488 | json_afi_safi); | |
2986cac2 | 11489 | } |
11490 | } | |
11491 | } | |
11492 | ||
36235319 QY |
11493 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11494 | struct peer *p, | |
11495 | bool use_json, | |
11496 | json_object *json) | |
2986cac2 | 11497 | { |
11498 | if (use_json) { | |
11499 | json_object *json_timer = NULL; | |
11500 | ||
11501 | json_timer = json_object_new_object(); | |
11502 | ||
13909c4f DS |
11503 | json_object_int_add(json_timer, "configuredRestartTimer", |
11504 | p->bgp->restart_time); | |
2986cac2 | 11505 | |
13909c4f DS |
11506 | json_object_int_add(json_timer, "receivedRestartTimer", |
11507 | p->v_gr_restart); | |
2986cac2 | 11508 | |
13909c4f DS |
11509 | if (p->t_gr_restart != NULL) |
11510 | json_object_int_add( | |
11511 | json_timer, "restartTimerRemaining", | |
11512 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11513 | |
11514 | json_object_object_add(json, "timers", json_timer); | |
11515 | } else { | |
11516 | ||
a53ca37b DA |
11517 | vty_out(vty, " Timers:\n"); |
11518 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11519 | p->bgp->restart_time); |
2986cac2 | 11520 | |
a53ca37b | 11521 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11522 | p->v_gr_restart); |
11523 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11524 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11525 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11526 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11527 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11528 | thread_timer_remain_second(p->t_gr_restart)); |
11529 | } | |
2986cac2 | 11530 | } |
11531 | } | |
11532 | ||
11533 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11534 | bool use_json, json_object *json) |
2986cac2 | 11535 | { |
11536 | char buf[SU_ADDRSTRLEN] = {0}; | |
11537 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11538 | /* '*' + v6 address of neighbor */ |
11539 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11540 | |
2986cac2 | 11541 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11542 | dn_flag[0] = '*'; | |
11543 | ||
11544 | if (p->conf_if) { | |
11545 | if (use_json) | |
13909c4f DS |
11546 | json_object_string_add( |
11547 | json, "neighborAddr", | |
2986cac2 | 11548 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11549 | ? "none" |
11550 | : sockunion2str(&p->su, buf, | |
11551 | SU_ADDRSTRLEN)); | |
2986cac2 | 11552 | else |
13909c4f | 11553 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11554 | BGP_PEER_SU_UNSPEC(p) |
11555 | ? "none" | |
11556 | : sockunion2str(&p->su, buf, | |
11557 | SU_ADDRSTRLEN)); | |
11558 | } else { | |
772270f3 QY |
11559 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11560 | p->host); | |
2986cac2 | 11561 | |
11562 | if (use_json) | |
36235319 QY |
11563 | json_object_string_add(json, "neighborAddr", |
11564 | neighborAddr); | |
2986cac2 | 11565 | else |
36235319 | 11566 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11567 | } |
11568 | ||
11569 | /* more gr info in new format */ | |
11570 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11571 | } | |
11572 | ||
d62a17ae | 11573 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11574 | safi_t safi, bool use_json, |
d62a17ae | 11575 | json_object *json_neigh) |
11576 | { | |
0291c246 MK |
11577 | struct bgp_filter *filter; |
11578 | struct peer_af *paf; | |
11579 | char orf_pfx_name[BUFSIZ]; | |
11580 | int orf_pfx_count; | |
11581 | json_object *json_af = NULL; | |
11582 | json_object *json_prefA = NULL; | |
11583 | json_object *json_prefB = NULL; | |
11584 | json_object *json_addr = NULL; | |
fa36596c | 11585 | json_object *json_advmap = NULL; |
d62a17ae | 11586 | |
11587 | if (use_json) { | |
11588 | json_addr = json_object_new_object(); | |
11589 | json_af = json_object_new_object(); | |
11590 | filter = &p->filter[afi][safi]; | |
11591 | ||
11592 | if (peer_group_active(p)) | |
11593 | json_object_string_add(json_addr, "peerGroupMember", | |
11594 | p->group->name); | |
11595 | ||
11596 | paf = peer_af_find(p, afi, safi); | |
11597 | if (paf && PAF_SUBGRP(paf)) { | |
11598 | json_object_int_add(json_addr, "updateGroupId", | |
11599 | PAF_UPDGRP(paf)->id); | |
11600 | json_object_int_add(json_addr, "subGroupId", | |
11601 | PAF_SUBGRP(paf)->id); | |
11602 | json_object_int_add(json_addr, "packetQueueLength", | |
11603 | bpacket_queue_virtual_length(paf)); | |
11604 | } | |
11605 | ||
11606 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11607 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11608 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11609 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11610 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11611 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11612 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11613 | json_object_int_add(json_af, "orfType", | |
11614 | ORF_TYPE_PREFIX); | |
11615 | json_prefA = json_object_new_object(); | |
11616 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11617 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11618 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11619 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11620 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11621 | use_json, json_prefA); | |
11622 | json_object_object_add(json_af, "orfPrefixList", | |
11623 | json_prefA); | |
11624 | } | |
11625 | ||
11626 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11627 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11628 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11629 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11630 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11631 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11632 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11633 | json_object_int_add(json_af, "orfOldType", | |
11634 | ORF_TYPE_PREFIX_OLD); | |
11635 | json_prefB = json_object_new_object(); | |
11636 | bgp_show_peer_afi_orf_cap( | |
11637 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11638 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11639 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11640 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11641 | json_prefB); | |
11642 | json_object_object_add(json_af, "orfOldPrefixList", | |
11643 | json_prefB); | |
11644 | } | |
11645 | ||
11646 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11647 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11648 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11649 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11650 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11651 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11652 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11653 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11654 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11655 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11656 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11657 | json_object_object_add(json_addr, "afDependentCap", | |
11658 | json_af); | |
11659 | else | |
11660 | json_object_free(json_af); | |
11661 | ||
772270f3 QY |
11662 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11663 | p->host, afi, safi); | |
d62a17ae | 11664 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11665 | NULL, afi, orf_pfx_name, use_json); | |
11666 | ||
11667 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11668 | PEER_STATUS_ORF_PREFIX_SEND) | |
11669 | || orf_pfx_count) { | |
11670 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11671 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11672 | json_object_boolean_true_add(json_neigh, | |
11673 | "orfSent"); | |
11674 | if (orf_pfx_count) | |
11675 | json_object_int_add(json_addr, "orfRecvCounter", | |
11676 | orf_pfx_count); | |
11677 | } | |
11678 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11679 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11680 | json_object_string_add( | |
11681 | json_addr, "orfFirstUpdate", | |
11682 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11683 | ||
11684 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11685 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11686 | json_object_boolean_true_add(json_addr, | |
11687 | "routeReflectorClient"); | |
11688 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11689 | PEER_FLAG_RSERVER_CLIENT)) | |
11690 | json_object_boolean_true_add(json_addr, | |
11691 | "routeServerClient"); | |
11692 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11693 | json_object_boolean_true_add(json_addr, | |
11694 | "inboundSoftConfigPermit"); | |
11695 | ||
11696 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11697 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11698 | json_object_boolean_true_add( | |
11699 | json_addr, | |
11700 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11701 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11702 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11703 | json_object_boolean_true_add( | |
11704 | json_addr, | |
11705 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11706 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11707 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11708 | json_object_boolean_true_add( | |
11709 | json_addr, | |
11710 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11711 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11712 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11713 | json_object_boolean_true_add( | |
11714 | json_addr, | |
11715 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11716 | ||
dcc68b5e MS |
11717 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11718 | json_object_boolean_true_add( | |
11719 | json_addr, | |
11720 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11721 | ->type_json_name); | |
d62a17ae | 11722 | |
11723 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11724 | json_object_string_add(json_addr, | |
11725 | "overrideASNsInOutboundUpdates", | |
11726 | "ifAspathEqualRemoteAs"); | |
11727 | ||
11728 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11729 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11730 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11731 | json_object_boolean_true_add(json_addr, | |
11732 | "routerAlwaysNextHop"); | |
11733 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11734 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11735 | json_object_boolean_true_add( | |
11736 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11737 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11738 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11739 | json_object_boolean_true_add( | |
11740 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11741 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11742 | json_object_boolean_true_add( | |
11743 | json_addr, "unchangedMedPropogatedToNbr"); | |
11744 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11745 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11746 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11747 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11748 | PEER_FLAG_SEND_COMMUNITY) | |
11749 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11750 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11751 | json_object_string_add(json_addr, | |
11752 | "commAttriSentToNbr", | |
11753 | "extendedAndStandard"); | |
11754 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11755 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11756 | json_object_string_add(json_addr, | |
11757 | "commAttriSentToNbr", | |
11758 | "extended"); | |
11759 | else | |
11760 | json_object_string_add(json_addr, | |
11761 | "commAttriSentToNbr", | |
11762 | "standard"); | |
11763 | } | |
11764 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11765 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11766 | if (p->default_rmap[afi][safi].name) | |
11767 | json_object_string_add( | |
11768 | json_addr, "defaultRouteMap", | |
11769 | p->default_rmap[afi][safi].name); | |
11770 | ||
11771 | if (paf && PAF_SUBGRP(paf) | |
11772 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11773 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11774 | json_object_boolean_true_add(json_addr, | |
11775 | "defaultSent"); | |
11776 | else | |
11777 | json_object_boolean_true_add(json_addr, | |
11778 | "defaultNotSent"); | |
11779 | } | |
11780 | ||
dff8f48d | 11781 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11782 | if (is_evpn_enabled()) |
60466a63 QY |
11783 | json_object_boolean_true_add( |
11784 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11785 | } |
11786 | ||
d62a17ae | 11787 | if (filter->plist[FILTER_IN].name |
11788 | || filter->dlist[FILTER_IN].name | |
11789 | || filter->aslist[FILTER_IN].name | |
11790 | || filter->map[RMAP_IN].name) | |
11791 | json_object_boolean_true_add(json_addr, | |
11792 | "inboundPathPolicyConfig"); | |
11793 | if (filter->plist[FILTER_OUT].name | |
11794 | || filter->dlist[FILTER_OUT].name | |
11795 | || filter->aslist[FILTER_OUT].name | |
11796 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11797 | json_object_boolean_true_add( | |
11798 | json_addr, "outboundPathPolicyConfig"); | |
11799 | ||
11800 | /* prefix-list */ | |
11801 | if (filter->plist[FILTER_IN].name) | |
11802 | json_object_string_add(json_addr, | |
11803 | "incomingUpdatePrefixFilterList", | |
11804 | filter->plist[FILTER_IN].name); | |
11805 | if (filter->plist[FILTER_OUT].name) | |
11806 | json_object_string_add(json_addr, | |
11807 | "outgoingUpdatePrefixFilterList", | |
11808 | filter->plist[FILTER_OUT].name); | |
11809 | ||
11810 | /* distribute-list */ | |
11811 | if (filter->dlist[FILTER_IN].name) | |
11812 | json_object_string_add( | |
11813 | json_addr, "incomingUpdateNetworkFilterList", | |
11814 | filter->dlist[FILTER_IN].name); | |
11815 | if (filter->dlist[FILTER_OUT].name) | |
11816 | json_object_string_add( | |
11817 | json_addr, "outgoingUpdateNetworkFilterList", | |
11818 | filter->dlist[FILTER_OUT].name); | |
11819 | ||
11820 | /* filter-list. */ | |
11821 | if (filter->aslist[FILTER_IN].name) | |
11822 | json_object_string_add(json_addr, | |
11823 | "incomingUpdateAsPathFilterList", | |
11824 | filter->aslist[FILTER_IN].name); | |
11825 | if (filter->aslist[FILTER_OUT].name) | |
11826 | json_object_string_add(json_addr, | |
11827 | "outgoingUpdateAsPathFilterList", | |
11828 | filter->aslist[FILTER_OUT].name); | |
11829 | ||
11830 | /* route-map. */ | |
11831 | if (filter->map[RMAP_IN].name) | |
11832 | json_object_string_add( | |
11833 | json_addr, "routeMapForIncomingAdvertisements", | |
11834 | filter->map[RMAP_IN].name); | |
11835 | if (filter->map[RMAP_OUT].name) | |
11836 | json_object_string_add( | |
11837 | json_addr, "routeMapForOutgoingAdvertisements", | |
11838 | filter->map[RMAP_OUT].name); | |
11839 | ||
9dac9fc8 | 11840 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11841 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11842 | && !bgp_inbound_policy_exists(p, filter)) |
11843 | json_object_string_add( | |
11844 | json_addr, "inboundEbgpRequiresPolicy", | |
11845 | "Inbound updates discarded due to missing policy"); | |
11846 | ||
11847 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11848 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11849 | && (!bgp_outbound_policy_exists(p, filter))) |
11850 | json_object_string_add( | |
11851 | json_addr, "outboundEbgpRequiresPolicy", | |
11852 | "Outbound updates discarded due to missing policy"); | |
11853 | ||
d62a17ae | 11854 | /* unsuppress-map */ |
11855 | if (filter->usmap.name) | |
11856 | json_object_string_add(json_addr, | |
11857 | "selectiveUnsuppressRouteMap", | |
11858 | filter->usmap.name); | |
11859 | ||
fa36596c MK |
11860 | /* advertise-map */ |
11861 | if (filter->advmap.aname) { | |
11862 | json_advmap = json_object_new_object(); | |
11863 | json_object_string_add(json_advmap, "condition", | |
11864 | filter->advmap.condition | |
11865 | ? "EXIST" | |
11866 | : "NON_EXIST"); | |
11867 | json_object_string_add(json_advmap, "conditionMap", | |
11868 | filter->advmap.cname); | |
11869 | json_object_string_add(json_advmap, "advertiseMap", | |
11870 | filter->advmap.aname); | |
11871 | json_object_string_add(json_advmap, "advertiseStatus", | |
11872 | filter->advmap.update_type | |
11873 | == ADVERTISE | |
11874 | ? "Advertise" | |
11875 | : "Withdraw"); | |
11876 | json_object_object_add(json_addr, "advertiseMap", | |
11877 | json_advmap); | |
11878 | } | |
11879 | ||
d62a17ae | 11880 | /* Receive prefix count */ |
11881 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11882 | p->pcount[afi][safi]); | |
50e05855 AD |
11883 | if (paf && PAF_SUBGRP(paf)) |
11884 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11885 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11886 | |
fde246e8 DA |
11887 | /* Maximum prefix */ |
11888 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11889 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11890 | p->pmax_out[afi][safi]); | |
11891 | ||
d62a17ae | 11892 | /* Maximum prefix */ |
11893 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11894 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11895 | p->pmax[afi][safi]); | |
11896 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11897 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11898 | json_object_boolean_true_add( | |
11899 | json_addr, "prefixAllowedMaxWarning"); | |
11900 | json_object_int_add(json_addr, | |
11901 | "prefixAllowedWarningThresh", | |
11902 | p->pmax_threshold[afi][safi]); | |
11903 | if (p->pmax_restart[afi][safi]) | |
11904 | json_object_int_add( | |
11905 | json_addr, | |
11906 | "prefixAllowedRestartIntervalMsecs", | |
11907 | p->pmax_restart[afi][safi] * 60000); | |
11908 | } | |
2986cac2 | 11909 | json_object_object_add(json_neigh, |
36235319 | 11910 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11911 | json_addr); |
11912 | ||
11913 | } else { | |
11914 | filter = &p->filter[afi][safi]; | |
11915 | ||
11916 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 11917 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11918 | |
11919 | if (peer_group_active(p)) | |
11920 | vty_out(vty, " %s peer-group member\n", | |
11921 | p->group->name); | |
11922 | ||
11923 | paf = peer_af_find(p, afi, safi); | |
11924 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 11925 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 11926 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
11927 | vty_out(vty, " Packet Queue length %d\n", | |
11928 | bpacket_queue_virtual_length(paf)); | |
11929 | } else { | |
11930 | vty_out(vty, " Not part of any update group\n"); | |
11931 | } | |
11932 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11933 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11934 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11935 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11936 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11937 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11938 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11939 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11940 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11941 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11942 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11943 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11944 | ||
11945 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11946 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11947 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11948 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11949 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11950 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11951 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11952 | vty_out(vty, | |
11953 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11954 | ORF_TYPE_PREFIX); | |
11955 | bgp_show_peer_afi_orf_cap( | |
11956 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11957 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11958 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11959 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11960 | } | |
11961 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11962 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11963 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11964 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11965 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11966 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11967 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11968 | vty_out(vty, | |
11969 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11970 | ORF_TYPE_PREFIX_OLD); | |
11971 | bgp_show_peer_afi_orf_cap( | |
11972 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11973 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11974 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11975 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
11976 | } | |
11977 | ||
772270f3 QY |
11978 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11979 | p->host, afi, safi); | |
d62a17ae | 11980 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11981 | NULL, afi, orf_pfx_name, use_json); | |
11982 | ||
11983 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11984 | PEER_STATUS_ORF_PREFIX_SEND) | |
11985 | || orf_pfx_count) { | |
11986 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
11987 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11988 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11989 | vty_out(vty, " sent;"); | |
11990 | if (orf_pfx_count) | |
11991 | vty_out(vty, " received (%d entries)", | |
11992 | orf_pfx_count); | |
11993 | vty_out(vty, "\n"); | |
11994 | } | |
11995 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11996 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11997 | vty_out(vty, | |
11998 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
11999 | ||
12000 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12001 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12002 | vty_out(vty, " Route-Reflector Client\n"); | |
12003 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12004 | PEER_FLAG_RSERVER_CLIENT)) | |
12005 | vty_out(vty, " Route-Server Client\n"); | |
12006 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12007 | vty_out(vty, | |
12008 | " Inbound soft reconfiguration allowed\n"); | |
12009 | ||
12010 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12011 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12012 | vty_out(vty, | |
12013 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12014 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12015 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12016 | vty_out(vty, | |
12017 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12018 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12019 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12020 | vty_out(vty, | |
12021 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12022 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12023 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12024 | vty_out(vty, | |
12025 | " Private AS numbers removed in updates to this neighbor\n"); | |
12026 | ||
dcc68b5e MS |
12027 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12028 | vty_out(vty, " %s\n", | |
12029 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12030 | ->human_description); | |
d62a17ae | 12031 | |
12032 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12033 | vty_out(vty, | |
12034 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12035 | ||
12036 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12037 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12038 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12039 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12040 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12041 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12042 | vty_out(vty, | |
12043 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12044 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12045 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12046 | vty_out(vty, | |
12047 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12048 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12049 | vty_out(vty, | |
12050 | " MED is propagated unchanged to this neighbor\n"); | |
12051 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12052 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12053 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12054 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12055 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12056 | vty_out(vty, | |
12057 | " Community attribute sent to this neighbor"); | |
12058 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12059 | PEER_FLAG_SEND_COMMUNITY) | |
12060 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12061 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12062 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12063 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12064 | vty_out(vty, "(all)\n"); | |
12065 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12066 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12067 | vty_out(vty, "(large)\n"); | |
12068 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12069 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12070 | vty_out(vty, "(extended)\n"); | |
12071 | else | |
12072 | vty_out(vty, "(standard)\n"); | |
12073 | } | |
12074 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12075 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12076 | vty_out(vty, " Default information originate,"); | |
12077 | ||
12078 | if (p->default_rmap[afi][safi].name) | |
12079 | vty_out(vty, " default route-map %s%s,", | |
12080 | p->default_rmap[afi][safi].map ? "*" | |
12081 | : "", | |
12082 | p->default_rmap[afi][safi].name); | |
12083 | if (paf && PAF_SUBGRP(paf) | |
12084 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12085 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12086 | vty_out(vty, " default sent\n"); | |
12087 | else | |
12088 | vty_out(vty, " default not sent\n"); | |
12089 | } | |
12090 | ||
dff8f48d MK |
12091 | /* advertise-vni-all */ |
12092 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12093 | if (is_evpn_enabled()) |
dff8f48d MK |
12094 | vty_out(vty, " advertise-all-vni\n"); |
12095 | } | |
12096 | ||
d62a17ae | 12097 | if (filter->plist[FILTER_IN].name |
12098 | || filter->dlist[FILTER_IN].name | |
12099 | || filter->aslist[FILTER_IN].name | |
12100 | || filter->map[RMAP_IN].name) | |
12101 | vty_out(vty, " Inbound path policy configured\n"); | |
12102 | if (filter->plist[FILTER_OUT].name | |
12103 | || filter->dlist[FILTER_OUT].name | |
12104 | || filter->aslist[FILTER_OUT].name | |
12105 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12106 | vty_out(vty, " Outbound path policy configured\n"); | |
12107 | ||
12108 | /* prefix-list */ | |
12109 | if (filter->plist[FILTER_IN].name) | |
12110 | vty_out(vty, | |
12111 | " Incoming update prefix filter list is %s%s\n", | |
12112 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12113 | filter->plist[FILTER_IN].name); | |
12114 | if (filter->plist[FILTER_OUT].name) | |
12115 | vty_out(vty, | |
12116 | " Outgoing update prefix filter list is %s%s\n", | |
12117 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12118 | filter->plist[FILTER_OUT].name); | |
12119 | ||
12120 | /* distribute-list */ | |
12121 | if (filter->dlist[FILTER_IN].name) | |
12122 | vty_out(vty, | |
12123 | " Incoming update network filter list is %s%s\n", | |
12124 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12125 | filter->dlist[FILTER_IN].name); | |
12126 | if (filter->dlist[FILTER_OUT].name) | |
12127 | vty_out(vty, | |
12128 | " Outgoing update network filter list is %s%s\n", | |
12129 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12130 | filter->dlist[FILTER_OUT].name); | |
12131 | ||
12132 | /* filter-list. */ | |
12133 | if (filter->aslist[FILTER_IN].name) | |
12134 | vty_out(vty, | |
12135 | " Incoming update AS path filter list is %s%s\n", | |
12136 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12137 | filter->aslist[FILTER_IN].name); | |
12138 | if (filter->aslist[FILTER_OUT].name) | |
12139 | vty_out(vty, | |
12140 | " Outgoing update AS path filter list is %s%s\n", | |
12141 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12142 | filter->aslist[FILTER_OUT].name); | |
12143 | ||
12144 | /* route-map. */ | |
12145 | if (filter->map[RMAP_IN].name) | |
12146 | vty_out(vty, | |
12147 | " Route map for incoming advertisements is %s%s\n", | |
12148 | filter->map[RMAP_IN].map ? "*" : "", | |
12149 | filter->map[RMAP_IN].name); | |
12150 | if (filter->map[RMAP_OUT].name) | |
12151 | vty_out(vty, | |
12152 | " Route map for outgoing advertisements is %s%s\n", | |
12153 | filter->map[RMAP_OUT].map ? "*" : "", | |
12154 | filter->map[RMAP_OUT].name); | |
12155 | ||
9dac9fc8 | 12156 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12157 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12158 | && !bgp_inbound_policy_exists(p, filter)) |
12159 | vty_out(vty, | |
12160 | " Inbound updates discarded due to missing policy\n"); | |
12161 | ||
12162 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12163 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12164 | && !bgp_outbound_policy_exists(p, filter)) |
12165 | vty_out(vty, | |
12166 | " Outbound updates discarded due to missing policy\n"); | |
12167 | ||
d62a17ae | 12168 | /* unsuppress-map */ |
12169 | if (filter->usmap.name) | |
12170 | vty_out(vty, | |
12171 | " Route map for selective unsuppress is %s%s\n", | |
12172 | filter->usmap.map ? "*" : "", | |
12173 | filter->usmap.name); | |
12174 | ||
7f7940e6 MK |
12175 | /* advertise-map */ |
12176 | if (filter->advmap.aname && filter->advmap.cname) | |
12177 | vty_out(vty, | |
12178 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12179 | filter->advmap.condition ? "EXIST" | |
12180 | : "NON_EXIST", | |
12181 | filter->advmap.cmap ? "*" : "", | |
12182 | filter->advmap.cname, | |
12183 | filter->advmap.amap ? "*" : "", | |
12184 | filter->advmap.aname, | |
fa36596c | 12185 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12186 | ? "Advertise" |
12187 | : "Withdraw"); | |
7f7940e6 | 12188 | |
d62a17ae | 12189 | /* Receive prefix count */ |
6cde4b45 | 12190 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12191 | p->pcount[afi][safi]); |
d62a17ae | 12192 | |
fde246e8 DA |
12193 | /* maximum-prefix-out */ |
12194 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12195 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12196 | vty_out(vty, | |
6cde4b45 | 12197 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12198 | p->pmax_out[afi][safi]); |
12199 | ||
d62a17ae | 12200 | /* Maximum prefix */ |
12201 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12202 | vty_out(vty, |
6cde4b45 | 12203 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12204 | p->pmax[afi][safi], |
12205 | CHECK_FLAG(p->af_flags[afi][safi], | |
12206 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12207 | ? " (warning-only)" | |
12208 | : ""); | |
12209 | vty_out(vty, " Threshold for warning message %d%%", | |
12210 | p->pmax_threshold[afi][safi]); | |
12211 | if (p->pmax_restart[afi][safi]) | |
12212 | vty_out(vty, ", restart interval %d min", | |
12213 | p->pmax_restart[afi][safi]); | |
12214 | vty_out(vty, "\n"); | |
12215 | } | |
12216 | ||
12217 | vty_out(vty, "\n"); | |
12218 | } | |
12219 | } | |
12220 | ||
9f049418 | 12221 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12222 | json_object *json) |
718e3744 | 12223 | { |
d62a17ae | 12224 | struct bgp *bgp; |
12225 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12226 | char timebuf[BGP_UPTIME_LEN]; | |
12227 | char dn_flag[2]; | |
d62a17ae | 12228 | afi_t afi; |
12229 | safi_t safi; | |
d7c0a89a QY |
12230 | uint16_t i; |
12231 | uint8_t *msg; | |
d62a17ae | 12232 | json_object *json_neigh = NULL; |
12233 | time_t epoch_tbuf; | |
4ab46701 | 12234 | uint32_t sync_tcp_mss; |
718e3744 | 12235 | |
d62a17ae | 12236 | bgp = p->bgp; |
12237 | ||
12238 | if (use_json) | |
12239 | json_neigh = json_object_new_object(); | |
12240 | ||
12241 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12242 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12243 | dn_flag[0] = '*'; | |
12244 | ||
12245 | if (!use_json) { | |
12246 | if (p->conf_if) /* Configured interface name. */ | |
12247 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12248 | BGP_PEER_SU_UNSPEC(p) | |
12249 | ? "None" | |
12250 | : sockunion2str(&p->su, buf, | |
12251 | SU_ADDRSTRLEN)); | |
12252 | else /* Configured IP address. */ | |
12253 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12254 | p->host); | |
12255 | } | |
12256 | ||
12257 | if (use_json) { | |
12258 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12259 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12260 | "none"); | |
12261 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12262 | json_object_string_add( | |
12263 | json_neigh, "bgpNeighborAddr", | |
12264 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12265 | ||
12266 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12267 | ||
12268 | if (p->change_local_as) | |
12269 | json_object_int_add(json_neigh, "localAs", | |
12270 | p->change_local_as); | |
12271 | else | |
12272 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12273 | ||
12274 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12275 | json_object_boolean_true_add(json_neigh, | |
12276 | "localAsNoPrepend"); | |
12277 | ||
12278 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12279 | json_object_boolean_true_add(json_neigh, | |
12280 | "localAsReplaceAs"); | |
12281 | } else { | |
12282 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12283 | || (p->as_type == AS_INTERNAL)) | |
12284 | vty_out(vty, "remote AS %u, ", p->as); | |
12285 | else | |
12286 | vty_out(vty, "remote AS Unspecified, "); | |
12287 | vty_out(vty, "local AS %u%s%s, ", | |
12288 | p->change_local_as ? p->change_local_as : p->local_as, | |
12289 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12290 | ? " no-prepend" | |
12291 | : "", | |
12292 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12293 | ? " replace-as" | |
12294 | : ""); | |
12295 | } | |
faa16034 DS |
12296 | /* peer type internal or confed-internal */ |
12297 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12298 | if (use_json) { |
12299 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12300 | json_object_boolean_true_add( | |
12301 | json_neigh, "nbrConfedInternalLink"); | |
12302 | else | |
12303 | json_object_boolean_true_add(json_neigh, | |
12304 | "nbrInternalLink"); | |
12305 | } else { | |
12306 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12307 | vty_out(vty, "confed-internal link\n"); | |
12308 | else | |
12309 | vty_out(vty, "internal link\n"); | |
12310 | } | |
faa16034 DS |
12311 | /* peer type external or confed-external */ |
12312 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12313 | if (use_json) { |
12314 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12315 | json_object_boolean_true_add( | |
12316 | json_neigh, "nbrConfedExternalLink"); | |
12317 | else | |
12318 | json_object_boolean_true_add(json_neigh, | |
12319 | "nbrExternalLink"); | |
12320 | } else { | |
12321 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12322 | vty_out(vty, "confed-external link\n"); | |
12323 | else | |
12324 | vty_out(vty, "external link\n"); | |
12325 | } | |
faa16034 DS |
12326 | } else { |
12327 | if (use_json) | |
12328 | json_object_boolean_true_add(json_neigh, | |
12329 | "nbrUnspecifiedLink"); | |
12330 | else | |
12331 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12332 | } |
12333 | ||
12334 | /* Description. */ | |
12335 | if (p->desc) { | |
12336 | if (use_json) | |
12337 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12338 | else | |
12339 | vty_out(vty, " Description: %s\n", p->desc); | |
12340 | } | |
12341 | ||
12342 | if (p->hostname) { | |
12343 | if (use_json) { | |
12344 | if (p->hostname) | |
12345 | json_object_string_add(json_neigh, "hostname", | |
12346 | p->hostname); | |
12347 | ||
12348 | if (p->domainname) | |
12349 | json_object_string_add(json_neigh, "domainname", | |
12350 | p->domainname); | |
12351 | } else { | |
12352 | if (p->domainname && (p->domainname[0] != '\0')) | |
12353 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12354 | p->domainname); | |
12355 | else | |
12356 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12357 | } | |
12358 | } | |
12359 | ||
12360 | /* Peer-group */ | |
12361 | if (p->group) { | |
12362 | if (use_json) { | |
12363 | json_object_string_add(json_neigh, "peerGroup", | |
12364 | p->group->name); | |
12365 | ||
12366 | if (dn_flag[0]) { | |
12367 | struct prefix prefix, *range = NULL; | |
12368 | ||
0154d8ce DS |
12369 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12370 | range = peer_group_lookup_dynamic_neighbor_range( | |
12371 | p->group, &prefix); | |
d62a17ae | 12372 | |
12373 | if (range) { | |
67d7e256 | 12374 | json_object_string_addf( |
d62a17ae | 12375 | json_neigh, |
67d7e256 DA |
12376 | "peerSubnetRangeGroup", "%pFX", |
12377 | range); | |
d62a17ae | 12378 | } |
12379 | } | |
12380 | } else { | |
12381 | vty_out(vty, | |
12382 | " Member of peer-group %s for session parameters\n", | |
12383 | p->group->name); | |
12384 | ||
12385 | if (dn_flag[0]) { | |
12386 | struct prefix prefix, *range = NULL; | |
12387 | ||
0154d8ce DS |
12388 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12389 | range = peer_group_lookup_dynamic_neighbor_range( | |
12390 | p->group, &prefix); | |
d62a17ae | 12391 | |
12392 | if (range) { | |
d62a17ae | 12393 | vty_out(vty, |
1b78780b DL |
12394 | " Belongs to the subnet range group: %pFX\n", |
12395 | range); | |
d62a17ae | 12396 | } |
12397 | } | |
12398 | } | |
12399 | } | |
12400 | ||
12401 | if (use_json) { | |
12402 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12403 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12404 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12405 | json_object_boolean_true_add(json_neigh, |
12406 | "adminShutDown"); | |
12407 | ||
12408 | /* BGP Version. */ | |
12409 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
12410 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
12411 | &p->remote_id); | |
12412 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
12413 | &bgp->router_id); | |
d62a17ae | 12414 | |
12415 | /* Confederation */ | |
12416 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12417 | && bgp_confederation_peers_check(bgp, p->as)) | |
12418 | json_object_boolean_true_add(json_neigh, | |
12419 | "nbrCommonAdmin"); | |
12420 | ||
12421 | /* Status. */ | |
12422 | json_object_string_add( | |
12423 | json_neigh, "bgpState", | |
12424 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12425 | ||
feb17238 | 12426 | if (peer_established(p)) { |
d62a17ae | 12427 | time_t uptime; |
d62a17ae | 12428 | |
12429 | uptime = bgp_clock(); | |
12430 | uptime -= p->uptime; | |
d62a17ae | 12431 | epoch_tbuf = time(NULL) - uptime; |
12432 | ||
d3c7efed DS |
12433 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12434 | uptime * 1000); | |
d62a17ae | 12435 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12436 | peer_uptime(p->uptime, timebuf, | |
12437 | BGP_UPTIME_LEN, 0, | |
12438 | NULL)); | |
12439 | json_object_int_add(json_neigh, | |
12440 | "bgpTimerUpEstablishedEpoch", | |
12441 | epoch_tbuf); | |
12442 | } | |
12443 | ||
12444 | else if (p->status == Active) { | |
12445 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12446 | json_object_string_add(json_neigh, "bgpStateIs", | |
12447 | "passive"); | |
12448 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12449 | json_object_string_add(json_neigh, "bgpStateIs", | |
12450 | "passiveNSF"); | |
12451 | } | |
12452 | ||
12453 | /* read timer */ | |
12454 | time_t uptime; | |
a2700b50 | 12455 | struct tm tm; |
d62a17ae | 12456 | |
12457 | uptime = bgp_clock(); | |
12458 | uptime -= p->readtime; | |
a2700b50 MS |
12459 | gmtime_r(&uptime, &tm); |
12460 | ||
d62a17ae | 12461 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12462 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12463 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12464 | |
12465 | uptime = bgp_clock(); | |
12466 | uptime -= p->last_write; | |
a2700b50 MS |
12467 | gmtime_r(&uptime, &tm); |
12468 | ||
d62a17ae | 12469 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12470 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12471 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12472 | |
12473 | uptime = bgp_clock(); | |
12474 | uptime -= p->update_time; | |
a2700b50 MS |
12475 | gmtime_r(&uptime, &tm); |
12476 | ||
d62a17ae | 12477 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12478 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12479 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12480 | |
12481 | /* Configured timer values. */ | |
12482 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12483 | p->v_holdtime * 1000); | |
12484 | json_object_int_add(json_neigh, | |
12485 | "bgpTimerKeepAliveIntervalMsecs", | |
12486 | p->v_keepalive * 1000); | |
d43114f3 DS |
12487 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
12488 | json_object_int_add(json_neigh, | |
12489 | "bgpTimerDelayOpenTimeMsecs", | |
12490 | p->v_delayopen * 1000); | |
12491 | } | |
12492 | ||
4ab46701 AR |
12493 | /* Configured and Synced tcp-mss value for peer */ |
12494 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12495 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12496 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
12497 | p->tcp_mss); | |
12498 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
12499 | sync_tcp_mss); | |
12500 | } | |
12501 | ||
b90a8e13 | 12502 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12503 | json_object_int_add(json_neigh, |
12504 | "bgpTimerConfiguredHoldTimeMsecs", | |
12505 | p->holdtime * 1000); | |
12506 | json_object_int_add( | |
12507 | json_neigh, | |
12508 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12509 | p->keepalive * 1000); | |
5d5393b9 DL |
12510 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12511 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12512 | json_object_int_add(json_neigh, |
12513 | "bgpTimerConfiguredHoldTimeMsecs", | |
12514 | bgp->default_holdtime); | |
12515 | json_object_int_add( | |
12516 | json_neigh, | |
12517 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12518 | bgp->default_keepalive); | |
d62a17ae | 12519 | } |
d08c0c80 DA |
12520 | |
12521 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
12522 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
12523 | json_object_boolean_true_add( | |
12524 | json_neigh, "extendedOptionalParametersLength"); | |
12525 | else | |
12526 | json_object_boolean_false_add( | |
12527 | json_neigh, "extendedOptionalParametersLength"); | |
d62a17ae | 12528 | } else { |
12529 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12530 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12531 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12532 | vty_out(vty, " Administratively shut down\n"); |
12533 | ||
12534 | /* BGP Version. */ | |
12535 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12536 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12537 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12538 | vty_out(vty, ", local router ID %s\n", |
12539 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12540 | sizeof(buf1))); | |
d62a17ae | 12541 | |
12542 | /* Confederation */ | |
12543 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12544 | && bgp_confederation_peers_check(bgp, p->as)) | |
12545 | vty_out(vty, | |
12546 | " Neighbor under common administration\n"); | |
12547 | ||
12548 | /* Status. */ | |
12549 | vty_out(vty, " BGP state = %s", | |
12550 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12551 | ||
feb17238 | 12552 | if (peer_established(p)) |
d62a17ae | 12553 | vty_out(vty, ", up for %8s", |
12554 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12555 | 0, NULL)); | |
12556 | ||
12557 | else if (p->status == Active) { | |
12558 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12559 | vty_out(vty, " (passive)"); | |
12560 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12561 | vty_out(vty, " (NSF passive)"); | |
12562 | } | |
12563 | vty_out(vty, "\n"); | |
12564 | ||
12565 | /* read timer */ | |
12566 | vty_out(vty, " Last read %s", | |
12567 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12568 | NULL)); | |
12569 | vty_out(vty, ", Last write %s\n", | |
12570 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12571 | NULL)); | |
12572 | ||
12573 | /* Configured timer values. */ | |
12574 | vty_out(vty, | |
12575 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12576 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12577 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12578 | vty_out(vty, " Configured hold time is %d", |
12579 | p->holdtime); | |
12580 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12581 | p->keepalive); | |
5d5393b9 DL |
12582 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12583 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12584 | vty_out(vty, " Configured hold time is %d", |
12585 | bgp->default_holdtime); | |
12586 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12587 | bgp->default_keepalive); | |
d62a17ae | 12588 | } |
d43114f3 DS |
12589 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
12590 | vty_out(vty, | |
12591 | " Configured DelayOpenTime is %d seconds\n", | |
12592 | p->delayopen); | |
4ab46701 AR |
12593 | |
12594 | /* Configured and synced tcp-mss value for peer */ | |
12595 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12596 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12597 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
12598 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
12599 | } | |
d08c0c80 DA |
12600 | |
12601 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
12602 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
12603 | vty_out(vty, | |
12604 | " Extended Optional Parameters Length is enabled\n"); | |
d62a17ae | 12605 | } |
12606 | /* Capability. */ | |
10711563 DA |
12607 | if (peer_established(p) && |
12608 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
12609 | if (use_json) { | |
12610 | json_object *json_cap = NULL; | |
d62a17ae | 12611 | |
10711563 | 12612 | json_cap = json_object_new_object(); |
d62a17ae | 12613 | |
10711563 DA |
12614 | /* AS4 */ |
12615 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
12616 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12617 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
12618 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
ef56aee4 | 12619 | json_object_string_add( |
10711563 | 12620 | json_cap, "4byteAs", |
ef56aee4 | 12621 | "advertisedAndReceived"); |
10711563 DA |
12622 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) |
12623 | json_object_string_add(json_cap, | |
12624 | "4byteAs", | |
12625 | "advertised"); | |
12626 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
12627 | json_object_string_add(json_cap, | |
12628 | "4byteAs", | |
12629 | "received"); | |
12630 | } | |
ef56aee4 | 12631 | |
10711563 DA |
12632 | /* Extended Message Support */ |
12633 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
12634 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12635 | json_object_string_add(json_cap, | |
12636 | "extendedMessage", | |
12637 | "advertisedAndReceived"); | |
12638 | else if (CHECK_FLAG(p->cap, | |
12639 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12640 | json_object_string_add(json_cap, | |
12641 | "extendedMessage", | |
12642 | "advertised"); | |
12643 | else if (CHECK_FLAG(p->cap, | |
12644 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12645 | json_object_string_add(json_cap, | |
12646 | "extendedMessage", | |
12647 | "received"); | |
ef56aee4 | 12648 | |
10711563 DA |
12649 | /* AddPath */ |
12650 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
12651 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
12652 | json_object *json_add = NULL; | |
12653 | const char *print_store; | |
d62a17ae | 12654 | |
10711563 | 12655 | json_add = json_object_new_object(); |
d62a17ae | 12656 | |
10711563 DA |
12657 | FOREACH_AFI_SAFI (afi, safi) { |
12658 | json_object *json_sub = NULL; | |
12659 | json_sub = json_object_new_object(); | |
12660 | print_store = get_afi_safi_str( | |
12661 | afi, safi, true); | |
d62a17ae | 12662 | |
10711563 DA |
12663 | if (CHECK_FLAG( |
12664 | p->af_cap[afi][safi], | |
12665 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
12666 | CHECK_FLAG( | |
12667 | p->af_cap[afi][safi], | |
12668 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
05c7a1cc QY |
12669 | if (CHECK_FLAG( |
12670 | p->af_cap[afi] | |
12671 | [safi], | |
10711563 DA |
12672 | PEER_CAP_ADDPATH_AF_TX_ADV) && |
12673 | CHECK_FLAG( | |
05c7a1cc QY |
12674 | p->af_cap[afi] |
12675 | [safi], | |
10711563 DA |
12676 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12677 | json_object_boolean_true_add( | |
12678 | json_sub, | |
12679 | "txAdvertisedAndReceived"); | |
12680 | else if ( | |
12681 | CHECK_FLAG( | |
12682 | p->af_cap[afi] | |
12683 | [safi], | |
12684 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12685 | json_object_boolean_true_add( | |
12686 | json_sub, | |
12687 | "txAdvertised"); | |
12688 | else if ( | |
12689 | CHECK_FLAG( | |
12690 | p->af_cap[afi] | |
12691 | [safi], | |
12692 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12693 | json_object_boolean_true_add( | |
12694 | json_sub, | |
12695 | "txReceived"); | |
12696 | } | |
d62a17ae | 12697 | |
10711563 DA |
12698 | if (CHECK_FLAG( |
12699 | p->af_cap[afi][safi], | |
12700 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
12701 | CHECK_FLAG( | |
12702 | p->af_cap[afi][safi], | |
12703 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
05c7a1cc QY |
12704 | if (CHECK_FLAG( |
12705 | p->af_cap[afi] | |
12706 | [safi], | |
10711563 DA |
12707 | PEER_CAP_ADDPATH_AF_RX_ADV) && |
12708 | CHECK_FLAG( | |
12709 | p->af_cap[afi] | |
12710 | [safi], | |
12711 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12712 | json_object_boolean_true_add( | |
12713 | json_sub, | |
12714 | "rxAdvertisedAndReceived"); | |
12715 | else if ( | |
12716 | CHECK_FLAG( | |
12717 | p->af_cap[afi] | |
12718 | [safi], | |
12719 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12720 | json_object_boolean_true_add( | |
12721 | json_sub, | |
12722 | "rxAdvertised"); | |
12723 | else if ( | |
12724 | CHECK_FLAG( | |
12725 | p->af_cap[afi] | |
12726 | [safi], | |
12727 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12728 | json_object_boolean_true_add( | |
12729 | json_sub, | |
12730 | "rxReceived"); | |
05c7a1cc QY |
12731 | } |
12732 | ||
10711563 DA |
12733 | if (CHECK_FLAG( |
12734 | p->af_cap[afi][safi], | |
12735 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
12736 | CHECK_FLAG( | |
12737 | p->af_cap[afi][safi], | |
12738 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
12739 | CHECK_FLAG( | |
12740 | p->af_cap[afi][safi], | |
12741 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
12742 | CHECK_FLAG( | |
12743 | p->af_cap[afi][safi], | |
12744 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12745 | json_object_object_add( | |
12746 | json_add, print_store, | |
12747 | json_sub); | |
12748 | else | |
12749 | json_object_free(json_sub); | |
d62a17ae | 12750 | } |
12751 | ||
10711563 DA |
12752 | json_object_object_add(json_cap, "addPath", |
12753 | json_add); | |
12754 | } | |
d62a17ae | 12755 | |
10711563 DA |
12756 | /* Dynamic */ |
12757 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
12758 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
12759 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
12760 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
12761 | json_object_string_add( | |
12762 | json_cap, "dynamic", | |
12763 | "advertisedAndReceived"); | |
12764 | else if (CHECK_FLAG(p->cap, | |
12765 | PEER_CAP_DYNAMIC_ADV)) | |
12766 | json_object_string_add(json_cap, | |
12767 | "dynamic", | |
12768 | "advertised"); | |
12769 | else if (CHECK_FLAG(p->cap, | |
12770 | PEER_CAP_DYNAMIC_RCV)) | |
12771 | json_object_string_add(json_cap, | |
12772 | "dynamic", | |
12773 | "received"); | |
12774 | } | |
d62a17ae | 12775 | |
10711563 DA |
12776 | /* Extended nexthop */ |
12777 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
12778 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12779 | json_object *json_nxt = NULL; | |
12780 | const char *print_store; | |
d62a17ae | 12781 | |
d62a17ae | 12782 | |
10711563 DA |
12783 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && |
12784 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
12785 | json_object_string_add( | |
12786 | json_cap, "extendedNexthop", | |
12787 | "advertisedAndReceived"); | |
12788 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
12789 | json_object_string_add( | |
12790 | json_cap, "extendedNexthop", | |
12791 | "advertised"); | |
12792 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
12793 | json_object_string_add( | |
12794 | json_cap, "extendedNexthop", | |
12795 | "received"); | |
d62a17ae | 12796 | |
10711563 DA |
12797 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
12798 | json_nxt = json_object_new_object(); | |
d62a17ae | 12799 | |
10711563 DA |
12800 | for (safi = SAFI_UNICAST; |
12801 | safi < SAFI_MAX; safi++) { | |
12802 | if (CHECK_FLAG( | |
12803 | p->af_cap[AFI_IP] | |
12804 | [safi], | |
12805 | PEER_CAP_ENHE_AF_RCV)) { | |
12806 | print_store = | |
12807 | get_afi_safi_str( | |
d62a17ae | 12808 | AFI_IP, |
10711563 DA |
12809 | safi, |
12810 | true); | |
12811 | json_object_string_add( | |
12812 | json_nxt, | |
12813 | print_store, | |
12814 | "recieved"); /* misspelled for compatibility */ | |
d62a17ae | 12815 | } |
d62a17ae | 12816 | } |
10711563 DA |
12817 | json_object_object_add( |
12818 | json_cap, | |
12819 | "extendedNexthopFamililesByPeer", | |
12820 | json_nxt); | |
d62a17ae | 12821 | } |
10711563 | 12822 | } |
d62a17ae | 12823 | |
10711563 DA |
12824 | /* Long-lived Graceful Restart */ |
12825 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
12826 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
12827 | json_object *json_llgr = NULL; | |
12828 | const char *afi_safi_str; | |
8606be87 | 12829 | |
10711563 DA |
12830 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && |
12831 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
12832 | json_object_string_add( | |
12833 | json_cap, | |
12834 | "longLivedGracefulRestart", | |
12835 | "advertisedAndReceived"); | |
12836 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
12837 | json_object_string_add( | |
12838 | json_cap, | |
12839 | "longLivedGracefulRestart", | |
12840 | "advertised"); | |
12841 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
12842 | json_object_string_add( | |
12843 | json_cap, | |
12844 | "longLivedGracefulRestart", | |
12845 | "received"); | |
8606be87 | 12846 | |
10711563 DA |
12847 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
12848 | json_llgr = json_object_new_object(); | |
8606be87 | 12849 | |
10711563 DA |
12850 | FOREACH_AFI_SAFI (afi, safi) { |
12851 | if (CHECK_FLAG( | |
12852 | p->af_cap[afi] | |
12853 | [safi], | |
12854 | PEER_CAP_ENHE_AF_RCV)) { | |
12855 | afi_safi_str = | |
12856 | get_afi_safi_str( | |
8606be87 DA |
12857 | afi, |
12858 | safi, | |
12859 | true); | |
10711563 DA |
12860 | json_object_string_add( |
12861 | json_llgr, | |
12862 | afi_safi_str, | |
12863 | "received"); | |
8606be87 | 12864 | } |
8606be87 | 12865 | } |
10711563 DA |
12866 | json_object_object_add( |
12867 | json_cap, | |
12868 | "longLivedGracefulRestartByPeer", | |
12869 | json_llgr); | |
8606be87 | 12870 | } |
10711563 | 12871 | } |
8606be87 | 12872 | |
10711563 DA |
12873 | /* Route Refresh */ |
12874 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
12875 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
12876 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
12877 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
12878 | (CHECK_FLAG(p->cap, | |
12879 | PEER_CAP_REFRESH_NEW_RCV) || | |
12880 | CHECK_FLAG(p->cap, | |
12881 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12882 | if (CHECK_FLAG( | |
12883 | p->cap, | |
12884 | PEER_CAP_REFRESH_OLD_RCV) && | |
12885 | CHECK_FLAG( | |
12886 | p->cap, | |
12887 | PEER_CAP_REFRESH_NEW_RCV)) | |
12888 | json_object_string_add( | |
12889 | json_cap, | |
12890 | "routeRefresh", | |
12891 | "advertisedAndReceivedOldNew"); | |
12892 | else { | |
d62a17ae | 12893 | if (CHECK_FLAG( |
12894 | p->cap, | |
10711563 | 12895 | PEER_CAP_REFRESH_OLD_RCV)) |
d62a17ae | 12896 | json_object_string_add( |
12897 | json_cap, | |
12898 | "routeRefresh", | |
10711563 DA |
12899 | "advertisedAndReceivedOld"); |
12900 | else | |
12901 | json_object_string_add( | |
12902 | json_cap, | |
12903 | "routeRefresh", | |
12904 | "advertisedAndReceivedNew"); | |
d62a17ae | 12905 | } |
10711563 DA |
12906 | } else if (CHECK_FLAG(p->cap, |
12907 | PEER_CAP_REFRESH_ADV)) | |
12908 | json_object_string_add(json_cap, | |
12909 | "routeRefresh", | |
12910 | "advertised"); | |
12911 | else if (CHECK_FLAG(p->cap, | |
12912 | PEER_CAP_REFRESH_NEW_RCV) || | |
12913 | CHECK_FLAG(p->cap, | |
12914 | PEER_CAP_REFRESH_OLD_RCV)) | |
12915 | json_object_string_add(json_cap, | |
12916 | "routeRefresh", | |
12917 | "received"); | |
12918 | } | |
d62a17ae | 12919 | |
10711563 DA |
12920 | /* Enhanced Route Refresh */ |
12921 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
12922 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
12923 | if (CHECK_FLAG(p->cap, | |
12924 | PEER_CAP_ENHANCED_RR_ADV) && | |
12925 | CHECK_FLAG(p->cap, | |
12926 | PEER_CAP_ENHANCED_RR_RCV)) | |
d77114b7 | 12927 | json_object_string_add( |
10711563 DA |
12928 | json_cap, |
12929 | "enhancedRouteRefresh", | |
12930 | "advertisedAndReceived"); | |
12931 | else if (CHECK_FLAG(p->cap, | |
12932 | PEER_CAP_ENHANCED_RR_ADV)) | |
d77114b7 | 12933 | json_object_string_add( |
10711563 DA |
12934 | json_cap, |
12935 | "enhancedRouteRefresh", | |
12936 | "advertised"); | |
12937 | else if (CHECK_FLAG(p->cap, | |
9af52ccf | 12938 | PEER_CAP_ENHANCED_RR_RCV)) |
10711563 DA |
12939 | json_object_string_add( |
12940 | json_cap, | |
12941 | "enhancedRouteRefresh", | |
12942 | "received"); | |
12943 | } | |
d77114b7 | 12944 | |
10711563 DA |
12945 | /* Multiprotocol Extensions */ |
12946 | json_object *json_multi = NULL; | |
d77114b7 | 12947 | |
10711563 | 12948 | json_multi = json_object_new_object(); |
d77114b7 | 12949 | |
10711563 DA |
12950 | FOREACH_AFI_SAFI (afi, safi) { |
12951 | if (p->afc_adv[afi][safi] || | |
12952 | p->afc_recv[afi][safi]) { | |
12953 | json_object *json_exten = NULL; | |
12954 | json_exten = json_object_new_object(); | |
12955 | ||
12956 | if (p->afc_adv[afi][safi] && | |
12957 | p->afc_recv[afi][safi]) | |
12958 | json_object_boolean_true_add( | |
12959 | json_exten, | |
9af52ccf | 12960 | "advertisedAndReceived"); |
10711563 DA |
12961 | else if (p->afc_adv[afi][safi]) |
12962 | json_object_boolean_true_add( | |
12963 | json_exten, | |
9af52ccf | 12964 | "advertised"); |
10711563 DA |
12965 | else if (p->afc_recv[afi][safi]) |
12966 | json_object_boolean_true_add( | |
12967 | json_exten, "received"); | |
9af52ccf | 12968 | |
10711563 DA |
12969 | json_object_object_add( |
12970 | json_multi, | |
12971 | get_afi_safi_str(afi, safi, | |
12972 | true), | |
12973 | json_exten); | |
12974 | } | |
12975 | } | |
12976 | json_object_object_add(json_cap, | |
12977 | "multiprotocolExtensions", | |
12978 | json_multi); | |
d62a17ae | 12979 | |
10711563 DA |
12980 | /* Hostname capabilities */ |
12981 | json_object *json_hname = NULL; | |
d62a17ae | 12982 | |
10711563 | 12983 | json_hname = json_object_new_object(); |
d62a17ae | 12984 | |
10711563 DA |
12985 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
12986 | json_object_string_add( | |
12987 | json_hname, "advHostName", | |
12988 | bgp->peer_self->hostname | |
12989 | ? bgp->peer_self->hostname | |
12990 | : "n/a"); | |
12991 | json_object_string_add( | |
12992 | json_hname, "advDomainName", | |
12993 | bgp->peer_self->domainname | |
12994 | ? bgp->peer_self->domainname | |
12995 | : "n/a"); | |
12996 | } | |
d77114b7 | 12997 | |
d77114b7 | 12998 | |
10711563 DA |
12999 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13000 | json_object_string_add( | |
13001 | json_hname, "rcvHostName", | |
13002 | p->hostname ? p->hostname : "n/a"); | |
13003 | json_object_string_add( | |
13004 | json_hname, "rcvDomainName", | |
13005 | p->domainname ? p->domainname : "n/a"); | |
13006 | } | |
d77114b7 | 13007 | |
10711563 DA |
13008 | json_object_object_add(json_cap, "hostName", |
13009 | json_hname); | |
d77114b7 | 13010 | |
10711563 DA |
13011 | /* Gracefull Restart */ |
13012 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
13013 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13014 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13015 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
d77114b7 | 13016 | json_object_string_add( |
10711563 DA |
13017 | json_cap, "gracefulRestart", |
13018 | "advertisedAndReceived"); | |
13019 | else if (CHECK_FLAG(p->cap, | |
13020 | PEER_CAP_RESTART_ADV)) | |
d77114b7 | 13021 | json_object_string_add( |
10711563 DA |
13022 | json_cap, |
13023 | "gracefulRestartCapability", | |
13024 | "advertised"); | |
13025 | else if (CHECK_FLAG(p->cap, | |
13026 | PEER_CAP_RESTART_RCV)) | |
13027 | json_object_string_add( | |
13028 | json_cap, | |
13029 | "gracefulRestartCapability", | |
13030 | "received"); | |
d77114b7 | 13031 | |
10711563 DA |
13032 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13033 | int restart_af_count = 0; | |
13034 | json_object *json_restart = NULL; | |
13035 | json_restart = json_object_new_object(); | |
d62a17ae | 13036 | |
10711563 DA |
13037 | json_object_int_add( |
13038 | json_cap, | |
13039 | "gracefulRestartRemoteTimerMsecs", | |
13040 | p->v_gr_restart * 1000); | |
d62a17ae | 13041 | |
10711563 | 13042 | FOREACH_AFI_SAFI (afi, safi) { |
05c7a1cc QY |
13043 | if (CHECK_FLAG( |
13044 | p->af_cap[afi] | |
13045 | [safi], | |
10711563 DA |
13046 | PEER_CAP_RESTART_AF_RCV)) { |
13047 | json_object *json_sub = | |
13048 | NULL; | |
13049 | json_sub = | |
13050 | json_object_new_object(); | |
d62a17ae | 13051 | |
05c7a1cc QY |
13052 | if (CHECK_FLAG( |
13053 | p->af_cap | |
13054 | [afi] | |
13055 | [safi], | |
10711563 DA |
13056 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13057 | json_object_boolean_true_add( | |
13058 | json_sub, | |
13059 | "preserved"); | |
13060 | restart_af_count++; | |
d62a17ae | 13061 | json_object_object_add( |
10711563 DA |
13062 | json_restart, |
13063 | get_afi_safi_str( | |
13064 | afi, | |
13065 | safi, | |
13066 | true), | |
13067 | json_sub); | |
d62a17ae | 13068 | } |
d62a17ae | 13069 | } |
10711563 DA |
13070 | if (!restart_af_count) { |
13071 | json_object_string_add( | |
13072 | json_cap, | |
13073 | "addressFamiliesByPeer", | |
13074 | "none"); | |
13075 | json_object_free(json_restart); | |
13076 | } else | |
13077 | json_object_object_add( | |
13078 | json_cap, | |
13079 | "addressFamiliesByPeer", | |
13080 | json_restart); | |
d62a17ae | 13081 | } |
10711563 DA |
13082 | } |
13083 | json_object_object_add( | |
13084 | json_neigh, "neighborCapabilities", json_cap); | |
13085 | } else { | |
13086 | vty_out(vty, " Neighbor capabilities:\n"); | |
13087 | ||
13088 | /* AS4 */ | |
13089 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13090 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13091 | vty_out(vty, " 4 Byte AS:"); | |
13092 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13093 | vty_out(vty, " advertised"); | |
13094 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13095 | vty_out(vty, " %sreceived", | |
13096 | CHECK_FLAG(p->cap, | |
13097 | PEER_CAP_AS4_ADV) | |
13098 | ? "and " | |
13099 | : ""); | |
13100 | vty_out(vty, "\n"); | |
13101 | } | |
d62a17ae | 13102 | |
10711563 DA |
13103 | /* Extended Message Support */ |
13104 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13105 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13106 | vty_out(vty, " Extended Message:"); | |
ef56aee4 | 13107 | if (CHECK_FLAG(p->cap, |
10711563 DA |
13108 | PEER_CAP_EXTENDED_MESSAGE_ADV)) |
13109 | vty_out(vty, " advertised"); | |
13110 | if (CHECK_FLAG(p->cap, | |
13111 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13112 | vty_out(vty, " %sreceived", | |
13113 | CHECK_FLAG( | |
13114 | p->cap, | |
13115 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13116 | ? "and " | |
13117 | : ""); | |
13118 | vty_out(vty, "\n"); | |
13119 | } | |
d62a17ae | 13120 | |
10711563 DA |
13121 | /* AddPath */ |
13122 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13123 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13124 | vty_out(vty, " AddPath:\n"); | |
d62a17ae | 13125 | |
10711563 | 13126 | FOREACH_AFI_SAFI (afi, safi) { |
ef56aee4 | 13127 | if (CHECK_FLAG( |
10711563 DA |
13128 | p->af_cap[afi][safi], |
13129 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13130 | CHECK_FLAG( | |
13131 | p->af_cap[afi][safi], | |
13132 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13133 | vty_out(vty, " %s: TX ", | |
13134 | get_afi_safi_str( | |
13135 | afi, safi, | |
13136 | false)); | |
ef56aee4 | 13137 | |
10711563 DA |
13138 | if (CHECK_FLAG( |
13139 | p->af_cap[afi] | |
13140 | [safi], | |
13141 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13142 | vty_out(vty, | |
13143 | "advertised"); | |
d62a17ae | 13144 | |
05c7a1cc QY |
13145 | if (CHECK_FLAG( |
13146 | p->af_cap[afi] | |
13147 | [safi], | |
10711563 | 13148 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
05c7a1cc | 13149 | vty_out(vty, |
10711563 DA |
13150 | "%sreceived", |
13151 | CHECK_FLAG( | |
13152 | p->af_cap | |
13153 | [afi] | |
13154 | [safi], | |
13155 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13156 | ? " and " | |
13157 | : ""); | |
05c7a1cc | 13158 | |
10711563 DA |
13159 | vty_out(vty, "\n"); |
13160 | } | |
d62a17ae | 13161 | |
9af52ccf | 13162 | if (CHECK_FLAG( |
10711563 DA |
13163 | p->af_cap[afi][safi], |
13164 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13165 | CHECK_FLAG( | |
13166 | p->af_cap[afi][safi], | |
13167 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13168 | vty_out(vty, " %s: RX ", | |
5cb5f4d0 | 13169 | get_afi_safi_str( |
10711563 DA |
13170 | afi, safi, |
13171 | false)); | |
d62a17ae | 13172 | |
05c7a1cc QY |
13173 | if (CHECK_FLAG( |
13174 | p->af_cap[afi] | |
13175 | [safi], | |
10711563 | 13176 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
05c7a1cc | 13177 | vty_out(vty, |
10711563 | 13178 | "advertised"); |
d62a17ae | 13179 | |
10711563 DA |
13180 | if (CHECK_FLAG( |
13181 | p->af_cap[afi] | |
13182 | [safi], | |
13183 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc | 13184 | vty_out(vty, |
10711563 DA |
13185 | "%sreceived", |
13186 | CHECK_FLAG( | |
13187 | p->af_cap | |
13188 | [afi] | |
13189 | [safi], | |
13190 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13191 | ? " and " | |
05c7a1cc | 13192 | : ""); |
d62a17ae | 13193 | |
05c7a1cc | 13194 | vty_out(vty, "\n"); |
05c7a1cc | 13195 | } |
d62a17ae | 13196 | } |
10711563 | 13197 | } |
d62a17ae | 13198 | |
10711563 DA |
13199 | /* Dynamic */ |
13200 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13201 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13202 | vty_out(vty, " Dynamic:"); | |
13203 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
13204 | vty_out(vty, " advertised"); | |
13205 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13206 | vty_out(vty, " %sreceived", | |
13207 | CHECK_FLAG(p->cap, | |
13208 | PEER_CAP_DYNAMIC_ADV) | |
13209 | ? "and " | |
13210 | : ""); | |
13211 | vty_out(vty, "\n"); | |
13212 | } | |
d62a17ae | 13213 | |
10711563 DA |
13214 | /* Extended nexthop */ |
13215 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13216 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13217 | vty_out(vty, " Extended nexthop:"); | |
13218 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13219 | vty_out(vty, " advertised"); | |
13220 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13221 | vty_out(vty, " %sreceived", | |
13222 | CHECK_FLAG(p->cap, | |
13223 | PEER_CAP_ENHE_ADV) | |
13224 | ? "and " | |
13225 | : ""); | |
13226 | vty_out(vty, "\n"); | |
d62a17ae | 13227 | |
10711563 | 13228 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
57f7feb6 | 13229 | vty_out(vty, |
10711563 DA |
13230 | " Address families by peer:\n "); |
13231 | for (safi = SAFI_UNICAST; | |
13232 | safi < SAFI_MAX; safi++) | |
13233 | if (CHECK_FLAG( | |
13234 | p->af_cap[AFI_IP] | |
13235 | [safi], | |
13236 | PEER_CAP_ENHE_AF_RCV)) | |
13237 | vty_out(vty, | |
13238 | " %s\n", | |
13239 | get_afi_safi_str( | |
13240 | AFI_IP, | |
13241 | safi, | |
13242 | false)); | |
d62a17ae | 13243 | } |
10711563 | 13244 | } |
d62a17ae | 13245 | |
10711563 DA |
13246 | /* Long-lived Graceful Restart */ |
13247 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13248 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13249 | vty_out(vty, | |
13250 | " Long-lived Graceful Restart:"); | |
13251 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13252 | vty_out(vty, " advertised"); | |
13253 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13254 | vty_out(vty, " %sreceived", | |
13255 | CHECK_FLAG(p->cap, | |
13256 | PEER_CAP_LLGR_ADV) | |
13257 | ? "and " | |
13258 | : ""); | |
13259 | vty_out(vty, "\n"); | |
8606be87 | 13260 | |
10711563 | 13261 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
57f7feb6 | 13262 | vty_out(vty, |
10711563 DA |
13263 | " Address families by peer:\n"); |
13264 | FOREACH_AFI_SAFI (afi, safi) | |
13265 | if (CHECK_FLAG( | |
13266 | p->af_cap[afi] | |
13267 | [safi], | |
13268 | PEER_CAP_LLGR_AF_RCV)) | |
13269 | vty_out(vty, | |
13270 | " %s\n", | |
13271 | get_afi_safi_str( | |
13272 | afi, | |
13273 | safi, | |
13274 | false)); | |
8606be87 | 13275 | } |
10711563 | 13276 | } |
8606be87 | 13277 | |
10711563 DA |
13278 | /* Route Refresh */ |
13279 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13280 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13281 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13282 | vty_out(vty, " Route refresh:"); | |
13283 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
13284 | vty_out(vty, " advertised"); | |
13285 | if (CHECK_FLAG(p->cap, | |
13286 | PEER_CAP_REFRESH_NEW_RCV) || | |
13287 | CHECK_FLAG(p->cap, | |
13288 | PEER_CAP_REFRESH_OLD_RCV)) | |
13289 | vty_out(vty, " %sreceived(%s)", | |
13290 | CHECK_FLAG(p->cap, | |
13291 | PEER_CAP_REFRESH_ADV) | |
13292 | ? "and " | |
13293 | : "", | |
13294 | (CHECK_FLAG( | |
13295 | p->cap, | |
13296 | PEER_CAP_REFRESH_OLD_RCV) && | |
13297 | CHECK_FLAG( | |
13298 | p->cap, | |
13299 | PEER_CAP_REFRESH_NEW_RCV)) | |
13300 | ? "old & new" | |
13301 | : CHECK_FLAG( | |
13302 | p->cap, | |
13303 | PEER_CAP_REFRESH_OLD_RCV) | |
13304 | ? "old" | |
13305 | : "new"); | |
d62a17ae | 13306 | |
d77114b7 | 13307 | vty_out(vty, "\n"); |
10711563 | 13308 | } |
d62a17ae | 13309 | |
10711563 DA |
13310 | /* Enhanced Route Refresh */ |
13311 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13312 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13313 | vty_out(vty, " Enhanced Route Refresh:"); | |
13314 | if (CHECK_FLAG(p->cap, | |
13315 | PEER_CAP_ENHANCED_RR_ADV)) | |
13316 | vty_out(vty, " advertised"); | |
13317 | if (CHECK_FLAG(p->cap, | |
13318 | PEER_CAP_ENHANCED_RR_RCV)) | |
13319 | vty_out(vty, " %sreceived", | |
13320 | CHECK_FLAG(p->cap, | |
13321 | PEER_CAP_REFRESH_ADV) | |
13322 | ? "and " | |
13323 | : ""); | |
13324 | vty_out(vty, "\n"); | |
13325 | } | |
13326 | ||
13327 | /* Multiprotocol Extensions */ | |
13328 | FOREACH_AFI_SAFI (afi, safi) | |
13329 | if (p->afc_adv[afi][safi] || | |
13330 | p->afc_recv[afi][safi]) { | |
13331 | vty_out(vty, " Address Family %s:", | |
13332 | get_afi_safi_str(afi, safi, | |
13333 | false)); | |
13334 | if (p->afc_adv[afi][safi]) | |
9af52ccf | 13335 | vty_out(vty, " advertised"); |
10711563 | 13336 | if (p->afc_recv[afi][safi]) |
9af52ccf | 13337 | vty_out(vty, " %sreceived", |
10711563 | 13338 | p->afc_adv[afi][safi] |
9af52ccf DA |
13339 | ? "and " |
13340 | : ""); | |
13341 | vty_out(vty, "\n"); | |
13342 | } | |
13343 | ||
10711563 DA |
13344 | /* Hostname capability */ |
13345 | vty_out(vty, " Hostname Capability:"); | |
d62a17ae | 13346 | |
10711563 DA |
13347 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13348 | vty_out(vty, | |
13349 | " advertised (name: %s,domain name: %s)", | |
13350 | bgp->peer_self->hostname | |
13351 | ? bgp->peer_self->hostname | |
13352 | : "n/a", | |
13353 | bgp->peer_self->domainname | |
13354 | ? bgp->peer_self->domainname | |
13355 | : "n/a"); | |
13356 | } else { | |
13357 | vty_out(vty, " not advertised"); | |
13358 | } | |
d77114b7 | 13359 | |
10711563 DA |
13360 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13361 | vty_out(vty, | |
13362 | " received (name: %s,domain name: %s)", | |
13363 | p->hostname ? p->hostname : "n/a", | |
13364 | p->domainname ? p->domainname : "n/a"); | |
13365 | } else { | |
13366 | vty_out(vty, " not received"); | |
d62a17ae | 13367 | } |
d62a17ae | 13368 | |
10711563 | 13369 | vty_out(vty, "\n"); |
d77114b7 | 13370 | |
10711563 DA |
13371 | /* Graceful Restart */ |
13372 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
13373 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13374 | vty_out(vty, | |
13375 | " Graceful Restart Capability:"); | |
13376 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
13377 | vty_out(vty, " advertised"); | |
13378 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
13379 | vty_out(vty, " %sreceived", | |
13380 | CHECK_FLAG(p->cap, | |
13381 | PEER_CAP_RESTART_ADV) | |
13382 | ? "and " | |
13383 | : ""); | |
d77114b7 MK |
13384 | vty_out(vty, "\n"); |
13385 | ||
10711563 DA |
13386 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13387 | int restart_af_count = 0; | |
d62a17ae | 13388 | |
10711563 DA |
13389 | vty_out(vty, |
13390 | " Remote Restart timer is %d seconds\n", | |
13391 | p->v_gr_restart); | |
13392 | vty_out(vty, | |
13393 | " Address families by peer:\n "); | |
d62a17ae | 13394 | |
10711563 DA |
13395 | FOREACH_AFI_SAFI (afi, safi) |
13396 | if (CHECK_FLAG( | |
13397 | p->af_cap[afi] | |
13398 | [safi], | |
13399 | PEER_CAP_RESTART_AF_RCV)) { | |
13400 | vty_out(vty, "%s%s(%s)", | |
13401 | restart_af_count | |
13402 | ? ", " | |
13403 | : "", | |
13404 | get_afi_safi_str( | |
13405 | afi, | |
13406 | safi, | |
13407 | false), | |
13408 | CHECK_FLAG( | |
13409 | p->af_cap | |
13410 | [afi] | |
13411 | [safi], | |
13412 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13413 | ? "preserved" | |
13414 | : "not preserved"); | |
13415 | restart_af_count++; | |
13416 | } | |
13417 | if (!restart_af_count) | |
13418 | vty_out(vty, "none"); | |
13419 | vty_out(vty, "\n"); | |
13420 | } | |
13421 | } /* Gracefull Restart */ | |
d62a17ae | 13422 | } |
13423 | } | |
13424 | ||
13425 | /* graceful restart information */ | |
10711563 DA |
13426 | json_object *json_grace = NULL; |
13427 | json_object *json_grace_send = NULL; | |
13428 | json_object *json_grace_recv = NULL; | |
13429 | int eor_send_af_count = 0; | |
13430 | int eor_receive_af_count = 0; | |
d62a17ae | 13431 | |
10711563 DA |
13432 | if (use_json) { |
13433 | json_grace = json_object_new_object(); | |
13434 | json_grace_send = json_object_new_object(); | |
13435 | json_grace_recv = json_object_new_object(); | |
13436 | ||
13437 | if ((peer_established(p)) && | |
13438 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13439 | FOREACH_AFI_SAFI (afi, safi) { | |
13440 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13441 | PEER_STATUS_EOR_SEND)) { | |
13442 | json_object_boolean_true_add( | |
13443 | json_grace_send, | |
13444 | get_afi_safi_str(afi, safi, | |
13445 | true)); | |
13446 | eor_send_af_count++; | |
d62a17ae | 13447 | } |
10711563 DA |
13448 | } |
13449 | FOREACH_AFI_SAFI (afi, safi) { | |
13450 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13451 | PEER_STATUS_EOR_RECEIVED)) { | |
13452 | json_object_boolean_true_add( | |
13453 | json_grace_recv, | |
13454 | get_afi_safi_str(afi, safi, | |
13455 | true)); | |
13456 | eor_receive_af_count++; | |
d62a17ae | 13457 | } |
13458 | } | |
10711563 DA |
13459 | } |
13460 | json_object_object_add(json_grace, "endOfRibSend", | |
13461 | json_grace_send); | |
13462 | json_object_object_add(json_grace, "endOfRibRecv", | |
13463 | json_grace_recv); | |
d62a17ae | 13464 | |
d62a17ae | 13465 | |
10711563 DA |
13466 | if (p->t_gr_restart) |
13467 | json_object_int_add( | |
13468 | json_grace, "gracefulRestartTimerMsecs", | |
13469 | thread_timer_remain_second(p->t_gr_restart) * | |
13470 | 1000); | |
2986cac2 | 13471 | |
10711563 DA |
13472 | if (p->t_gr_stale) |
13473 | json_object_int_add( | |
13474 | json_grace, "gracefulStalepathTimerMsecs", | |
13475 | thread_timer_remain_second(p->t_gr_stale) * | |
13476 | 1000); | |
13477 | /* more gr info in new format */ | |
13478 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json_grace); | |
13479 | json_object_object_add(json_neigh, "gracefulRestartInfo", | |
13480 | json_grace); | |
13481 | } else { | |
13482 | vty_out(vty, " Graceful restart information:\n"); | |
13483 | if ((peer_established(p)) && | |
13484 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13485 | ||
13486 | vty_out(vty, " End-of-RIB send: "); | |
13487 | FOREACH_AFI_SAFI (afi, safi) { | |
13488 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13489 | PEER_STATUS_EOR_SEND)) { | |
13490 | vty_out(vty, "%s%s", | |
13491 | eor_send_af_count ? ", " : "", | |
13492 | get_afi_safi_str(afi, safi, | |
13493 | false)); | |
13494 | eor_send_af_count++; | |
d62a17ae | 13495 | } |
10711563 DA |
13496 | } |
13497 | vty_out(vty, "\n"); | |
13498 | vty_out(vty, " End-of-RIB received: "); | |
13499 | FOREACH_AFI_SAFI (afi, safi) { | |
13500 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13501 | PEER_STATUS_EOR_RECEIVED)) { | |
13502 | vty_out(vty, "%s%s", | |
13503 | eor_receive_af_count ? ", " | |
13504 | : "", | |
13505 | get_afi_safi_str(afi, safi, | |
13506 | false)); | |
13507 | eor_receive_af_count++; | |
d62a17ae | 13508 | } |
d62a17ae | 13509 | } |
10711563 DA |
13510 | vty_out(vty, "\n"); |
13511 | } | |
d62a17ae | 13512 | |
10711563 DA |
13513 | if (p->t_gr_restart) |
13514 | vty_out(vty, | |
13515 | " The remaining time of restart timer is %ld\n", | |
13516 | thread_timer_remain_second(p->t_gr_restart)); | |
d62a17ae | 13517 | |
10711563 DA |
13518 | if (p->t_gr_stale) |
13519 | vty_out(vty, | |
13520 | " The remaining time of stalepath timer is %ld\n", | |
13521 | thread_timer_remain_second(p->t_gr_stale)); | |
2986cac2 | 13522 | |
10711563 DA |
13523 | /* more gr info in new format */ |
13524 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
13525 | } | |
2986cac2 | 13526 | |
d62a17ae | 13527 | if (use_json) { |
13528 | json_object *json_stat = NULL; | |
13529 | json_stat = json_object_new_object(); | |
13530 | /* Packet counts. */ | |
43aa5965 QY |
13531 | |
13532 | atomic_size_t outq_count, inq_count; | |
13533 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13534 | memory_order_relaxed); | |
13535 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13536 | memory_order_relaxed); | |
13537 | ||
13538 | json_object_int_add(json_stat, "depthInq", | |
13539 | (unsigned long)inq_count); | |
d62a17ae | 13540 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13541 | (unsigned long)outq_count); |
0112e9e0 QY |
13542 | json_object_int_add(json_stat, "opensSent", |
13543 | atomic_load_explicit(&p->open_out, | |
13544 | memory_order_relaxed)); | |
13545 | json_object_int_add(json_stat, "opensRecv", | |
13546 | atomic_load_explicit(&p->open_in, | |
13547 | memory_order_relaxed)); | |
d62a17ae | 13548 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13549 | atomic_load_explicit(&p->notify_out, |
13550 | memory_order_relaxed)); | |
d62a17ae | 13551 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13552 | atomic_load_explicit(&p->notify_in, |
13553 | memory_order_relaxed)); | |
13554 | json_object_int_add(json_stat, "updatesSent", | |
13555 | atomic_load_explicit(&p->update_out, | |
13556 | memory_order_relaxed)); | |
13557 | json_object_int_add(json_stat, "updatesRecv", | |
13558 | atomic_load_explicit(&p->update_in, | |
13559 | memory_order_relaxed)); | |
d62a17ae | 13560 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13561 | atomic_load_explicit(&p->keepalive_out, |
13562 | memory_order_relaxed)); | |
d62a17ae | 13563 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13564 | atomic_load_explicit(&p->keepalive_in, |
13565 | memory_order_relaxed)); | |
d62a17ae | 13566 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13567 | atomic_load_explicit(&p->refresh_out, |
13568 | memory_order_relaxed)); | |
d62a17ae | 13569 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13570 | atomic_load_explicit(&p->refresh_in, |
13571 | memory_order_relaxed)); | |
d62a17ae | 13572 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13573 | atomic_load_explicit(&p->dynamic_cap_out, |
13574 | memory_order_relaxed)); | |
d62a17ae | 13575 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13576 | atomic_load_explicit(&p->dynamic_cap_in, |
13577 | memory_order_relaxed)); | |
13578 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13579 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13580 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13581 | } else { | |
43aa5965 QY |
13582 | atomic_size_t outq_count, inq_count; |
13583 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13584 | memory_order_relaxed); | |
13585 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13586 | memory_order_relaxed); | |
13587 | ||
d62a17ae | 13588 | /* Packet counts. */ |
13589 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13590 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13591 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13592 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13593 | vty_out(vty, " Opens: %10d %10d\n", |
13594 | atomic_load_explicit(&p->open_out, | |
13595 | memory_order_relaxed), | |
13596 | atomic_load_explicit(&p->open_in, | |
13597 | memory_order_relaxed)); | |
13598 | vty_out(vty, " Notifications: %10d %10d\n", | |
13599 | atomic_load_explicit(&p->notify_out, | |
13600 | memory_order_relaxed), | |
13601 | atomic_load_explicit(&p->notify_in, | |
13602 | memory_order_relaxed)); | |
13603 | vty_out(vty, " Updates: %10d %10d\n", | |
13604 | atomic_load_explicit(&p->update_out, | |
13605 | memory_order_relaxed), | |
13606 | atomic_load_explicit(&p->update_in, | |
13607 | memory_order_relaxed)); | |
13608 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13609 | atomic_load_explicit(&p->keepalive_out, | |
13610 | memory_order_relaxed), | |
13611 | atomic_load_explicit(&p->keepalive_in, | |
13612 | memory_order_relaxed)); | |
13613 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13614 | atomic_load_explicit(&p->refresh_out, | |
13615 | memory_order_relaxed), | |
13616 | atomic_load_explicit(&p->refresh_in, | |
13617 | memory_order_relaxed)); | |
d62a17ae | 13618 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13619 | atomic_load_explicit(&p->dynamic_cap_out, |
13620 | memory_order_relaxed), | |
13621 | atomic_load_explicit(&p->dynamic_cap_in, | |
13622 | memory_order_relaxed)); | |
13623 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13624 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13625 | } |
13626 | ||
13627 | if (use_json) { | |
13628 | /* advertisement-interval */ | |
13629 | json_object_int_add(json_neigh, | |
13630 | "minBtwnAdvertisementRunsTimerMsecs", | |
13631 | p->v_routeadv * 1000); | |
13632 | ||
13633 | /* Update-source. */ | |
13634 | if (p->update_if || p->update_source) { | |
13635 | if (p->update_if) | |
13636 | json_object_string_add(json_neigh, | |
13637 | "updateSource", | |
13638 | p->update_if); | |
13639 | else if (p->update_source) | |
13640 | json_object_string_add( | |
13641 | json_neigh, "updateSource", | |
13642 | sockunion2str(p->update_source, buf1, | |
13643 | SU_ADDRSTRLEN)); | |
13644 | } | |
13645 | } else { | |
13646 | /* advertisement-interval */ | |
13647 | vty_out(vty, | |
13648 | " Minimum time between advertisement runs is %d seconds\n", | |
13649 | p->v_routeadv); | |
13650 | ||
13651 | /* Update-source. */ | |
13652 | if (p->update_if || p->update_source) { | |
13653 | vty_out(vty, " Update source is "); | |
13654 | if (p->update_if) | |
13655 | vty_out(vty, "%s", p->update_if); | |
13656 | else if (p->update_source) | |
13657 | vty_out(vty, "%s", | |
13658 | sockunion2str(p->update_source, buf1, | |
13659 | SU_ADDRSTRLEN)); | |
13660 | vty_out(vty, "\n"); | |
13661 | } | |
13662 | ||
13663 | vty_out(vty, "\n"); | |
13664 | } | |
13665 | ||
13666 | /* Address Family Information */ | |
13667 | json_object *json_hold = NULL; | |
13668 | ||
13669 | if (use_json) | |
13670 | json_hold = json_object_new_object(); | |
13671 | ||
05c7a1cc QY |
13672 | FOREACH_AFI_SAFI (afi, safi) |
13673 | if (p->afc[afi][safi]) | |
13674 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13675 | json_hold); | |
d62a17ae | 13676 | |
13677 | if (use_json) { | |
13678 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13679 | json_hold); | |
13680 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13681 | p->established); | |
13682 | json_object_int_add(json_neigh, "connectionsDropped", | |
13683 | p->dropped); | |
13684 | } else | |
13685 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13686 | p->established, p->dropped); | |
13687 | ||
13688 | if (!p->last_reset) { | |
13689 | if (use_json) | |
13690 | json_object_string_add(json_neigh, "lastReset", | |
13691 | "never"); | |
13692 | else | |
13693 | vty_out(vty, " Last reset never\n"); | |
13694 | } else { | |
13695 | if (use_json) { | |
13696 | time_t uptime; | |
a2700b50 | 13697 | struct tm tm; |
d62a17ae | 13698 | |
13699 | uptime = bgp_clock(); | |
13700 | uptime -= p->resettime; | |
a2700b50 MS |
13701 | gmtime_r(&uptime, &tm); |
13702 | ||
d62a17ae | 13703 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13704 | (tm.tm_sec * 1000) |
13705 | + (tm.tm_min * 60000) | |
13706 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13707 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13708 | } else { |
13709 | vty_out(vty, " Last reset %s, ", | |
13710 | peer_uptime(p->resettime, timebuf, | |
13711 | BGP_UPTIME_LEN, 0, NULL)); | |
13712 | ||
3577f1c5 | 13713 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13714 | if (p->last_reset_cause_size) { |
13715 | msg = p->last_reset_cause; | |
13716 | vty_out(vty, | |
13717 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13718 | for (i = 1; i <= p->last_reset_cause_size; | |
13719 | i++) { | |
13720 | vty_out(vty, "%02X", *msg++); | |
13721 | ||
13722 | if (i != p->last_reset_cause_size) { | |
13723 | if (i % 16 == 0) { | |
13724 | vty_out(vty, "\n "); | |
13725 | } else if (i % 4 == 0) { | |
13726 | vty_out(vty, " "); | |
13727 | } | |
13728 | } | |
13729 | } | |
13730 | vty_out(vty, "\n"); | |
13731 | } | |
13732 | } | |
13733 | } | |
13734 | ||
13735 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13736 | if (use_json) | |
13737 | json_object_boolean_true_add(json_neigh, | |
13738 | "prefixesConfigExceedMax"); | |
13739 | else | |
13740 | vty_out(vty, | |
13741 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13742 | ||
13743 | if (p->t_pmax_restart) { | |
13744 | if (use_json) { | |
13745 | json_object_boolean_true_add( | |
13746 | json_neigh, "reducePrefixNumFrom"); | |
13747 | json_object_int_add(json_neigh, | |
13748 | "restartInTimerMsec", | |
13749 | thread_timer_remain_second( | |
13750 | p->t_pmax_restart) | |
13751 | * 1000); | |
13752 | } else | |
13753 | vty_out(vty, | |
13754 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13755 | p->host, thread_timer_remain_second( |
13756 | p->t_pmax_restart)); | |
d62a17ae | 13757 | } else { |
13758 | if (use_json) | |
13759 | json_object_boolean_true_add( | |
13760 | json_neigh, | |
13761 | "reducePrefixNumAndClearIpBgp"); | |
13762 | else | |
13763 | vty_out(vty, | |
13764 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13765 | p->host); | |
13766 | } | |
13767 | } | |
13768 | ||
13769 | /* EBGP Multihop and GTSM */ | |
13770 | if (p->sort != BGP_PEER_IBGP) { | |
13771 | if (use_json) { | |
e2521429 | 13772 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13773 | json_object_int_add(json_neigh, |
13774 | "externalBgpNbrMaxHopsAway", | |
13775 | p->gtsm_hops); | |
c8d6f0d6 | 13776 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13777 | json_object_int_add(json_neigh, |
13778 | "externalBgpNbrMaxHopsAway", | |
13779 | p->ttl); | |
13780 | } else { | |
e2521429 | 13781 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13782 | vty_out(vty, |
13783 | " External BGP neighbor may be up to %d hops away.\n", | |
13784 | p->gtsm_hops); | |
c8d6f0d6 | 13785 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13786 | vty_out(vty, |
13787 | " External BGP neighbor may be up to %d hops away.\n", | |
13788 | p->ttl); | |
13789 | } | |
13790 | } else { | |
e2521429 | 13791 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13792 | if (use_json) |
13793 | json_object_int_add(json_neigh, | |
13794 | "internalBgpNbrMaxHopsAway", | |
13795 | p->gtsm_hops); | |
13796 | else | |
13797 | vty_out(vty, | |
13798 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13799 | p->gtsm_hops); | |
13800 | } | |
13801 | } | |
13802 | ||
13803 | /* Local address. */ | |
13804 | if (p->su_local) { | |
13805 | if (use_json) { | |
13806 | json_object_string_add(json_neigh, "hostLocal", | |
13807 | sockunion2str(p->su_local, buf1, | |
13808 | SU_ADDRSTRLEN)); | |
13809 | json_object_int_add(json_neigh, "portLocal", | |
13810 | ntohs(p->su_local->sin.sin_port)); | |
13811 | } else | |
13812 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13813 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13814 | ntohs(p->su_local->sin.sin_port)); | |
13815 | } | |
13816 | ||
13817 | /* Remote address. */ | |
13818 | if (p->su_remote) { | |
13819 | if (use_json) { | |
13820 | json_object_string_add(json_neigh, "hostForeign", | |
13821 | sockunion2str(p->su_remote, buf1, | |
13822 | SU_ADDRSTRLEN)); | |
13823 | json_object_int_add(json_neigh, "portForeign", | |
13824 | ntohs(p->su_remote->sin.sin_port)); | |
13825 | } else | |
13826 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13827 | sockunion2str(p->su_remote, buf1, | |
13828 | SU_ADDRSTRLEN), | |
13829 | ntohs(p->su_remote->sin.sin_port)); | |
13830 | } | |
13831 | ||
13832 | /* Nexthop display. */ | |
13833 | if (p->su_local) { | |
13834 | if (use_json) { | |
c949c771 DA |
13835 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
13836 | &p->nexthop.v4); | |
13837 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
13838 | "%pI6", &p->nexthop.v6_global); | |
13839 | json_object_string_addf(json_neigh, "nexthopLocal", | |
13840 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 13841 | if (p->shared_network) |
13842 | json_object_string_add(json_neigh, | |
13843 | "bgpConnection", | |
13844 | "sharedNetwork"); | |
13845 | else | |
13846 | json_object_string_add(json_neigh, | |
13847 | "bgpConnection", | |
13848 | "nonSharedNetwork"); | |
13849 | } else { | |
13850 | vty_out(vty, "Nexthop: %s\n", | |
13851 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13852 | sizeof(buf1))); | |
13853 | vty_out(vty, "Nexthop global: %s\n", | |
13854 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13855 | sizeof(buf1))); | |
13856 | vty_out(vty, "Nexthop local: %s\n", | |
13857 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13858 | sizeof(buf1))); | |
13859 | vty_out(vty, "BGP connection: %s\n", | |
13860 | p->shared_network ? "shared network" | |
13861 | : "non shared network"); | |
13862 | } | |
13863 | } | |
13864 | ||
13865 | /* Timer information. */ | |
13866 | if (use_json) { | |
13867 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13868 | p->v_connect); | |
feb17238 | 13869 | if (peer_established(p) && p->rtt) |
d62a17ae | 13870 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
13871 | p->rtt); | |
13872 | if (p->t_start) | |
13873 | json_object_int_add( | |
13874 | json_neigh, "nextStartTimerDueInMsecs", | |
13875 | thread_timer_remain_second(p->t_start) * 1000); | |
13876 | if (p->t_connect) | |
13877 | json_object_int_add( | |
13878 | json_neigh, "nextConnectTimerDueInMsecs", | |
13879 | thread_timer_remain_second(p->t_connect) | |
13880 | * 1000); | |
13881 | if (p->t_routeadv) { | |
13882 | json_object_int_add(json_neigh, "mraiInterval", | |
13883 | p->v_routeadv); | |
13884 | json_object_int_add( | |
13885 | json_neigh, "mraiTimerExpireInMsecs", | |
13886 | thread_timer_remain_second(p->t_routeadv) | |
13887 | * 1000); | |
13888 | } | |
13889 | if (p->password) | |
13890 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13891 | 1); | |
13892 | ||
13893 | if (p->t_read) | |
13894 | json_object_string_add(json_neigh, "readThread", "on"); | |
13895 | else | |
13896 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13897 | |
13898 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13899 | json_object_string_add(json_neigh, "writeThread", "on"); |
13900 | else | |
13901 | json_object_string_add(json_neigh, "writeThread", | |
13902 | "off"); | |
13903 | } else { | |
13904 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13905 | p->v_connect); | |
feb17238 | 13906 | if (peer_established(p) && p->rtt) |
d62a17ae | 13907 | vty_out(vty, "Estimated round trip time: %d ms\n", |
13908 | p->rtt); | |
13909 | if (p->t_start) | |
13910 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13911 | thread_timer_remain_second(p->t_start)); | |
13912 | if (p->t_connect) | |
13913 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13914 | thread_timer_remain_second(p->t_connect)); | |
13915 | if (p->t_routeadv) | |
13916 | vty_out(vty, | |
13917 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13918 | p->v_routeadv, | |
13919 | thread_timer_remain_second(p->t_routeadv)); | |
13920 | if (p->password) | |
13921 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13922 | ||
cac9e917 | 13923 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
13924 | p->t_read ? "on" : "off", |
13925 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13926 | ? "on" | |
cac9e917 | 13927 | : "off", p->fd); |
d62a17ae | 13928 | } |
13929 | ||
13930 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13931 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13932 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13933 | ||
13934 | if (!use_json) | |
13935 | vty_out(vty, "\n"); | |
13936 | ||
13937 | /* BFD information. */ | |
21bfce98 RZ |
13938 | if (p->bfd_config) |
13939 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 13940 | |
13941 | if (use_json) { | |
13942 | if (p->conf_if) /* Configured interface name. */ | |
13943 | json_object_object_add(json, p->conf_if, json_neigh); | |
13944 | else /* Configured IP address. */ | |
13945 | json_object_object_add(json, p->host, json_neigh); | |
13946 | } | |
13947 | } | |
13948 | ||
36235319 QY |
13949 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
13950 | enum show_type type, | |
13951 | union sockunion *su, | |
13952 | const char *conf_if, afi_t afi, | |
74a630b6 | 13953 | bool use_json) |
2986cac2 | 13954 | { |
13955 | struct listnode *node, *nnode; | |
13956 | struct peer *peer; | |
13957 | int find = 0; | |
13958 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 13959 | json_object *json = NULL; |
2986cac2 | 13960 | json_object *json_neighbor = NULL; |
13961 | ||
74a630b6 NT |
13962 | if (use_json) { |
13963 | json = json_object_new_object(); | |
13964 | json_neighbor = json_object_new_object(); | |
13965 | } | |
13966 | ||
2986cac2 | 13967 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
13968 | ||
13969 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13970 | continue; | |
13971 | ||
13972 | if ((peer->afc[afi][safi]) == 0) | |
13973 | continue; | |
13974 | ||
2ba1fe69 | 13975 | if (type == show_all) { |
2986cac2 | 13976 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 13977 | json_neighbor); |
2986cac2 | 13978 | |
74a630b6 | 13979 | if (use_json) { |
13909c4f DS |
13980 | json_object_object_add(json, peer->host, |
13981 | json_neighbor); | |
74a630b6 NT |
13982 | json_neighbor = NULL; |
13983 | } | |
2986cac2 | 13984 | |
2ba1fe69 | 13985 | } else if (type == show_peer) { |
2986cac2 | 13986 | if (conf_if) { |
13987 | if ((peer->conf_if | |
13909c4f DS |
13988 | && !strcmp(peer->conf_if, conf_if)) |
13989 | || (peer->hostname | |
2986cac2 | 13990 | && !strcmp(peer->hostname, conf_if))) { |
13991 | find = 1; | |
13909c4f DS |
13992 | bgp_show_peer_gr_status(vty, peer, |
13993 | use_json, | |
13994 | json_neighbor); | |
2986cac2 | 13995 | } |
13996 | } else { | |
13997 | if (sockunion_same(&peer->su, su)) { | |
13998 | find = 1; | |
13909c4f DS |
13999 | bgp_show_peer_gr_status(vty, peer, |
14000 | use_json, | |
14001 | json_neighbor); | |
2986cac2 | 14002 | } |
14003 | } | |
13909c4f DS |
14004 | if (use_json && find) |
14005 | json_object_object_add(json, peer->host, | |
14006 | json_neighbor); | |
2986cac2 | 14007 | } |
14008 | ||
74a630b6 NT |
14009 | if (find) { |
14010 | json_neighbor = NULL; | |
2986cac2 | 14011 | break; |
74a630b6 | 14012 | } |
2986cac2 | 14013 | } |
14014 | ||
14015 | if (type == show_peer && !find) { | |
14016 | if (use_json) | |
13909c4f | 14017 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14018 | else |
14019 | vty_out(vty, "%% No such neighbor\n"); | |
14020 | } | |
14021 | if (use_json) { | |
74a630b6 NT |
14022 | if (json_neighbor) |
14023 | json_object_free(json_neighbor); | |
75eeda93 | 14024 | vty_json(vty, json); |
2986cac2 | 14025 | } else { |
14026 | vty_out(vty, "\n"); | |
14027 | } | |
14028 | ||
14029 | return CMD_SUCCESS; | |
14030 | } | |
14031 | ||
d62a17ae | 14032 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14033 | enum show_type type, union sockunion *su, | |
9f049418 | 14034 | const char *conf_if, bool use_json, |
d62a17ae | 14035 | json_object *json) |
14036 | { | |
14037 | struct listnode *node, *nnode; | |
14038 | struct peer *peer; | |
14039 | int find = 0; | |
9f049418 | 14040 | bool nbr_output = false; |
d1927ebe AS |
14041 | afi_t afi = AFI_MAX; |
14042 | safi_t safi = SAFI_MAX; | |
14043 | ||
14044 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14045 | afi = AFI_IP; | |
14046 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14047 | afi = AFI_IP6; | |
14048 | } | |
d62a17ae | 14049 | |
14050 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14051 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14052 | continue; | |
14053 | ||
14054 | switch (type) { | |
14055 | case show_all: | |
14056 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14057 | nbr_output = true; |
d62a17ae | 14058 | break; |
14059 | case show_peer: | |
14060 | if (conf_if) { | |
14061 | if ((peer->conf_if | |
14062 | && !strcmp(peer->conf_if, conf_if)) | |
14063 | || (peer->hostname | |
14064 | && !strcmp(peer->hostname, conf_if))) { | |
14065 | find = 1; | |
14066 | bgp_show_peer(vty, peer, use_json, | |
14067 | json); | |
14068 | } | |
14069 | } else { | |
14070 | if (sockunion_same(&peer->su, su)) { | |
14071 | find = 1; | |
14072 | bgp_show_peer(vty, peer, use_json, | |
14073 | json); | |
14074 | } | |
14075 | } | |
14076 | break; | |
d1927ebe AS |
14077 | case show_ipv4_peer: |
14078 | case show_ipv6_peer: | |
14079 | FOREACH_SAFI (safi) { | |
14080 | if (peer->afc[afi][safi]) { | |
14081 | if (conf_if) { | |
14082 | if ((peer->conf_if | |
14083 | && !strcmp(peer->conf_if, conf_if)) | |
14084 | || (peer->hostname | |
14085 | && !strcmp(peer->hostname, conf_if))) { | |
14086 | find = 1; | |
14087 | bgp_show_peer(vty, peer, use_json, | |
14088 | json); | |
14089 | break; | |
14090 | } | |
14091 | } else { | |
14092 | if (sockunion_same(&peer->su, su)) { | |
14093 | find = 1; | |
14094 | bgp_show_peer(vty, peer, use_json, | |
14095 | json); | |
14096 | break; | |
14097 | } | |
14098 | } | |
14099 | } | |
14100 | } | |
14101 | break; | |
14102 | case show_ipv4_all: | |
14103 | case show_ipv6_all: | |
14104 | FOREACH_SAFI (safi) { | |
14105 | if (peer->afc[afi][safi]) { | |
14106 | bgp_show_peer(vty, peer, use_json, json); | |
14107 | nbr_output = true; | |
14108 | break; | |
14109 | } | |
14110 | } | |
14111 | break; | |
d62a17ae | 14112 | } |
14113 | } | |
14114 | ||
d1927ebe AS |
14115 | if ((type == show_peer || type == show_ipv4_peer || |
14116 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14117 | if (use_json) |
14118 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14119 | else | |
88b7d255 | 14120 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14121 | } |
14122 | ||
d1927ebe AS |
14123 | if (type != show_peer && type != show_ipv4_peer && |
14124 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14125 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14126 | |
d62a17ae | 14127 | if (use_json) { |
996c9314 LB |
14128 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14129 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14130 | } else { |
14131 | vty_out(vty, "\n"); | |
14132 | } | |
14133 | ||
14134 | return CMD_SUCCESS; | |
14135 | } | |
14136 | ||
36235319 QY |
14137 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14138 | enum show_type type, | |
14139 | const char *ip_str, | |
14140 | afi_t afi, bool use_json) | |
2986cac2 | 14141 | { |
14142 | ||
14143 | int ret; | |
14144 | struct bgp *bgp; | |
14145 | union sockunion su; | |
2986cac2 | 14146 | |
14147 | bgp = bgp_get_default(); | |
14148 | ||
13909c4f DS |
14149 | if (!bgp) |
14150 | return; | |
2986cac2 | 14151 | |
13909c4f DS |
14152 | if (!use_json) |
14153 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14154 | NULL); | |
2986cac2 | 14155 | |
13909c4f DS |
14156 | if (ip_str) { |
14157 | ret = str2sockunion(ip_str, &su); | |
14158 | if (ret < 0) | |
13909c4f | 14159 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14160 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14161 | else | |
14162 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14163 | NULL, afi, use_json); | |
13909c4f DS |
14164 | } else |
14165 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14166 | afi, use_json); |
2986cac2 | 14167 | } |
14168 | ||
d62a17ae | 14169 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14170 | enum show_type type, |
14171 | const char *ip_str, | |
9f049418 | 14172 | bool use_json) |
d62a17ae | 14173 | { |
0291c246 MK |
14174 | struct listnode *node, *nnode; |
14175 | struct bgp *bgp; | |
71aedaa3 | 14176 | union sockunion su; |
0291c246 | 14177 | json_object *json = NULL; |
71aedaa3 | 14178 | int ret, is_first = 1; |
9f049418 | 14179 | bool nbr_output = false; |
d62a17ae | 14180 | |
14181 | if (use_json) | |
14182 | vty_out(vty, "{\n"); | |
14183 | ||
14184 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14185 | nbr_output = true; |
d62a17ae | 14186 | if (use_json) { |
14187 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14188 | flog_err( |
e50f7cfd | 14189 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14190 | "Unable to allocate memory for JSON object"); |
14191 | vty_out(vty, | |
14192 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14193 | return; | |
14194 | } | |
14195 | ||
14196 | json_object_int_add(json, "vrfId", | |
14197 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14198 | ? -1 |
14199 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14200 | json_object_string_add( |
14201 | json, "vrfName", | |
14202 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14203 | ? VRF_DEFAULT_NAME |
d62a17ae | 14204 | : bgp->name); |
14205 | ||
14206 | if (!is_first) | |
14207 | vty_out(vty, ",\n"); | |
14208 | else | |
14209 | is_first = 0; | |
14210 | ||
14211 | vty_out(vty, "\"%s\":", | |
14212 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14213 | ? VRF_DEFAULT_NAME |
d62a17ae | 14214 | : bgp->name); |
14215 | } else { | |
14216 | vty_out(vty, "\nInstance %s:\n", | |
14217 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14218 | ? VRF_DEFAULT_NAME |
d62a17ae | 14219 | : bgp->name); |
14220 | } | |
71aedaa3 | 14221 | |
d1927ebe AS |
14222 | if (type == show_peer || type == show_ipv4_peer || |
14223 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14224 | ret = str2sockunion(ip_str, &su); |
14225 | if (ret < 0) | |
14226 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14227 | use_json, json); | |
14228 | else | |
14229 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14230 | use_json, json); | |
14231 | } else { | |
d1927ebe | 14232 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14233 | use_json, json); |
14234 | } | |
b77004d6 | 14235 | json_object_free(json); |
121067e9 | 14236 | json = NULL; |
d62a17ae | 14237 | } |
14238 | ||
3e78a6ce | 14239 | if (use_json) |
d62a17ae | 14240 | vty_out(vty, "}\n"); |
9f049418 DS |
14241 | else if (!nbr_output) |
14242 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14243 | } |
14244 | ||
14245 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14246 | enum show_type type, const char *ip_str, | |
9f049418 | 14247 | bool use_json) |
d62a17ae | 14248 | { |
14249 | int ret; | |
14250 | struct bgp *bgp; | |
14251 | union sockunion su; | |
14252 | json_object *json = NULL; | |
14253 | ||
14254 | if (name) { | |
14255 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14256 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14257 | use_json); | |
d62a17ae | 14258 | return CMD_SUCCESS; |
14259 | } else { | |
14260 | bgp = bgp_lookup_by_name(name); | |
14261 | if (!bgp) { | |
14262 | if (use_json) { | |
14263 | json = json_object_new_object(); | |
75eeda93 | 14264 | vty_json(vty, json); |
d62a17ae | 14265 | } else |
14266 | vty_out(vty, | |
9f049418 | 14267 | "%% BGP instance not found\n"); |
d62a17ae | 14268 | |
14269 | return CMD_WARNING; | |
14270 | } | |
14271 | } | |
14272 | } else { | |
14273 | bgp = bgp_get_default(); | |
14274 | } | |
14275 | ||
14276 | if (bgp) { | |
14277 | json = json_object_new_object(); | |
14278 | if (ip_str) { | |
14279 | ret = str2sockunion(ip_str, &su); | |
14280 | if (ret < 0) | |
14281 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14282 | use_json, json); | |
14283 | else | |
14284 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14285 | use_json, json); | |
14286 | } else { | |
14287 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14288 | json); | |
14289 | } | |
14290 | json_object_free(json); | |
ca61fd25 DS |
14291 | } else { |
14292 | if (use_json) | |
14293 | vty_out(vty, "{}\n"); | |
14294 | else | |
14295 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14296 | } |
14297 | ||
14298 | return CMD_SUCCESS; | |
4fb25c53 DW |
14299 | } |
14300 | ||
2986cac2 | 14301 | |
14302 | ||
14303 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14304 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14305 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14306 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14307 | SHOW_STR | |
14308 | BGP_STR | |
14309 | IP_STR | |
14310 | IPV6_STR | |
14311 | NEIGHBOR_STR | |
14312 | "Neighbor to display information about\n" | |
14313 | "Neighbor to display information about\n" | |
14314 | "Neighbor on BGP configured interface\n" | |
14315 | GR_SHOW | |
14316 | JSON_STR) | |
14317 | { | |
14318 | char *sh_arg = NULL; | |
14319 | enum show_type sh_type; | |
14320 | int idx = 0; | |
14321 | afi_t afi = AFI_MAX; | |
2986cac2 | 14322 | bool uj = use_json(argc, argv); |
14323 | ||
36235319 | 14324 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14325 | afi = AFI_MAX; |
14326 | ||
14327 | idx++; | |
14328 | ||
14329 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14330 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14331 | || argv_find(argv, argc, "WORD", &idx)) { | |
14332 | sh_type = show_peer; | |
14333 | sh_arg = argv[idx]->arg; | |
14334 | } else | |
14335 | sh_type = show_all; | |
14336 | ||
14337 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14338 | return CMD_SUCCESS; | |
14339 | ||
14340 | ||
36235319 QY |
14341 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14342 | afi, uj); | |
2986cac2 | 14343 | } |
14344 | ||
716b2d8a | 14345 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14346 | DEFUN (show_ip_bgp_neighbors, |
14347 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14348 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14349 | SHOW_STR |
14350 | IP_STR | |
14351 | BGP_STR | |
f2a8972b | 14352 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14353 | "Address Family\n" |
14354 | "Address Family\n" | |
718e3744 | 14355 | "Detailed information on TCP and BGP neighbor connections\n" |
14356 | "Neighbor to display information about\n" | |
a80beece | 14357 | "Neighbor to display information about\n" |
91d37724 | 14358 | "Neighbor on BGP configured interface\n" |
9973d184 | 14359 | JSON_STR) |
718e3744 | 14360 | { |
d62a17ae | 14361 | char *vrf = NULL; |
14362 | char *sh_arg = NULL; | |
14363 | enum show_type sh_type; | |
d1927ebe | 14364 | afi_t afi = AFI_MAX; |
718e3744 | 14365 | |
9f049418 | 14366 | bool uj = use_json(argc, argv); |
718e3744 | 14367 | |
d62a17ae | 14368 | int idx = 0; |
718e3744 | 14369 | |
9a8bdf1c PG |
14370 | /* [<vrf> VIEWVRFNAME] */ |
14371 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14372 | vrf = argv[idx + 1]->arg; | |
14373 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14374 | vrf = NULL; | |
14375 | } else if (argv_find(argv, argc, "view", &idx)) | |
14376 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14377 | vrf = argv[idx + 1]->arg; |
718e3744 | 14378 | |
d62a17ae | 14379 | idx++; |
d1927ebe AS |
14380 | |
14381 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14382 | sh_type = show_ipv4_all; | |
14383 | afi = AFI_IP; | |
14384 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14385 | sh_type = show_ipv6_all; | |
14386 | afi = AFI_IP6; | |
14387 | } else { | |
14388 | sh_type = show_all; | |
14389 | } | |
14390 | ||
d62a17ae | 14391 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14392 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14393 | || argv_find(argv, argc, "WORD", &idx)) { | |
14394 | sh_type = show_peer; | |
14395 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14396 | } |
14397 | ||
14398 | if (sh_type == show_peer && afi == AFI_IP) { | |
14399 | sh_type = show_ipv4_peer; | |
14400 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14401 | sh_type = show_ipv6_peer; | |
14402 | } | |
856ca177 | 14403 | |
d62a17ae | 14404 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14405 | } |
14406 | ||
716b2d8a | 14407 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14408 | paths' and `show ip mbgp paths'. Those functions results are the |
14409 | same.*/ | |
f412b39a | 14410 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14411 | show_ip_bgp_paths_cmd, |
46f296b4 | 14412 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14413 | SHOW_STR |
14414 | IP_STR | |
14415 | BGP_STR | |
46f296b4 | 14416 | BGP_SAFI_HELP_STR |
718e3744 | 14417 | "Path information\n") |
14418 | { | |
d62a17ae | 14419 | vty_out(vty, "Address Refcnt Path\n"); |
14420 | aspath_print_all_vty(vty); | |
14421 | return CMD_SUCCESS; | |
718e3744 | 14422 | } |
14423 | ||
718e3744 | 14424 | #include "hash.h" |
14425 | ||
e3b78da8 | 14426 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14427 | struct vty *vty) |
718e3744 | 14428 | { |
d62a17ae | 14429 | struct community *com; |
718e3744 | 14430 | |
e3b78da8 | 14431 | com = (struct community *)bucket->data; |
3f65c5b1 | 14432 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14433 | community_str(com, false)); |
718e3744 | 14434 | } |
14435 | ||
14436 | /* Show BGP's community internal data. */ | |
f412b39a | 14437 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14438 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14439 | "show [ip] bgp community-info", |
718e3744 | 14440 | SHOW_STR |
14441 | IP_STR | |
14442 | BGP_STR | |
14443 | "List all bgp community information\n") | |
14444 | { | |
d62a17ae | 14445 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14446 | |
d62a17ae | 14447 | hash_iterate(community_hash(), |
e3b78da8 | 14448 | (void (*)(struct hash_bucket *, |
d62a17ae | 14449 | void *))community_show_all_iterator, |
14450 | vty); | |
718e3744 | 14451 | |
d62a17ae | 14452 | return CMD_SUCCESS; |
718e3744 | 14453 | } |
14454 | ||
e3b78da8 | 14455 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14456 | struct vty *vty) |
57d187bc | 14457 | { |
d62a17ae | 14458 | struct lcommunity *lcom; |
57d187bc | 14459 | |
e3b78da8 | 14460 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14461 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14462 | lcommunity_str(lcom, false)); |
57d187bc JS |
14463 | } |
14464 | ||
14465 | /* Show BGP's community internal data. */ | |
14466 | DEFUN (show_ip_bgp_lcommunity_info, | |
14467 | show_ip_bgp_lcommunity_info_cmd, | |
14468 | "show ip bgp large-community-info", | |
14469 | SHOW_STR | |
14470 | IP_STR | |
14471 | BGP_STR | |
14472 | "List all bgp large-community information\n") | |
14473 | { | |
d62a17ae | 14474 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14475 | |
d62a17ae | 14476 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14477 | (void (*)(struct hash_bucket *, |
d62a17ae | 14478 | void *))lcommunity_show_all_iterator, |
14479 | vty); | |
57d187bc | 14480 | |
d62a17ae | 14481 | return CMD_SUCCESS; |
57d187bc | 14482 | } |
2986cac2 | 14483 | /* Graceful Restart */ |
14484 | ||
14485 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14486 | struct bgp *bgp, |
14487 | bool use_json, | |
14488 | json_object *json) | |
2986cac2 | 14489 | { |
57d187bc JS |
14490 | |
14491 | ||
2986cac2 | 14492 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14493 | ||
7318ae88 | 14494 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14495 | |
14496 | switch (bgp_global_gr_mode) { | |
14497 | ||
14498 | case GLOBAL_HELPER: | |
13909c4f | 14499 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14500 | break; |
14501 | ||
14502 | case GLOBAL_GR: | |
13909c4f | 14503 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14504 | break; |
14505 | ||
14506 | case GLOBAL_DISABLE: | |
13909c4f | 14507 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14508 | break; |
14509 | ||
14510 | case GLOBAL_INVALID: | |
2986cac2 | 14511 | vty_out(vty, |
2ba1fe69 | 14512 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14513 | break; |
14514 | } | |
14515 | vty_out(vty, "\n"); | |
14516 | } | |
14517 | ||
36235319 QY |
14518 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14519 | enum show_type type, | |
14520 | const char *ip_str, | |
14521 | afi_t afi, bool use_json) | |
2986cac2 | 14522 | { |
14523 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14524 | afi = AFI_IP; | |
14525 | ||
14526 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14527 | ||
36235319 QY |
14528 | bgp_show_neighbor_graceful_restart_vty( |
14529 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14530 | afi++; |
14531 | } | |
14532 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14533 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14534 | use_json); | |
2986cac2 | 14535 | } else { |
14536 | return CMD_ERR_INCOMPLETE; | |
14537 | } | |
14538 | ||
14539 | return CMD_SUCCESS; | |
14540 | } | |
14541 | /* Graceful Restart */ | |
14542 | ||
f412b39a | 14543 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14544 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14545 | "show [ip] bgp attribute-info", |
718e3744 | 14546 | SHOW_STR |
14547 | IP_STR | |
14548 | BGP_STR | |
14549 | "List all bgp attribute information\n") | |
14550 | { | |
d62a17ae | 14551 | attr_show_all(vty); |
14552 | return CMD_SUCCESS; | |
718e3744 | 14553 | } |
6b0655a2 | 14554 | |
03915806 CS |
14555 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14556 | afi_t afi, safi_t safi, | |
14557 | bool use_json, json_object *json) | |
53089bec | 14558 | { |
14559 | struct bgp *bgp; | |
14560 | struct listnode *node; | |
14561 | char *vname; | |
14562 | char buf1[INET6_ADDRSTRLEN]; | |
14563 | char *ecom_str; | |
14564 | vpn_policy_direction_t dir; | |
14565 | ||
03915806 | 14566 | if (json) { |
b46dfd20 DS |
14567 | json_object *json_import_vrfs = NULL; |
14568 | json_object *json_export_vrfs = NULL; | |
14569 | ||
b46dfd20 DS |
14570 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14571 | ||
53089bec | 14572 | if (!bgp) { |
75eeda93 | 14573 | vty_json(vty, json); |
b46dfd20 | 14574 | |
53089bec | 14575 | return CMD_WARNING; |
14576 | } | |
b46dfd20 | 14577 | |
94d4c685 DS |
14578 | /* Provide context for the block */ |
14579 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14580 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14581 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14582 | |
b46dfd20 DS |
14583 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14584 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14585 | json_object_string_add(json, "importFromVrfs", "none"); | |
14586 | json_object_string_add(json, "importRts", "none"); | |
14587 | } else { | |
6ce24e52 DS |
14588 | json_import_vrfs = json_object_new_array(); |
14589 | ||
b46dfd20 DS |
14590 | for (ALL_LIST_ELEMENTS_RO( |
14591 | bgp->vpn_policy[afi].import_vrf, | |
14592 | node, vname)) | |
14593 | json_object_array_add(json_import_vrfs, | |
14594 | json_object_new_string(vname)); | |
14595 | ||
b20875ea CS |
14596 | json_object_object_add(json, "importFromVrfs", |
14597 | json_import_vrfs); | |
b46dfd20 | 14598 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14599 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14600 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14601 | bgp->vpn_policy[afi].rtlist[dir], |
14602 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14603 | json_object_string_add(json, "importRts", |
14604 | ecom_str); | |
14605 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14606 | } else | |
14607 | json_object_string_add(json, "importRts", | |
14608 | "none"); | |
b46dfd20 DS |
14609 | } |
14610 | ||
14611 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14612 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14613 | json_object_string_add(json, "exportToVrfs", "none"); | |
14614 | json_object_string_add(json, "routeDistinguisher", | |
14615 | "none"); | |
14616 | json_object_string_add(json, "exportRts", "none"); | |
14617 | } else { | |
6ce24e52 DS |
14618 | json_export_vrfs = json_object_new_array(); |
14619 | ||
b46dfd20 DS |
14620 | for (ALL_LIST_ELEMENTS_RO( |
14621 | bgp->vpn_policy[afi].export_vrf, | |
14622 | node, vname)) | |
14623 | json_object_array_add(json_export_vrfs, | |
14624 | json_object_new_string(vname)); | |
14625 | json_object_object_add(json, "exportToVrfs", | |
14626 | json_export_vrfs); | |
14627 | json_object_string_add(json, "routeDistinguisher", | |
14628 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14629 | buf1, RD_ADDRSTRLEN)); | |
14630 | ||
14631 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14632 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14633 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14634 | bgp->vpn_policy[afi].rtlist[dir], |
14635 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14636 | json_object_string_add(json, "exportRts", |
14637 | ecom_str); | |
14638 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14639 | } else | |
14640 | json_object_string_add(json, "exportRts", | |
14641 | "none"); | |
b46dfd20 DS |
14642 | } |
14643 | ||
03915806 | 14644 | if (use_json) { |
75eeda93 | 14645 | vty_json(vty, json); |
03915806 | 14646 | } |
53089bec | 14647 | } else { |
b46dfd20 DS |
14648 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14649 | ||
53089bec | 14650 | if (!bgp) { |
b46dfd20 | 14651 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14652 | return CMD_WARNING; |
14653 | } | |
53089bec | 14654 | |
b46dfd20 DS |
14655 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14656 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14657 | vty_out(vty, | |
14658 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14659 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14660 | else { |
14661 | vty_out(vty, | |
14662 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14663 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14664 | |
14665 | for (ALL_LIST_ELEMENTS_RO( | |
14666 | bgp->vpn_policy[afi].import_vrf, | |
14667 | node, vname)) | |
14668 | vty_out(vty, " %s\n", vname); | |
14669 | ||
14670 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14671 | ecom_str = NULL; |
14672 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14673 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14674 | bgp->vpn_policy[afi].rtlist[dir], |
14675 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14676 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14677 | |
b20875ea CS |
14678 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14679 | } else | |
14680 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14681 | } |
53089bec | 14682 | |
b46dfd20 DS |
14683 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14684 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14685 | vty_out(vty, | |
14686 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14687 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14688 | else { |
14689 | vty_out(vty, | |
04c9077f | 14690 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14691 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14692 | |
14693 | for (ALL_LIST_ELEMENTS_RO( | |
14694 | bgp->vpn_policy[afi].export_vrf, | |
14695 | node, vname)) | |
14696 | vty_out(vty, " %s\n", vname); | |
14697 | ||
14698 | vty_out(vty, "RD: %s\n", | |
14699 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14700 | buf1, RD_ADDRSTRLEN)); | |
14701 | ||
14702 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14703 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14704 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14705 | bgp->vpn_policy[afi].rtlist[dir], |
14706 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14707 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14708 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14709 | } else | |
14710 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14711 | } |
53089bec | 14712 | } |
14713 | ||
14714 | return CMD_SUCCESS; | |
14715 | } | |
14716 | ||
03915806 CS |
14717 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14718 | safi_t safi, bool use_json) | |
14719 | { | |
14720 | struct listnode *node, *nnode; | |
14721 | struct bgp *bgp; | |
14722 | char *vrf_name = NULL; | |
14723 | json_object *json = NULL; | |
14724 | json_object *json_vrf = NULL; | |
14725 | json_object *json_vrfs = NULL; | |
14726 | ||
14727 | if (use_json) { | |
14728 | json = json_object_new_object(); | |
14729 | json_vrfs = json_object_new_object(); | |
14730 | } | |
14731 | ||
14732 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14733 | ||
14734 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14735 | vrf_name = bgp->name; | |
14736 | ||
14737 | if (use_json) { | |
14738 | json_vrf = json_object_new_object(); | |
14739 | } else { | |
14740 | vty_out(vty, "\nInstance %s:\n", | |
14741 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14742 | ? VRF_DEFAULT_NAME : bgp->name); | |
14743 | } | |
14744 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14745 | if (use_json) { | |
14746 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14747 | json_object_object_add(json_vrfs, | |
14748 | VRF_DEFAULT_NAME, json_vrf); | |
14749 | else | |
14750 | json_object_object_add(json_vrfs, vrf_name, | |
14751 | json_vrf); | |
14752 | } | |
14753 | } | |
14754 | ||
14755 | if (use_json) { | |
14756 | json_object_object_add(json, "vrfs", json_vrfs); | |
75eeda93 | 14757 | vty_json(vty, json); |
03915806 CS |
14758 | } |
14759 | ||
14760 | return CMD_SUCCESS; | |
14761 | } | |
14762 | ||
53089bec | 14763 | /* "show [ip] bgp route-leak" command. */ |
14764 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14765 | show_ip_bgp_route_leak_cmd, |
14766 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14767 | SHOW_STR |
14768 | IP_STR | |
14769 | BGP_STR | |
14770 | BGP_INSTANCE_HELP_STR | |
14771 | BGP_AFI_HELP_STR | |
14772 | BGP_SAFI_HELP_STR | |
14773 | "Route leaking information\n" | |
14774 | JSON_STR) | |
53089bec | 14775 | { |
14776 | char *vrf = NULL; | |
14777 | afi_t afi = AFI_MAX; | |
14778 | safi_t safi = SAFI_MAX; | |
14779 | ||
9f049418 | 14780 | bool uj = use_json(argc, argv); |
53089bec | 14781 | int idx = 0; |
03915806 | 14782 | json_object *json = NULL; |
53089bec | 14783 | |
14784 | /* show [ip] bgp */ | |
14785 | if (argv_find(argv, argc, "ip", &idx)) { | |
14786 | afi = AFI_IP; | |
14787 | safi = SAFI_UNICAST; | |
14788 | } | |
14789 | /* [vrf VIEWVRFNAME] */ | |
14790 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14791 | vty_out(vty, |
14792 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14793 | return CMD_WARNING; |
14794 | } | |
14795 | ||
9a8bdf1c PG |
14796 | if (argv_find(argv, argc, "vrf", &idx)) { |
14797 | vrf = argv[idx + 1]->arg; | |
14798 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14799 | vrf = NULL; | |
14800 | } | |
53089bec | 14801 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
c48349e3 | 14802 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
53089bec | 14803 | argv_find_and_parse_safi(argv, argc, &idx, &safi); |
53089bec | 14804 | |
14805 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14806 | vty_out(vty, |
14807 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14808 | return CMD_WARNING; |
14809 | } | |
14810 | ||
03915806 CS |
14811 | if (vrf && strmatch(vrf, "all")) |
14812 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14813 | ||
14814 | if (uj) | |
14815 | json = json_object_new_object(); | |
14816 | ||
14817 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14818 | } |
14819 | ||
d62a17ae | 14820 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14821 | safi_t safi) | |
f186de26 | 14822 | { |
d62a17ae | 14823 | struct listnode *node, *nnode; |
14824 | struct bgp *bgp; | |
f186de26 | 14825 | |
d62a17ae | 14826 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14827 | vty_out(vty, "\nInstance %s:\n", | |
14828 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14829 | ? VRF_DEFAULT_NAME |
d62a17ae | 14830 | : bgp->name); |
14831 | update_group_show(bgp, afi, safi, vty, 0); | |
14832 | } | |
f186de26 | 14833 | } |
14834 | ||
d62a17ae | 14835 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14836 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14837 | { |
d62a17ae | 14838 | struct bgp *bgp; |
4fb25c53 | 14839 | |
d62a17ae | 14840 | if (name) { |
14841 | if (strmatch(name, "all")) { | |
14842 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14843 | return CMD_SUCCESS; | |
14844 | } else { | |
14845 | bgp = bgp_lookup_by_name(name); | |
14846 | } | |
14847 | } else { | |
14848 | bgp = bgp_get_default(); | |
14849 | } | |
4fb25c53 | 14850 | |
d62a17ae | 14851 | if (bgp) |
14852 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14853 | return CMD_SUCCESS; | |
4fb25c53 DW |
14854 | } |
14855 | ||
8fe8a7f6 DS |
14856 | DEFUN (show_ip_bgp_updgrps, |
14857 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14858 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14859 | SHOW_STR |
14860 | IP_STR | |
14861 | BGP_STR | |
14862 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14863 | BGP_AFI_HELP_STR |
9bedbb1e | 14864 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14865 | "Detailed info about dynamic update groups\n" |
14866 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14867 | { |
d62a17ae | 14868 | char *vrf = NULL; |
14869 | afi_t afi = AFI_IP6; | |
14870 | safi_t safi = SAFI_UNICAST; | |
14871 | uint64_t subgrp_id = 0; | |
14872 | ||
14873 | int idx = 0; | |
14874 | ||
14875 | /* show [ip] bgp */ | |
14876 | if (argv_find(argv, argc, "ip", &idx)) | |
14877 | afi = AFI_IP; | |
9a8bdf1c PG |
14878 | /* [<vrf> VIEWVRFNAME] */ |
14879 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14880 | vrf = argv[idx + 1]->arg; | |
14881 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14882 | vrf = NULL; | |
14883 | } else if (argv_find(argv, argc, "view", &idx)) | |
14884 | /* [<view> VIEWVRFNAME] */ | |
14885 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14886 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14887 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14888 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14889 | } | |
5bf15956 | 14890 | |
d62a17ae | 14891 | /* get subgroup id, if provided */ |
14892 | idx = argc - 1; | |
14893 | if (argv[idx]->type == VARIABLE_TKN) | |
14894 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14895 | |
d62a17ae | 14896 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14897 | } |
14898 | ||
f186de26 | 14899 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14900 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14901 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14902 | SHOW_STR |
716b2d8a | 14903 | IP_STR |
f186de26 | 14904 | BGP_STR |
14905 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 14906 | "Detailed info about dynamic update groups\n") |
f186de26 | 14907 | { |
d62a17ae | 14908 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
14909 | return CMD_SUCCESS; | |
f186de26 | 14910 | } |
14911 | ||
43d3f4fc DS |
14912 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
14913 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14914 | "show [ip] bgp l2vpn evpn update-groups", | |
14915 | SHOW_STR | |
14916 | IP_STR | |
14917 | BGP_STR | |
14918 | "l2vpn address family\n" | |
14919 | "evpn sub-address family\n" | |
14920 | "Detailed info about dynamic update groups\n") | |
14921 | { | |
14922 | char *vrf = NULL; | |
14923 | uint64_t subgrp_id = 0; | |
14924 | ||
14925 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14926 | return CMD_SUCCESS; | |
14927 | } | |
14928 | ||
5bf15956 DW |
14929 | DEFUN (show_bgp_updgrps_stats, |
14930 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 14931 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 14932 | SHOW_STR |
716b2d8a | 14933 | IP_STR |
3f9c7369 | 14934 | BGP_STR |
0c7b1b01 | 14935 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
14936 | "Statistics\n") |
14937 | { | |
d62a17ae | 14938 | struct bgp *bgp; |
3f9c7369 | 14939 | |
d62a17ae | 14940 | bgp = bgp_get_default(); |
14941 | if (bgp) | |
14942 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 14943 | |
d62a17ae | 14944 | return CMD_SUCCESS; |
3f9c7369 DS |
14945 | } |
14946 | ||
8386ac43 | 14947 | DEFUN (show_bgp_instance_updgrps_stats, |
14948 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 14949 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 14950 | SHOW_STR |
716b2d8a | 14951 | IP_STR |
8386ac43 | 14952 | BGP_STR |
14953 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 14954 | "Detailed info about dynamic update groups\n" |
8386ac43 | 14955 | "Statistics\n") |
14956 | { | |
d62a17ae | 14957 | int idx_word = 3; |
14958 | struct bgp *bgp; | |
8386ac43 | 14959 | |
d62a17ae | 14960 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
14961 | if (bgp) | |
14962 | update_group_show_stats(bgp, vty); | |
8386ac43 | 14963 | |
d62a17ae | 14964 | return CMD_SUCCESS; |
8386ac43 | 14965 | } |
14966 | ||
d62a17ae | 14967 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
14968 | afi_t afi, safi_t safi, | |
14969 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 14970 | { |
d62a17ae | 14971 | struct bgp *bgp; |
8386ac43 | 14972 | |
d62a17ae | 14973 | if (name) |
14974 | bgp = bgp_lookup_by_name(name); | |
14975 | else | |
14976 | bgp = bgp_get_default(); | |
8386ac43 | 14977 | |
d62a17ae | 14978 | if (bgp) { |
14979 | if (!strcmp(what, "advertise-queue")) | |
14980 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
14981 | subgrp_id); | |
14982 | else if (!strcmp(what, "advertised-routes")) | |
14983 | update_group_show_advertised(bgp, afi, safi, vty, | |
14984 | subgrp_id); | |
14985 | else if (!strcmp(what, "packet-queue")) | |
14986 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
14987 | subgrp_id); | |
14988 | } | |
3f9c7369 DS |
14989 | } |
14990 | ||
dc64bdec QY |
14991 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
14992 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
14993 | "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", | |
14994 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
14995 | BGP_SAFI_HELP_STR | |
14996 | "Detailed info about dynamic update groups\n" | |
14997 | "Specific subgroup to display info for\n" | |
14998 | "Advertisement queue\n" | |
14999 | "Announced routes\n" | |
15000 | "Packet queue\n") | |
3f9c7369 | 15001 | { |
dc64bdec QY |
15002 | uint64_t subgrp_id = 0; |
15003 | afi_t afiz; | |
15004 | safi_t safiz; | |
15005 | if (sgid) | |
15006 | subgrp_id = strtoull(sgid, NULL, 10); | |
15007 | ||
15008 | if (!ip && !afi) | |
15009 | afiz = AFI_IP6; | |
15010 | if (!ip && afi) | |
15011 | afiz = bgp_vty_afi_from_str(afi); | |
15012 | if (ip && !afi) | |
15013 | afiz = AFI_IP; | |
15014 | if (ip && afi) { | |
15015 | afiz = bgp_vty_afi_from_str(afi); | |
15016 | if (afiz != AFI_IP) | |
15017 | vty_out(vty, | |
15018 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15019 | return CMD_WARNING; | |
15020 | } | |
d62a17ae | 15021 | |
dc64bdec | 15022 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15023 | |
dc64bdec | 15024 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15025 | return CMD_SUCCESS; |
15026 | } | |
15027 | ||
6f4eacf3 DA |
15028 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15029 | json_object *json) | |
d62a17ae | 15030 | { |
15031 | struct listnode *node, *nnode; | |
15032 | struct prefix *range; | |
15033 | struct peer *conf; | |
15034 | struct peer *peer; | |
d62a17ae | 15035 | afi_t afi; |
15036 | safi_t safi; | |
15037 | const char *peer_status; | |
d62a17ae | 15038 | int lr_count; |
15039 | int dynamic; | |
6f4eacf3 DA |
15040 | bool af_cfgd; |
15041 | json_object *json_peer_group = NULL; | |
15042 | json_object *json_peer_group_afc = NULL; | |
15043 | json_object *json_peer_group_members = NULL; | |
15044 | json_object *json_peer_group_dynamic = NULL; | |
15045 | json_object *json_peer_group_dynamic_af = NULL; | |
15046 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15047 | |
15048 | conf = group->conf; | |
15049 | ||
6f4eacf3 DA |
15050 | if (json) { |
15051 | json_peer_group = json_object_new_object(); | |
15052 | json_peer_group_afc = json_object_new_array(); | |
15053 | } | |
15054 | ||
d62a17ae | 15055 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15056 | if (json) |
15057 | json_object_int_add(json_peer_group, "remoteAs", | |
15058 | conf->as); | |
15059 | else | |
15060 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15061 | group->name, conf->as); | |
d62a17ae | 15062 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15063 | if (json) |
15064 | json_object_int_add(json_peer_group, "remoteAs", | |
15065 | group->bgp->as); | |
15066 | else | |
15067 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15068 | group->name, group->bgp->as); | |
d62a17ae | 15069 | } else { |
6f4eacf3 DA |
15070 | if (!json) |
15071 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15072 | } |
f14e6fdb | 15073 | |
6f4eacf3 DA |
15074 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15075 | if (json) | |
15076 | json_object_string_add(json_peer_group, "type", | |
15077 | "internal"); | |
15078 | else | |
15079 | vty_out(vty, " Peer-group type is internal\n"); | |
15080 | } else { | |
15081 | if (json) | |
15082 | json_object_string_add(json_peer_group, "type", | |
15083 | "external"); | |
15084 | else | |
15085 | vty_out(vty, " Peer-group type is external\n"); | |
15086 | } | |
d62a17ae | 15087 | |
15088 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15089 | if (!json) |
15090 | vty_out(vty, " Configured address-families:"); | |
15091 | ||
05c7a1cc QY |
15092 | FOREACH_AFI_SAFI (afi, safi) { |
15093 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15094 | af_cfgd = true; |
15095 | if (json) | |
15096 | json_object_array_add( | |
15097 | json_peer_group_afc, | |
15098 | json_object_new_string(get_afi_safi_str( | |
15099 | afi, safi, false))); | |
15100 | else | |
15101 | vty_out(vty, " %s;", | |
15102 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15103 | } |
05c7a1cc | 15104 | } |
6f4eacf3 DA |
15105 | |
15106 | if (json) { | |
15107 | json_object_object_add(json_peer_group, | |
15108 | "addressFamiliesConfigured", | |
15109 | json_peer_group_afc); | |
15110 | } else { | |
15111 | if (!af_cfgd) | |
15112 | vty_out(vty, " none\n"); | |
15113 | else | |
15114 | vty_out(vty, "\n"); | |
15115 | } | |
d62a17ae | 15116 | |
15117 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15118 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15119 | lr_count = listcount(group->listen_range[afi]); |
15120 | if (lr_count) { | |
6f4eacf3 DA |
15121 | if (json) { |
15122 | if (!json_peer_group_dynamic) | |
15123 | json_peer_group_dynamic = | |
15124 | json_object_new_object(); | |
15125 | ||
15126 | json_peer_group_dynamic_af = | |
15127 | json_object_new_object(); | |
15128 | json_peer_group_ranges = | |
15129 | json_object_new_array(); | |
15130 | json_object_int_add(json_peer_group_dynamic_af, | |
15131 | "count", lr_count); | |
15132 | } else { | |
15133 | vty_out(vty, " %d %s listen range(s)\n", | |
15134 | lr_count, afi2str(afi)); | |
15135 | } | |
d62a17ae | 15136 | |
15137 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15138 | nnode, range)) { |
15139 | if (json) { | |
15140 | char buf[BUFSIZ]; | |
15141 | ||
15142 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15143 | range); | |
15144 | ||
15145 | json_object_array_add( | |
15146 | json_peer_group_ranges, | |
15147 | json_object_new_string(buf)); | |
15148 | } else { | |
15149 | vty_out(vty, " %pFX\n", range); | |
15150 | } | |
15151 | } | |
15152 | ||
15153 | if (json) { | |
15154 | json_object_object_add( | |
15155 | json_peer_group_dynamic_af, "ranges", | |
15156 | json_peer_group_ranges); | |
15157 | ||
15158 | json_object_object_add( | |
15159 | json_peer_group_dynamic, afi2str(afi), | |
15160 | json_peer_group_dynamic_af); | |
15161 | } | |
d62a17ae | 15162 | } |
15163 | } | |
f14e6fdb | 15164 | |
6f4eacf3 DA |
15165 | if (json_peer_group_dynamic) |
15166 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15167 | json_peer_group_dynamic); | |
15168 | ||
d62a17ae | 15169 | /* Display group members and their status */ |
15170 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15171 | if (json) |
15172 | json_peer_group_members = json_object_new_object(); | |
15173 | else | |
15174 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15175 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15176 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15177 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15178 | peer_status = "Idle (Admin)"; |
15179 | else if (CHECK_FLAG(peer->sflags, | |
15180 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15181 | peer_status = "Idle (PfxCt)"; | |
15182 | else | |
15183 | peer_status = lookup_msg(bgp_status_msg, | |
15184 | peer->status, NULL); | |
15185 | ||
15186 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15187 | |
15188 | if (json) { | |
15189 | json_object *json_peer_group_member = | |
15190 | json_object_new_object(); | |
15191 | ||
15192 | json_object_string_add(json_peer_group_member, | |
15193 | "status", peer_status); | |
15194 | ||
15195 | if (dynamic) | |
15196 | json_object_boolean_true_add( | |
15197 | json_peer_group_member, | |
15198 | "dynamic"); | |
15199 | ||
15200 | json_object_object_add(json_peer_group_members, | |
15201 | peer->host, | |
15202 | json_peer_group_member); | |
15203 | } else { | |
15204 | vty_out(vty, " %s %s %s \n", peer->host, | |
15205 | dynamic ? "(dynamic)" : "", | |
15206 | peer_status); | |
15207 | } | |
d62a17ae | 15208 | } |
6f4eacf3 DA |
15209 | if (json) |
15210 | json_object_object_add(json_peer_group, "members", | |
15211 | json_peer_group_members); | |
d62a17ae | 15212 | } |
f14e6fdb | 15213 | |
6f4eacf3 DA |
15214 | if (json) |
15215 | json_object_object_add(json, group->name, json_peer_group); | |
15216 | ||
d62a17ae | 15217 | return CMD_SUCCESS; |
15218 | } | |
15219 | ||
ff9959b0 | 15220 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15221 | const char *group_name, bool uj) |
d62a17ae | 15222 | { |
ff9959b0 | 15223 | struct bgp *bgp; |
d62a17ae | 15224 | struct listnode *node, *nnode; |
15225 | struct peer_group *group; | |
ff9959b0 | 15226 | bool found = false; |
6f4eacf3 DA |
15227 | json_object *json = NULL; |
15228 | ||
15229 | if (uj) | |
15230 | json = json_object_new_object(); | |
ff9959b0 QY |
15231 | |
15232 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15233 | ||
15234 | if (!bgp) { | |
c48349e3 | 15235 | if (uj) |
75eeda93 | 15236 | vty_json(vty, json); |
c48349e3 | 15237 | else |
6f4eacf3 | 15238 | vty_out(vty, "%% BGP instance not found\n"); |
6f4eacf3 | 15239 | |
ff9959b0 QY |
15240 | return CMD_WARNING; |
15241 | } | |
d62a17ae | 15242 | |
15243 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15244 | if (group_name) { |
15245 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15246 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15247 | found = true; |
15248 | break; | |
d62a17ae | 15249 | } |
ff9959b0 | 15250 | } else { |
6f4eacf3 | 15251 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15252 | } |
f14e6fdb | 15253 | } |
f14e6fdb | 15254 | |
6f4eacf3 | 15255 | if (group_name && !found && !uj) |
d62a17ae | 15256 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15257 | |
c48349e3 | 15258 | if (uj) |
75eeda93 | 15259 | vty_json(vty, json); |
6f4eacf3 | 15260 | |
d62a17ae | 15261 | return CMD_SUCCESS; |
f14e6fdb DS |
15262 | } |
15263 | ||
6f4eacf3 DA |
15264 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
15265 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15266 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15267 | "Detailed information on BGP peer groups\n" | |
15268 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 15269 | { |
d62a17ae | 15270 | char *vrf, *pg; |
d62a17ae | 15271 | int idx = 0; |
6f4eacf3 | 15272 | bool uj = use_json(argc, argv); |
f14e6fdb | 15273 | |
a4d82a8a PZ |
15274 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15275 | : NULL; | |
d62a17ae | 15276 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15277 | |
6f4eacf3 | 15278 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 15279 | } |
3f9c7369 | 15280 | |
d6e3c605 | 15281 | |
718e3744 | 15282 | /* Redistribute VTY commands. */ |
15283 | ||
585f1adc IR |
15284 | DEFUN (bgp_redistribute_ipv4, |
15285 | bgp_redistribute_ipv4_cmd, | |
15286 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15287 | "Redistribute information from another routing protocol\n" | |
15288 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15289 | { |
585f1adc | 15290 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15291 | int idx_protocol = 1; |
585f1adc | 15292 | int type; |
37a87b8f | 15293 | |
585f1adc IR |
15294 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15295 | if (type < 0) { | |
15296 | vty_out(vty, "%% Invalid route type\n"); | |
15297 | return CMD_WARNING_CONFIG_FAILED; | |
15298 | } | |
7f323236 | 15299 | |
585f1adc IR |
15300 | bgp_redist_add(bgp, AFI_IP, type, 0); |
15301 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 15302 | } |
15303 | ||
d62a17ae | 15304 | ALIAS_HIDDEN( |
15305 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15306 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15307 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15308 | |
585f1adc IR |
15309 | DEFUN (bgp_redistribute_ipv4_rmap, |
15310 | bgp_redistribute_ipv4_rmap_cmd, | |
15311 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15312 | "Redistribute information from another routing protocol\n" | |
15313 | FRR_IP_REDIST_HELP_STR_BGPD | |
15314 | "Route map reference\n" | |
15315 | "Pointer to route-map entries\n") | |
718e3744 | 15316 | { |
585f1adc | 15317 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15318 | int idx_protocol = 1; |
15319 | int idx_word = 3; | |
585f1adc IR |
15320 | int type; |
15321 | struct bgp_redist *red; | |
15322 | bool changed; | |
15323 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
15324 | vty, argv[idx_word]->arg); | |
15325 | ||
15326 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15327 | if (type < 0) { | |
15328 | vty_out(vty, "%% Invalid route type\n"); | |
15329 | return CMD_WARNING_CONFIG_FAILED; | |
15330 | } | |
37a87b8f | 15331 | |
585f1adc IR |
15332 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15333 | changed = | |
15334 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15335 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 15336 | } |
15337 | ||
d62a17ae | 15338 | ALIAS_HIDDEN( |
15339 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15340 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15341 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15342 | "Route map reference\n" | |
15343 | "Pointer to route-map entries\n") | |
596c17ba | 15344 | |
585f1adc IR |
15345 | DEFUN (bgp_redistribute_ipv4_metric, |
15346 | bgp_redistribute_ipv4_metric_cmd, | |
15347 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15348 | "Redistribute information from another routing protocol\n" | |
15349 | FRR_IP_REDIST_HELP_STR_BGPD | |
15350 | "Metric for redistributed routes\n" | |
15351 | "Default metric\n") | |
718e3744 | 15352 | { |
585f1adc | 15353 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15354 | int idx_protocol = 1; |
15355 | int idx_number = 3; | |
585f1adc IR |
15356 | int type; |
15357 | uint32_t metric; | |
15358 | struct bgp_redist *red; | |
15359 | bool changed; | |
15360 | ||
15361 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15362 | if (type < 0) { | |
15363 | vty_out(vty, "%% Invalid route type\n"); | |
15364 | return CMD_WARNING_CONFIG_FAILED; | |
15365 | } | |
15366 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15367 | |
585f1adc IR |
15368 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15369 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15370 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15371 | } |
15372 | ||
15373 | ALIAS_HIDDEN( | |
15374 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15375 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15376 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15377 | "Metric for redistributed routes\n" | |
15378 | "Default metric\n") | |
596c17ba | 15379 | |
585f1adc IR |
15380 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
15381 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15382 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15383 | "Redistribute information from another routing protocol\n" | |
15384 | FRR_IP_REDIST_HELP_STR_BGPD | |
15385 | "Route map reference\n" | |
15386 | "Pointer to route-map entries\n" | |
15387 | "Metric for redistributed routes\n" | |
15388 | "Default metric\n") | |
718e3744 | 15389 | { |
585f1adc | 15390 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15391 | int idx_protocol = 1; |
15392 | int idx_word = 3; | |
15393 | int idx_number = 5; | |
585f1adc IR |
15394 | int type; |
15395 | uint32_t metric; | |
15396 | struct bgp_redist *red; | |
15397 | bool changed; | |
15398 | struct route_map *route_map = | |
15399 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15400 | ||
15401 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15402 | if (type < 0) { | |
15403 | vty_out(vty, "%% Invalid route type\n"); | |
15404 | return CMD_WARNING_CONFIG_FAILED; | |
15405 | } | |
15406 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15407 | |
585f1adc IR |
15408 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15409 | changed = | |
15410 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15411 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15412 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15413 | } |
15414 | ||
15415 | ALIAS_HIDDEN( | |
15416 | bgp_redistribute_ipv4_rmap_metric, | |
15417 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15418 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15419 | " route-map WORD metric (0-4294967295)", | |
15420 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15421 | "Route map reference\n" | |
15422 | "Pointer to route-map entries\n" | |
15423 | "Metric for redistributed routes\n" | |
15424 | "Default metric\n") | |
596c17ba | 15425 | |
585f1adc IR |
15426 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
15427 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15428 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15429 | "Redistribute information from another routing protocol\n" | |
15430 | FRR_IP_REDIST_HELP_STR_BGPD | |
15431 | "Metric for redistributed routes\n" | |
15432 | "Default metric\n" | |
15433 | "Route map reference\n" | |
15434 | "Pointer to route-map entries\n") | |
718e3744 | 15435 | { |
585f1adc | 15436 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15437 | int idx_protocol = 1; |
37a87b8f | 15438 | int idx_number = 3; |
585f1adc IR |
15439 | int idx_word = 5; |
15440 | int type; | |
15441 | uint32_t metric; | |
15442 | struct bgp_redist *red; | |
15443 | bool changed; | |
15444 | struct route_map *route_map = | |
15445 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15446 | ||
15447 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15448 | if (type < 0) { | |
15449 | vty_out(vty, "%% Invalid route type\n"); | |
15450 | return CMD_WARNING_CONFIG_FAILED; | |
15451 | } | |
15452 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15453 | |
585f1adc IR |
15454 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15455 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15456 | changed |= | |
15457 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15458 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15459 | } |
15460 | ||
15461 | ALIAS_HIDDEN( | |
15462 | bgp_redistribute_ipv4_metric_rmap, | |
15463 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15464 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15465 | " metric (0-4294967295) route-map WORD", | |
15466 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15467 | "Metric for redistributed routes\n" | |
15468 | "Default metric\n" | |
15469 | "Route map reference\n" | |
15470 | "Pointer to route-map entries\n") | |
596c17ba | 15471 | |
585f1adc IR |
15472 | DEFUN (bgp_redistribute_ipv4_ospf, |
15473 | bgp_redistribute_ipv4_ospf_cmd, | |
15474 | "redistribute <ospf|table> (1-65535)", | |
15475 | "Redistribute information from another routing protocol\n" | |
15476 | "Open Shortest Path First (OSPFv2)\n" | |
15477 | "Non-main Kernel Routing Table\n" | |
15478 | "Instance ID/Table ID\n") | |
7c8ff89e | 15479 | { |
585f1adc IR |
15480 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15481 | int idx_ospf_table = 1; | |
d62a17ae | 15482 | int idx_number = 2; |
585f1adc IR |
15483 | unsigned short instance; |
15484 | unsigned short protocol; | |
7c8ff89e | 15485 | |
585f1adc | 15486 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 15487 | |
585f1adc IR |
15488 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15489 | protocol = ZEBRA_ROUTE_OSPF; | |
15490 | else | |
15491 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 15492 | |
585f1adc IR |
15493 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15494 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
15495 | } |
15496 | ||
d62a17ae | 15497 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15498 | "redistribute <ospf|table> (1-65535)", | |
15499 | "Redistribute information from another routing protocol\n" | |
15500 | "Open Shortest Path First (OSPFv2)\n" | |
15501 | "Non-main Kernel Routing Table\n" | |
15502 | "Instance ID/Table ID\n") | |
596c17ba | 15503 | |
585f1adc IR |
15504 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
15505 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15506 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15507 | "Redistribute information from another routing protocol\n" | |
15508 | "Open Shortest Path First (OSPFv2)\n" | |
15509 | "Non-main Kernel Routing Table\n" | |
15510 | "Instance ID/Table ID\n" | |
15511 | "Route map reference\n" | |
15512 | "Pointer to route-map entries\n") | |
7c8ff89e | 15513 | { |
585f1adc IR |
15514 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15515 | int idx_ospf_table = 1; | |
d62a17ae | 15516 | int idx_number = 2; |
15517 | int idx_word = 4; | |
585f1adc IR |
15518 | struct bgp_redist *red; |
15519 | unsigned short instance; | |
15520 | int protocol; | |
15521 | bool changed; | |
15522 | struct route_map *route_map = | |
15523 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15524 | ||
15525 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15526 | protocol = ZEBRA_ROUTE_OSPF; | |
15527 | else | |
15528 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15529 | |
585f1adc IR |
15530 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15531 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15532 | changed = | |
15533 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15534 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15535 | } |
15536 | ||
15537 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15538 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15539 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15540 | "Redistribute information from another routing protocol\n" | |
15541 | "Open Shortest Path First (OSPFv2)\n" | |
15542 | "Non-main Kernel Routing Table\n" | |
15543 | "Instance ID/Table ID\n" | |
15544 | "Route map reference\n" | |
15545 | "Pointer to route-map entries\n") | |
596c17ba | 15546 | |
585f1adc IR |
15547 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
15548 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15549 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15550 | "Redistribute information from another routing protocol\n" | |
15551 | "Open Shortest Path First (OSPFv2)\n" | |
15552 | "Non-main Kernel Routing Table\n" | |
15553 | "Instance ID/Table ID\n" | |
15554 | "Metric for redistributed routes\n" | |
15555 | "Default metric\n") | |
7c8ff89e | 15556 | { |
585f1adc IR |
15557 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15558 | int idx_ospf_table = 1; | |
d62a17ae | 15559 | int idx_number = 2; |
15560 | int idx_number_2 = 4; | |
585f1adc IR |
15561 | uint32_t metric; |
15562 | struct bgp_redist *red; | |
15563 | unsigned short instance; | |
15564 | int protocol; | |
15565 | bool changed; | |
15566 | ||
15567 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15568 | protocol = ZEBRA_ROUTE_OSPF; | |
15569 | else | |
15570 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15571 | |
585f1adc IR |
15572 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15573 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15574 | |
585f1adc IR |
15575 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15576 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15577 | metric); | |
15578 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15579 | } |
15580 | ||
15581 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15582 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15583 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15584 | "Redistribute information from another routing protocol\n" | |
15585 | "Open Shortest Path First (OSPFv2)\n" | |
15586 | "Non-main Kernel Routing Table\n" | |
15587 | "Instance ID/Table ID\n" | |
15588 | "Metric for redistributed routes\n" | |
15589 | "Default metric\n") | |
596c17ba | 15590 | |
585f1adc IR |
15591 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
15592 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15593 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15594 | "Redistribute information from another routing protocol\n" | |
15595 | "Open Shortest Path First (OSPFv2)\n" | |
15596 | "Non-main Kernel Routing Table\n" | |
15597 | "Instance ID/Table ID\n" | |
15598 | "Route map reference\n" | |
15599 | "Pointer to route-map entries\n" | |
15600 | "Metric for redistributed routes\n" | |
15601 | "Default metric\n") | |
7c8ff89e | 15602 | { |
585f1adc IR |
15603 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15604 | int idx_ospf_table = 1; | |
d62a17ae | 15605 | int idx_number = 2; |
15606 | int idx_word = 4; | |
15607 | int idx_number_2 = 6; | |
585f1adc IR |
15608 | uint32_t metric; |
15609 | struct bgp_redist *red; | |
15610 | unsigned short instance; | |
15611 | int protocol; | |
15612 | bool changed; | |
15613 | struct route_map *route_map = | |
15614 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15615 | ||
15616 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15617 | protocol = ZEBRA_ROUTE_OSPF; | |
15618 | else | |
15619 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15620 | |
585f1adc IR |
15621 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15622 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15623 | |
585f1adc IR |
15624 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15625 | changed = | |
15626 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15627 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15628 | metric); | |
15629 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15630 | } |
15631 | ||
15632 | ALIAS_HIDDEN( | |
15633 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15634 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15635 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15636 | "Redistribute information from another routing protocol\n" | |
15637 | "Open Shortest Path First (OSPFv2)\n" | |
15638 | "Non-main Kernel Routing Table\n" | |
15639 | "Instance ID/Table ID\n" | |
15640 | "Route map reference\n" | |
15641 | "Pointer to route-map entries\n" | |
15642 | "Metric for redistributed routes\n" | |
15643 | "Default metric\n") | |
596c17ba | 15644 | |
585f1adc IR |
15645 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
15646 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15647 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15648 | "Redistribute information from another routing protocol\n" | |
15649 | "Open Shortest Path First (OSPFv2)\n" | |
15650 | "Non-main Kernel Routing Table\n" | |
15651 | "Instance ID/Table ID\n" | |
15652 | "Metric for redistributed routes\n" | |
15653 | "Default metric\n" | |
15654 | "Route map reference\n" | |
15655 | "Pointer to route-map entries\n") | |
7c8ff89e | 15656 | { |
585f1adc IR |
15657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15658 | int idx_ospf_table = 1; | |
d62a17ae | 15659 | int idx_number = 2; |
15660 | int idx_number_2 = 4; | |
15661 | int idx_word = 6; | |
585f1adc IR |
15662 | uint32_t metric; |
15663 | struct bgp_redist *red; | |
15664 | unsigned short instance; | |
15665 | int protocol; | |
15666 | bool changed; | |
15667 | struct route_map *route_map = | |
15668 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15669 | ||
15670 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15671 | protocol = ZEBRA_ROUTE_OSPF; | |
15672 | else | |
15673 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15674 | |
585f1adc IR |
15675 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15676 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15677 | |
585f1adc IR |
15678 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15679 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15680 | metric); | |
15681 | changed |= | |
15682 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15683 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15684 | } |
15685 | ||
15686 | ALIAS_HIDDEN( | |
15687 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15688 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15689 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15690 | "Redistribute information from another routing protocol\n" | |
15691 | "Open Shortest Path First (OSPFv2)\n" | |
15692 | "Non-main Kernel Routing Table\n" | |
15693 | "Instance ID/Table ID\n" | |
15694 | "Metric for redistributed routes\n" | |
15695 | "Default metric\n" | |
15696 | "Route map reference\n" | |
15697 | "Pointer to route-map entries\n") | |
596c17ba | 15698 | |
585f1adc IR |
15699 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
15700 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15701 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15702 | NO_STR | |
15703 | "Redistribute information from another routing protocol\n" | |
15704 | "Open Shortest Path First (OSPFv2)\n" | |
15705 | "Non-main Kernel Routing Table\n" | |
15706 | "Instance ID/Table ID\n" | |
15707 | "Metric for redistributed routes\n" | |
15708 | "Default metric\n" | |
15709 | "Route map reference\n" | |
15710 | "Pointer to route-map entries\n") | |
7c8ff89e | 15711 | { |
585f1adc IR |
15712 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15713 | int idx_ospf_table = 2; | |
d62a17ae | 15714 | int idx_number = 3; |
585f1adc IR |
15715 | unsigned short instance; |
15716 | int protocol; | |
37a87b8f | 15717 | |
585f1adc IR |
15718 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15719 | protocol = ZEBRA_ROUTE_OSPF; | |
15720 | else | |
15721 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15722 | |
585f1adc IR |
15723 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15724 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 15725 | } |
15726 | ||
15727 | ALIAS_HIDDEN( | |
15728 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15729 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15730 | NO_STR |
15731 | "Redistribute information from another routing protocol\n" | |
15732 | "Open Shortest Path First (OSPFv2)\n" | |
15733 | "Non-main Kernel Routing Table\n" | |
15734 | "Instance ID/Table ID\n" | |
15735 | "Metric for redistributed routes\n" | |
15736 | "Default metric\n" | |
15737 | "Route map reference\n" | |
15738 | "Pointer to route-map entries\n") | |
596c17ba | 15739 | |
585f1adc IR |
15740 | DEFUN (no_bgp_redistribute_ipv4, |
15741 | no_bgp_redistribute_ipv4_cmd, | |
15742 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15743 | NO_STR | |
15744 | "Redistribute information from another routing protocol\n" | |
15745 | FRR_IP_REDIST_HELP_STR_BGPD | |
15746 | "Metric for redistributed routes\n" | |
15747 | "Default metric\n" | |
15748 | "Route map reference\n" | |
15749 | "Pointer to route-map entries\n") | |
718e3744 | 15750 | { |
585f1adc | 15751 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15752 | int idx_protocol = 2; |
585f1adc | 15753 | int type; |
d62a17ae | 15754 | |
585f1adc IR |
15755 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15756 | if (type < 0) { | |
15757 | vty_out(vty, "%% Invalid route type\n"); | |
15758 | return CMD_WARNING_CONFIG_FAILED; | |
15759 | } | |
15760 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 15761 | } |
15762 | ||
15763 | ALIAS_HIDDEN( | |
15764 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15765 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15766 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15767 | NO_STR |
15768 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15769 | "Metric for redistributed routes\n" | |
15770 | "Default metric\n" | |
15771 | "Route map reference\n" | |
15772 | "Pointer to route-map entries\n") | |
596c17ba | 15773 | |
585f1adc IR |
15774 | DEFUN (bgp_redistribute_ipv6, |
15775 | bgp_redistribute_ipv6_cmd, | |
15776 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15777 | "Redistribute information from another routing protocol\n" | |
15778 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15779 | { |
585f1adc | 15780 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15781 | int idx_protocol = 1; |
585f1adc | 15782 | int type; |
718e3744 | 15783 | |
585f1adc IR |
15784 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15785 | if (type < 0) { | |
15786 | vty_out(vty, "%% Invalid route type\n"); | |
15787 | return CMD_WARNING_CONFIG_FAILED; | |
15788 | } | |
718e3744 | 15789 | |
585f1adc IR |
15790 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
15791 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 15792 | } |
15793 | ||
585f1adc IR |
15794 | DEFUN (bgp_redistribute_ipv6_rmap, |
15795 | bgp_redistribute_ipv6_rmap_cmd, | |
15796 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15797 | "Redistribute information from another routing protocol\n" | |
15798 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15799 | "Route map reference\n" | |
15800 | "Pointer to route-map entries\n") | |
718e3744 | 15801 | { |
585f1adc | 15802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15803 | int idx_protocol = 1; |
15804 | int idx_word = 3; | |
585f1adc IR |
15805 | int type; |
15806 | struct bgp_redist *red; | |
15807 | bool changed; | |
15808 | struct route_map *route_map = | |
15809 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15810 | ||
15811 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15812 | if (type < 0) { | |
15813 | vty_out(vty, "%% Invalid route type\n"); | |
15814 | return CMD_WARNING_CONFIG_FAILED; | |
15815 | } | |
37a87b8f | 15816 | |
585f1adc IR |
15817 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15818 | changed = | |
15819 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15820 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15821 | } |
15822 | ||
585f1adc | 15823 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 15824 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 15825 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 15826 | "Redistribute information from another routing protocol\n" |
ab0181ee | 15827 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 15828 | "Metric for redistributed routes\n" |
15829 | "Default metric\n") | |
15830 | { | |
585f1adc | 15831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15832 | int idx_protocol = 1; |
15833 | int idx_number = 3; | |
585f1adc IR |
15834 | int type; |
15835 | uint32_t metric; | |
15836 | struct bgp_redist *red; | |
15837 | bool changed; | |
15838 | ||
15839 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15840 | if (type < 0) { | |
15841 | vty_out(vty, "%% Invalid route type\n"); | |
15842 | return CMD_WARNING_CONFIG_FAILED; | |
15843 | } | |
15844 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15845 | |
585f1adc IR |
15846 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15847 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
15848 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15849 | } |
15850 | ||
585f1adc IR |
15851 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
15852 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15853 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15854 | "Redistribute information from another routing protocol\n" | |
15855 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15856 | "Route map reference\n" | |
15857 | "Pointer to route-map entries\n" | |
15858 | "Metric for redistributed routes\n" | |
15859 | "Default metric\n") | |
718e3744 | 15860 | { |
585f1adc | 15861 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15862 | int idx_protocol = 1; |
15863 | int idx_word = 3; | |
15864 | int idx_number = 5; | |
585f1adc IR |
15865 | int type; |
15866 | uint32_t metric; | |
15867 | struct bgp_redist *red; | |
15868 | bool changed; | |
15869 | struct route_map *route_map = | |
15870 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15871 | ||
15872 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15873 | if (type < 0) { | |
15874 | vty_out(vty, "%% Invalid route type\n"); | |
15875 | return CMD_WARNING_CONFIG_FAILED; | |
15876 | } | |
15877 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15878 | |
585f1adc IR |
15879 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15880 | changed = | |
15881 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15882 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
15883 | metric); | |
15884 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15885 | } |
15886 | ||
585f1adc IR |
15887 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
15888 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15889 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15890 | "Redistribute information from another routing protocol\n" | |
15891 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15892 | "Metric for redistributed routes\n" | |
15893 | "Default metric\n" | |
15894 | "Route map reference\n" | |
15895 | "Pointer to route-map entries\n") | |
718e3744 | 15896 | { |
585f1adc | 15897 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15898 | int idx_protocol = 1; |
37a87b8f | 15899 | int idx_number = 3; |
585f1adc IR |
15900 | int idx_word = 5; |
15901 | int type; | |
15902 | uint32_t metric; | |
15903 | struct bgp_redist *red; | |
15904 | bool changed; | |
15905 | struct route_map *route_map = | |
15906 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15907 | ||
15908 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15909 | if (type < 0) { | |
15910 | vty_out(vty, "%% Invalid route type\n"); | |
15911 | return CMD_WARNING_CONFIG_FAILED; | |
15912 | } | |
15913 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15914 | |
585f1adc IR |
15915 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15916 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
15917 | metric); | |
15918 | changed |= | |
15919 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15920 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15921 | } |
15922 | ||
585f1adc IR |
15923 | DEFUN (no_bgp_redistribute_ipv6, |
15924 | no_bgp_redistribute_ipv6_cmd, | |
15925 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15926 | NO_STR | |
15927 | "Redistribute information from another routing protocol\n" | |
15928 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15929 | "Metric for redistributed routes\n" | |
15930 | "Default metric\n" | |
15931 | "Route map reference\n" | |
15932 | "Pointer to route-map entries\n") | |
718e3744 | 15933 | { |
585f1adc | 15934 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15935 | int idx_protocol = 2; |
585f1adc | 15936 | int type; |
37a87b8f | 15937 | |
585f1adc IR |
15938 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15939 | if (type < 0) { | |
15940 | vty_out(vty, "%% Invalid route type\n"); | |
15941 | return CMD_WARNING_CONFIG_FAILED; | |
15942 | } | |
718e3744 | 15943 | |
585f1adc | 15944 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 15945 | } |
15946 | ||
4ab46701 AR |
15947 | /* Neighbor update tcp-mss. */ |
15948 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
15949 | const char *tcp_mss_str) | |
15950 | { | |
15951 | struct peer *peer; | |
15952 | uint32_t tcp_mss_val = 0; | |
15953 | ||
15954 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
15955 | if (!peer) | |
15956 | return CMD_WARNING_CONFIG_FAILED; | |
15957 | ||
15958 | if (tcp_mss_str) { | |
15959 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
15960 | peer_tcp_mss_set(peer, tcp_mss_val); | |
15961 | } else { | |
15962 | peer_tcp_mss_unset(peer); | |
15963 | } | |
15964 | ||
15965 | return CMD_SUCCESS; | |
15966 | } | |
15967 | ||
15968 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
15969 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
15970 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
15971 | "TCP max segment size\n" | |
15972 | "TCP MSS value\n") | |
15973 | { | |
15974 | int peer_index = 1; | |
15975 | int mss_index = 3; | |
15976 | ||
15977 | vty_out(vty, | |
15978 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
15979 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
15980 | argv[mss_index]->arg); | |
15981 | } | |
15982 | ||
15983 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
15984 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
15985 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
15986 | "TCP max segment size\n" | |
15987 | "TCP MSS value\n") | |
15988 | { | |
15989 | int peer_index = 2; | |
15990 | ||
15991 | vty_out(vty, | |
15992 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
15993 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
15994 | } | |
15995 | ||
dd65f45e DL |
15996 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15997 | afi_t afi, safi_t safi) | |
d62a17ae | 15998 | { |
15999 | int i; | |
16000 | ||
16001 | /* Unicast redistribution only. */ | |
16002 | if (safi != SAFI_UNICAST) | |
2b791107 | 16003 | return; |
d62a17ae | 16004 | |
16005 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16006 | /* Redistribute BGP does not make sense. */ | |
16007 | if (i != ZEBRA_ROUTE_BGP) { | |
16008 | struct list *red_list; | |
16009 | struct listnode *node; | |
16010 | struct bgp_redist *red; | |
16011 | ||
16012 | red_list = bgp->redist[afi][i]; | |
16013 | if (!red_list) | |
16014 | continue; | |
16015 | ||
16016 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16017 | /* "redistribute" configuration. */ |
16018 | vty_out(vty, " redistribute %s", | |
16019 | zebra_route_string(i)); | |
16020 | if (red->instance) | |
16021 | vty_out(vty, " %d", red->instance); | |
16022 | if (red->redist_metric_flag) | |
16023 | vty_out(vty, " metric %u", | |
16024 | red->redist_metric); | |
16025 | if (red->rmap.name) | |
16026 | vty_out(vty, " route-map %s", | |
16027 | red->rmap.name); | |
16028 | vty_out(vty, "\n"); | |
16029 | } | |
16030 | } | |
16031 | } | |
718e3744 | 16032 | } |
6b0655a2 | 16033 | |
dd65f45e DL |
16034 | /* peer-group helpers for config-write */ |
16035 | ||
16036 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16037 | { | |
16038 | if (!peer_group_active(peer)) { | |
16039 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16040 | return !CHECK_FLAG(peer->flags, flag); | |
16041 | else | |
16042 | return !!CHECK_FLAG(peer->flags, flag); | |
16043 | } | |
16044 | ||
16045 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16046 | } | |
16047 | ||
16048 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16049 | uint32_t flag) | |
16050 | { | |
16051 | if (!peer_group_active(peer)) { | |
16052 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16053 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16054 | else | |
16055 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16056 | } | |
16057 | ||
16058 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16059 | } | |
16060 | ||
16061 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16062 | uint8_t type, int direct) | |
16063 | { | |
16064 | struct bgp_filter *filter; | |
16065 | ||
16066 | if (peer_group_active(peer)) | |
16067 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16068 | type); | |
16069 | ||
16070 | filter = &peer->filter[afi][safi]; | |
16071 | switch (type) { | |
16072 | case PEER_FT_DISTRIBUTE_LIST: | |
16073 | return !!(filter->dlist[direct].name); | |
16074 | case PEER_FT_FILTER_LIST: | |
16075 | return !!(filter->aslist[direct].name); | |
16076 | case PEER_FT_PREFIX_LIST: | |
16077 | return !!(filter->plist[direct].name); | |
16078 | case PEER_FT_ROUTE_MAP: | |
16079 | return !!(filter->map[direct].name); | |
16080 | case PEER_FT_UNSUPPRESS_MAP: | |
16081 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16082 | case PEER_FT_ADVERTISE_MAP: |
16083 | return !!(filter->advmap.aname | |
16084 | && ((filter->advmap.condition == direct) | |
16085 | && filter->advmap.cname)); | |
dd65f45e DL |
16086 | default: |
16087 | return false; | |
16088 | } | |
16089 | } | |
16090 | ||
16091 | /* Return true if the addpath type is set for peer and different from | |
16092 | * peer-group. | |
16093 | */ | |
3dc339cd DA |
16094 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16095 | safi_t safi) | |
dd65f45e DL |
16096 | { |
16097 | enum bgp_addpath_strat type, g_type; | |
16098 | ||
16099 | type = peer->addpath_type[afi][safi]; | |
16100 | ||
16101 | if (type != BGP_ADDPATH_NONE) { | |
16102 | if (peer_group_active(peer)) { | |
16103 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16104 | ||
16105 | if (type != g_type) | |
3dc339cd | 16106 | return true; |
dd65f45e | 16107 | else |
3dc339cd | 16108 | return false; |
dd65f45e DL |
16109 | } |
16110 | ||
3dc339cd | 16111 | return true; |
dd65f45e DL |
16112 | } |
16113 | ||
3dc339cd | 16114 | return false; |
dd65f45e DL |
16115 | } |
16116 | ||
b9c7bc5a | 16117 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16118 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16119 | afi_t afi) |
16120 | { | |
b9c7bc5a | 16121 | int indent = 2; |
53970de3 | 16122 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16123 | |
8a066a70 | 16124 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16125 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16126 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16127 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16128 | bgp->vpn_policy[afi] | |
bb4f6190 | 16129 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16130 | else |
16131 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16132 | bgp->vpn_policy[afi] | |
16133 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16134 | } | |
12a844a5 DS |
16135 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16136 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16137 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16138 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16139 | return; | |
16140 | ||
e70e9f8e PZ |
16141 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16142 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16143 | ||
16144 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16145 | ||
16146 | } else { | |
16147 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16148 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16149 | bgp->vpn_policy[afi].tovpn_label); | |
16150 | } | |
ddb5b488 | 16151 | } |
53970de3 RS |
16152 | |
16153 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16154 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16155 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16156 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16157 | } else if (tovpn_sid_index != 0) { | |
16158 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16159 | tovpn_sid_index); | |
16160 | } | |
16161 | ||
ddb5b488 PZ |
16162 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16163 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16164 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16165 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16166 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16167 | sizeof(buf))); | |
16168 | } | |
16169 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16170 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16171 | ||
16172 | char buf[PREFIX_STRLEN]; | |
16173 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16174 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16175 | sizeof(buf))) { | |
16176 | ||
b9c7bc5a PZ |
16177 | vty_out(vty, "%*snexthop vpn export %s\n", |
16178 | indent, "", buf); | |
ddb5b488 PZ |
16179 | } |
16180 | } | |
16181 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16182 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16183 | && ecommunity_cmp( | |
16184 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16185 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16186 | ||
16187 | char *b = ecommunity_ecom2str( | |
16188 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16189 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16190 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16191 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16192 | } else { | |
16193 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16194 | char *b = ecommunity_ecom2str( | |
16195 | bgp->vpn_policy[afi] | |
16196 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16197 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16198 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16199 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16200 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16201 | } | |
16202 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16203 | char *b = ecommunity_ecom2str( | |
16204 | bgp->vpn_policy[afi] | |
16205 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16206 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16207 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16208 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16209 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16210 | } | |
16211 | } | |
bb4f6190 DS |
16212 | |
16213 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16214 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16215 | bgp->vpn_policy[afi] |
16216 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16217 | |
301ad80a PG |
16218 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16219 | char *b = ecommunity_ecom2str( | |
16220 | bgp->vpn_policy[afi] | |
16221 | .import_redirect_rtlist, | |
16222 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16223 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16224 | |
9a659715 PG |
16225 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16226 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16227 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16228 | indent, "", b); |
16229 | else | |
16230 | vty_out(vty, "%*srt redirect import %s\n", | |
16231 | indent, "", b); | |
301ad80a PG |
16232 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16233 | } | |
ddb5b488 PZ |
16234 | } |
16235 | ||
dd65f45e DL |
16236 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16237 | afi_t afi, safi_t safi) | |
16238 | { | |
16239 | struct bgp_filter *filter; | |
16240 | char *addr; | |
16241 | ||
16242 | addr = peer->host; | |
16243 | filter = &peer->filter[afi][safi]; | |
16244 | ||
16245 | /* distribute-list. */ | |
16246 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16247 | FILTER_IN)) | |
16248 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16249 | filter->dlist[FILTER_IN].name); | |
16250 | ||
16251 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16252 | FILTER_OUT)) | |
16253 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16254 | filter->dlist[FILTER_OUT].name); | |
16255 | ||
16256 | /* prefix-list. */ | |
16257 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16258 | FILTER_IN)) | |
16259 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16260 | filter->plist[FILTER_IN].name); | |
16261 | ||
16262 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16263 | FILTER_OUT)) | |
16264 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16265 | filter->plist[FILTER_OUT].name); | |
16266 | ||
16267 | /* route-map. */ | |
16268 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16269 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16270 | filter->map[RMAP_IN].name); | |
16271 | ||
16272 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16273 | RMAP_OUT)) | |
16274 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16275 | filter->map[RMAP_OUT].name); | |
16276 | ||
16277 | /* unsuppress-map */ | |
16278 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16279 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16280 | filter->usmap.name); | |
16281 | ||
7f7940e6 MK |
16282 | /* advertise-map : always applied in OUT direction*/ |
16283 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16284 | CONDITION_NON_EXIST)) | |
16285 | vty_out(vty, | |
16286 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16287 | addr, filter->advmap.aname, filter->advmap.cname); | |
16288 | ||
16289 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16290 | CONDITION_EXIST)) | |
16291 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16292 | addr, filter->advmap.aname, filter->advmap.cname); | |
16293 | ||
dd65f45e DL |
16294 | /* filter-list. */ |
16295 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16296 | FILTER_IN)) | |
16297 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16298 | filter->aslist[FILTER_IN].name); | |
16299 | ||
16300 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16301 | FILTER_OUT)) | |
16302 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16303 | filter->aslist[FILTER_OUT].name); | |
16304 | } | |
16305 | ||
16306 | /* BGP peer configuration display function. */ | |
16307 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16308 | struct peer *peer) | |
16309 | { | |
16310 | struct peer *g_peer = NULL; | |
16311 | char buf[SU_ADDRSTRLEN]; | |
16312 | char *addr; | |
16313 | int if_pg_printed = false; | |
16314 | int if_ras_printed = false; | |
16315 | ||
16316 | /* Skip dynamic neighbors. */ | |
16317 | if (peer_dynamic_neighbor(peer)) | |
16318 | return; | |
16319 | ||
16320 | if (peer->conf_if) | |
16321 | addr = peer->conf_if; | |
16322 | else | |
16323 | addr = peer->host; | |
16324 | ||
16325 | /************************************ | |
16326 | ****** Global to the neighbor ****** | |
16327 | ************************************/ | |
16328 | if (peer->conf_if) { | |
16329 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16330 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16331 | else | |
16332 | vty_out(vty, " neighbor %s interface", addr); | |
16333 | ||
16334 | if (peer_group_active(peer)) { | |
16335 | vty_out(vty, " peer-group %s", peer->group->name); | |
16336 | if_pg_printed = true; | |
16337 | } else if (peer->as_type == AS_SPECIFIED) { | |
16338 | vty_out(vty, " remote-as %u", peer->as); | |
16339 | if_ras_printed = true; | |
16340 | } else if (peer->as_type == AS_INTERNAL) { | |
16341 | vty_out(vty, " remote-as internal"); | |
16342 | if_ras_printed = true; | |
16343 | } else if (peer->as_type == AS_EXTERNAL) { | |
16344 | vty_out(vty, " remote-as external"); | |
16345 | if_ras_printed = true; | |
16346 | } | |
16347 | ||
16348 | vty_out(vty, "\n"); | |
16349 | } | |
16350 | ||
16351 | /* remote-as and peer-group */ | |
16352 | /* peer is a member of a peer-group */ | |
16353 | if (peer_group_active(peer)) { | |
16354 | g_peer = peer->group->conf; | |
16355 | ||
16356 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16357 | if (peer->as_type == AS_SPECIFIED) { | |
16358 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16359 | addr, peer->as); | |
16360 | } else if (peer->as_type == AS_INTERNAL) { | |
16361 | vty_out(vty, | |
16362 | " neighbor %s remote-as internal\n", | |
16363 | addr); | |
16364 | } else if (peer->as_type == AS_EXTERNAL) { | |
16365 | vty_out(vty, | |
16366 | " neighbor %s remote-as external\n", | |
16367 | addr); | |
16368 | } | |
16369 | } | |
16370 | ||
16371 | /* For swpX peers we displayed the peer-group | |
16372 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16373 | if (!if_pg_printed) | |
16374 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16375 | peer->group->name); | |
16376 | } | |
16377 | ||
16378 | /* peer is NOT a member of a peer-group */ | |
16379 | else { | |
16380 | /* peer is a peer-group, declare the peer-group */ | |
16381 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16382 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16383 | } | |
16384 | ||
16385 | if (!if_ras_printed) { | |
16386 | if (peer->as_type == AS_SPECIFIED) { | |
16387 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16388 | addr, peer->as); | |
16389 | } else if (peer->as_type == AS_INTERNAL) { | |
16390 | vty_out(vty, | |
16391 | " neighbor %s remote-as internal\n", | |
16392 | addr); | |
16393 | } else if (peer->as_type == AS_EXTERNAL) { | |
16394 | vty_out(vty, | |
16395 | " neighbor %s remote-as external\n", | |
16396 | addr); | |
16397 | } | |
16398 | } | |
16399 | } | |
16400 | ||
16401 | /* local-as */ | |
16402 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16403 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16404 | peer->change_local_as); | |
16405 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16406 | vty_out(vty, " no-prepend"); | |
16407 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16408 | vty_out(vty, " replace-as"); | |
16409 | vty_out(vty, "\n"); | |
16410 | } | |
16411 | ||
16412 | /* description */ | |
16413 | if (peer->desc) { | |
16414 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16415 | } | |
16416 | ||
16417 | /* shutdown */ | |
16418 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16419 | if (peer->tx_shutdown_message) | |
16420 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16421 | peer->tx_shutdown_message); | |
16422 | else | |
16423 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16424 | } | |
16425 | ||
8336c896 DA |
16426 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16427 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16428 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16429 | ||
dd65f45e | 16430 | /* bfd */ |
21bfce98 RZ |
16431 | if (peer->bfd_config) |
16432 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
16433 | |
16434 | /* password */ | |
16435 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16436 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16437 | peer->password); | |
16438 | ||
16439 | /* neighbor solo */ | |
16440 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16441 | if (!peer_group_active(peer)) { | |
16442 | vty_out(vty, " neighbor %s solo\n", addr); | |
16443 | } | |
16444 | } | |
16445 | ||
16446 | /* BGP port */ | |
16447 | if (peer->port != BGP_PORT_DEFAULT) { | |
16448 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16449 | } | |
16450 | ||
16451 | /* Local interface name */ | |
16452 | if (peer->ifname) { | |
16453 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16454 | } | |
16455 | ||
4ab46701 AR |
16456 | /* TCP max segment size */ |
16457 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
16458 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
16459 | ||
dd65f45e DL |
16460 | /* passive */ |
16461 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16462 | vty_out(vty, " neighbor %s passive\n", addr); | |
16463 | ||
16464 | /* ebgp-multihop */ | |
16465 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16466 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16467 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16468 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16469 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16470 | peer->ttl); | |
16471 | } | |
16472 | } | |
16473 | ||
16474 | /* ttl-security hops */ | |
e2521429 | 16475 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16476 | if (!peer_group_active(peer) |
16477 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16478 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16479 | addr, peer->gtsm_hops); | |
16480 | } | |
16481 | } | |
16482 | ||
16483 | /* disable-connected-check */ | |
16484 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16485 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16486 | ||
27aa23a4 DA |
16487 | /* link-bw-encoding-ieee */ |
16488 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
16489 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
16490 | addr); | |
16491 | ||
d08c0c80 DA |
16492 | /* extended-optional-parameters */ |
16493 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
16494 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
16495 | addr); | |
16496 | ||
dd65f45e DL |
16497 | /* enforce-first-as */ |
16498 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16499 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16500 | ||
16501 | /* update-source */ | |
16502 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16503 | if (peer->update_source) | |
16504 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16505 | sockunion2str(peer->update_source, buf, | |
16506 | SU_ADDRSTRLEN)); | |
16507 | else if (peer->update_if) | |
16508 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16509 | peer->update_if); | |
16510 | } | |
16511 | ||
16512 | /* advertisement-interval */ | |
16513 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16514 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16515 | peer->routeadv); | |
16516 | ||
16517 | /* timers */ | |
16518 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16519 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16520 | peer->keepalive, peer->holdtime); | |
16521 | ||
16522 | /* timers connect */ | |
16523 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16524 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16525 | peer->connect); | |
5d5393b9 DL |
16526 | /* need special-case handling for changed default values due to |
16527 | * config profile / version (because there is no "timers bgp connect" | |
16528 | * command, we need to save this per-peer :/) | |
16529 | */ | |
16530 | else if (!peer_group_active(peer) && !peer->connect && | |
16531 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16532 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16533 | peer->bgp->default_connect_retry); | |
dd65f45e | 16534 | |
d43114f3 DS |
16535 | /* timers delayopen */ |
16536 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16537 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16538 | peer->delayopen); | |
16539 | /* Save config even though flag is not set if default values have been | |
16540 | * changed | |
16541 | */ | |
16542 | else if (!peer_group_active(peer) && !peer->delayopen | |
16543 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16544 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16545 | peer->bgp->default_delayopen); | |
16546 | ||
dd65f45e DL |
16547 | /* capability dynamic */ |
16548 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16549 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16550 | ||
16551 | /* capability extended-nexthop */ | |
16552 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
843770f6 DA |
16553 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) |
16554 | vty_out(vty, | |
16555 | " no neighbor %s capability extended-nexthop\n", | |
16556 | addr); | |
16557 | else if (!peer->conf_if) | |
16558 | vty_out(vty, | |
16559 | " neighbor %s capability extended-nexthop\n", | |
16560 | addr); | |
dd65f45e DL |
16561 | } |
16562 | ||
16563 | /* dont-capability-negotiation */ | |
16564 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16565 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16566 | ||
16567 | /* override-capability */ | |
16568 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16569 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16570 | ||
16571 | /* strict-capability-match */ | |
16572 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16573 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16574 | ||
16575 | /* Sender side AS path loop detection. */ | |
16576 | if (peer->as_path_loop_detection) | |
16577 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16578 | addr); | |
cfd47646 | 16579 | |
16580 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16581 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16582 | |
16583 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16584 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16585 | vty_out(vty, |
16586 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16587 | } else if (CHECK_FLAG( |
16588 | peer->peer_gr_new_status_flag, | |
16589 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16590 | vty_out(vty, |
16591 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16592 | } else if ( |
16593 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16594 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16595 | && !(CHECK_FLAG( | |
16596 | peer->peer_gr_new_status_flag, | |
16597 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16598 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16599 | addr); | |
cfd47646 | 16600 | } |
16601 | } | |
dd65f45e DL |
16602 | } |
16603 | ||
16604 | /* BGP peer configuration display function. */ | |
16605 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16606 | struct peer *peer, afi_t afi, safi_t safi) | |
16607 | { | |
16608 | struct peer *g_peer = NULL; | |
16609 | char *addr; | |
16610 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16611 | ||
16612 | /* Skip dynamic neighbors. */ | |
16613 | if (peer_dynamic_neighbor(peer)) | |
16614 | return; | |
16615 | ||
16616 | if (peer->conf_if) | |
16617 | addr = peer->conf_if; | |
16618 | else | |
16619 | addr = peer->host; | |
16620 | ||
16621 | /************************************ | |
16622 | ****** Per AF to the neighbor ****** | |
16623 | ************************************/ | |
16624 | if (peer_group_active(peer)) { | |
16625 | g_peer = peer->group->conf; | |
16626 | ||
16627 | /* If the peer-group is active but peer is not, print a 'no | |
16628 | * activate' */ | |
16629 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16630 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16631 | } | |
16632 | ||
16633 | /* If the peer-group is not active but peer is, print an | |
16634 | 'activate' */ | |
16635 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16636 | vty_out(vty, " neighbor %s activate\n", addr); | |
16637 | } | |
16638 | } else { | |
16639 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
16640 | if (safi == SAFI_ENCAP) |
16641 | vty_out(vty, " neighbor %s activate\n", addr); | |
16642 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
16643 | vty_out(vty, " neighbor %s activate\n", addr); |
16644 | } else { | |
38d11af5 TA |
16645 | if (bgp->default_af[afi][safi]) |
16646 | vty_out(vty, " no neighbor %s activate\n", | |
16647 | addr); | |
dd65f45e DL |
16648 | } |
16649 | } | |
16650 | ||
16651 | /* addpath TX knobs */ | |
16652 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16653 | switch (peer->addpath_type[afi][safi]) { | |
16654 | case BGP_ADDPATH_ALL: | |
16655 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16656 | addr); | |
16657 | break; | |
16658 | case BGP_ADDPATH_BEST_PER_AS: | |
16659 | vty_out(vty, | |
16660 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16661 | addr); | |
16662 | break; | |
16663 | case BGP_ADDPATH_MAX: | |
16664 | case BGP_ADDPATH_NONE: | |
16665 | break; | |
16666 | } | |
16667 | } | |
16668 | ||
7c0e4312 DA |
16669 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
16670 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
16671 | ||
dd65f45e DL |
16672 | /* ORF capability. */ |
16673 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16674 | || peergroup_af_flag_check(peer, afi, safi, | |
16675 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16676 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16677 | ||
16678 | if (peergroup_af_flag_check(peer, afi, safi, | |
16679 | PEER_FLAG_ORF_PREFIX_SM) | |
16680 | && peergroup_af_flag_check(peer, afi, safi, | |
16681 | PEER_FLAG_ORF_PREFIX_RM)) | |
16682 | vty_out(vty, " both"); | |
16683 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16684 | PEER_FLAG_ORF_PREFIX_SM)) | |
16685 | vty_out(vty, " send"); | |
16686 | else | |
16687 | vty_out(vty, " receive"); | |
16688 | vty_out(vty, "\n"); | |
16689 | } | |
16690 | ||
dd65f45e DL |
16691 | /* Route reflector client. */ |
16692 | if (peergroup_af_flag_check(peer, afi, safi, | |
16693 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16694 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16695 | } | |
16696 | ||
16697 | /* next-hop-self force */ | |
16698 | if (peergroup_af_flag_check(peer, afi, safi, | |
16699 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16700 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16701 | } | |
16702 | ||
16703 | /* next-hop-self */ | |
16704 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16705 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16706 | } | |
16707 | ||
16708 | /* remove-private-AS */ | |
16709 | if (peergroup_af_flag_check(peer, afi, safi, | |
16710 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16711 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16712 | addr); | |
16713 | } | |
16714 | ||
16715 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16716 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16717 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16718 | addr); | |
16719 | } | |
16720 | ||
16721 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16722 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16723 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16724 | } | |
16725 | ||
16726 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16727 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16728 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16729 | } | |
16730 | ||
16731 | /* as-override */ | |
16732 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16733 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16734 | } | |
16735 | ||
16736 | /* send-community print. */ | |
16737 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16738 | PEER_FLAG_SEND_COMMUNITY); | |
16739 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16740 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16741 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16742 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16743 | ||
16744 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16745 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16746 | } else { | |
16747 | if (flag_scomm) | |
16748 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16749 | if (flag_secomm) | |
16750 | vty_out(vty, | |
16751 | " no neighbor %s send-community extended\n", | |
16752 | addr); | |
16753 | ||
16754 | if (flag_slcomm) | |
16755 | vty_out(vty, " no neighbor %s send-community large\n", | |
16756 | addr); | |
16757 | } | |
16758 | ||
16759 | /* Default information */ | |
16760 | if (peergroup_af_flag_check(peer, afi, safi, | |
16761 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16762 | vty_out(vty, " neighbor %s default-originate", addr); | |
16763 | ||
16764 | if (peer->default_rmap[afi][safi].name) | |
16765 | vty_out(vty, " route-map %s", | |
16766 | peer->default_rmap[afi][safi].name); | |
16767 | ||
16768 | vty_out(vty, "\n"); | |
16769 | } | |
16770 | ||
16771 | /* Soft reconfiguration inbound. */ | |
16772 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16773 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16774 | addr); | |
16775 | } | |
16776 | ||
16777 | /* maximum-prefix. */ | |
16778 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16779 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16780 | peer->pmax[afi][safi]); |
16781 | ||
16782 | if (peer->pmax_threshold[afi][safi] | |
16783 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16784 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16785 | if (peer_af_flag_check(peer, afi, safi, | |
16786 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16787 | vty_out(vty, " warning-only"); | |
16788 | if (peer->pmax_restart[afi][safi]) | |
16789 | vty_out(vty, " restart %u", | |
16790 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16791 | if (peer_af_flag_check(peer, afi, safi, |
16792 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16793 | vty_out(vty, " force"); | |
dd65f45e DL |
16794 | |
16795 | vty_out(vty, "\n"); | |
16796 | } | |
16797 | ||
fde246e8 DA |
16798 | /* maximum-prefix-out */ |
16799 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16800 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16801 | addr, peer->pmax_out[afi][safi]); |
16802 | ||
dd65f45e DL |
16803 | /* Route server client. */ |
16804 | if (peergroup_af_flag_check(peer, afi, safi, | |
16805 | PEER_FLAG_RSERVER_CLIENT)) { | |
16806 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16807 | } | |
16808 | ||
16809 | /* Nexthop-local unchanged. */ | |
16810 | if (peergroup_af_flag_check(peer, afi, safi, | |
16811 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16812 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16813 | } | |
16814 | ||
16815 | /* allowas-in <1-10> */ | |
16816 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16817 | if (peer_af_flag_check(peer, afi, safi, | |
16818 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16819 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16820 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16821 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16822 | } else { | |
16823 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16824 | peer->allowas_in[afi][safi]); | |
16825 | } | |
16826 | } | |
16827 | ||
16828 | /* weight */ | |
16829 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16830 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16831 | peer->weight[afi][safi]); | |
16832 | ||
16833 | /* Filter. */ | |
16834 | bgp_config_write_filter(vty, peer, afi, safi); | |
16835 | ||
16836 | /* atribute-unchanged. */ | |
16837 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16838 | || (safi != SAFI_EVPN | |
16839 | && peer_af_flag_check(peer, afi, safi, | |
16840 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16841 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16842 | ||
16843 | if (!peer_group_active(peer) | |
16844 | || peergroup_af_flag_check(peer, afi, safi, | |
16845 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16846 | || peergroup_af_flag_check(peer, afi, safi, | |
16847 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16848 | || peergroup_af_flag_check(peer, afi, safi, | |
16849 | PEER_FLAG_MED_UNCHANGED)) { | |
16850 | ||
16851 | vty_out(vty, | |
16852 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16853 | addr, | |
16854 | peer_af_flag_check(peer, afi, safi, | |
16855 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16856 | ? " as-path" | |
16857 | : "", | |
16858 | peer_af_flag_check(peer, afi, safi, | |
16859 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16860 | ? " next-hop" | |
16861 | : "", | |
16862 | peer_af_flag_check(peer, afi, safi, | |
16863 | PEER_FLAG_MED_UNCHANGED) | |
16864 | ? " med" | |
16865 | : ""); | |
16866 | } | |
16867 | } | |
16868 | } | |
16869 | ||
16870 | /* Address family based peer configuration display. */ | |
16871 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16872 | safi_t safi) | |
16873 | { | |
16874 | struct peer *peer; | |
16875 | struct peer_group *group; | |
16876 | struct listnode *node, *nnode; | |
16877 | ||
16878 | ||
16879 | vty_frame(vty, " !\n address-family "); | |
16880 | if (afi == AFI_IP) { | |
16881 | if (safi == SAFI_UNICAST) | |
16882 | vty_frame(vty, "ipv4 unicast"); | |
16883 | else if (safi == SAFI_LABELED_UNICAST) | |
16884 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16885 | else if (safi == SAFI_MULTICAST) | |
16886 | vty_frame(vty, "ipv4 multicast"); | |
16887 | else if (safi == SAFI_MPLS_VPN) | |
16888 | vty_frame(vty, "ipv4 vpn"); | |
16889 | else if (safi == SAFI_ENCAP) | |
16890 | vty_frame(vty, "ipv4 encap"); | |
16891 | else if (safi == SAFI_FLOWSPEC) | |
16892 | vty_frame(vty, "ipv4 flowspec"); | |
16893 | } else if (afi == AFI_IP6) { | |
16894 | if (safi == SAFI_UNICAST) | |
16895 | vty_frame(vty, "ipv6 unicast"); | |
16896 | else if (safi == SAFI_LABELED_UNICAST) | |
16897 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16898 | else if (safi == SAFI_MULTICAST) | |
16899 | vty_frame(vty, "ipv6 multicast"); | |
16900 | else if (safi == SAFI_MPLS_VPN) | |
16901 | vty_frame(vty, "ipv6 vpn"); | |
16902 | else if (safi == SAFI_ENCAP) | |
16903 | vty_frame(vty, "ipv6 encap"); | |
16904 | else if (safi == SAFI_FLOWSPEC) | |
16905 | vty_frame(vty, "ipv6 flowspec"); | |
16906 | } else if (afi == AFI_L2VPN) { | |
16907 | if (safi == SAFI_EVPN) | |
16908 | vty_frame(vty, "l2vpn evpn"); | |
16909 | } | |
16910 | vty_frame(vty, "\n"); | |
16911 | ||
16912 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16913 | ||
16914 | bgp_config_write_network(vty, bgp, afi, safi); | |
16915 | ||
16916 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16917 | ||
8a4e7fe6 DA |
16918 | /* BGP flag dampening. */ |
16919 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 16920 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 16921 | |
dd65f45e DL |
16922 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
16923 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16924 | ||
16925 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
16926 | /* Do not display doppelganger peers */ |
16927 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16928 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
16929 | } | |
16930 | ||
16931 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
16932 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
16933 | ||
16934 | if (safi == SAFI_EVPN) | |
16935 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
16936 | ||
16937 | if (safi == SAFI_FLOWSPEC) | |
16938 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
16939 | ||
16940 | if (safi == SAFI_UNICAST) { | |
16941 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
16942 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16943 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
16944 | ||
16945 | vty_out(vty, " export vpn\n"); | |
16946 | } | |
16947 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16948 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
16949 | ||
16950 | vty_out(vty, " import vpn\n"); | |
16951 | } | |
16952 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
16953 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
16954 | char *name; | |
16955 | ||
16956 | for (ALL_LIST_ELEMENTS_RO( | |
16957 | bgp->vpn_policy[afi].import_vrf, node, | |
16958 | name)) | |
16959 | vty_out(vty, " import vrf %s\n", name); | |
16960 | } | |
16961 | } | |
16962 | ||
16963 | vty_endframe(vty, " exit-address-family\n"); | |
16964 | } | |
16965 | ||
16966 | int bgp_config_write(struct vty *vty) | |
16967 | { | |
16968 | struct bgp *bgp; | |
16969 | struct peer_group *group; | |
16970 | struct peer *peer; | |
16971 | struct listnode *node, *nnode; | |
16972 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
16973 | afi_t afi; |
16974 | safi_t safi; | |
dd65f45e DL |
16975 | |
16976 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
16977 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
16978 | bm->rmap_update_timer); | |
16979 | ||
d70583f7 D |
16980 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
16981 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
16982 | if (bm->v_update_delay != bm->v_establish_wait) | |
16983 | vty_out(vty, " %d", bm->v_establish_wait); | |
16984 | vty_out(vty, "\n"); | |
16985 | } | |
16986 | ||
9acb67cb DS |
16987 | if (bm->wait_for_fib) |
16988 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
16989 | ||
05bd726c | 16990 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
16991 | vty_out(vty, "bgp graceful-shutdown\n"); | |
16992 | ||
c163f297 DS |
16993 | /* No-RIB (Zebra) option flag configuration */ |
16994 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
16995 | vty_out(vty, "bgp no-rib\n"); | |
16996 | ||
ec0acb80 | 16997 | if (!CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
e46723a5 DS |
16998 | vty_out(vty, "no bgp send-extra-data zebra\n"); |
16999 | ||
dd65f45e DL |
17000 | /* BGP configuration. */ |
17001 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17002 | ||
17003 | /* skip all auto created vrf as they dont have user config */ | |
17004 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17005 | continue; | |
17006 | ||
17007 | /* Router bgp ASN */ | |
17008 | vty_out(vty, "router bgp %u", bgp->as); | |
17009 | ||
17010 | if (bgp->name) | |
17011 | vty_out(vty, " %s %s", | |
17012 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17013 | ? "view" : "vrf", bgp->name); | |
17014 | vty_out(vty, "\n"); | |
17015 | ||
17016 | /* BGP fast-external-failover. */ | |
17017 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17018 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17019 | ||
17020 | /* BGP router ID. */ | |
3a6290bd | 17021 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17022 | vty_out(vty, " bgp router-id %pI4\n", |
17023 | &bgp->router_id_static); | |
dd65f45e | 17024 | |
c208c586 S |
17025 | /* Suppress fib pending */ |
17026 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17027 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17028 | ||
dd65f45e | 17029 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17030 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17031 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17032 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17033 | CHECK_FLAG(bgp->flags, |
17034 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17035 | ? "" |
17036 | : "no "); | |
17037 | ||
17038 | /* BGP configuration. */ | |
892fedb6 | 17039 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17040 | vty_out(vty, " bgp always-compare-med\n"); |
17041 | ||
17042 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17043 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17044 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17045 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17046 | CHECK_FLAG(bgp->flags, | |
17047 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17048 | ? "" | |
17049 | : "no "); | |
dd65f45e DL |
17050 | |
17051 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17052 | if (bgp->reject_as_sets) |
dd65f45e DL |
17053 | vty_out(vty, " bgp reject-as-sets\n"); |
17054 | ||
2adac256 DA |
17055 | /* Suppress duplicate updates if the route actually not changed |
17056 | */ | |
17057 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17058 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17059 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17060 | CHECK_FLAG(bgp->flags, | |
17061 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17062 | ? "" | |
17063 | : "no "); | |
17064 | ||
b16bcbba TA |
17065 | /* BGP default <afi>-<safi> */ |
17066 | FOREACH_AFI_SAFI (afi, safi) { | |
17067 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17068 | if (!bgp->default_af[afi][safi]) | |
17069 | vty_out(vty, " no bgp default %s\n", | |
17070 | get_bgp_default_af_flag(afi, | |
17071 | safi)); | |
17072 | } else if (bgp->default_af[afi][safi]) | |
17073 | vty_out(vty, " bgp default %s\n", | |
17074 | get_bgp_default_af_flag(afi, safi)); | |
17075 | } | |
e84c59af | 17076 | |
dd65f45e DL |
17077 | /* BGP default local-preference. */ |
17078 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17079 | vty_out(vty, " bgp default local-preference %u\n", | |
17080 | bgp->default_local_pref); | |
17081 | ||
17082 | /* BGP default show-hostname */ | |
892fedb6 | 17083 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17084 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17085 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17086 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17087 | ? "" |
17088 | : "no "); | |
17089 | ||
aef999a2 DA |
17090 | /* BGP default show-nexthop-hostname */ |
17091 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17092 | != SAVE_BGP_SHOW_HOSTNAME) | |
17093 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17094 | CHECK_FLAG(bgp->flags, | |
17095 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17096 | ? "" | |
17097 | : "no "); | |
17098 | ||
dd65f45e DL |
17099 | /* BGP default subgroup-pkt-queue-max. */ |
17100 | if (bgp->default_subgroup_pkt_queue_max | |
17101 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17102 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17103 | bgp->default_subgroup_pkt_queue_max); | |
17104 | ||
17105 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17106 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17107 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17108 | ||
17109 | /* BGP cluster ID. */ | |
17110 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17111 | vty_out(vty, " bgp cluster-id %pI4\n", |
17112 | &bgp->cluster_id); | |
dd65f45e DL |
17113 | |
17114 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17115 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17116 | vty_out(vty, |
17117 | " bgp disable-ebgp-connected-route-check\n"); | |
17118 | ||
17119 | /* Confederation identifier*/ | |
17120 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17121 | vty_out(vty, " bgp confederation identifier %u\n", | |
17122 | bgp->confed_id); | |
17123 | ||
17124 | /* Confederation peer */ | |
17125 | if (bgp->confed_peers_cnt > 0) { | |
17126 | int i; | |
17127 | ||
17128 | vty_out(vty, " bgp confederation peers"); | |
17129 | ||
17130 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17131 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17132 | ||
17133 | vty_out(vty, "\n"); | |
17134 | } | |
17135 | ||
17136 | /* BGP deterministic-med. */ | |
892fedb6 | 17137 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17138 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17139 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17140 | CHECK_FLAG(bgp->flags, |
17141 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17142 | ? "" |
17143 | : "no "); | |
17144 | ||
17145 | /* BGP update-delay. */ | |
17146 | bgp_config_write_update_delay(vty, bgp); | |
17147 | ||
17148 | if (bgp->v_maxmed_onstartup | |
17149 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17150 | vty_out(vty, " bgp max-med on-startup %u", | |
17151 | bgp->v_maxmed_onstartup); | |
17152 | if (bgp->maxmed_onstartup_value | |
17153 | != BGP_MAXMED_VALUE_DEFAULT) | |
17154 | vty_out(vty, " %u", | |
17155 | bgp->maxmed_onstartup_value); | |
17156 | vty_out(vty, "\n"); | |
17157 | } | |
17158 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17159 | vty_out(vty, " bgp max-med administrative"); | |
17160 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17161 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17162 | vty_out(vty, "\n"); | |
17163 | } | |
17164 | ||
17165 | /* write quanta */ | |
17166 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17167 | /* read quanta */ | |
17168 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17169 | ||
17170 | /* coalesce time */ | |
17171 | bgp_config_write_coalesce_time(vty, bgp); | |
17172 | ||
05bd726c | 17173 | /* BGP per-instance graceful-shutdown */ |
17174 | /* BGP-wide settings and per-instance settings are mutually | |
17175 | * exclusive. | |
17176 | */ | |
17177 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17178 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17179 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17180 | ||
8606be87 DA |
17181 | /* Long-lived Graceful Restart */ |
17182 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
17183 | vty_out(vty, | |
17184 | " bgp long-lived-graceful-restart stale-time %u\n", | |
17185 | bgp->llgr_stale_time); | |
17186 | ||
dd65f45e DL |
17187 | /* BGP graceful-restart. */ |
17188 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17189 | vty_out(vty, | |
17190 | " bgp graceful-restart stalepath-time %u\n", | |
17191 | bgp->stalepath_time); | |
cfd47646 | 17192 | |
dd65f45e DL |
17193 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17194 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17195 | bgp->restart_time); | |
cfd47646 | 17196 | |
17197 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17198 | vty_out(vty, | |
17199 | " bgp graceful-restart select-defer-time %u\n", | |
17200 | bgp->select_defer_time); | |
17201 | ||
17202 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17203 | vty_out(vty, " bgp graceful-restart\n"); |
17204 | ||
cfd47646 | 17205 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17206 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17207 | ||
dd65f45e | 17208 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17209 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17210 | vty_out(vty, |
17211 | " bgp graceful-restart preserve-fw-state\n"); | |
17212 | ||
dc95985f | 17213 | /* Stale timer for RIB */ |
17214 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17215 | vty_out(vty, | |
17216 | " bgp graceful-restart rib-stale-time %u\n", | |
17217 | bgp->rib_stale_time); | |
17218 | ||
dd65f45e | 17219 | /* BGP bestpath method. */ |
892fedb6 | 17220 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17221 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17222 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17223 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17224 | ||
892fedb6 DA |
17225 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17226 | if (CHECK_FLAG(bgp->flags, | |
17227 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17228 | vty_out(vty, |
17229 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17230 | } else { | |
17231 | vty_out(vty, | |
17232 | " bgp bestpath as-path multipath-relax\n"); | |
17233 | } | |
17234 | } | |
17235 | ||
892fedb6 | 17236 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17237 | vty_out(vty, |
17238 | " bgp route-reflector allow-outbound-policy\n"); | |
17239 | } | |
892fedb6 | 17240 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17241 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17242 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17243 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17244 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17245 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17246 | vty_out(vty, " confed"); |
892fedb6 DA |
17247 | if (CHECK_FLAG(bgp->flags, |
17248 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17249 | vty_out(vty, " missing-as-worst"); |
17250 | vty_out(vty, "\n"); | |
17251 | } | |
17252 | ||
ee88563a JM |
17253 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
17254 | vty_out(vty, | |
17255 | " bgp bestpath peer-type multipath-relax\n"); | |
17256 | ||
f7e1c681 | 17257 | /* Link bandwidth handling. */ |
17258 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17259 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17260 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17261 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17262 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17263 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17264 | ||
dd65f45e | 17265 | /* BGP network import check. */ |
892fedb6 | 17266 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17267 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17268 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17269 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17270 | ? "" |
17271 | : "no "); | |
17272 | ||
17273 | /* BGP timers configuration. */ | |
5d5393b9 | 17274 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 17275 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
17276 | vty_out(vty, " timers bgp %u %u\n", |
17277 | bgp->default_keepalive, bgp->default_holdtime); | |
17278 | ||
b042667a TI |
17279 | /* BGP minimum holdtime configuration. */ |
17280 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
17281 | && bgp->default_min_holdtime != 0) | |
17282 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
17283 | bgp->default_min_holdtime); | |
17284 | ||
389e4f92 QY |
17285 | /* Conditional advertisement timer configuration */ |
17286 | if (bgp->condition_check_period | |
17287 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
17288 | vty_out(vty, | |
17289 | " bgp conditional-advertisement timer %u\n", | |
17290 | bgp->condition_check_period); | |
17291 | ||
dd65f45e DL |
17292 | /* peer-group */ |
17293 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17294 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17295 | } | |
17296 | ||
17297 | /* Normal neighbor configuration. */ | |
17298 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17299 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17300 | bgp_config_write_peer_global(vty, bgp, peer); | |
17301 | } | |
17302 | ||
17303 | /* listen range and limit for dynamic BGP neighbors */ | |
17304 | bgp_config_write_listen(vty, bgp); | |
17305 | ||
17306 | /* | |
17307 | * BGP default autoshutdown neighbors | |
17308 | * | |
17309 | * This must be placed after any peer and peer-group | |
17310 | * configuration, to avoid setting all peers to shutdown after | |
17311 | * a daemon restart, which is undesired behavior. (see #2286) | |
17312 | */ | |
17313 | if (bgp->autoshutdown) | |
17314 | vty_out(vty, " bgp default shutdown\n"); | |
17315 | ||
9cf59432 DS |
17316 | /* BGP instance administrative shutdown */ |
17317 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17318 | vty_out(vty, " bgp shutdown\n"); | |
17319 | ||
f852eb98 PG |
17320 | if (bgp->fast_convergence) |
17321 | vty_out(vty, " bgp fast-convergence\n"); | |
17322 | ||
a0281b2e HS |
17323 | if (bgp->srv6_enabled) { |
17324 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 17325 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
17326 | vty_out(vty, " locator %s\n", |
17327 | bgp->srv6_locator_name); | |
ff7c3ee1 | 17328 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
17329 | } |
17330 | ||
17331 | ||
dd65f45e DL |
17332 | /* IPv4 unicast configuration. */ |
17333 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17334 | ||
17335 | /* IPv4 multicast configuration. */ | |
17336 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17337 | ||
17338 | /* IPv4 labeled-unicast configuration. */ | |
17339 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17340 | ||
17341 | /* IPv4 VPN configuration. */ | |
17342 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17343 | ||
17344 | /* ENCAPv4 configuration. */ | |
17345 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17346 | ||
17347 | /* FLOWSPEC v4 configuration. */ | |
17348 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17349 | ||
17350 | /* IPv6 unicast configuration. */ | |
17351 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17352 | ||
17353 | /* IPv6 multicast configuration. */ | |
17354 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17355 | ||
17356 | /* IPv6 labeled-unicast configuration. */ | |
17357 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17358 | SAFI_LABELED_UNICAST); | |
17359 | ||
17360 | /* IPv6 VPN configuration. */ | |
17361 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17362 | ||
17363 | /* ENCAPv6 configuration. */ | |
17364 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17365 | ||
17366 | /* FLOWSPEC v6 configuration. */ | |
17367 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17368 | ||
17369 | /* EVPN configuration. */ | |
17370 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17371 | ||
17372 | hook_call(bgp_inst_config_write, bgp, vty); | |
17373 | ||
49e5a4a0 | 17374 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17375 | bgp_rfapi_cfg_write(vty, bgp); |
17376 | #endif | |
17377 | ||
07679ad9 | 17378 | vty_out(vty, "exit\n"); |
dd65f45e DL |
17379 | vty_out(vty, "!\n"); |
17380 | } | |
17381 | return 0; | |
17382 | } | |
17383 | ||
ddb5b488 | 17384 | |
718e3744 | 17385 | /* BGP node structure. */ |
d62a17ae | 17386 | static struct cmd_node bgp_node = { |
f4b8291f | 17387 | .name = "bgp", |
62b346ee | 17388 | .node = BGP_NODE, |
24389580 | 17389 | .parent_node = CONFIG_NODE, |
62b346ee | 17390 | .prompt = "%s(config-router)# ", |
612c2c15 | 17391 | .config_write = bgp_config_write, |
718e3744 | 17392 | }; |
17393 | ||
d62a17ae | 17394 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17395 | .name = "bgp ipv4 unicast", |
62b346ee | 17396 | .node = BGP_IPV4_NODE, |
24389580 | 17397 | .parent_node = BGP_NODE, |
62b346ee | 17398 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17399 | .no_xpath = true, |
718e3744 | 17400 | }; |
17401 | ||
d62a17ae | 17402 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17403 | .name = "bgp ipv4 multicast", |
62b346ee | 17404 | .node = BGP_IPV4M_NODE, |
24389580 | 17405 | .parent_node = BGP_NODE, |
62b346ee | 17406 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17407 | .no_xpath = true, |
718e3744 | 17408 | }; |
17409 | ||
d62a17ae | 17410 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17411 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17412 | .node = BGP_IPV4L_NODE, |
24389580 | 17413 | .parent_node = BGP_NODE, |
62b346ee | 17414 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17415 | .no_xpath = true, |
f51bae9c DS |
17416 | }; |
17417 | ||
d62a17ae | 17418 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 17419 | .name = "bgp ipv6 unicast", |
62b346ee | 17420 | .node = BGP_IPV6_NODE, |
24389580 | 17421 | .parent_node = BGP_NODE, |
62b346ee | 17422 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17423 | .no_xpath = true, |
718e3744 | 17424 | }; |
17425 | ||
d62a17ae | 17426 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17427 | .name = "bgp ipv6 multicast", |
62b346ee | 17428 | .node = BGP_IPV6M_NODE, |
24389580 | 17429 | .parent_node = BGP_NODE, |
62b346ee | 17430 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17431 | .no_xpath = true, |
25ffbdc1 | 17432 | }; |
17433 | ||
d62a17ae | 17434 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17435 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17436 | .node = BGP_IPV6L_NODE, |
24389580 | 17437 | .parent_node = BGP_NODE, |
62b346ee | 17438 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17439 | .no_xpath = true, |
f51bae9c DS |
17440 | }; |
17441 | ||
62b346ee | 17442 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17443 | .name = "bgp vpnv4", |
62b346ee | 17444 | .node = BGP_VPNV4_NODE, |
24389580 | 17445 | .parent_node = BGP_NODE, |
62b346ee | 17446 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17447 | .no_xpath = true, |
62b346ee | 17448 | }; |
6b0655a2 | 17449 | |
62b346ee | 17450 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17451 | .name = "bgp vpnv6", |
62b346ee | 17452 | .node = BGP_VPNV6_NODE, |
24389580 | 17453 | .parent_node = BGP_NODE, |
62b346ee | 17454 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 17455 | .no_xpath = true, |
62b346ee | 17456 | }; |
8ecd3266 | 17457 | |
62b346ee | 17458 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17459 | .name = "bgp evpn", |
62b346ee | 17460 | .node = BGP_EVPN_NODE, |
24389580 | 17461 | .parent_node = BGP_NODE, |
62b346ee | 17462 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 17463 | .no_xpath = true, |
62b346ee | 17464 | }; |
4e0b7b6d | 17465 | |
62b346ee | 17466 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17467 | .name = "bgp evpn vni", |
62b346ee | 17468 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17469 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17470 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17471 | }; |
90e60aa7 | 17472 | |
62b346ee | 17473 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17474 | .name = "bgp ipv4 flowspec", |
62b346ee | 17475 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17476 | .parent_node = BGP_NODE, |
62b346ee | 17477 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17478 | .no_xpath = true, |
62b346ee | 17479 | }; |
7c40bf39 | 17480 | |
62b346ee | 17481 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17482 | .name = "bgp ipv6 flowspec", |
62b346ee | 17483 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17484 | .parent_node = BGP_NODE, |
62b346ee | 17485 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 17486 | .no_xpath = true, |
62b346ee | 17487 | }; |
7c40bf39 | 17488 | |
bfaab44d HS |
17489 | static struct cmd_node bgp_srv6_node = { |
17490 | .name = "bgp srv6", | |
17491 | .node = BGP_SRV6_NODE, | |
17492 | .parent_node = BGP_NODE, | |
17493 | .prompt = "%s(config-router-srv6)# ", | |
17494 | }; | |
17495 | ||
d62a17ae | 17496 | static void community_list_vty(void); |
1f8ae70b | 17497 | |
8c20061f DA |
17498 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17499 | { | |
17500 | struct bgp *bgp; | |
17501 | struct peer_group *group; | |
17502 | struct listnode *lnbgp, *lnpeer; | |
17503 | ||
17504 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17505 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17506 | vector_set(comps, | |
17507 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
17508 | } | |
17509 | } | |
17510 | ||
17511 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
b8a815e5 | 17512 | { |
d62a17ae | 17513 | struct bgp *bgp; |
17514 | struct peer *peer; | |
d62a17ae | 17515 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17516 | |
d62a17ae | 17517 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17518 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17519 | /* only provide suggestions on the appropriate input | |
17520 | * token type, | |
17521 | * they'll otherwise show up multiple times */ | |
17522 | enum cmd_token_type match_type; | |
17523 | char *name = peer->host; | |
d48ed3e0 | 17524 | |
d62a17ae | 17525 | if (peer->conf_if) { |
17526 | match_type = VARIABLE_TKN; | |
17527 | name = peer->conf_if; | |
17528 | } else if (strchr(peer->host, ':')) | |
17529 | match_type = IPV6_TKN; | |
17530 | else | |
17531 | match_type = IPV4_TKN; | |
d48ed3e0 | 17532 | |
d62a17ae | 17533 | if (token->type != match_type) |
17534 | continue; | |
d48ed3e0 | 17535 | |
d62a17ae | 17536 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17537 | } | |
d62a17ae | 17538 | } |
b8a815e5 DL |
17539 | } |
17540 | ||
8c20061f DA |
17541 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
17542 | { | |
17543 | bgp_ac_peer(comps, token); | |
84de1483 DA |
17544 | |
17545 | if (token->type == VARIABLE_TKN) | |
17546 | bgp_ac_peergroup(comps, token); | |
8c20061f DA |
17547 | } |
17548 | ||
b8a815e5 | 17549 | static const struct cmd_variable_handler bgp_var_neighbor[] = { |
d62a17ae | 17550 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17551 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17552 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17553 | {.completions = NULL}}; |
17554 | ||
47a306a0 DS |
17555 | static const struct cmd_variable_handler bgp_var_peergroup[] = { |
17556 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17557 | {.completions = NULL} }; | |
17558 | ||
d62a17ae | 17559 | void bgp_vty_init(void) |
17560 | { | |
17561 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17562 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17563 | |
17564 | /* Install bgp top node. */ | |
612c2c15 DL |
17565 | install_node(&bgp_node); |
17566 | install_node(&bgp_ipv4_unicast_node); | |
17567 | install_node(&bgp_ipv4_multicast_node); | |
17568 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17569 | install_node(&bgp_ipv6_unicast_node); | |
17570 | install_node(&bgp_ipv6_multicast_node); | |
17571 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17572 | install_node(&bgp_vpnv4_node); | |
17573 | install_node(&bgp_vpnv6_node); | |
17574 | install_node(&bgp_evpn_node); | |
17575 | install_node(&bgp_evpn_vni_node); | |
17576 | install_node(&bgp_flowspecv4_node); | |
17577 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 17578 | install_node(&bgp_srv6_node); |
d62a17ae | 17579 | |
17580 | /* Install default VTY commands to new nodes. */ | |
17581 | install_default(BGP_NODE); | |
17582 | install_default(BGP_IPV4_NODE); | |
17583 | install_default(BGP_IPV4M_NODE); | |
17584 | install_default(BGP_IPV4L_NODE); | |
17585 | install_default(BGP_IPV6_NODE); | |
17586 | install_default(BGP_IPV6M_NODE); | |
17587 | install_default(BGP_IPV6L_NODE); | |
17588 | install_default(BGP_VPNV4_NODE); | |
17589 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17590 | install_default(BGP_FLOWSPECV4_NODE); |
17591 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17592 | install_default(BGP_EVPN_NODE); |
17593 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 17594 | install_default(BGP_SRV6_NODE); |
d62a17ae | 17595 | |
8029b216 AK |
17596 | /* "bgp local-mac" hidden commands. */ |
17597 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17598 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17599 | ||
9acb67cb DS |
17600 | /* "bgp suppress-fib-pending" global */ |
17601 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17602 | ||
d62a17ae | 17603 | /* bgp route-map delay-timer commands. */ |
17604 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17605 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17606 | ||
f852eb98 PG |
17607 | /* bgp fast-convergence command */ |
17608 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
17609 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
17610 | ||
d70583f7 D |
17611 | /* global bgp update-delay command */ |
17612 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17613 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17614 | ||
05bd726c | 17615 | /* global bgp graceful-shutdown command */ |
17616 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17617 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17618 | ||
d62a17ae | 17619 | /* Dummy commands (Currently not supported) */ |
17620 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17621 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17622 | ||
17623 | /* "router bgp" commands. */ | |
17624 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17625 | ||
17626 | /* "no router bgp" commands. */ | |
17627 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17628 | ||
17629 | /* "bgp router-id" commands. */ | |
17630 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17631 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17632 | ||
c208c586 S |
17633 | /* "bgp suppress-fib-pending" command */ |
17634 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17635 | ||
d62a17ae | 17636 | /* "bgp cluster-id" commands. */ |
17637 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17638 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17639 | ||
c163f297 DS |
17640 | /* "bgp no-rib" commands. */ |
17641 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17642 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17643 | ||
e46723a5 DS |
17644 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
17645 | ||
d62a17ae | 17646 | /* "bgp confederation" commands. */ |
17647 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17648 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17649 | ||
17650 | /* "bgp confederation peers" commands. */ | |
17651 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17652 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17653 | ||
17654 | /* bgp max-med command */ | |
17655 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17656 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17657 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17658 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17659 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17660 | ||
17661 | /* bgp disable-ebgp-connected-nh-check */ | |
17662 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17663 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17664 | ||
17665 | /* bgp update-delay command */ | |
17666 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17667 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17668 | |
17669 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17670 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17671 | |
17672 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17673 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17674 | ||
17675 | /* "maximum-paths" commands. */ | |
17676 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17677 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17678 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17679 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17680 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17681 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17682 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17683 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17684 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17685 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17686 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17687 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17688 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17689 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17690 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17691 | ||
39edabac PG |
17692 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17693 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17694 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17695 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17696 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17697 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17698 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17699 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17700 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17701 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17702 | ||
17703 | /* "timers bgp" commands. */ | |
17704 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17705 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17706 | ||
b042667a TI |
17707 | /* "minimum-holdtime" commands. */ |
17708 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
17709 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
17710 | ||
d62a17ae | 17711 | /* route-map delay-timer commands - per instance for backwards compat. |
17712 | */ | |
17713 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17714 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17715 | ||
17716 | /* "bgp client-to-client reflection" commands */ | |
17717 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17718 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17719 | ||
17720 | /* "bgp always-compare-med" commands */ | |
17721 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17722 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17723 | ||
9dac9fc8 DA |
17724 | /* bgp ebgp-requires-policy */ |
17725 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17726 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17727 | ||
2adac256 DA |
17728 | /* bgp suppress-duplicates */ |
17729 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17730 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
17731 | ||
fb29348a DA |
17732 | /* bgp reject-as-sets */ |
17733 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17734 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17735 | ||
d62a17ae | 17736 | /* "bgp deterministic-med" commands */ |
17737 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17738 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17739 | ||
055679e9 | 17740 | /* "bgp graceful-restart" command */ |
36235319 QY |
17741 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17742 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17743 | |
17744 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17745 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17746 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17747 | |
17748 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17749 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17750 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17751 | |
17752 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17753 | install_element(BGP_NODE, | |
17754 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17755 | install_element(BGP_NODE, | |
17756 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17757 | ||
17758 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17759 | install_element(BGP_NODE, | |
17760 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17761 | install_element(BGP_NODE, | |
17762 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17763 | ||
d62a17ae | 17764 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17765 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17766 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17767 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17768 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17769 | install_element(BGP_NODE, |
17770 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17771 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17772 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17773 | ||
d6e3c15b | 17774 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17775 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17776 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17777 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17778 | |
7f323236 DW |
17779 | /* "bgp graceful-shutdown" commands */ |
17780 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17781 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17782 | ||
8606be87 DA |
17783 | /* "bgp long-lived-graceful-restart" commands */ |
17784 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
17785 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
17786 | ||
d62a17ae | 17787 | /* "bgp fast-external-failover" commands */ |
17788 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17789 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17790 | ||
d62a17ae | 17791 | /* "bgp bestpath compare-routerid" commands */ |
17792 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17793 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17794 | ||
17795 | /* "bgp bestpath as-path ignore" commands */ | |
17796 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17797 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17798 | ||
17799 | /* "bgp bestpath as-path confed" commands */ | |
17800 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17801 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17802 | ||
17803 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17804 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17805 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17806 | ||
ee88563a JM |
17807 | /* "bgp bestpath peer-type multipath-relax" commands */ |
17808 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
17809 | install_element(BGP_NODE, | |
17810 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
17811 | ||
d62a17ae | 17812 | /* "bgp log-neighbor-changes" commands */ |
17813 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17814 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17815 | ||
17816 | /* "bgp bestpath med" commands */ | |
17817 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17818 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17819 | ||
f7e1c681 | 17820 | /* "bgp bestpath bandwidth" commands */ |
17821 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17822 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17823 | |
b16bcbba TA |
17824 | /* "no bgp default <afi>-<safi>" commands. */ |
17825 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 17826 | |
d62a17ae | 17827 | /* "bgp network import-check" commands. */ |
17828 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17829 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17830 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17831 | ||
17832 | /* "bgp default local-preference" commands. */ | |
17833 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17834 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17835 | ||
17836 | /* bgp default show-hostname */ | |
17837 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17838 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17839 | ||
aef999a2 DA |
17840 | /* bgp default show-nexthop-hostname */ |
17841 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17842 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17843 | ||
d62a17ae | 17844 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17845 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17846 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17847 | ||
17848 | /* bgp ibgp-allow-policy-mods command */ | |
17849 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17850 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17851 | ||
17852 | /* "bgp listen limit" commands. */ | |
17853 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17854 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17855 | ||
17856 | /* "bgp listen range" commands. */ | |
17857 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17858 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17859 | ||
8175f54a | 17860 | /* "bgp default shutdown" command */ |
f26845f9 | 17861 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17862 | |
17863 | /* "bgp shutdown" commands */ | |
17864 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 17865 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 17866 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 17867 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 17868 | |
d62a17ae | 17869 | /* "neighbor remote-as" commands. */ |
17870 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17871 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17872 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17873 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17874 | install_element(BGP_NODE, | |
17875 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17876 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17877 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17878 | ||
17879 | /* "neighbor peer-group" commands. */ | |
17880 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17881 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17882 | install_element(BGP_NODE, | |
17883 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17884 | ||
17885 | /* "neighbor local-as" commands. */ | |
17886 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17887 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17888 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17889 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17890 | ||
17891 | /* "neighbor solo" commands. */ | |
17892 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17893 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17894 | ||
17895 | /* "neighbor password" commands. */ | |
17896 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17897 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17898 | ||
17899 | /* "neighbor activate" commands. */ | |
17900 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17901 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17902 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17903 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17904 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17905 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17906 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17907 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17908 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 17909 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
17910 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 17911 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
17912 | ||
17913 | /* "no neighbor activate" commands. */ | |
17914 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17915 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17916 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17917 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17918 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17919 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17920 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17921 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17922 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 17923 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
17924 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 17925 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
17926 | ||
17927 | /* "neighbor peer-group" set commands. */ | |
17928 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17929 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17930 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17931 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17932 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17933 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17934 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17935 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17936 | install_element(BGP_FLOWSPECV4_NODE, |
17937 | &neighbor_set_peer_group_hidden_cmd); | |
17938 | install_element(BGP_FLOWSPECV6_NODE, | |
17939 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17940 | |
17941 | /* "no neighbor peer-group unset" commands. */ | |
17942 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17943 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17944 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17945 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17946 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17947 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17948 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17949 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17950 | install_element(BGP_FLOWSPECV4_NODE, |
17951 | &no_neighbor_set_peer_group_hidden_cmd); | |
17952 | install_element(BGP_FLOWSPECV6_NODE, | |
17953 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17954 | |
17955 | /* "neighbor softreconfiguration inbound" commands.*/ | |
17956 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
17957 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
17958 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17959 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17960 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17961 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17962 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17963 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17964 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17965 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17966 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
17967 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17968 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
17969 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17970 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
17971 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
17972 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
17973 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 17974 | install_element(BGP_FLOWSPECV4_NODE, |
17975 | &neighbor_soft_reconfiguration_cmd); | |
17976 | install_element(BGP_FLOWSPECV4_NODE, | |
17977 | &no_neighbor_soft_reconfiguration_cmd); | |
17978 | install_element(BGP_FLOWSPECV6_NODE, | |
17979 | &neighbor_soft_reconfiguration_cmd); | |
17980 | install_element(BGP_FLOWSPECV6_NODE, | |
17981 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
17982 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
17983 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 17984 | |
17985 | /* "neighbor attribute-unchanged" commands. */ | |
17986 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
17987 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
17988 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
17989 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
17990 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
17991 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17992 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
17993 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
17994 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
17995 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
17996 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
17997 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
17998 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
17999 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18000 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18001 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18002 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18003 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18004 | ||
18005 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18006 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18007 | ||
b8ad84d2 PG |
18008 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
18009 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18010 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18011 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18012 | ||
d62a17ae | 18013 | /* "nexthop-local unchanged" commands */ |
18014 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18015 | install_element(BGP_IPV6_NODE, | |
18016 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18017 | ||
18018 | /* "neighbor next-hop-self" commands. */ | |
18019 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18020 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18021 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18022 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18023 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18024 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18025 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18026 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18027 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18028 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18029 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18030 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18031 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18032 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18033 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18034 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18035 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18036 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
18037 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
18038 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 18039 | |
18040 | /* "neighbor next-hop-self force" commands. */ | |
18041 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18042 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
18043 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18044 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18045 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
18046 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18047 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18048 | install_element(BGP_IPV4_NODE, | |
18049 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18050 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18051 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18052 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18053 | install_element(BGP_IPV4M_NODE, | |
18054 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18055 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18056 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18057 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18058 | install_element(BGP_IPV4L_NODE, | |
18059 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18060 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18061 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18062 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18063 | install_element(BGP_IPV6_NODE, | |
18064 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18065 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18066 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18067 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18068 | install_element(BGP_IPV6M_NODE, | |
18069 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18070 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18071 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18072 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18073 | install_element(BGP_IPV6L_NODE, | |
18074 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18075 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18076 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18077 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18078 | install_element(BGP_VPNV4_NODE, | |
18079 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18080 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18081 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18082 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18083 | install_element(BGP_VPNV6_NODE, | |
18084 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18085 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18086 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18087 | |
18088 | /* "neighbor as-override" commands. */ | |
18089 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18090 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18091 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18092 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18093 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18094 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18095 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18096 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18097 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18098 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18099 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18100 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18101 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18102 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18103 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18104 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18105 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18106 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18107 | ||
18108 | /* "neighbor remove-private-AS" commands. */ | |
18109 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18110 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18111 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18112 | install_element(BGP_NODE, | |
18113 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18114 | install_element(BGP_NODE, | |
18115 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18116 | install_element(BGP_NODE, | |
18117 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18118 | install_element(BGP_NODE, | |
18119 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18120 | install_element( | |
18121 | BGP_NODE, | |
18122 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18123 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18124 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18125 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18126 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18127 | install_element(BGP_IPV4_NODE, | |
18128 | &neighbor_remove_private_as_replace_as_cmd); | |
18129 | install_element(BGP_IPV4_NODE, | |
18130 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18131 | install_element(BGP_IPV4_NODE, | |
18132 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18133 | install_element(BGP_IPV4_NODE, | |
18134 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18135 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18136 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18137 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18138 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18139 | install_element(BGP_IPV4M_NODE, | |
18140 | &neighbor_remove_private_as_replace_as_cmd); | |
18141 | install_element(BGP_IPV4M_NODE, | |
18142 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18143 | install_element(BGP_IPV4M_NODE, | |
18144 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18145 | install_element(BGP_IPV4M_NODE, | |
18146 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18147 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18148 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18149 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18150 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18151 | install_element(BGP_IPV4L_NODE, | |
18152 | &neighbor_remove_private_as_replace_as_cmd); | |
18153 | install_element(BGP_IPV4L_NODE, | |
18154 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18155 | install_element(BGP_IPV4L_NODE, | |
18156 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18157 | install_element(BGP_IPV4L_NODE, | |
18158 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18159 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18160 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18161 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18162 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18163 | install_element(BGP_IPV6_NODE, | |
18164 | &neighbor_remove_private_as_replace_as_cmd); | |
18165 | install_element(BGP_IPV6_NODE, | |
18166 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18167 | install_element(BGP_IPV6_NODE, | |
18168 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18169 | install_element(BGP_IPV6_NODE, | |
18170 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18171 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18172 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18173 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18174 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18175 | install_element(BGP_IPV6M_NODE, | |
18176 | &neighbor_remove_private_as_replace_as_cmd); | |
18177 | install_element(BGP_IPV6M_NODE, | |
18178 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18179 | install_element(BGP_IPV6M_NODE, | |
18180 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18181 | install_element(BGP_IPV6M_NODE, | |
18182 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18183 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18184 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18185 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18186 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18187 | install_element(BGP_IPV6L_NODE, | |
18188 | &neighbor_remove_private_as_replace_as_cmd); | |
18189 | install_element(BGP_IPV6L_NODE, | |
18190 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18191 | install_element(BGP_IPV6L_NODE, | |
18192 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18193 | install_element(BGP_IPV6L_NODE, | |
18194 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18195 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18196 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18197 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18198 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18199 | install_element(BGP_VPNV4_NODE, | |
18200 | &neighbor_remove_private_as_replace_as_cmd); | |
18201 | install_element(BGP_VPNV4_NODE, | |
18202 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18203 | install_element(BGP_VPNV4_NODE, | |
18204 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18205 | install_element(BGP_VPNV4_NODE, | |
18206 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18207 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18208 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18209 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18210 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18211 | install_element(BGP_VPNV6_NODE, | |
18212 | &neighbor_remove_private_as_replace_as_cmd); | |
18213 | install_element(BGP_VPNV6_NODE, | |
18214 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18215 | install_element(BGP_VPNV6_NODE, | |
18216 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18217 | install_element(BGP_VPNV6_NODE, | |
18218 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18219 | ||
18220 | /* "neighbor send-community" commands.*/ | |
18221 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18222 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18223 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18224 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18225 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18226 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18227 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18228 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18229 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18230 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18231 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18232 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18233 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18234 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18235 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18236 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18237 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18238 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18239 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18240 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18241 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18242 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18243 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18244 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18245 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18246 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18247 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18248 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18249 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18250 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18251 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18252 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18253 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18254 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18255 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18256 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18257 | ||
18258 | /* "neighbor route-reflector" commands.*/ | |
18259 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18260 | install_element(BGP_NODE, | |
18261 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18262 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18263 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18264 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18265 | install_element(BGP_IPV4M_NODE, | |
18266 | &no_neighbor_route_reflector_client_cmd); | |
18267 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18268 | install_element(BGP_IPV4L_NODE, | |
18269 | &no_neighbor_route_reflector_client_cmd); | |
18270 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18271 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18272 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18273 | install_element(BGP_IPV6M_NODE, | |
18274 | &no_neighbor_route_reflector_client_cmd); | |
18275 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18276 | install_element(BGP_IPV6L_NODE, | |
18277 | &no_neighbor_route_reflector_client_cmd); | |
18278 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18279 | install_element(BGP_VPNV4_NODE, | |
18280 | &no_neighbor_route_reflector_client_cmd); | |
18281 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18282 | install_element(BGP_VPNV6_NODE, | |
18283 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18284 | install_element(BGP_FLOWSPECV4_NODE, |
18285 | &neighbor_route_reflector_client_cmd); | |
18286 | install_element(BGP_FLOWSPECV4_NODE, | |
18287 | &no_neighbor_route_reflector_client_cmd); | |
18288 | install_element(BGP_FLOWSPECV6_NODE, | |
18289 | &neighbor_route_reflector_client_cmd); | |
18290 | install_element(BGP_FLOWSPECV6_NODE, | |
18291 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18292 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18293 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18294 | ||
18295 | /* "neighbor route-server" commands.*/ | |
18296 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18297 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18298 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18299 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18300 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18301 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18302 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18303 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18304 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18305 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18306 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18307 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18308 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18309 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18310 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18311 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18312 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18313 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18314 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18315 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18316 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18317 | install_element(BGP_FLOWSPECV4_NODE, | |
18318 | &no_neighbor_route_server_client_cmd); | |
18319 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18320 | install_element(BGP_FLOWSPECV6_NODE, | |
18321 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18322 | |
7c0e4312 DA |
18323 | /* "neighbor disable-addpath-rx" commands. */ |
18324 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18325 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18326 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18327 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18328 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18329 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18330 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18331 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18332 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18333 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18334 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18335 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18336 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18337 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18338 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18339 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18340 | ||
d62a17ae | 18341 | /* "neighbor addpath-tx-all-paths" commands.*/ |
18342 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18343 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18344 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18345 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18346 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18347 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18348 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18349 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18350 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18351 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18352 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18353 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18354 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18355 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18356 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18357 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18358 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18359 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18360 | ||
18361 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18362 | install_element(BGP_NODE, | |
18363 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18364 | install_element(BGP_NODE, | |
18365 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18366 | install_element(BGP_IPV4_NODE, | |
18367 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18368 | install_element(BGP_IPV4_NODE, | |
18369 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18370 | install_element(BGP_IPV4M_NODE, | |
18371 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18372 | install_element(BGP_IPV4M_NODE, | |
18373 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18374 | install_element(BGP_IPV4L_NODE, | |
18375 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18376 | install_element(BGP_IPV4L_NODE, | |
18377 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18378 | install_element(BGP_IPV6_NODE, | |
18379 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18380 | install_element(BGP_IPV6_NODE, | |
18381 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18382 | install_element(BGP_IPV6M_NODE, | |
18383 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18384 | install_element(BGP_IPV6M_NODE, | |
18385 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18386 | install_element(BGP_IPV6L_NODE, | |
18387 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18388 | install_element(BGP_IPV6L_NODE, | |
18389 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18390 | install_element(BGP_VPNV4_NODE, | |
18391 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18392 | install_element(BGP_VPNV4_NODE, | |
18393 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18394 | install_element(BGP_VPNV6_NODE, | |
18395 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18396 | install_element(BGP_VPNV6_NODE, | |
18397 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18398 | ||
2b31007c RZ |
18399 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18400 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18401 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18402 | ||
d62a17ae | 18403 | /* "neighbor passive" commands. */ |
18404 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18405 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18406 | ||
18407 | ||
18408 | /* "neighbor shutdown" commands. */ | |
18409 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18410 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18411 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18412 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18413 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18414 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18415 | |
18416 | /* "neighbor capability extended-nexthop" commands.*/ | |
18417 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18418 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18419 | ||
18420 | /* "neighbor capability orf prefix-list" commands.*/ | |
18421 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18422 | install_element(BGP_NODE, | |
18423 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18424 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18425 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18426 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18427 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18428 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18429 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18430 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18431 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18432 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18433 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18434 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18435 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18436 | ||
18437 | /* "neighbor capability dynamic" commands.*/ | |
18438 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18439 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18440 | ||
18441 | /* "neighbor dont-capability-negotiate" commands. */ | |
18442 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18443 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18444 | ||
18445 | /* "neighbor ebgp-multihop" commands. */ | |
18446 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18447 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18448 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18449 | ||
18450 | /* "neighbor disable-connected-check" commands. */ | |
18451 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18452 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18453 | ||
7ab294ea DA |
18454 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
18455 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
18456 | install_element(BGP_NODE, | |
18457 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 18458 | |
d08c0c80 DA |
18459 | /* "neighbor extended-optional-parameters" commands. */ |
18460 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
18461 | install_element(BGP_NODE, | |
18462 | &no_neighbor_extended_optional_parameters_cmd); | |
18463 | ||
47cbc09b PM |
18464 | /* "neighbor enforce-first-as" commands. */ |
18465 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18466 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18467 | ||
d62a17ae | 18468 | /* "neighbor description" commands. */ |
18469 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18470 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18471 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18472 | |
18473 | /* "neighbor update-source" commands. "*/ | |
18474 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18475 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18476 | ||
18477 | /* "neighbor default-originate" commands. */ | |
18478 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18479 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18480 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18481 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18482 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18483 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18484 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18485 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18486 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18487 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18488 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18489 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18490 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18491 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18492 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18493 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18494 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18495 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18496 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18497 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18498 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18499 | ||
18500 | /* "neighbor port" commands. */ | |
18501 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18502 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18503 | ||
18504 | /* "neighbor weight" commands. */ | |
18505 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18506 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18507 | ||
18508 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18509 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18510 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18511 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18512 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18513 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18514 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18515 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18516 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18517 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18518 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18519 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18520 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18521 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18522 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18523 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18524 | ||
18525 | /* "neighbor override-capability" commands. */ | |
18526 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18527 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18528 | ||
18529 | /* "neighbor strict-capability-match" commands. */ | |
18530 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18531 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18532 | ||
18533 | /* "neighbor timers" commands. */ | |
18534 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18535 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18536 | ||
18537 | /* "neighbor timers connect" commands. */ | |
18538 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18539 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18540 | ||
d43114f3 DS |
18541 | /* "neighbor timers delayopen" commands. */ |
18542 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18543 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18544 | ||
d62a17ae | 18545 | /* "neighbor advertisement-interval" commands. */ |
18546 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18547 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18548 | ||
18549 | /* "neighbor interface" commands. */ | |
18550 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18551 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18552 | ||
18553 | /* "neighbor distribute" commands. */ | |
18554 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18555 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18556 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18557 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18558 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18559 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18560 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18561 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18562 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18563 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18564 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18565 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18566 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18567 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18568 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18569 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18570 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18571 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18572 | ||
18573 | /* "neighbor prefix-list" commands. */ | |
18574 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 18575 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 18576 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18577 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18578 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18579 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18580 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18581 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18582 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18583 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18584 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18585 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18586 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18587 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18588 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18589 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18590 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18591 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18592 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18593 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18594 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18595 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18596 | |
18597 | /* "neighbor filter-list" commands. */ | |
18598 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18599 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18600 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18601 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18602 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18603 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18604 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18605 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18606 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18607 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18608 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18609 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18610 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18611 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18612 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18613 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18614 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18615 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18616 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18617 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18618 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18619 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18620 | |
18621 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
18622 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
18623 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 18624 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18625 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18626 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18627 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18628 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18629 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18630 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18631 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18632 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18633 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18634 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18635 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18636 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18637 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18638 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18639 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18640 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18641 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18642 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18643 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 18644 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18645 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18646 | |
18647 | /* "neighbor unsuppress-map" commands. */ | |
18648 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18649 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18650 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18651 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18652 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18653 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18654 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18655 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18656 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18657 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18658 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18659 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18660 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18661 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18662 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18663 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18664 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18665 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18666 | ||
7f7940e6 | 18667 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 18668 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 18669 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 18670 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18671 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18672 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18673 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18674 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18675 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18676 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18677 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18678 | |
fde246e8 DA |
18679 | /* neighbor maximum-prefix-out commands. */ |
18680 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18681 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18682 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18683 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18684 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18685 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18686 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18687 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18688 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18689 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18690 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18691 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18692 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18693 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18694 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18695 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18696 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18697 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18698 | ||
d62a17ae | 18699 | /* "neighbor maximum-prefix" commands. */ |
18700 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18701 | install_element(BGP_NODE, | |
18702 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18703 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18704 | install_element(BGP_NODE, | |
18705 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18706 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18707 | install_element(BGP_NODE, | |
18708 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18709 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18710 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18711 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18712 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18713 | install_element(BGP_IPV4_NODE, | |
18714 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18715 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18716 | install_element(BGP_IPV4_NODE, | |
18717 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18718 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18719 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18720 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18721 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18722 | install_element(BGP_IPV4M_NODE, | |
18723 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18724 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18725 | install_element(BGP_IPV4M_NODE, | |
18726 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18727 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18728 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18729 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18730 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18731 | install_element(BGP_IPV4L_NODE, | |
18732 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18733 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18734 | install_element(BGP_IPV4L_NODE, | |
18735 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18736 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18737 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18738 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18739 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18740 | install_element(BGP_IPV6_NODE, | |
18741 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18742 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18743 | install_element(BGP_IPV6_NODE, | |
18744 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18745 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18746 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18747 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18748 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18749 | install_element(BGP_IPV6M_NODE, | |
18750 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18751 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18752 | install_element(BGP_IPV6M_NODE, | |
18753 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18754 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18755 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18756 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18757 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18758 | install_element(BGP_IPV6L_NODE, | |
18759 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18760 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18761 | install_element(BGP_IPV6L_NODE, | |
18762 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18763 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18764 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18765 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18766 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18767 | install_element(BGP_VPNV4_NODE, | |
18768 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18769 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18770 | install_element(BGP_VPNV4_NODE, | |
18771 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18772 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18773 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18774 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18775 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18776 | install_element(BGP_VPNV6_NODE, | |
18777 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18778 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18779 | install_element(BGP_VPNV6_NODE, | |
18780 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18781 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18782 | ||
18783 | /* "neighbor allowas-in" */ | |
18784 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18785 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18786 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18787 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18788 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18789 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18790 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18791 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18792 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18793 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18794 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18795 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18796 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18797 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18798 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18799 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18800 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18801 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18802 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18803 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18804 | ||
18805 | /* address-family commands. */ | |
18806 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18807 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18808 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18809 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18810 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18811 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18812 | |
d62a17ae | 18813 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18814 | ||
18815 | /* "exit-address-family" command. */ | |
18816 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18817 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18818 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18819 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18820 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18821 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18822 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18823 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18824 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18825 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18826 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18827 | ||
18828 | /* "clear ip bgp commands" */ | |
18829 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18830 | ||
18831 | /* clear ip bgp prefix */ | |
18832 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18833 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18834 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18835 | ||
18836 | /* "show [ip] bgp summary" commands. */ | |
18837 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18838 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18839 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18840 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18841 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18842 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18843 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18844 | ||
18845 | /* "show [ip] bgp neighbors" commands. */ | |
18846 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18847 | ||
36235319 | 18848 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18849 | |
d62a17ae | 18850 | /* "show [ip] bgp peer-group" commands. */ |
18851 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18852 | ||
18853 | /* "show [ip] bgp paths" commands. */ | |
18854 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18855 | ||
18856 | /* "show [ip] bgp community" commands. */ | |
18857 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18858 | ||
18859 | /* "show ip bgp large-community" commands. */ | |
18860 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18861 | /* "show [ip] bgp attribute-info" commands. */ | |
18862 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18863 | /* "show [ip] bgp route-leak" command */ |
18864 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18865 | |
18866 | /* "redistribute" commands. */ | |
18867 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18868 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18869 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18870 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18871 | install_element(BGP_NODE, | |
18872 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18873 | install_element(BGP_NODE, | |
18874 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18875 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18876 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18877 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18878 | install_element(BGP_NODE, | |
18879 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18880 | install_element(BGP_NODE, | |
18881 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18882 | install_element(BGP_NODE, | |
18883 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18884 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18885 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18886 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18887 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18888 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18889 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18890 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18891 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18892 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18893 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18894 | install_element(BGP_IPV4_NODE, | |
18895 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18896 | install_element(BGP_IPV4_NODE, | |
18897 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18898 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18899 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18900 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18901 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18902 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18903 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18904 | ||
b9c7bc5a PZ |
18905 | /* import|export vpn [route-map WORD] */ |
18906 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18907 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 18908 | |
12a844a5 DS |
18909 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
18910 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18911 | ||
d62a17ae | 18912 | /* ttl_security commands */ |
18913 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18914 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18915 | ||
18916 | /* "show [ip] bgp memory" commands. */ | |
18917 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18918 | ||
acf71666 MK |
18919 | /* "show bgp martian next-hop" */ |
18920 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18921 | ||
48ecf8f5 DS |
18922 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
18923 | ||
d62a17ae | 18924 | /* "show [ip] bgp views" commands. */ |
18925 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18926 | ||
18927 | /* "show [ip] bgp vrfs" commands. */ | |
18928 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18929 | ||
18930 | /* Community-list. */ | |
18931 | community_list_vty(); | |
ddb5b488 | 18932 | |
ed0e57e3 DA |
18933 | community_alias_vty(); |
18934 | ||
ddb5b488 | 18935 | /* vpn-policy commands */ |
b9c7bc5a PZ |
18936 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
18937 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18938 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18939 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18940 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18941 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18942 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18943 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18944 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18945 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18946 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
18947 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 18948 | |
301ad80a PG |
18949 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
18950 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18951 | ||
b9c7bc5a PZ |
18952 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
18953 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18954 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18955 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
18956 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
18957 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
18958 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
18959 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18960 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
18961 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
18962 | |
18963 | /* tcp-mss command */ | |
18964 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
18965 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
18966 | |
18967 | /* srv6 commands */ | |
ea372e81 | 18968 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 18969 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 18970 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 18971 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 18972 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
18973 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
18974 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
718e3744 | 18975 | } |
6b0655a2 | 18976 | |
718e3744 | 18977 | #include "memory.h" |
18978 | #include "bgp_regex.h" | |
18979 | #include "bgp_clist.h" | |
18980 | #include "bgp_ecommunity.h" | |
18981 | ||
18982 | /* VTY functions. */ | |
18983 | ||
18984 | /* Direction value to string conversion. */ | |
d62a17ae | 18985 | static const char *community_direct_str(int direct) |
18986 | { | |
18987 | switch (direct) { | |
18988 | case COMMUNITY_DENY: | |
18989 | return "deny"; | |
18990 | case COMMUNITY_PERMIT: | |
18991 | return "permit"; | |
18992 | default: | |
18993 | return "unknown"; | |
18994 | } | |
718e3744 | 18995 | } |
18996 | ||
18997 | /* Display error string. */ | |
d62a17ae | 18998 | static void community_list_perror(struct vty *vty, int ret) |
18999 | { | |
19000 | switch (ret) { | |
19001 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19002 | vty_out(vty, "%% Can't find community-list\n"); | |
19003 | break; | |
19004 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19005 | vty_out(vty, "%% Malformed community-list value\n"); | |
19006 | break; | |
19007 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19008 | vty_out(vty, | |
19009 | "%% Community name conflict, previously defined as standard community\n"); | |
19010 | break; | |
19011 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19012 | vty_out(vty, | |
19013 | "%% Community name conflict, previously defined as expanded community\n"); | |
19014 | break; | |
19015 | } | |
718e3744 | 19016 | } |
19017 | ||
5bf15956 DW |
19018 | /* "community-list" keyword help string. */ |
19019 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19020 | ||
7336e101 SP |
19021 | /*community-list standard */ |
19022 | DEFUN (community_list_standard, | |
19023 | bgp_community_list_standard_cmd, | |
a2099c1d | 19024 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19025 | BGP_STR |
718e3744 | 19026 | COMMUNITY_LIST_STR |
19027 | "Community list number (standard)\n" | |
5bf15956 | 19028 | "Add an standard community-list entry\n" |
718e3744 | 19029 | "Community list name\n" |
2f8cc0e5 DA |
19030 | "Sequence number of an entry\n" |
19031 | "Sequence number\n" | |
718e3744 | 19032 | "Specify community to reject\n" |
19033 | "Specify community to accept\n" | |
19034 | COMMUNITY_VAL_STR) | |
19035 | { | |
d62a17ae | 19036 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19037 | char *seq = NULL; |
d62a17ae | 19038 | int direct = 0; |
19039 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 19040 | int idx = 0; |
7336e101 | 19041 | |
a08032fe | 19042 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19043 | if (idx) |
19044 | seq = argv[idx]->arg; | |
19045 | ||
19046 | idx = 0; | |
d62a17ae | 19047 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19048 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19049 | cl_name_or_number = argv[idx]->arg; |
19050 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19051 | : COMMUNITY_DENY; | |
19052 | argv_find(argv, argc, "AA:NN", &idx); | |
19053 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19054 | |
2f8cc0e5 DA |
19055 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19056 | direct, style); | |
42f914d4 | 19057 | |
d62a17ae | 19058 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19059 | |
d62a17ae | 19060 | if (ret < 0) { |
19061 | /* Display error string. */ | |
19062 | community_list_perror(vty, ret); | |
19063 | return CMD_WARNING_CONFIG_FAILED; | |
19064 | } | |
42f914d4 | 19065 | |
d62a17ae | 19066 | return CMD_SUCCESS; |
718e3744 | 19067 | } |
19068 | ||
7336e101 SP |
19069 | DEFUN (no_community_list_standard_all, |
19070 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 19071 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19072 | NO_STR |
19073 | BGP_STR | |
19074 | COMMUNITY_LIST_STR | |
19075 | "Community list number (standard)\n" | |
19076 | "Add an standard community-list entry\n" | |
19077 | "Community list name\n" | |
2f8cc0e5 DA |
19078 | "Sequence number of an entry\n" |
19079 | "Sequence number\n" | |
7336e101 SP |
19080 | "Specify community to reject\n" |
19081 | "Specify community to accept\n" | |
19082 | COMMUNITY_VAL_STR) | |
718e3744 | 19083 | { |
d62a17ae | 19084 | char *cl_name_or_number = NULL; |
174b5cb9 | 19085 | char *str = NULL; |
d62a17ae | 19086 | int direct = 0; |
19087 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19088 | char *seq = NULL; |
d62a17ae | 19089 | int idx = 0; |
7336e101 | 19090 | |
a08032fe | 19091 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19092 | if (idx) |
19093 | seq = argv[idx]->arg; | |
19094 | ||
19095 | idx = 0; | |
174b5cb9 DA |
19096 | argv_find(argv, argc, "permit", &idx); |
19097 | argv_find(argv, argc, "deny", &idx); | |
19098 | ||
19099 | if (idx) { | |
19100 | direct = argv_find(argv, argc, "permit", &idx) | |
19101 | ? COMMUNITY_PERMIT | |
19102 | : COMMUNITY_DENY; | |
19103 | ||
19104 | idx = 0; | |
19105 | argv_find(argv, argc, "AA:NN", &idx); | |
19106 | str = argv_concat(argv, argc, idx); | |
19107 | } | |
19108 | ||
19109 | idx = 0; | |
d62a17ae | 19110 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19111 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19112 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 19113 | |
2f8cc0e5 | 19114 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19115 | direct, style); |
42f914d4 | 19116 | |
d62a17ae | 19117 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19118 | |
d62a17ae | 19119 | if (ret < 0) { |
19120 | community_list_perror(vty, ret); | |
19121 | return CMD_WARNING_CONFIG_FAILED; | |
19122 | } | |
42f914d4 | 19123 | |
d62a17ae | 19124 | return CMD_SUCCESS; |
718e3744 | 19125 | } |
7336e101 | 19126 | |
174b5cb9 | 19127 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 19128 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
19129 | NO_STR BGP_STR COMMUNITY_LIST_STR |
19130 | "Community list number (standard)\n" | |
19131 | "Add an standard community-list entry\n" | |
19132 | "Community list name\n") | |
19133 | ||
7336e101 SP |
19134 | /*community-list expanded */ |
19135 | DEFUN (community_list_expanded_all, | |
19136 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 19137 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19138 | BGP_STR |
19139 | COMMUNITY_LIST_STR | |
718e3744 | 19140 | "Community list number (expanded)\n" |
5bf15956 | 19141 | "Add an expanded community-list entry\n" |
718e3744 | 19142 | "Community list name\n" |
2f8cc0e5 DA |
19143 | "Sequence number of an entry\n" |
19144 | "Sequence number\n" | |
718e3744 | 19145 | "Specify community to reject\n" |
19146 | "Specify community to accept\n" | |
19147 | COMMUNITY_VAL_STR) | |
19148 | { | |
d62a17ae | 19149 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19150 | char *seq = NULL; |
d62a17ae | 19151 | int direct = 0; |
19152 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19153 | int idx = 0; |
7b9a4750 | 19154 | |
a08032fe | 19155 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19156 | if (idx) |
19157 | seq = argv[idx]->arg; | |
19158 | ||
19159 | idx = 0; | |
19160 | ||
d62a17ae | 19161 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19162 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19163 | cl_name_or_number = argv[idx]->arg; |
19164 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19165 | : COMMUNITY_DENY; | |
19166 | argv_find(argv, argc, "AA:NN", &idx); | |
19167 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19168 | |
2f8cc0e5 DA |
19169 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19170 | direct, style); | |
42f914d4 | 19171 | |
d62a17ae | 19172 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19173 | |
d62a17ae | 19174 | if (ret < 0) { |
19175 | /* Display error string. */ | |
19176 | community_list_perror(vty, ret); | |
19177 | return CMD_WARNING_CONFIG_FAILED; | |
19178 | } | |
42f914d4 | 19179 | |
d62a17ae | 19180 | return CMD_SUCCESS; |
718e3744 | 19181 | } |
19182 | ||
7336e101 SP |
19183 | DEFUN (no_community_list_expanded_all, |
19184 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 19185 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19186 | NO_STR |
19187 | BGP_STR | |
19188 | COMMUNITY_LIST_STR | |
19189 | "Community list number (expanded)\n" | |
19190 | "Add an expanded community-list entry\n" | |
19191 | "Community list name\n" | |
2f8cc0e5 DA |
19192 | "Sequence number of an entry\n" |
19193 | "Sequence number\n" | |
7336e101 SP |
19194 | "Specify community to reject\n" |
19195 | "Specify community to accept\n" | |
19196 | COMMUNITY_VAL_STR) | |
718e3744 | 19197 | { |
d62a17ae | 19198 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19199 | char *seq = NULL; |
174b5cb9 | 19200 | char *str = NULL; |
d62a17ae | 19201 | int direct = 0; |
19202 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19203 | int idx = 0; |
174b5cb9 | 19204 | |
a08032fe | 19205 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19206 | if (idx) |
19207 | seq = argv[idx]->arg; | |
19208 | ||
19209 | idx = 0; | |
174b5cb9 DA |
19210 | argv_find(argv, argc, "permit", &idx); |
19211 | argv_find(argv, argc, "deny", &idx); | |
19212 | ||
19213 | if (idx) { | |
19214 | direct = argv_find(argv, argc, "permit", &idx) | |
19215 | ? COMMUNITY_PERMIT | |
19216 | : COMMUNITY_DENY; | |
19217 | ||
19218 | idx = 0; | |
19219 | argv_find(argv, argc, "AA:NN", &idx); | |
19220 | str = argv_concat(argv, argc, idx); | |
7336e101 | 19221 | } |
174b5cb9 DA |
19222 | |
19223 | idx = 0; | |
d62a17ae | 19224 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19225 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19226 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 19227 | |
2f8cc0e5 | 19228 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19229 | direct, style); |
42f914d4 | 19230 | |
d62a17ae | 19231 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19232 | |
d62a17ae | 19233 | if (ret < 0) { |
19234 | community_list_perror(vty, ret); | |
19235 | return CMD_WARNING_CONFIG_FAILED; | |
19236 | } | |
42f914d4 | 19237 | |
d62a17ae | 19238 | return CMD_SUCCESS; |
718e3744 | 19239 | } |
19240 | ||
36d4bb44 EB |
19241 | ALIAS(no_community_list_expanded_all, |
19242 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 19243 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 19244 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
19245 | "Community list number (expanded)\n" |
19246 | "Add an expanded community-list entry\n" | |
19247 | "Community list name\n") | |
19248 | ||
8d9b8ed9 PM |
19249 | /* Return configuration string of community-list entry. */ |
19250 | static const char *community_list_config_str(struct community_entry *entry) | |
19251 | { | |
19252 | const char *str; | |
19253 | ||
19254 | if (entry->any) | |
19255 | str = ""; | |
19256 | else { | |
19257 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
19258 | str = community_str(entry->u.com, false); | |
19259 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
19260 | str = lcommunity_str(entry->u.lcom, false); | |
19261 | else | |
19262 | str = entry->config; | |
19263 | } | |
19264 | return str; | |
19265 | } | |
19266 | ||
d62a17ae | 19267 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19268 | { |
d62a17ae | 19269 | struct community_entry *entry; |
718e3744 | 19270 | |
d62a17ae | 19271 | for (entry = list->head; entry; entry = entry->next) { |
19272 | if (entry == list->head) { | |
19273 | if (all_digit(list->name)) | |
19274 | vty_out(vty, "Community %s list %s\n", | |
19275 | entry->style == COMMUNITY_LIST_STANDARD | |
19276 | ? "standard" | |
19277 | : "(expanded) access", | |
19278 | list->name); | |
19279 | else | |
19280 | vty_out(vty, "Named Community %s list %s\n", | |
19281 | entry->style == COMMUNITY_LIST_STANDARD | |
19282 | ? "standard" | |
19283 | : "expanded", | |
19284 | list->name); | |
19285 | } | |
19286 | if (entry->any) | |
19287 | vty_out(vty, " %s\n", | |
19288 | community_direct_str(entry->direct)); | |
19289 | else | |
19290 | vty_out(vty, " %s %s\n", | |
19291 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19292 | community_list_config_str(entry)); |
d62a17ae | 19293 | } |
718e3744 | 19294 | } |
19295 | ||
7336e101 SP |
19296 | DEFUN (show_community_list, |
19297 | show_bgp_community_list_cmd, | |
19298 | "show bgp community-list", | |
718e3744 | 19299 | SHOW_STR |
7336e101 | 19300 | BGP_STR |
718e3744 | 19301 | "List community-list\n") |
19302 | { | |
d62a17ae | 19303 | struct community_list *list; |
19304 | struct community_list_master *cm; | |
718e3744 | 19305 | |
d62a17ae | 19306 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19307 | if (!cm) | |
19308 | return CMD_SUCCESS; | |
718e3744 | 19309 | |
d62a17ae | 19310 | for (list = cm->num.head; list; list = list->next) |
19311 | community_list_show(vty, list); | |
718e3744 | 19312 | |
d62a17ae | 19313 | for (list = cm->str.head; list; list = list->next) |
19314 | community_list_show(vty, list); | |
718e3744 | 19315 | |
d62a17ae | 19316 | return CMD_SUCCESS; |
718e3744 | 19317 | } |
19318 | ||
7336e101 SP |
19319 | DEFUN (show_community_list_arg, |
19320 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 19321 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19322 | SHOW_STR |
19323 | BGP_STR | |
718e3744 | 19324 | "List community-list\n" |
19325 | "Community-list number\n" | |
960b69b9 | 19326 | "Community-list name\n" |
19327 | "Detailed information on community-list\n") | |
718e3744 | 19328 | { |
d62a17ae | 19329 | int idx_comm_list = 3; |
19330 | struct community_list *list; | |
718e3744 | 19331 | |
e237b0d2 | 19332 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19333 | COMMUNITY_LIST_MASTER); |
19334 | if (!list) { | |
19335 | vty_out(vty, "%% Can't find community-list\n"); | |
19336 | return CMD_WARNING; | |
19337 | } | |
718e3744 | 19338 | |
d62a17ae | 19339 | community_list_show(vty, list); |
718e3744 | 19340 | |
d62a17ae | 19341 | return CMD_SUCCESS; |
718e3744 | 19342 | } |
6b0655a2 | 19343 | |
57d187bc JS |
19344 | /* |
19345 | * Large Community code. | |
19346 | */ | |
d62a17ae | 19347 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19348 | struct cmd_token **argv, int style, | |
19349 | int reject_all_digit_name) | |
19350 | { | |
19351 | int ret; | |
19352 | int direct; | |
19353 | char *str; | |
19354 | int idx = 0; | |
19355 | char *cl_name; | |
2f8cc0e5 DA |
19356 | char *seq = NULL; |
19357 | ||
a08032fe | 19358 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19359 | seq = argv[idx]->arg; |
d62a17ae | 19360 | |
2f8cc0e5 | 19361 | idx = 0; |
d62a17ae | 19362 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19363 | : COMMUNITY_DENY; | |
19364 | ||
19365 | /* All digit name check. */ | |
19366 | idx = 0; | |
a2099c1d | 19367 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19368 | argv_find(argv, argc, "(1-99)", &idx); |
19369 | argv_find(argv, argc, "(100-500)", &idx); | |
19370 | cl_name = argv[idx]->arg; | |
19371 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19372 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19373 | return CMD_WARNING_CONFIG_FAILED; | |
19374 | } | |
19375 | ||
19376 | idx = 0; | |
19377 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19378 | argv_find(argv, argc, "LINE", &idx); | |
19379 | /* Concat community string argument. */ | |
19380 | if (idx) | |
19381 | str = argv_concat(argv, argc, idx); | |
19382 | else | |
19383 | str = NULL; | |
19384 | ||
2f8cc0e5 | 19385 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19386 | |
19387 | /* Free temporary community list string allocated by | |
19388 | argv_concat(). */ | |
0a22ddfb | 19389 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19390 | |
19391 | if (ret < 0) { | |
19392 | community_list_perror(vty, ret); | |
19393 | return CMD_WARNING_CONFIG_FAILED; | |
19394 | } | |
19395 | return CMD_SUCCESS; | |
19396 | } | |
19397 | ||
19398 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19399 | struct cmd_token **argv, int style) | |
19400 | { | |
19401 | int ret; | |
19402 | int direct = 0; | |
19403 | char *str = NULL; | |
19404 | int idx = 0; | |
2f8cc0e5 | 19405 | char *seq = NULL; |
d62a17ae | 19406 | |
a08032fe | 19407 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19408 | seq = argv[idx]->arg; |
d62a17ae | 19409 | |
2f8cc0e5 | 19410 | idx = 0; |
d62a17ae | 19411 | argv_find(argv, argc, "permit", &idx); |
19412 | argv_find(argv, argc, "deny", &idx); | |
19413 | ||
19414 | if (idx) { | |
19415 | /* Check the list direct. */ | |
19416 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19417 | direct = COMMUNITY_PERMIT; | |
19418 | else | |
19419 | direct = COMMUNITY_DENY; | |
19420 | ||
19421 | idx = 0; | |
19422 | argv_find(argv, argc, "LINE", &idx); | |
19423 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19424 | /* Concat community string argument. */ | |
19425 | str = argv_concat(argv, argc, idx); | |
19426 | } | |
19427 | ||
19428 | idx = 0; | |
19429 | argv_find(argv, argc, "(1-99)", &idx); | |
19430 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 19431 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19432 | |
19433 | /* Unset community list. */ | |
2f8cc0e5 | 19434 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19435 | style); |
19436 | ||
19437 | /* Free temporary community list string allocated by | |
19438 | argv_concat(). */ | |
0a22ddfb | 19439 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19440 | |
19441 | if (ret < 0) { | |
19442 | community_list_perror(vty, ret); | |
19443 | return CMD_WARNING_CONFIG_FAILED; | |
19444 | } | |
19445 | ||
19446 | return CMD_SUCCESS; | |
57d187bc JS |
19447 | } |
19448 | ||
19449 | /* "large-community-list" keyword help string. */ | |
19450 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19451 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19452 | ||
7336e101 SP |
19453 | DEFUN (lcommunity_list_standard, |
19454 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19455 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19456 | BGP_STR |
19457 | LCOMMUNITY_LIST_STR | |
19458 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19459 | "Sequence number of an entry\n" |
19460 | "Sequence number\n" | |
7336e101 SP |
19461 | "Specify large community to reject\n" |
19462 | "Specify large community to accept\n" | |
19463 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19464 | { |
d62a17ae | 19465 | return lcommunity_list_set_vty(vty, argc, argv, |
19466 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19467 | } |
19468 | ||
7336e101 SP |
19469 | DEFUN (lcommunity_list_expanded, |
19470 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19471 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19472 | BGP_STR |
19473 | LCOMMUNITY_LIST_STR | |
19474 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19475 | "Sequence number of an entry\n" |
19476 | "Sequence number\n" | |
7336e101 SP |
19477 | "Specify large community to reject\n" |
19478 | "Specify large community to accept\n" | |
19479 | "An ordered list as a regular-expression\n") | |
57d187bc | 19480 | { |
d62a17ae | 19481 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19482 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19483 | } |
19484 | ||
7336e101 SP |
19485 | DEFUN (lcommunity_list_name_standard, |
19486 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 19487 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19488 | BGP_STR |
19489 | LCOMMUNITY_LIST_STR | |
19490 | "Specify standard large-community-list\n" | |
19491 | "Large Community list name\n" | |
2f8cc0e5 DA |
19492 | "Sequence number of an entry\n" |
19493 | "Sequence number\n" | |
7336e101 SP |
19494 | "Specify large community to reject\n" |
19495 | "Specify large community to accept\n" | |
19496 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19497 | { |
d62a17ae | 19498 | return lcommunity_list_set_vty(vty, argc, argv, |
19499 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19500 | } |
19501 | ||
7336e101 SP |
19502 | DEFUN (lcommunity_list_name_expanded, |
19503 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 19504 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19505 | BGP_STR |
19506 | LCOMMUNITY_LIST_STR | |
19507 | "Specify expanded large-community-list\n" | |
19508 | "Large Community list name\n" | |
2f8cc0e5 DA |
19509 | "Sequence number of an entry\n" |
19510 | "Sequence number\n" | |
7336e101 SP |
19511 | "Specify large community to reject\n" |
19512 | "Specify large community to accept\n" | |
19513 | "An ordered list as a regular-expression\n") | |
57d187bc | 19514 | { |
d62a17ae | 19515 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19516 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19517 | } |
19518 | ||
4378f57c DA |
19519 | DEFUN (no_lcommunity_list_all, |
19520 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 19521 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
19522 | NO_STR |
19523 | BGP_STR | |
19524 | LCOMMUNITY_LIST_STR | |
19525 | "Large Community list number (standard)\n" | |
19526 | "Large Community list number (expanded)\n" | |
19527 | "Large Community list name\n") | |
57d187bc | 19528 | { |
7336e101 SP |
19529 | return lcommunity_list_unset_vty(vty, argc, argv, |
19530 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19531 | } |
19532 | ||
4378f57c DA |
19533 | DEFUN (no_lcommunity_list_name_standard_all, |
19534 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 19535 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
19536 | NO_STR |
19537 | BGP_STR | |
19538 | LCOMMUNITY_LIST_STR | |
19539 | "Specify standard large-community-list\n" | |
19540 | "Large Community list name\n") | |
19541 | { | |
19542 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19543 | LARGE_COMMUNITY_LIST_STANDARD); | |
19544 | } | |
19545 | ||
7336e101 SP |
19546 | DEFUN (no_lcommunity_list_name_expanded_all, |
19547 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 19548 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
19549 | NO_STR |
19550 | BGP_STR | |
19551 | LCOMMUNITY_LIST_STR | |
19552 | "Specify expanded large-community-list\n" | |
19553 | "Large Community list name\n") | |
57d187bc | 19554 | { |
d62a17ae | 19555 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19556 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19557 | } |
19558 | ||
7336e101 SP |
19559 | DEFUN (no_lcommunity_list_standard, |
19560 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19561 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19562 | NO_STR |
19563 | BGP_STR | |
19564 | LCOMMUNITY_LIST_STR | |
19565 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19566 | "Sequence number of an entry\n" |
19567 | "Sequence number\n" | |
7336e101 SP |
19568 | "Specify large community to reject\n" |
19569 | "Specify large community to accept\n" | |
19570 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19571 | { |
d62a17ae | 19572 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19573 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19574 | } |
19575 | ||
7336e101 SP |
19576 | DEFUN (no_lcommunity_list_expanded, |
19577 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19578 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19579 | NO_STR |
19580 | BGP_STR | |
19581 | LCOMMUNITY_LIST_STR | |
19582 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19583 | "Sequence number of an entry\n" |
19584 | "Sequence number\n" | |
7336e101 SP |
19585 | "Specify large community to reject\n" |
19586 | "Specify large community to accept\n" | |
19587 | "An ordered list as a regular-expression\n") | |
57d187bc | 19588 | { |
d62a17ae | 19589 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19590 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19591 | } |
19592 | ||
7336e101 SP |
19593 | DEFUN (no_lcommunity_list_name_standard, |
19594 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 19595 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19596 | NO_STR |
19597 | BGP_STR | |
19598 | LCOMMUNITY_LIST_STR | |
19599 | "Specify standard large-community-list\n" | |
19600 | "Large Community list name\n" | |
2f8cc0e5 DA |
19601 | "Sequence number of an entry\n" |
19602 | "Sequence number\n" | |
7336e101 SP |
19603 | "Specify large community to reject\n" |
19604 | "Specify large community to accept\n" | |
19605 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19606 | { |
d62a17ae | 19607 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19608 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19609 | } |
19610 | ||
7336e101 SP |
19611 | DEFUN (no_lcommunity_list_name_expanded, |
19612 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 19613 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19614 | NO_STR |
19615 | BGP_STR | |
19616 | LCOMMUNITY_LIST_STR | |
19617 | "Specify expanded large-community-list\n" | |
19618 | "Large community list name\n" | |
2f8cc0e5 DA |
19619 | "Sequence number of an entry\n" |
19620 | "Sequence number\n" | |
7336e101 SP |
19621 | "Specify large community to reject\n" |
19622 | "Specify large community to accept\n" | |
19623 | "An ordered list as a regular-expression\n") | |
57d187bc | 19624 | { |
d62a17ae | 19625 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19626 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19627 | } |
19628 | ||
d62a17ae | 19629 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19630 | { | |
19631 | struct community_entry *entry; | |
19632 | ||
19633 | for (entry = list->head; entry; entry = entry->next) { | |
19634 | if (entry == list->head) { | |
19635 | if (all_digit(list->name)) | |
19636 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19637 | entry->style == |
19638 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19639 | ? "standard" |
19640 | : "(expanded) access", | |
19641 | list->name); | |
19642 | else | |
19643 | vty_out(vty, | |
19644 | "Named large community %s list %s\n", | |
169b72c8 | 19645 | entry->style == |
19646 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19647 | ? "standard" |
19648 | : "expanded", | |
19649 | list->name); | |
19650 | } | |
19651 | if (entry->any) | |
19652 | vty_out(vty, " %s\n", | |
19653 | community_direct_str(entry->direct)); | |
19654 | else | |
19655 | vty_out(vty, " %s %s\n", | |
19656 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19657 | community_list_config_str(entry)); |
d62a17ae | 19658 | } |
57d187bc JS |
19659 | } |
19660 | ||
7336e101 SP |
19661 | DEFUN (show_lcommunity_list, |
19662 | show_bgp_lcommunity_list_cmd, | |
19663 | "show bgp large-community-list", | |
57d187bc | 19664 | SHOW_STR |
7336e101 | 19665 | BGP_STR |
57d187bc JS |
19666 | "List large-community list\n") |
19667 | { | |
d62a17ae | 19668 | struct community_list *list; |
19669 | struct community_list_master *cm; | |
57d187bc | 19670 | |
d62a17ae | 19671 | cm = community_list_master_lookup(bgp_clist, |
19672 | LARGE_COMMUNITY_LIST_MASTER); | |
19673 | if (!cm) | |
19674 | return CMD_SUCCESS; | |
57d187bc | 19675 | |
d62a17ae | 19676 | for (list = cm->num.head; list; list = list->next) |
19677 | lcommunity_list_show(vty, list); | |
57d187bc | 19678 | |
d62a17ae | 19679 | for (list = cm->str.head; list; list = list->next) |
19680 | lcommunity_list_show(vty, list); | |
57d187bc | 19681 | |
d62a17ae | 19682 | return CMD_SUCCESS; |
57d187bc JS |
19683 | } |
19684 | ||
7336e101 SP |
19685 | DEFUN (show_lcommunity_list_arg, |
19686 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 19687 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19688 | SHOW_STR |
19689 | BGP_STR | |
57d187bc | 19690 | "List large-community list\n" |
960b69b9 | 19691 | "Large-community-list number\n" |
19692 | "Large-community-list name\n" | |
19693 | "Detailed information on large-community-list\n") | |
57d187bc | 19694 | { |
d62a17ae | 19695 | struct community_list *list; |
57d187bc | 19696 | |
e237b0d2 | 19697 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19698 | LARGE_COMMUNITY_LIST_MASTER); |
19699 | if (!list) { | |
960b69b9 | 19700 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19701 | return CMD_WARNING; |
19702 | } | |
57d187bc | 19703 | |
d62a17ae | 19704 | lcommunity_list_show(vty, list); |
57d187bc | 19705 | |
d62a17ae | 19706 | return CMD_SUCCESS; |
57d187bc JS |
19707 | } |
19708 | ||
718e3744 | 19709 | /* "extcommunity-list" keyword help string. */ |
19710 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19711 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19712 | ||
7336e101 SP |
19713 | DEFUN (extcommunity_list_standard, |
19714 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 19715 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19716 | BGP_STR |
718e3744 | 19717 | EXTCOMMUNITY_LIST_STR |
19718 | "Extended Community list number (standard)\n" | |
718e3744 | 19719 | "Specify standard extcommunity-list\n" |
5bf15956 | 19720 | "Community list name\n" |
2f8cc0e5 DA |
19721 | "Sequence number of an entry\n" |
19722 | "Sequence number\n" | |
718e3744 | 19723 | "Specify community to reject\n" |
19724 | "Specify community to accept\n" | |
19725 | EXTCOMMUNITY_VAL_STR) | |
19726 | { | |
d62a17ae | 19727 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19728 | int direct = 0; | |
19729 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19730 | char *seq = NULL; |
42f914d4 | 19731 | |
d62a17ae | 19732 | int idx = 0; |
7b9a4750 | 19733 | |
d62a17ae | 19734 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19735 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19736 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 19737 | |
a08032fe | 19738 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19739 | seq = argv[idx]->arg; |
19740 | ||
d62a17ae | 19741 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19742 | : COMMUNITY_DENY; | |
19743 | argv_find(argv, argc, "AA:NN", &idx); | |
19744 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19745 | |
2f8cc0e5 | 19746 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19747 | direct, style); |
42f914d4 | 19748 | |
d62a17ae | 19749 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19750 | |
d62a17ae | 19751 | if (ret < 0) { |
19752 | community_list_perror(vty, ret); | |
19753 | return CMD_WARNING_CONFIG_FAILED; | |
19754 | } | |
42f914d4 | 19755 | |
d62a17ae | 19756 | return CMD_SUCCESS; |
718e3744 | 19757 | } |
19758 | ||
7336e101 SP |
19759 | DEFUN (extcommunity_list_name_expanded, |
19760 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 19761 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19762 | BGP_STR |
19763 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19764 | "Extended Community list number (expanded)\n" |
718e3744 | 19765 | "Specify expanded extcommunity-list\n" |
19766 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19767 | "Sequence number of an entry\n" |
19768 | "Sequence number\n" | |
718e3744 | 19769 | "Specify community to reject\n" |
19770 | "Specify community to accept\n" | |
19771 | "An ordered list as a regular-expression\n") | |
19772 | { | |
d62a17ae | 19773 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19774 | int direct = 0; | |
19775 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19776 | char *seq = NULL; |
d62a17ae | 19777 | int idx = 0; |
7336e101 | 19778 | |
d62a17ae | 19779 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19780 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19781 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 19782 | |
a08032fe | 19783 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19784 | seq = argv[idx]->arg; |
19785 | ||
d62a17ae | 19786 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19787 | : COMMUNITY_DENY; | |
19788 | argv_find(argv, argc, "LINE", &idx); | |
19789 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19790 | |
2f8cc0e5 | 19791 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19792 | direct, style); |
42f914d4 | 19793 | |
d62a17ae | 19794 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19795 | |
d62a17ae | 19796 | if (ret < 0) { |
19797 | community_list_perror(vty, ret); | |
19798 | return CMD_WARNING_CONFIG_FAILED; | |
19799 | } | |
42f914d4 | 19800 | |
d62a17ae | 19801 | return CMD_SUCCESS; |
718e3744 | 19802 | } |
19803 | ||
7336e101 SP |
19804 | DEFUN (no_extcommunity_list_standard_all, |
19805 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 19806 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19807 | NO_STR |
19808 | BGP_STR | |
19809 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19810 | "Extended Community list number (standard)\n" |
718e3744 | 19811 | "Specify standard extcommunity-list\n" |
5bf15956 | 19812 | "Community list name\n" |
2f8cc0e5 DA |
19813 | "Sequence number of an entry\n" |
19814 | "Sequence number\n" | |
718e3744 | 19815 | "Specify community to reject\n" |
19816 | "Specify community to accept\n" | |
19817 | EXTCOMMUNITY_VAL_STR) | |
19818 | { | |
d62a17ae | 19819 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19820 | int direct = 0; | |
19821 | char *cl_number_or_name = NULL; | |
d4455c89 | 19822 | char *str = NULL; |
2f8cc0e5 | 19823 | char *seq = NULL; |
d62a17ae | 19824 | int idx = 0; |
d4455c89 | 19825 | |
a08032fe | 19826 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19827 | seq = argv[idx]->arg; |
19828 | ||
19829 | idx = 0; | |
d4455c89 DA |
19830 | argv_find(argv, argc, "permit", &idx); |
19831 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19832 | if (idx) { |
19833 | direct = argv_find(argv, argc, "permit", &idx) | |
19834 | ? COMMUNITY_PERMIT | |
19835 | : COMMUNITY_DENY; | |
19836 | ||
19837 | idx = 0; | |
19838 | argv_find(argv, argc, "AA:NN", &idx); | |
19839 | str = argv_concat(argv, argc, idx); | |
19840 | } | |
19841 | ||
19842 | idx = 0; | |
d62a17ae | 19843 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19844 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19845 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 19846 | |
d62a17ae | 19847 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19848 | seq, direct, style); |
42f914d4 | 19849 | |
d62a17ae | 19850 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19851 | |
d62a17ae | 19852 | if (ret < 0) { |
19853 | community_list_perror(vty, ret); | |
19854 | return CMD_WARNING_CONFIG_FAILED; | |
19855 | } | |
42f914d4 | 19856 | |
d62a17ae | 19857 | return CMD_SUCCESS; |
718e3744 | 19858 | } |
19859 | ||
d4455c89 DA |
19860 | ALIAS(no_extcommunity_list_standard_all, |
19861 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 19862 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 19863 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19864 | "Extended Community list number (standard)\n" |
19865 | "Specify standard extcommunity-list\n" | |
19866 | "Community list name\n") | |
19867 | ||
7336e101 SP |
19868 | DEFUN (no_extcommunity_list_expanded_all, |
19869 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 19870 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19871 | NO_STR |
19872 | BGP_STR | |
19873 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19874 | "Extended Community list number (expanded)\n" |
718e3744 | 19875 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19876 | "Extended Community list name\n" |
2f8cc0e5 DA |
19877 | "Sequence number of an entry\n" |
19878 | "Sequence number\n" | |
718e3744 | 19879 | "Specify community to reject\n" |
19880 | "Specify community to accept\n" | |
19881 | "An ordered list as a regular-expression\n") | |
19882 | { | |
d62a17ae | 19883 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19884 | int direct = 0; | |
19885 | char *cl_number_or_name = NULL; | |
d4455c89 | 19886 | char *str = NULL; |
2f8cc0e5 | 19887 | char *seq = NULL; |
d62a17ae | 19888 | int idx = 0; |
d4455c89 | 19889 | |
a08032fe | 19890 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19891 | seq = argv[idx]->arg; |
19892 | ||
19893 | idx = 0; | |
d4455c89 DA |
19894 | argv_find(argv, argc, "permit", &idx); |
19895 | argv_find(argv, argc, "deny", &idx); | |
19896 | ||
19897 | if (idx) { | |
19898 | direct = argv_find(argv, argc, "permit", &idx) | |
19899 | ? COMMUNITY_PERMIT | |
19900 | : COMMUNITY_DENY; | |
19901 | ||
19902 | idx = 0; | |
19903 | argv_find(argv, argc, "LINE", &idx); | |
19904 | str = argv_concat(argv, argc, idx); | |
19905 | } | |
19906 | ||
19907 | idx = 0; | |
d62a17ae | 19908 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19909 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19910 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 19911 | |
d62a17ae | 19912 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19913 | seq, direct, style); |
42f914d4 | 19914 | |
d62a17ae | 19915 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19916 | |
d62a17ae | 19917 | if (ret < 0) { |
19918 | community_list_perror(vty, ret); | |
19919 | return CMD_WARNING_CONFIG_FAILED; | |
19920 | } | |
42f914d4 | 19921 | |
d62a17ae | 19922 | return CMD_SUCCESS; |
718e3744 | 19923 | } |
19924 | ||
d4455c89 DA |
19925 | ALIAS(no_extcommunity_list_expanded_all, |
19926 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 19927 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 19928 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19929 | "Extended Community list number (expanded)\n" |
19930 | "Specify expanded extcommunity-list\n" | |
19931 | "Extended Community list name\n") | |
19932 | ||
d62a17ae | 19933 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19934 | { |
d62a17ae | 19935 | struct community_entry *entry; |
718e3744 | 19936 | |
d62a17ae | 19937 | for (entry = list->head; entry; entry = entry->next) { |
19938 | if (entry == list->head) { | |
19939 | if (all_digit(list->name)) | |
19940 | vty_out(vty, "Extended community %s list %s\n", | |
19941 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19942 | ? "standard" | |
19943 | : "(expanded) access", | |
19944 | list->name); | |
19945 | else | |
19946 | vty_out(vty, | |
19947 | "Named extended community %s list %s\n", | |
19948 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19949 | ? "standard" | |
19950 | : "expanded", | |
19951 | list->name); | |
19952 | } | |
19953 | if (entry->any) | |
19954 | vty_out(vty, " %s\n", | |
19955 | community_direct_str(entry->direct)); | |
19956 | else | |
19957 | vty_out(vty, " %s %s\n", | |
19958 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19959 | community_list_config_str(entry)); |
d62a17ae | 19960 | } |
718e3744 | 19961 | } |
19962 | ||
7336e101 SP |
19963 | DEFUN (show_extcommunity_list, |
19964 | show_bgp_extcommunity_list_cmd, | |
19965 | "show bgp extcommunity-list", | |
718e3744 | 19966 | SHOW_STR |
7336e101 | 19967 | BGP_STR |
718e3744 | 19968 | "List extended-community list\n") |
19969 | { | |
d62a17ae | 19970 | struct community_list *list; |
19971 | struct community_list_master *cm; | |
718e3744 | 19972 | |
d62a17ae | 19973 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
19974 | if (!cm) | |
19975 | return CMD_SUCCESS; | |
718e3744 | 19976 | |
d62a17ae | 19977 | for (list = cm->num.head; list; list = list->next) |
19978 | extcommunity_list_show(vty, list); | |
718e3744 | 19979 | |
d62a17ae | 19980 | for (list = cm->str.head; list; list = list->next) |
19981 | extcommunity_list_show(vty, list); | |
718e3744 | 19982 | |
d62a17ae | 19983 | return CMD_SUCCESS; |
718e3744 | 19984 | } |
19985 | ||
7336e101 SP |
19986 | DEFUN (show_extcommunity_list_arg, |
19987 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 19988 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19989 | SHOW_STR |
19990 | BGP_STR | |
718e3744 | 19991 | "List extended-community list\n" |
19992 | "Extcommunity-list number\n" | |
960b69b9 | 19993 | "Extcommunity-list name\n" |
19994 | "Detailed information on extcommunity-list\n") | |
718e3744 | 19995 | { |
d62a17ae | 19996 | int idx_comm_list = 3; |
19997 | struct community_list *list; | |
718e3744 | 19998 | |
e237b0d2 | 19999 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20000 | EXTCOMMUNITY_LIST_MASTER); |
20001 | if (!list) { | |
20002 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20003 | return CMD_WARNING; | |
20004 | } | |
718e3744 | 20005 | |
d62a17ae | 20006 | extcommunity_list_show(vty, list); |
718e3744 | 20007 | |
d62a17ae | 20008 | return CMD_SUCCESS; |
718e3744 | 20009 | } |
6b0655a2 | 20010 | |
718e3744 | 20011 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 20012 | static int community_list_config_write(struct vty *vty) |
20013 | { | |
20014 | struct community_list *list; | |
20015 | struct community_entry *entry; | |
20016 | struct community_list_master *cm; | |
20017 | int write = 0; | |
20018 | ||
20019 | /* Community-list. */ | |
20020 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20021 | ||
20022 | for (list = cm->num.head; list; list = list->next) | |
20023 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20024 | vty_out(vty, |
20025 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20026 | list->name, entry->seq, | |
d62a17ae | 20027 | community_direct_str(entry->direct), |
20028 | community_list_config_str(entry)); | |
20029 | write++; | |
20030 | } | |
20031 | for (list = cm->str.head; list; list = list->next) | |
20032 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20033 | vty_out(vty, |
20034 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 20035 | entry->style == COMMUNITY_LIST_STANDARD |
20036 | ? "standard" | |
20037 | : "expanded", | |
2f8cc0e5 DA |
20038 | list->name, entry->seq, |
20039 | community_direct_str(entry->direct), | |
d62a17ae | 20040 | community_list_config_str(entry)); |
20041 | write++; | |
20042 | } | |
20043 | ||
20044 | /* Extcommunity-list. */ | |
20045 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20046 | ||
20047 | for (list = cm->num.head; list; list = list->next) | |
20048 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20049 | vty_out(vty, |
20050 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20051 | list->name, entry->seq, | |
20052 | community_direct_str(entry->direct), | |
d62a17ae | 20053 | community_list_config_str(entry)); |
20054 | write++; | |
20055 | } | |
20056 | for (list = cm->str.head; list; list = list->next) | |
20057 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20058 | vty_out(vty, |
6cde4b45 | 20059 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20060 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20061 | ? "standard" | |
20062 | : "expanded", | |
2f8cc0e5 DA |
20063 | list->name, entry->seq, |
20064 | community_direct_str(entry->direct), | |
d62a17ae | 20065 | community_list_config_str(entry)); |
20066 | write++; | |
20067 | } | |
20068 | ||
20069 | ||
20070 | /* lcommunity-list. */ | |
20071 | cm = community_list_master_lookup(bgp_clist, | |
20072 | LARGE_COMMUNITY_LIST_MASTER); | |
20073 | ||
20074 | for (list = cm->num.head; list; list = list->next) | |
20075 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20076 | vty_out(vty, |
6cde4b45 | 20077 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20078 | list->name, entry->seq, |
20079 | community_direct_str(entry->direct), | |
d62a17ae | 20080 | community_list_config_str(entry)); |
20081 | write++; | |
20082 | } | |
20083 | for (list = cm->str.head; list; list = list->next) | |
20084 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20085 | vty_out(vty, |
6cde4b45 | 20086 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20087 | |
d62a17ae | 20088 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20089 | ? "standard" | |
20090 | : "expanded", | |
2f8cc0e5 | 20091 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20092 | community_list_config_str(entry)); |
20093 | write++; | |
20094 | } | |
20095 | ||
20096 | return write; | |
20097 | } | |
20098 | ||
612c2c15 | 20099 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20100 | static struct cmd_node community_list_node = { |
f4b8291f | 20101 | .name = "community list", |
62b346ee DL |
20102 | .node = COMMUNITY_LIST_NODE, |
20103 | .prompt = "", | |
612c2c15 | 20104 | .config_write = community_list_config_write, |
718e3744 | 20105 | }; |
20106 | ||
d62a17ae | 20107 | static void community_list_vty(void) |
20108 | { | |
612c2c15 | 20109 | install_node(&community_list_node); |
d62a17ae | 20110 | |
20111 | /* Community-list. */ | |
7336e101 SP |
20112 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20113 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20114 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20115 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20116 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20117 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20118 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20119 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20120 | |
20121 | /* Extcommunity-list. */ | |
7336e101 SP |
20122 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20123 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20124 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20125 | install_element(CONFIG_NODE, |
20126 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20127 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20128 | install_element(CONFIG_NODE, |
20129 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20130 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20131 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20132 | |
20133 | /* Large Community List */ | |
7336e101 | 20134 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20135 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20136 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20137 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20138 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20139 | install_element(CONFIG_NODE, | |
20140 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20141 | install_element(CONFIG_NODE, |
20142 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20143 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20144 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20145 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20146 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20147 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20148 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
20149 | |
20150 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 20151 | } |
ed0e57e3 DA |
20152 | |
20153 | static struct cmd_node community_alias_node = { | |
20154 | .name = "community alias", | |
20155 | .node = COMMUNITY_ALIAS_NODE, | |
20156 | .prompt = "", | |
20157 | .config_write = bgp_community_alias_write, | |
20158 | }; | |
20159 | ||
20160 | void community_alias_vty(void) | |
20161 | { | |
20162 | install_node(&community_alias_node); | |
20163 | ||
20164 | /* Community-list. */ | |
20165 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
20166 | |
20167 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 20168 | } |